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 INCLUDES= -nostdinc -I- ${INCLMAGIC} -I. -I$S -I$S/dev
42 # This hack is to allow kernel compiles to succeed on machines w/out srcdist
43 .if exists($S/../include)
44 INCLUDES+= -I$S/../include
46 INCLUDES+= -I/usr/include
49 # This hack lets us use the Intel ACPICA code without spamming a new
50 # include path into 100+ source files.
51 INCLUDES+= -I$S/contrib/dev/acpica/Subsystem/Include
53 COPTS= ${INCLUDES} ${IDENT} -D_KERNEL -include opt_global.h
54 CFLAGS= ${COPTFLAGS} ${CWARNFLAGS} ${DEBUG} ${COPTS}
56 # XXX LOCORE means "don't declare C stuff" not "for locore.s".
57 ASM_CFLAGS= -x assembler-with-cpp -DLOCORE ${CFLAGS}
59 # Select the correct set of tools. Can't set OBJFORMAT here because it
60 # doesn't get exported into the environment, and if it were exported
61 # then it might break building of utilities.
67 CFLAGS+= -malign-functions=4
69 IDENT+= -DGPROF4 -DGUPROF
70 PROF+= -mprofiler-epilogue
74 # Put configuration-specific C flags last (except for ${PROF}) so that they
75 # can override the others.
76 CFLAGS+= ${CONF_CFLAGS}
78 NORMAL_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
79 NORMAL_C_C= ${CC} -c ${CFLAGS} ${PROF} ${.IMPSRC}
80 NORMAL_S= ${CC} -c ${ASM_CFLAGS} ${.IMPSRC}
81 PROFILE_C= ${CC} -c ${CFLAGS} ${.IMPSRC}
83 NORMAL_M= perl5 $S/kern/makeobjops.pl -c $<; \
84 ${CC} -c ${CFLAGS} ${PROF} ${.PREFIX}.c
86 GEN_CFILES= $S/$M/$M/genassym.c
87 # setdef0.c and setdef1.c are intentionally
88 # omitted from SYSTEM_CFILES. They include setdefs.h, a header which
89 # is generated from all of ${OBJS}. We don't want to have to compile
90 # everything just to do a make depend.
91 SYSTEM_CFILES= param.c vnode_if.c hints.c config.c
92 SYSTEM_SFILES= $S/$M/$M/locore.s
93 SYSTEM_DEP= Makefile ${SYSTEM_OBJS}
94 SYSTEM_OBJS= locore.o setdef0.o vnode_if.o ${OBJS} param.o hints.o config.o \
96 SYSTEM_LD= @${LD} ${FMT} -Bdynamic -T $S/conf/ldscript.$M \
97 -export-dynamic -dynamic-linker /red/herring \
98 -o ${.TARGET} -X ${SYSTEM_OBJS} vers.o
99 SYSTEM_LD_TAIL= @${OBJCOPY} --strip-symbol gcc2_compiled. ${.TARGET} ; \
100 ${SIZE} ${FMT} ${.TARGET} ; chmod 755 ${.TARGET}
101 SYSTEM_DEP+= $S/conf/ldscript.$M
119 depend: kernel-depend
121 cleandepend: kernel-cleandepend
122 clobber: kernel-clobber
124 install: kernel-install
125 install.debug: kernel-install.debug
126 reinstall: kernel-reinstall
127 reinstall.debug: kernel-reinstall.debug
130 FULLKERNEL= ${KERNEL_KO}
132 FULLKERNEL= ${KERNEL_KO}.debug
133 ${KERNEL_KO}: ${FULLKERNEL}
134 ${OBJCOPY} --strip-debug ${FULLKERNEL} ${KERNEL_KO}
137 ${FULLKERNEL}: ${SYSTEM_DEP} vers.o
139 @echo linking ${.TARGET}
144 ${SYSTEM_OBJS}: vnode_if.h ${BEFORE_DEPEND:M*.h} ${MFILES:T:S/.m$/.h/}
147 .for mfile in ${MFILES}
148 ${mfile:T:S/.m$/.h/}: ${mfile}
149 perl5 $S/kern/makeobjops.pl -h ${mfile}
153 rm -f *.o *.so *.So *.ko *.s eddep errs \
154 ${FULLKERNEL} ${KERNEL_KO} linterrs makelinks param.c \
155 setdef[01].c setdefs.h tags \
156 vers.c vnode_if.c vnode_if.h \
157 ${MFILES:T:S/.m$/.c/} ${MFILES:T:S/.m$/.h/} \
161 find . -type f ! -name version -delete
164 # @lint -hbxn -DGENERIC -Dvolatile= ${COPTS} \
165 # $S/$M/$M/Locore.c ${CFILES} param.c | \
166 # grep -v 'struct/union .* never defined' | \
167 # grep -v 'possible pointer alignment problem'
169 locore.o: $S/$M/$M/locore.s assym.s
172 # This is a hack. BFD "optimizes" away dynamic mode if there are no
173 # dynamic references. We could probably do a '-Bforcedynamic' mode like
174 # in the a.out ld. For now, this works.
177 ${CC} ${FMT} -shared -nostdlib hack.c -o hack.So
180 .ORDER: setdefs.h setdef0.c setdef1.c
182 setdef0.o: setdef0.c setdefs.h
185 setdef1.o: setdef1.c setdefs.h
188 setdef0.c setdef1.c setdefs.h: Makefile ${OBJS}
189 @perl5 $S/kern/gensetdefs.pl ${OBJS}
191 # this rule stops ./assym.s in .depend from causing problems
194 assym.s: $S/kern/genassym.sh genassym.o
195 OBJFORMAT=elf sh $S/kern/genassym.sh genassym.o > ${.TARGET}
197 genassym.o: $S/$M/$M/genassym.c
198 ${CC} -c ${CFLAGS} -elf $S/$M/$M/genassym.c
200 ${SYSTEM_OBJS} genassym.o vers.o: opt_global.h
204 ${MAKE} _kernel-depend
206 _kernel-depend: assym.s param.c vnode_if.h ${BEFORE_DEPEND} \
207 ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES} ${SFILES} \
208 ${SYSTEM_SFILES} ${MFILES:T:S/.m$/.h/}
210 mkdep -a -f .newdep ${CFLAGS} ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES}
211 env MKDEP_CPP="${CC} -E" \
212 mkdep -a -f .newdep ${ASM_CFLAGS} ${SFILES} ${SYSTEM_SFILES}
214 mv -f .newdep .depend
220 egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
221 sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
222 echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
223 sort -u | comm -23 - dontlink | \
224 sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks
225 sh makelinks; rm -f dontlink
228 @[ -f .depend ] || { echo "you must make depend first"; exit 1; }
229 sh $S/conf/systags.sh
231 sed -e 's, ../, ,' tags > tags1
233 kernel-install kernel-install.debug:
234 .if exists(${DESTDIR}/boot)
235 @if [ ! -f ${DESTDIR}/boot/device.hints ] ; then \
236 echo "You must set up a ${DESTDIR}/boot/device.hints file first." ; \
239 @if [ x"`grep device.hints ${DESTDIR}/boot/defaults/loader.conf ${DESTDIR}/boot/loader.conf`" = "x" ]; then \
240 echo "You must activate /boot/device.hints in loader.conf." ; \
244 @if [ ! -f ${KERNEL_KO}${.TARGET:S/kernel-install//} ] ; then \
245 echo "You must build a kernel first." ; \
248 .if exists(${DESTDIR}${KODIR})
249 .if exists(${DESTDIR}${KODIR}.old)
250 @-chflags -R noschg ${DESTDIR}${KODIR}.old
251 -rm -rf ${DESTDIR}${KODIR}.old
253 mv ${DESTDIR}${KODIR} ${DESTDIR}${KODIR}.old
255 mkdir -p ${DESTDIR}${KODIR}
256 @if [ -f ${DESTDIR}${KODIR}/${KERNEL_KO} ] ; then \
257 chflags noschg ${DESTDIR}${KODIR}/${KERNEL_KO} ; \
259 install -c -m 555 -o root -g wheel -fschg \
260 ${KERNEL_KO}${.TARGET:S/kernel-install//} ${DESTDIR}${KODIR}
262 kernel-reinstall kernel-reinstall.debug:
263 @if [ -f ${DESTDIR}${KODIR}/${KERNEL_KO} ] ; then \
264 chflags noschg ${DESTDIR}${KODIR}/${KERNEL_KO} ; \
266 install -c -m 555 -o root -g wheel -fschg \
267 ${KERNEL_KO}${.TARGET:S/kernel-reinstall//} ${DESTDIR}${KODIR}
269 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists($S/modules)
271 depend: modules-depend
273 cleandepend: modules-cleandepend
274 cleandir: modules-cleandir
275 clobber: modules-clobber
277 install: modules-install
278 install.debug: modules-install.debug
279 reinstall: modules-reinstall
280 reinstall.debug: modules-reinstall.debug
283 MKMODULESENV= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR}
286 @mkdir -p ${.OBJDIR}/modules
287 cd $S/modules ; env ${MKMODULESENV} ${MAKE} obj ; \
288 env ${MKMODULESENV} ${MAKE} all
291 @mkdir -p ${.OBJDIR}/modules
292 cd $S/modules ; env ${MKMODULESENV} ${MAKE} obj ; \
293 env ${MKMODULESENV} ${MAKE} depend
296 cd $S/modules ; env ${MKMODULESENV} ${MAKE} clean
299 cd $S/modules ; env ${MKMODULESENV} ${MAKE} cleandepend
301 modules-clobber: modules-clean
302 rm -rf ${MKMODULESENV}
305 cd $S/modules ; env ${MKMODULESENV} ${MAKE} cleandir
308 cd $S/modules ; env ${MKMODULESENV} ${MAKE} tags
310 modules-install modules-install.debug:
311 cd $S/modules ; env ${MKMODULESENV} ${MAKE} install
313 modules-reinstall modules-reinstall.debug:
314 cd $S/modules ; env ${MKMODULESENV} ${MAKE} install
319 param.c: $S/conf/param.c
326 vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP}
327 sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT}
329 # XXX strictly, everything depends on Makefile because changes to ${PROF}
330 # only appear there, but we don't handle that.
337 vnode_if.c: $S/kern/vnode_if.pl $S/kern/vnode_if.src
338 perl5 $S/kern/vnode_if.pl -c $S/kern/vnode_if.src
340 vnode_if.h: $S/kern/vnode_if.pl $S/kern/vnode_if.src
341 perl5 $S/kern/vnode_if.pl -h $S/kern/vnode_if.src
346 # Commented out for now pending a better solution.
347 # How do we pick up compiler version specific flags??
348 #.if exists($S/../share/mk)
349 #.include "$S/../share/mk/bsd.kern.mk"
351 .include <bsd.kern.mk>
356 # DO NOT DELETE THIS LINE -- make depend uses it