Makefile.i386 revision 1.108
1#	$NetBSD: Makefile.i386,v 1.108 2000/12/17 15:52:41 jdolecek 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.if (${OBJECT_FMT} == "ELF")
56#LINKFLAGS+=	-N
57.else
58LINKFLAGS+=	-z
59.endif
60
61.if defined(KERN_LDSCRIPT)
62LINKFLAGS+=	-T ${I386}/conf/${KERN_LDSCRIPT}
63.endif
64
65STRIPFLAGS=	-g
66
67%INCLUDES
68
69### find out what to use for libkern
70KERN_AS=	obj
71.include "$S/lib/libkern/Makefile.inc"
72.ifndef PROF
73LIBKERN=	${KERNLIB}
74.else
75LIBKERN=	${KERNLIB_PROF}
76.endif
77
78### find out what to use for libcompat
79.include "$S/compat/common/Makefile.inc"
80.ifndef PROF
81LIBCOMPAT=	${COMPATLIB}
82.else
83LIBCOMPAT=	${COMPATLIB_PROF}
84.endif
85
86# compile rules: rules are named ${TYPE}_${SUFFIX} where TYPE is NORMAL or
87# HOSTED}, and SUFFIX is the file suffix, capitalized (e.g. C for a .c file).
88
89NORMAL_C=	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c $<
90NOPROF_C=	${CC} ${CFLAGS} ${CPPFLAGS} -c $<
91NORMAL_S=	${CC} ${AFLAGS} ${CPPFLAGS} -c $<
92
93%OBJS
94
95%CFILES
96
97%SFILES
98
99# load lines for config "xxx" will be emitted as:
100# xxx: ${SYSTEM_DEP} swapxxx.o
101#	${SYSTEM_LD_HEAD}
102#	${SYSTEM_LD} swapxxx.o
103#	${SYSTEM_LD_TAIL}
104SYSTEM_OBJ=	locore.o \
105		param.o ioconf.o ${OBJS} ${LIBCOMPAT} ${LIBKERN}
106SYSTEM_DEP=	Makefile ${SYSTEM_OBJ}
107SYSTEM_LD_HEAD=	rm -f $@
108SYSTEM_LD=	@echo ${LD} ${LINKFLAGS} -o $@ '$${SYSTEM_OBJ}' vers.o; \
109		${LD} ${LINKFLAGS} -o $@ ${SYSTEM_OBJ} vers.o
110SYSTEM_LD_TAIL=	@${SIZE} $@; chmod 755 $@
111
112DEBUG?=
113.if ${DEBUG} == "-g"
114LINKFLAGS+=	-X
115SYSTEM_LD_TAIL+=; \
116		echo mv -f $@ $@.gdb; mv -f $@ $@.gdb; \
117		echo ${STRIP} ${STRIPFLAGS} -o $@ $@.gdb; \
118		${STRIP} ${STRIPFLAGS} -o $@ $@.gdb
119.else
120LINKFLAGS+=	-X
121.endif
122
123%LOAD
124
125assym.h: $S/kern/genassym.sh ${I386}/i386/genassym.cf
126	sh $S/kern/genassym.sh ${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} \
127	    < ${I386}/i386/genassym.cf > assym.h.tmp && \
128	mv -f assym.h.tmp assym.h
129
130param.c: $S/conf/param.c
131	rm -f param.c
132	cp $S/conf/param.c .
133
134param.o: param.c Makefile
135	${NORMAL_C}
136
137ioconf.o: ioconf.c
138	${NORMAL_C}
139
140newvers: ${SYSTEM_DEP} ${SYSTEM_SWAP_DEP}
141	sh $S/conf/newvers.sh
142	${CC} ${CFLAGS} ${CPPFLAGS} ${PROF} -c vers.c
143
144
145__CLEANKERNEL: .USE
146	@echo "${.TARGET}ing the kernel objects"
147	rm -f eddep *netbsd netbsd.gdb tags *.[io] [a-z]*.s \
148	    [Ee]rrs linterrs makelinks assym.h.tmp assym.h
149
150__CLEANDEPEND: .USE
151	rm -f .depend
152
153clean: __CLEANKERNEL
154
155cleandir distclean: __CLEANKERNEL __CLEANDEPEND
156
157lint:
158	@lint -hbxncez -Dvolatile= ${CPPFLAGS} -UKGDB \
159	    ${I386}/i386/Locore.c ${CFILES} \
160	    ioconf.c param.c | \
161	    grep -v 'static function .* unused'
162
163tags:
164	@echo "see $S/kern/Makefile for tags"
165
166links:
167	egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
168	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
169	echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
170	  sort -u | comm -23 - dontlink | \
171	  sed 's,../.*/\(.*.o\),rm -f \1; ln -s ../GENERIC/\1 \1,' > makelinks
172	sh makelinks && rm -f dontlink
173
174SRCS=	${I386}/i386/locore.s \
175	param.c ioconf.c ${CFILES} ${SFILES}
176depend: .depend
177.depend: ${SRCS} assym.h param.c
178	${MKDEP} ${AFLAGS} ${CPPFLAGS} ${I386}/i386/locore.s
179	${MKDEP} -a ${CFLAGS} ${CPPFLAGS} param.c ioconf.c ${CFILES}
180	${MKDEP} -a ${AFLAGS} ${CPPFLAGS} ${SFILES}
181	sh $S/kern/genassym.sh ${MKDEP} -f assym.dep ${CFLAGS} \
182	  ${CPPFLAGS} < ${I386}/i386/genassym.cf
183	@sed -e 's/.*\.o:.*\.c/assym.h:/' < assym.dep >> .depend
184	@rm -f assym.dep
185
186dependall: depend all
187
188
189# depend on root or device configuration
190autoconf.o conf.o: Makefile
191
192# depend on network or filesystem configuration
193uipc_proto.o vfs_conf.o: Makefile
194
195# depend on maxusers
196machdep.o: Makefile
197
198# depend on CPU configuration
199locore.o machdep.o: Makefile
200
201
202locore.o: ${I386}/i386/locore.s assym.h
203	${NORMAL_S}
204
205# The install target can be redefined by putting a
206# install-kernel-${MACHINE_NAME} target into /etc/mk.conf
207MACHINE_NAME!=  uname -n
208install: install-kernel-${MACHINE_NAME}
209.if !target(install-kernel-${MACHINE_NAME}})
210install-kernel-${MACHINE_NAME}:
211	rm -f /onetbsd
212	ln /netbsd /onetbsd
213	cp netbsd /nnetbsd
214	mv /nnetbsd /netbsd
215.endif
216
217%RULES
218