kern.post.mk revision 111802
1101877Sjmallett# Part of unified Makefile for building kernels. This includes all 292821Simp# the definitions that need to be included after all the % directives, 392821Simp# except %RULES and things that act like they are part of %RULES 485909Simp# 588893Simp# Most make variables should not be defined in this file. Instead, they 688893Simp# should be defined in the kern.pre.mk so that port makefiles can 788969Simp# override or augment them. 888893Simp# 985909Simp# $FreeBSD: head/sys/conf/kern.post.mk 111802 2003-03-03 09:35:44Z ru $ 1085909Simp# 1185909Simp 12111211Sru.MAIN: all 1385909Simp 14111802Sru.for target in all clean cleandepend cleandir clobber depend install \ 15111802Sru obj reinstall tags 16111211Sru${target}: kernel-${target} 17111211Sru.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists($S/modules) 18111211Sru${target}: modules-${target} 19111211Srumodules-${target}: 20111802Sru cd $S/modules; ${MKMODULESENV} ${MAKE} \ 21111802Sru ${target:S/^reinstall$/install/:S/^clobber$/cleandir/} 22111211Sru.endif 23111211Sru.endfor 2485909Simp 25111211Sru.ORDER: kernel-install modules-install 26111211Sru 27111211Srukernel-all: ${KERNEL_KO} 28111211Sru 29111802Srukernel-cleandir: kernel-clean 30111802Sru 31111802Srukernel-clobber: 32111766Sru find . -maxdepth 1 ! -type d ! -name version -delete 33111211Sru 34111766Srukernel-obj: 35111766Sru 36111211Sru.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists($S/modules) 37111211Srumodules: modules-all 38111211Sru 39111211Sru.if !defined(NO_MODULES_OBJ) 40111211Srumodules-all modules-depend: modules-obj 41111211Sru.endif 42111211Sru.endif 43111211Sru 4485909Simp.if !defined(DEBUG) 4585909SimpFULLKERNEL= ${KERNEL_KO} 4685909Simp.else 4785909SimpFULLKERNEL= ${KERNEL_KO}.debug 4885909Simp${KERNEL_KO}: ${FULLKERNEL} 4985909Simp ${OBJCOPY} --strip-debug ${FULLKERNEL} ${KERNEL_KO} 5095356Sruinstall.debug reinstall.debug: 5195356Sru cd ${.CURDIR}; ${MAKE} -DINSTALL_DEBUG ${.TARGET:R} 5285909Simp.endif 5385909Simp 5485909Simp${FULLKERNEL}: ${SYSTEM_DEP} vers.o 5585909Simp @rm -f ${.TARGET} 5685909Simp @echo linking ${.TARGET} 5785909Simp ${SYSTEM_LD} 5885909Simp ${SYSTEM_LD_TAIL} 5985909Simp 6085909Simp.if !exists(.depend) 61111687Sru${SYSTEM_OBJS}: assym.s vnode_if.h ${BEFORE_DEPEND:M*.h} ${MFILES:T:S/.m$/.h/} 6285909Simp.endif 6385909Simp 6485909Simp.for mfile in ${MFILES} 65102082Sbde# XXX the low quality .m.o rules gnerated by config are normally used 66102082Sbde# instead of the .m.c rules here. 67102082Sbde${mfile:T:S/.m$/.c/}: ${mfile} 68102082Sbde ${AWK} -f $S/tools/makeobjops.awk ${mfile} -c 6985909Simp${mfile:T:S/.m$/.h/}: ${mfile} 7095844Sobrien ${AWK} -f $S/tools/makeobjops.awk ${mfile} -h 7185909Simp.endfor 7285909Simp 73109514Sobrien.if !exists(.depend) 74109514Sobrienacphy.o amphy.o bmtphy.o brgphy.o dcphy.o e1000phy.o exphy.o if_bge.o if_tx.o \ 75109514Sobrieninphy.o lxtphy.o nsgphy.o nsphy.o pnaphy.o pnphy.o qsphy.o rlphy.o tdkphy.o \ 76109514Sobrientlphy.o xmphy.o: miidevs.h 77109514Sobrien.endif 78109514Sobrien 7985909Simpkernel-clean: 8085909Simp rm -f *.o *.so *.So *.ko *.s eddep errs \ 81103436Speter ${FULLKERNEL} ${KERNEL_KO} linterrs makelinks tags \ 82111606Sphk vers.c vnode_if.c vnode_if.h majors.c \ 8385909Simp ${MFILES:T:S/.m$/.c/} ${MFILES:T:S/.m$/.h/} \ 8485909Simp ${CLEAN} 8585909Simp 8692491Smarkmlint: ${CFILES} 87105173Sphk @${LINT} ${LINTKERNFLAGS} ${CFLAGS:M-[DILU]*} ${.ALLSRC} 8892491Smarkm 8985909Simp# This is a hack. BFD "optimizes" away dynamic mode if there are no 9085909Simp# dynamic references. We could probably do a '-Bforcedynamic' mode like 9185909Simp# in the a.out ld. For now, this works. 9285909SimpHACK_EXTRA_FLAGS?= -shared 9385909Simphack.So: Makefile 9485909Simp touch hack.c 9585909Simp ${CC} ${FMT} ${HACK_EXTRA_FLAGS} -nostdlib hack.c -o hack.So 9685909Simp rm -f hack.c 9785909Simp 9885909Simp# this rule stops ./assym.s in .depend from causing problems 9985909Simp./assym.s: assym.s 10085909Simp 10185909Simpassym.s: $S/kern/genassym.sh genassym.o 102103436Speter NM=${NM} sh $S/kern/genassym.sh genassym.o > ${.TARGET} 10385909Simp 10492821Simp# XXX used to force -elf after CFLAGS to work around breakage of cc -aout 10592821Simp# (genassym.sh makes some assumptions and cc stopped satisfying them). 10685909Simpgenassym.o: $S/$M/$M/genassym.c 10789180Smsmith ${CC} -c ${CFLAGS:N-fno-common} $S/$M/$M/genassym.c 10885909Simp 10985909Simp${SYSTEM_OBJS} genassym.o vers.o: opt_global.h 11085909Simp 11185909Simpkernel-depend: 11286048Simp.if defined(EXTRA_KERNELDEP) 11386048Simp ${EXTRA_KERNELDEP} 11486048Simp.endif 11585909Simp rm -f .olddep 11685909Simp if [ -f .depend ]; then mv .depend .olddep; fi 11785909Simp ${MAKE} _kernel-depend 11885909Simp 119102082Sbde# XXX this belongs elsewhere (inside GEN_CFILES if possible). 120102082SbdeGEN_M_CFILES= ${MFILES:T:S/.m$/.c/} 121102082Sbde 122102073Sbde# The argument list can be very long, so use make -V and xargs to 12391104Sjake# pass it to mkdep. 124109514Sobrien_kernel-depend: assym.s vnode_if.h miidevs.h ${BEFORE_DEPEND} \ 125102082Sbde ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES} ${GEN_M_CFILES} \ 126111684Sru ${SFILES} ${MFILES:T:S/.m$/.h/} 12785909Simp if [ -f .olddep ]; then mv .olddep .depend; fi 12885909Simp rm -f .newdep 129102082Sbde ${MAKE} -V CFILES -V SYSTEM_CFILES -V GEN_CFILES -V GEN_M_CFILES | \ 130102073Sbde MKDEP_CPP="${CC} -E" CC="${CC}" xargs mkdep -a -f .newdep ${CFLAGS} 131111684Sru ${MAKE} -V SFILES | \ 132102073Sbde MKDEP_CPP="${CC} -E" xargs mkdep -a -f .newdep ${ASM_CFLAGS} 13385909Simp rm -f .depend 13485909Simp mv .newdep .depend 13585909Simp 13685909Simpkernel-cleandepend: 13785909Simp rm -f .depend 13885909Simp 13985909Simplinks: 14085909Simp egrep '#if' ${CFILES} | sed -f $S/conf/defines | \ 14185909Simp sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink 14291046Sluigi ${MAKE} -V CFILES | tr -s ' ' '\12' | sed 's/\.c/.o/' | \ 14385909Simp sort -u | comm -23 - dontlink | \ 14485909Simp sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks 14585909Simp sh makelinks; rm -f dontlink 14685909Simp 14785909Simpkernel-tags: 14885909Simp @[ -f .depend ] || { echo "you must make depend first"; exit 1; } 14985909Simp sh $S/conf/systags.sh 15085909Simp rm -f tags1 15185909Simp sed -e 's, ../, ,' tags > tags1 15285909Simp 15395356Srukernel-install: 15485909Simp.if exists(${DESTDIR}/boot) 15585909Simp @if [ ! -f ${DESTDIR}/boot/device.hints ] ; then \ 15685909Simp echo "You must set up a ${DESTDIR}/boot/device.hints file first." ; \ 15785909Simp exit 1 ; \ 15885909Simp fi 15985909Simp @if [ x"`grep device.hints ${DESTDIR}/boot/defaults/loader.conf ${DESTDIR}/boot/loader.conf`" = "x" ]; then \ 16085909Simp echo "You must activate /boot/device.hints in loader.conf." ; \ 16185909Simp exit 1 ; \ 16285909Simp fi 16385909Simp.endif 16495356Sru @if [ ! -f ${FULLKERNEL} ] ; then \ 16585909Simp echo "You must build a kernel first." ; \ 16685909Simp exit 1 ; \ 16785909Simp fi 16885909Simp.if exists(${DESTDIR}${KODIR}) 16985909Simp -thiskernel=`sysctl -n kern.bootfile` ; \ 17085909Simp if [ "$$thiskernel" = ${DESTDIR}${KODIR}.old/${KERNEL_KO} ] ; then \ 17185909Simp chflags -R noschg ${DESTDIR}${KODIR} ; \ 17285909Simp rm -rf ${DESTDIR}${KODIR} ; \ 17385909Simp else \ 17485909Simp if [ -d ${DESTDIR}${KODIR}.old ] ; then \ 17585909Simp chflags -R noschg ${DESTDIR}${KODIR}.old ; \ 17685909Simp rm -rf ${DESTDIR}${KODIR}.old ; \ 17785909Simp fi ; \ 17885909Simp mv ${DESTDIR}${KODIR} ${DESTDIR}${KODIR}.old ; \ 17985909Simp if [ "$$thiskernel" = ${DESTDIR}${KODIR}/${KERNEL_KO} ] ; then \ 18096398Sdd sysctl kern.bootfile=${DESTDIR}${KODIR}.old/${KERNEL_KO} ; \ 18185909Simp fi; \ 18285909Simp fi 18385909Simp.endif 18485909Simp mkdir -p ${DESTDIR}${KODIR} 18595356Sru.if defined(DEBUG) && defined(INSTALL_DEBUG) 186109514Sobrien ${INSTALL} -p -m 555 -o root -g wheel ${FULLKERNEL} ${DESTDIR}${KODIR} 18795356Sru.else 188109514Sobrien ${INSTALL} -p -m 555 -o root -g wheel ${KERNEL_KO} ${DESTDIR}${KODIR} 18995356Sru.endif 19085909Simp 19195356Srukernel-reinstall: 19285909Simp @-chflags -R noschg ${DESTDIR}${KODIR} 19395356Sru.if defined(DEBUG) && defined(INSTALL_DEBUG) 194109514Sobrien ${INSTALL} -p -m 555 -o root -g wheel ${FULLKERNEL} ${DESTDIR}${KODIR} 19595356Sru.else 196109514Sobrien ${INSTALL} -p -m 555 -o root -g wheel ${KERNEL_KO} ${DESTDIR}${KODIR} 19795356Sru.endif 19885909Simp 19985909Simpconfig.o: 20085909Simp ${NORMAL_C} 20185909Simp 20292821Simpenv.o: env.c 20392821Simp ${NORMAL_C} 20492821Simp 20592821Simphints.o: hints.c 20692821Simp ${NORMAL_C} 20792821Simp 20885909Simpvers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP} 20999932Sbde sh $S/conf/newvers.sh ${KERN_IDENT} 21085909Simp 21185909Simp# XXX strictly, everything depends on Makefile because changes to ${PROF} 21285909Simp# only appear there, but we don't handle that. 21385909Simpvers.o: 21485909Simp ${NORMAL_C} 21585909Simp 21691512Sobrienvnode_if.c: $S/tools/vnode_if.awk $S/kern/vnode_if.src 21791512Sobrien ${AWK} -f $S/tools/vnode_if.awk $S/kern/vnode_if.src -c 21885909Simp 21991512Sobrienvnode_if.h: $S/tools/vnode_if.awk $S/kern/vnode_if.src 22091512Sobrien ${AWK} -f $S/tools/vnode_if.awk $S/kern/vnode_if.src -h 22185909Simp 22285909Simpvnode_if.o: 22385909Simp ${NORMAL_C} 22485909Simp 225111606Sphkmajors.c: $S/conf/majors $S/conf/majors.awk 226111606Sphk ${AWK} -f $S/conf/majors.awk $S/conf/majors > majors.c 227111606Sphk 228111606Sphkmajors.o: 229111606Sphk ${NORMAL_C} 230111606Sphk 231111686Sru.include "kern.mk" 232