xref: /freebsd/sys/conf/Makefile.i386 (revision 0640d357f29fb1c0daaaffadd0416c5981413afd)
1# Makefile.i386 -- with config changes.
2# Copyright 1990 W. Jolitz
3#	from: @(#)Makefile.i386	7.1 5/10/91
4#	$Id: Makefile.i386,v 1.126 1998/10/10 01:00:56 peter Exp $
5#
6# Makefile for FreeBSD
7#
8# This makefile is constructed from a machine description:
9#	config machineid
10# Most changes should be made in the machine description
11#	/sys/i386/conf/``machineid''
12# after which you should do
13#	 config machineid
14# Generic makefile changes should be made in
15#	/sys/i386/conf/Makefile.i386
16# after which config should be rerun for all machines.
17#
18
19# Which version of config(8) is required.
20%VERSREQ=	300008
21
22KERNFORMAT?=	aout
23
24STD8X16FONT?=	iso
25
26.if exists(./@/.)
27S=	./@
28.else
29S=	../..
30.endif
31I386=	${S}/i386
32
33COPTFLAGS?=-O
34INCLUDES= -nostdinc -I- -I. -I$S
35# This hack is to allow kernel compiles to succeed on machines w/out srcdist
36.if exists($S/../include)
37INCLUDES+= -I$S/../include
38.else
39INCLUDES+= -I/usr/include
40.endif
41COPTS=	${INCLUDES} ${IDENT} -DKERNEL -include opt_global.h
42CFLAGS=	${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS}
43
44# XXX LOCORE means "don't declare C stuff" not "for locore.s".
45ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS}
46
47# Use the default object format for genassym, etc.
48GEN_CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS}
49
50# Select the correct set of tools. Can't set OBJFORMAT here because it
51# doesn't get exported into the environment, and if it were exported
52# then it might break building of genassym, etc.
53.if ${KERNFORMAT} == "elf"
54CFLAGS+=	-elf
55.else
56CFLAGS+=	-aout
57.endif
58
59LOAD_ADDRESS?=	F0100000
60DEFINED_PROF=	${PROF}
61.if defined(PROF)
62CFLAGS+=	-malign-functions=4
63.if ${PROFLEVEL} >= 2
64IDENT+=	-DGPROF4 -DGUPROF
65PROF+=	-mprofiler-epilogue
66.endif
67.endif
68
69NORMAL_C= ${CC} -c ${CFLAGS} ${PROF} $<
70NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} $<
71NORMAL_S= ${CC} -c ${ASM_CFLAGS} $<
72DRIVER_C= ${CC} -c ${CFLAGS} ${PROF} $<
73DRIVER_C_C= ${CC} -c ${CFLAGS} ${PROF} $<
74DRIVER_S= ${CC} -c -x ${ASM_CFLAGS} $<
75PROFILE_C= ${CC} -c ${CFLAGS} $<
76
77GEN_CFILES= ${I386}/i386/genassym.c ${I386}/i386/gensetdefs.c
78# ${I386}/i386/setdef0.c and ${I386}/i386/setdef1.c are intentionally
79# omitted from SYSTEM_CFILES.  They include setdefs.h, a header which
80# is generated from all of ${OBJS}.  We don't want to have to compile
81# everything just to do a make depend.
82SYSTEM_CFILES= ioconf.c param.c vnode_if.c config.c
83SYSTEM_SFILES= ${I386}/i386/locore.s
84SYSTEM_DEP= Makefile symbols.exclude symbols.sort ${SYSTEM_OBJS}
85.if ${CFLAGS:M-g} == ""
86SYMORDER_EXCLUDE=-x symbols.exclude
87.endif
88SYSTEM_LD_HEAD= @echo loading ${.TARGET}; rm -f ${.TARGET}
89.if ${KERNFORMAT} == aout
90SYSTEM_OBJS= locore.o vnode_if.o ${OBJS} ioconf.o param.o config.o
91SYSTEM_LD= @${LD} -aout -Bstatic -Z -T ${LOAD_ADDRESS} -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
92SYSTEM_LD_TAIL= @echo rearranging symbols; \
93	symorder -m ${SYMORDER_EXCLUDE} symbols.sort ${.TARGET}; \
94	size -aout ${.TARGET} ; chmod 755 ${.TARGET}
95.endif
96.if ${KERNFORMAT} == aoutkld
97SYSTEM_OBJS= locore.o vnode_if.o ${OBJS} ioconf.o param.o config.o
98SYSTEM_LD= @${LD} -aout -Bforcedynamic -Z -T ${LOAD_ADDRESS} -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
99SYSTEM_LD_TAIL= @echo rearranging symbols; \
100	symorder -m ${SYMORDER_EXCLUDE} symbols.sort ${.TARGET}; \
101	size -aout ${.TARGET} ; chmod 755 ${.TARGET}
102.endif
103.if ${KERNFORMAT} == elf
104# kld compatable export of symbols.
105SYSTEM_OBJS= locore.o setdef0.o vnode_if.o ${OBJS} ioconf.o param.o config.o \
106	setdef1.o hack.so
107SYSTEM_LD= @${LD} -elf -Bdynamic -T $S/i386/conf/kernel.script \
108	-export-dynamic -dynamic-linker /red/herring \
109	-o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
110SYSTEM_LD_TAIL= @size -elf ${.TARGET} ; chmod 755 ${.TARGET}
111SYSTEM_DEP+= $S/i386/conf/kernel.script
112.endif
113
114%BEFORE_DEPEND
115
116%OBJS
117
118%CFILES
119
120%SFILES
121
122%MFILES
123
124%LOAD
125
126%CLEAN
127
128clean:
129	rm -f *.o *.so *.ko *.s eddep errs genassym gensetdefs kernel linterrs \
130	      makelinks param.c setdefs.h symbols.exclude symbols.sort tags \
131	      vers.c vnode_if.c vnode_if.h ${CLEAN}
132
133#lint: /tmp param.c
134#	@lint -hbxn -DGENERIC -Dvolatile= ${COPTS} \
135#	  ${I386}/i386/Locore.c ${CFILES} ioconf.c param.c | \
136#	    grep -v 'struct/union .* never defined' | \
137#	    grep -v 'possible pointer alignment problem'
138
139symbols.exclude:
140	echo "gcc2_compiled." >symbols.exclude
141	echo "___gnu_compiled_c" >>symbols.exclude
142
143symbols.sort: ${I386}/i386/symbols.raw
144	grep -v '^#' ${I386}/i386/symbols.raw \
145	    | sed 's/^	//' | sort -u > symbols.sort
146
147locore.o: ${I386}/i386/locore.s assym.s
148	${NORMAL_S}
149
150.if ${KERNFORMAT} == elf
151# This is a hack.  BFD "optimizes" away dynamic mode if there are no
152# dynamic references.  We could probably do a '-Bforcedynamic' mode like
153# in the a.out ld.  For now, this works.
154hack.so: Makefile
155	touch hack.c
156	${CC} -elf -shared -nostdlib hack.c -o hack.so
157	rm -f hack.c
158.endif
159
160setdef0.o: ${I386}/i386/setdef0.c setdefs.h
161	${NORMAL_C}
162
163setdef1.o: ${I386}/i386/setdef1.c setdefs.h
164	${NORMAL_C}
165
166setdefs.h: gensetdefs ${OBJS}
167	./gensetdefs ${OBJS} >setdefs.h
168
169gensetdefs: gensetdefs.o
170	${CC} ${GEN_CFLAGS} gensetdefs.o -o ${.TARGET}
171
172gensetdefs.o: ${I386}/i386/gensetdefs.c
173	${CC} -c ${GEN_CFLAGS} ${I386}/i386/gensetdefs.c
174
175# this rule stops ./assym.s in .depend from causing problems
176./assym.s: assym.s
177
178assym.s: genassym
179	./genassym >assym.s
180
181genassym.o: ${I386}/i386/genassym.c
182	${CC} -c ${GEN_CFLAGS} ${I386}/i386/genassym.c
183
184genassym: genassym.o
185	${CC} ${GEN_CFLAGS} genassym.o -o ${.TARGET}
186
187${SYSTEM_OBJS} genassym.o gensetdefs.o vers.o: opt_global.h
188
189# XXX this assumes that the options for NORMAL_C* and DRIVER_C* are identical.
190depend: assym.s param.c vnode_if.h ${BEFORE_DEPEND}
191	rm -f .newdep
192	mkdep -a -f .newdep ${CFLAGS} ${CFILES} ${SYSTEM_CFILES}
193	mkdep -a -f .newdep ${GEN_CFLAGS} ${GEN_CFILES}
194	env MKDEP_CPP="${CC} -E" \
195	    mkdep -a -f .newdep ${ASM_CFLAGS} ${SFILES} ${SYSTEM_SFILES}
196	rm -f .depend
197	mv -f .newdep .depend
198
199cleandepend:
200	rm -f .depend
201
202links:
203	egrep '#if' ${CFILES:Nswapkernel.c} | sed -f $S/conf/defines | \
204	  sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
205	echo ${CFILES:Nswapkernel.c} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
206	  sort -u | comm -23 - dontlink | \
207	  sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks
208	sh makelinks && rm -f dontlink
209
210tags:
211	@echo "see $S/kern/Makefile for tags"
212
213install:
214	@if [ ! -f kernel ] ; then \
215		echo "You must first build your kernel before trying to install." ; \
216		exit 1 ; \
217	fi
218.if exists(${DESTDIR}/kernel)
219	chflags noschg ${DESTDIR}/kernel
220	mv ${DESTDIR}/kernel ${DESTDIR}/kernel.old
221.endif
222	PATH=$${PATH}:/sbin:/usr/sbin; \
223	if [ `sysctl -n kern.bootfile` = ${DESTDIR}/kernel ] ; then \
224		sysctl -w kern.bootfile=${DESTDIR}/kernel.old ; \
225		if [ -f /var/db/kvm_kernel.db ] ; then \
226			mv -f /var/db/kvm_kernel.db /var/db/kvm_kernel.old.db ; \
227		fi \
228	fi
229	install -c -m 555 -o root -g wheel -fschg kernel ${DESTDIR}/
230
231config.o:
232	${NORMAL_C}
233
234ioconf.o:
235	${NORMAL_C}
236
237param.c: $S/conf/param.c
238	-rm -f param.c
239	cp $S/conf/param.c .
240
241param.o:
242	${NORMAL_C}
243
244vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP}
245	sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT}
246
247# XXX strictly, everything depends on Makefile because changes to ${PROF}
248# only appear there, but we don't handle that.
249vers.o:
250	${NORMAL_C}
251
252.ORDER: vnode_if.c vnode_if.h
253vnode_if.c vnode_if.h: $S/kern/vnode_if.sh $S/kern/vnode_if.src
254	sh $S/kern/vnode_if.sh $S/kern/vnode_if.src
255
256vnode_if.o:
257	${NORMAL_C}
258
259.if exists($S/../share/mk)
260.include "$S/../share/mk/bsd.kern.mk"
261.else
262.include <bsd.kern.mk>
263.endif
264
265%RULES
266
267# DO NOT DELETE THIS LINE -- make depend uses it
268