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