Makefile.i386 revision 1.107
1#	$NetBSD: Makefile.i386,v 1.107 2000/09/07 06:39:36 thorpej Exp $
2
3# Makefile for NetBSD
4#
5# This makefile is constructed from a machine description:
6#	config machineid
7# Most changes should be made in the machine description
8#	/sys/arch/i386/conf/``machineid''
9# after which you should do
10#	config machineid
11# Machine generic makefile changes should be made in
12#	/sys/arch/i386/conf/Makefile.i386
13# after which config should be rerun for all machines of that type.
14#
15# N.B.: NO DEPENDENCIES ON FOLLOWING FLAGS ARE VISIBLE TO MAKEFILE
16#	IF YOU CHANGE THE DEFINITION OF ANY OF THESE RECOMPILE EVERYTHING
17#
18# -DTRACE	compile in kernel tracing hooks
19# -DQUOTA	compile in file system quotas
20
21.include <bsd.own.mk>
22
23# DEBUG is set to -g if debugging.
24# PROF is set to -pg if profiling.
25
26AR?=	ar
27AS?=	as
28CC?=	cc
29CPP?=	cpp
30LD?=	ld
31LORDER?=lorder
32MKDEP?=	mkdep
33NM?=	nm
34RANLIB?=ranlib
35SIZE?=	size
36STRIP?=	strip
37TSORT?=	tsort -q
38
39COPTS?=	-O2
40
41# source tree is located via $S relative to the compilation directory
42.ifndef S
43S!=	cd ../../../..; pwd
44.endif
45I386=	$S/arch/i386
46
47HAVE_EGCS!=	${CC} --version | egrep "^(2\.[89]|egcs)" ; echo
48INCLUDES=	-I. -I$S/arch -I$S -nostdinc
49CPPFLAGS=	${INCLUDES} ${IDENT} ${PARAM} -D_KERNEL -Di386
50CWARNFLAGS?=	-Werror -Wall -Wmissing-prototypes -Wstrict-prototypes \
51		-Wpointer-arith
52# XXX Delete -Wuninitialized for now, since the compiler doesn't
53# XXX always get it right.  --thorpej
54CWARNFLAGS+=	-Wno-uninitialized
55.if (${HAVE_EGCS} != "")
56CWARNFLAGS+=	-Wno-main
57.endif
58CFLAGS=		${DEBUG} ${COPTS} ${CWARNFLAGS}
59AFLAGS=		-x assembler-with-cpp -traditional-cpp -D_LOCORE
60LINKFLAGS=	-Ttext c0100000 -e start
61.if (${OBJECT_FMT} == "ELF")
62#LINKFLAGS+=	-N
63.else
64LINKFLAGS+=	-z
65.endif
66
67.if defined(KERN_LDSCRIPT)
68LINKFLAGS+=	-T ${I386}/conf/${KERN_LDSCRIPT}
69.endif
70
71STRIPFLAGS=	-g
72
73%INCLUDES
74
75### find out what to use for libkern
76KERN_AS=	obj
77.include "$S/lib/libkern/Makefile.inc"
78.ifndef PROF
79LIBKERN=	${KERNLIB}
80.else
81LIBKERN=	${KERNLIB_PROF}
82.endif
83
84### find out what to use for libcompat
85.include "$S/compat/common/Makefile.inc"
86.ifndef PROF
87LIBCOMPAT=	${COMPATLIB}
88.else
89LIBCOMPAT=	${COMPATLIB_PROF}
90.endif
91
92# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
93# HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
94
95NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
96NOPROF_C=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
97NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
98
99%OBJS
100
101%CFILES
102
103%SFILES
104
105# load lines for config "xxx" will be emitted as:
106# xxx: ${SYSTEM_DEP} swapxxx.o
107#	${SYSTEM_LD_HEAD}
108#	${SYSTEM_LD} swapxxx.o
109#	${SYSTEM_LD_TAIL}
110SYSTEM_OBJ=	locore.o \
111		param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
112SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
113SYSTEM_LD_HEAD=	rm -f $@
114SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
115		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
116SYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
117
118DEBUG?=
119.if ${DEBUG} == "-g"
120LINKFLAGS+=	-X
121SYSTEM_LD_TAIL+=; \
122		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
123		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
124		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
125.else
126LINKFLAGS+=	-X
127.endif
128
129%LOAD
130
131assym.h: $S/kern/genassym.sh ${I386}/i386/genassym.cf
132	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
133	    < ${I386}/i386/genassym.cf > assym.h.tmp && \
134	mv -f assym.h.tmp assym.h
135
136param.c: $S/conf/param.c
137	rm -f param.c
138	cp $S/conf/param.c .
139
140param.o: param.c Makefile
141	${NORMAL_C}
142
143ioconf.o: ioconf.c
144	${NORMAL_C}
145
146newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
147	sh $S/conf/newvers.sh
148	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
149
150
151__CLEANKERNEL: .USE
152	@echo "${.TARGET}ing the kernel objects"
153	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
154	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
155
156__CLEANDEPEND: .USE
157	rm -f .depend
158
159clean: __CLEANKERNEL
160
161cleandir distclean: __CLEANKERNEL __CLEANDEPEND
162
163lint:
164	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
165	    ${I386}/i386/Locore.c ${CFILES} \
166	    ioconf.c param.c | \
167	    grep -v 'static function .* unused'
168
169tags:
170	@echo "see $S/kern/Makefile for tags"
171
172links:
173	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
174	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
175	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
176	  sort -u | comm -23 - dontlink | \
177	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
178	sh makelinks && rm -f dontlink
179
180SRCS=	${I386}/i386/locore.s \
181	param.c ioconf.c ${CFILES} ${SFILES}
182depend: .depend
183.depend: ${SRCS} assym.h param.c
184	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${I386}/i386/locore.s
185	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
186	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
187	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
188	  ${CPPFLAGS} < ${I386}/i386/genassym.cf
189	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
190	@rm -f assym.dep
191
192dependall: depend all
193
194
195# depend on root or device configuration
196autoconf.o conf.o: Makefile
197
198# depend on network or filesystem configuration
199uipc_proto.o vfs_conf.o: Makefile
200
201# depend on maxusers
202machdep.o: Makefile
203
204# depend on CPU configuration
205locore.o machdep.o: Makefile
206
207
208locore.o: ${I386}/i386/locore.s assym.h
209	${NORMAL_S}
210
211# The install target can be redefined by putting a
212# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
213MACHINE_NAME!=  uname -n
214install: install-kernel-${MACHINE_NAME}
215.if !target(install-kernel-${MACHINE_NAME}})
216install-kernel-${MACHINE_NAME}:
217	rm -f /onetbsd
218	ln /netbsd /onetbsd
219	cp netbsd /nnetbsd
220	mv /nnetbsd /netbsd
221.endif
222
223%RULES
224