1 # Makefile.i386 -- with config changes.
2 # Copyright 1990 W. Jolitz
3 # from: @(#)Makefile.i386 7.1 5/10/91
8 # This makefile is constructed from a machine description:
10 # Most changes should be made in the machine description
11 # /sys/i386/conf/``machineid''
12 # after which you should do
14 # Generic makefile changes should be made in
15 # /sys/i386/conf/Makefile.i386
16 # after which config should be rerun for all machines.
19 # Which version of config(8) is required.
22 # Can be overridden by makeoptions or /etc/make.conf
25 KODIR?= /boot/${KERNEL}
41 .if !defined(NO_CPU_COPTFLAGS)
42 COPTFLAGS+= ${_CPUCFLAGS}
44 INCLUDES= -nostdinc -I- ${INCLMAGIC} -I. -I$S -I$S/dev
46 # This hack lets us use the Intel ACPICA code without spamming a new
47 # include path into 100+ source files.
48 INCLUDES+= -I$S/contrib/dev/acpica
50 # ... and the same for ipfilter
51 INCLUDES+= -I$S/contrib/ipfilter
53 # This hack is to allow kernel compiles to succeed on machines w/out srcdist
54 .if exists($S/../include)
55 INCLUDES+= -I$S/../include
57 INCLUDES+= -I/usr/include
60 COPTS= ${INCLUDES} ${IDENT} -D_KERNEL -include opt_global.h
61 CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS}
63 # XXX LOCORE means "don't declare C stuff" not "for locore.s".
64 ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS}
66 # Select the correct set of tools. Can't set OBJFORMAT here because it
67 # doesn't get exported into the environment, and if it were exported
68 # then it might break building of utilities.
74 CFLAGS+= -malign-functions=4
76 IDENT+= -DGPROF4 -DGUPROF
77 PROF+= -mprofiler-epilogue
81 # Put configuration-specific C flags last (except for ${PROF}) so that they
82 # can override the others.
83 CFLAGS+= ${CONF_CFLAGS}
85 NORMAL_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
86 NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
87 NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${.IMPSRC}
88 PROFILE_C= ${CC} -c ${CFLAGS} ${.IMPSRC}
90 NORMAL_M= perl5 $S/kern/makeobjops.pl -c $<; \
91 ${CC} -c ${CFLAGS} ${PROF} ${.PREFIX}.c
93 GEN_CFILES= $S/$M/$M/genassym.c
94 SYSTEM_CFILES= vnode_if.c hints.c config.c
95 SYSTEM_SFILES= $S/$M/$M/locore.s
96 SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
97 SYSTEM_OBJS= locore.o vnode_if.o ${OBJS} hints.o config.o hack.So
98 SYSTEM_LD= @${LD} ${FMT} -Bdynamic -T $S/conf/ldscript.$M \
99 -export-dynamic -dynamic-linker /red/herring \
100 -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
101 SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
102 ${SIZE} ${FMT} ${.TARGET} ; chmod 755 ${.TARGET}
103 SYSTEM_DEP+= $S/conf/ldscript.$M
121 depend: kernel-depend
123 cleandepend: kernel-cleandepend
124 clobber: kernel-clobber
126 install: kernel-install
127 install.debug: kernel-install.debug
128 reinstall: kernel-reinstall
129 reinstall.debug: kernel-reinstall.debug
132 FULLKERNEL= ${KERNEL_KO}
134 FULLKERNEL= ${KERNEL_KO}.debug
135 ${KERNEL_KO}: ${FULLKERNEL}
136 ${OBJCOPY} --strip-debug ${FULLKERNEL} ${KERNEL_KO}
139 ${FULLKERNEL}: ${SYSTEM_DEP} vers.o
141 @echo linking ${.TARGET}
146 ${SYSTEM_OBJS}: vnode_if.h ${BEFORE_DEPEND:M*.h} ${MFILES:T:S/.m$/.h/}
149 .for mfile in ${MFILES}
150 ${mfile:T:S/.m$/.h/}: ${mfile}
151 perl5 $S/kern/makeobjops.pl -h ${mfile}
155 rm -f *.o *.so *.So *.ko *.s eddep errs \
156 ${FULLKERNEL} ${KERNEL_KO} linterrs makelinks \
157 setdef[01].c setdefs.h tags \
158 vers.c vnode_if.c vnode_if.h \
159 ${MFILES:T:S/.m$/.c/} ${MFILES:T:S/.m$/.h/} \
163 find . -type f ! -name version -delete
166 # @lint -hbxn -DGENERIC -Dvolatile= ${COPTS} \
167 # $S/$M/$M/Locore.c ${CFILES} | \
168 # grep -v 'struct/union .* never defined' | \
169 # grep -v 'possible pointer alignment problem'
171 locore.o: $S/$M/$M/locore.s assym.s
174 # This is a hack. BFD "optimizes" away dynamic mode if there are no
175 # dynamic references. We could probably do a '-Bforcedynamic' mode like
176 # in the a.out ld. For now, this works.
179 ${CC} ${FMT} -shared -nostdlib hack.c -o hack.So
182 # this rule stops ./assym.s in .depend from causing problems
185 assym.s: $S/kern/genassym.sh genassym.o
186 OBJFORMAT=elf sh $S/kern/genassym.sh genassym.o > ${.TARGET}
188 genassym.o: $S/$M/$M/genassym.c
189 ${CC} -c ${CFLAGS} -elf $S/$M/$M/genassym.c
191 ${SYSTEM_OBJS} genassym.o vers.o: opt_global.h
195 if [ -f .depend ]; then mv .depend .olddep; fi
196 ${MAKE} _kernel-depend
198 _kernel-depend: assym.s vnode_if.h ${BEFORE_DEPEND} \
199 ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES} ${SFILES} \
200 ${SYSTEM_SFILES} ${MFILES:T:S/.m$/.h/}
201 if [ -f .olddep ]; then mv .olddep .depend; fi
203 mkdep -a -f .newdep ${CFLAGS} ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES}
204 env MKDEP_CPP="${CC} -E" \
205 mkdep -a -f .newdep ${ASM_CFLAGS} ${SFILES} ${SYSTEM_SFILES}
213 egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
214 sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
215 echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
216 sort -u | comm -23 - dontlink | \
217 sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks
218 sh makelinks; rm -f dontlink
221 @[ -f .depend ] || { echo "you must make depend first"; exit 1; }
222 sh $S/conf/systags.sh
224 sed -e 's, ../, ,' tags > tags1
226 kernel-install kernel-install.debug:
227 .if exists(${DESTDIR}/boot)
228 @if [ ! -f ${DESTDIR}/boot/device.hints ] ; then \
229 echo "You must set up a ${DESTDIR}/boot/device.hints file first." ; \
232 @if [ x"`grep device.hints ${DESTDIR}/boot/defaults/loader.conf ${DESTDIR}/boot/loader.conf`" = "x" ]; then \
233 echo "You must activate /boot/device.hints in loader.conf." ; \
237 @if [ ! -f ${KERNEL_KO}${.TARGET:S/kernel-install//} ] ; then \
238 echo "You must build a kernel first." ; \
241 .if exists(${DESTDIR}${KODIR})
242 .if exists(${DESTDIR}${KODIR}.old)
243 @-chflags -R noschg ${DESTDIR}${KODIR}.old
244 -rm -rf ${DESTDIR}${KODIR}.old
246 mv ${DESTDIR}${KODIR} ${DESTDIR}${KODIR}.old
248 mkdir -p ${DESTDIR}${KODIR}
249 install -c -m 555 -o root -g wheel \
250 ${KERNEL_KO}${.TARGET:S/kernel-install//} ${DESTDIR}${KODIR}
252 kernel-reinstall kernel-reinstall.debug:
253 @-chflags -R noschg ${DESTDIR}${KODIR}
254 install -c -m 555 -o root -g wheel \
255 ${KERNEL_KO}${.TARGET:S/kernel-reinstall//} ${DESTDIR}${KODIR}
257 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists($S/modules)
259 depend: modules-depend
261 cleandepend: modules-cleandepend
262 cleandir: modules-cleandir
263 clobber: modules-clobber
265 install: modules-install
266 install.debug: modules-install.debug
267 reinstall: modules-reinstall
268 reinstall.debug: modules-reinstall.debug
271 MKMODULESENV= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR}
272 .if defined(MODULES_OVERRIDE)
273 MKMODULESENV+= MODULES_OVERRIDE="${MODULES_OVERRIDE}"
276 MKMODULESENV+= DEBUG="${DEBUG}" DEBUG_FLAGS="${DEBUG}"
280 @mkdir -p ${.OBJDIR}/modules
281 cd $S/modules ; env ${MKMODULESENV} ${MAKE} obj ; \
282 env ${MKMODULESENV} ${MAKE} all
285 @mkdir -p ${.OBJDIR}/modules
286 cd $S/modules ; env ${MKMODULESENV} ${MAKE} obj ; \
287 env ${MKMODULESENV} ${MAKE} depend
290 cd $S/modules ; env ${MKMODULESENV} ${MAKE} clean
293 cd $S/modules ; env ${MKMODULESENV} ${MAKE} cleandepend
295 modules-clobber: modules-clean
296 rm -rf ${MKMODULESENV}
299 cd $S/modules ; env ${MKMODULESENV} ${MAKE} cleandir
302 cd $S/modules ; env ${MKMODULESENV} ${MAKE} tags
304 modules-install modules-install.debug:
305 cd $S/modules ; env ${MKMODULESENV} ${MAKE} install
307 modules-reinstall modules-reinstall.debug:
308 cd $S/modules ; env ${MKMODULESENV} ${MAKE} install
313 vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP}
314 sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT}
316 # XXX strictly, everything depends on Makefile because changes to ${PROF}
317 # only appear there, but we don't handle that.
324 vnode_if.c: $S/kern/vnode_if.pl $S/kern/vnode_if.src
325 perl5 $S/kern/vnode_if.pl -c $S/kern/vnode_if.src
327 vnode_if.h: $S/kern/vnode_if.pl $S/kern/vnode_if.src
328 perl5 $S/kern/vnode_if.pl -h $S/kern/vnode_if.src
333 # Commented out for now pending a better solution.
334 # How do we pick up compiler version specific flags??
335 #.if exists($S/../share/mk)
336 #.include "$S/../share/mk/bsd.kern.mk"
338 .include <bsd.kern.mk>
343 # DO NOT DELETE THIS LINE -- make depend uses it