kern.post.mk revision 85909
185909Simp# kern.post.mk 285909Simp# 385909Simp# Unified Makefile for building kenrels. This includes all the definitions 485909Simp# that need to be included after all the % directives, except %RULES and 585909Simp# things that act like they are part of %RULES 685909Simp# 785909Simp# $FreeBSD: head/sys/conf/kern.post.mk 85909 2001-11-02 21:34:20Z imp $ 885909Simp# 985909Simp 1085909Simp.PHONY: all modules 1185909Simp 1285909Simpall: ${KERNEL_KO} 1385909Simp 1485909Simpdepend: kernel-depend 1585909Simpclean: kernel-clean 1685909Simpcleandepend: kernel-cleandepend 1785909Simpclobber: kernel-clobber 1885909Simptags: kernel-tags 1985909Simpinstall: kernel-install 2085909Simpinstall.debug: kernel-install.debug 2185909Simpreinstall: kernel-reinstall 2285909Simpreinstall.debug: kernel-reinstall.debug 2385909Simp 2485909Simp.if !defined(DEBUG) 2585909SimpFULLKERNEL= ${KERNEL_KO} 2685909Simp.else 2785909SimpFULLKERNEL= ${KERNEL_KO}.debug 2885909Simp${KERNEL_KO}: ${FULLKERNEL} 2985909Simp ${OBJCOPY} --strip-debug ${FULLKERNEL} ${KERNEL_KO} 3085909Simp.endif 3185909Simp 3285909Simp${FULLKERNEL}: ${SYSTEM_DEP} vers.o 3385909Simp @rm -f ${.TARGET} 3485909Simp @echo linking ${.TARGET} 3585909Simp ${SYSTEM_LD} 3685909Simp ${SYSTEM_LD_TAIL} 3785909Simp 3885909Simp.if !exists(.depend) 3985909Simp${SYSTEM_OBJS}: vnode_if.h ${BEFORE_DEPEND:M*.h} ${MFILES:T:S/.m$/.h/} 4085909Simp.endif 4185909Simp 4285909Simp.for mfile in ${MFILES} 4385909Simp${mfile:T:S/.m$/.h/}: ${mfile} 4485909Simp perl5 $S/kern/makeobjops.pl -h ${mfile} 4585909Simp.endfor 4685909Simp 4785909Simpkernel-clean: 4885909Simp rm -f *.o *.so *.So *.ko *.s eddep errs \ 4985909Simp ${FULLKERNEL} ${KERNEL_KO} linterrs makelinks \ 5085909Simp setdef[01].c setdefs.h tags \ 5185909Simp vers.c vnode_if.c vnode_if.h \ 5285909Simp ${MFILES:T:S/.m$/.c/} ${MFILES:T:S/.m$/.h/} \ 5385909Simp ${CLEAN} 5485909Simp 5585909Simpkernel-clobber: 5685909Simp find . -type f ! -name version -delete 5785909Simp 5885909Simplocore.o: $S/$M/$M/locore.s assym.s 5985909Simp ${NORMAL_S} 6085909Simp 6185909Simp# This is a hack. BFD "optimizes" away dynamic mode if there are no 6285909Simp# dynamic references. We could probably do a '-Bforcedynamic' mode like 6385909Simp# in the a.out ld. For now, this works. 6485909SimpHACK_EXTRA_FLAGS?= -shared 6585909Simphack.So: Makefile 6685909Simp touch hack.c 6785909Simp ${CC} ${FMT} ${HACK_EXTRA_FLAGS} -nostdlib hack.c -o hack.So 6885909Simp rm -f hack.c 6985909Simp 7085909Simp# this rule stops ./assym.s in .depend from causing problems 7185909Simp./assym.s: assym.s 7285909Simp 7385909Simpassym.s: $S/kern/genassym.sh genassym.o 7485909Simp NM=${NM} OBJFORMAT=elf sh $S/kern/genassym.sh genassym.o > ${.TARGET} 7585909Simp 7685909Simpgenassym.o: $S/$M/$M/genassym.c 7785909Simp ${CC} -c ${CFLAGS} $S/$M/$M/genassym.c 7885909Simp 7985909Simp${SYSTEM_OBJS} genassym.o vers.o: opt_global.h 8085909Simp 8185909Simpkernel-depend: 8285909Simp rm -f .olddep 8385909Simp if [ -f .depend ]; then mv .depend .olddep; fi 8485909Simp ${MAKE} _kernel-depend 8585909Simp 8685909Simp_kernel-depend: assym.s vnode_if.h ${BEFORE_DEPEND} \ 8785909Simp ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES} ${SFILES} \ 8885909Simp ${SYSTEM_SFILES} ${MFILES:T:S/.m$/.h/} 8985909Simp if [ -f .olddep ]; then mv .olddep .depend; fi 9085909Simp rm -f .newdep 9185909Simp env MKDEP_CPP="${CC} -E" CC="${CC}" \ 9285909Simp mkdep -a -f .newdep ${CFLAGS} ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES} 9385909Simp env MKDEP_CPP="${CC} -E" \ 9485909Simp mkdep -a -f .newdep ${ASM_CFLAGS} ${SFILES} ${SYSTEM_SFILES} 9585909Simp rm -f .depend 9685909Simp mv .newdep .depend 9785909Simp 9885909Simpkernel-cleandepend: 9985909Simp rm -f .depend 10085909Simp 10185909Simplinks: 10285909Simp egrep '#if' ${CFILES} | sed -f $S/conf/defines | \ 10385909Simp sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink 10485909Simp echo ${CFILES} | tr -s ' ' '\12' | sed 's/\.c/.o/' | \ 10585909Simp sort -u | comm -23 - dontlink | \ 10685909Simp sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks 10785909Simp sh makelinks; rm -f dontlink 10885909Simp 10985909Simpkernel-tags: 11085909Simp @[ -f .depend ] || { echo "you must make depend first"; exit 1; } 11185909Simp sh $S/conf/systags.sh 11285909Simp rm -f tags1 11385909Simp sed -e 's, ../, ,' tags > tags1 11485909Simp 11585909Simpkernel-install kernel-install.debug: 11685909Simp.if exists(${DESTDIR}/boot) 11785909Simp @if [ ! -f ${DESTDIR}/boot/device.hints ] ; then \ 11885909Simp echo "You must set up a ${DESTDIR}/boot/device.hints file first." ; \ 11985909Simp exit 1 ; \ 12085909Simp fi 12185909Simp @if [ x"`grep device.hints ${DESTDIR}/boot/defaults/loader.conf ${DESTDIR}/boot/loader.conf`" = "x" ]; then \ 12285909Simp echo "You must activate /boot/device.hints in loader.conf." ; \ 12385909Simp exit 1 ; \ 12485909Simp fi 12585909Simp.endif 12685909Simp @if [ ! -f ${KERNEL_KO}${.TARGET:S/kernel-install//} ] ; then \ 12785909Simp echo "You must build a kernel first." ; \ 12885909Simp exit 1 ; \ 12985909Simp fi 13085909Simp.if exists(${DESTDIR}${KODIR}) 13185909Simp -thiskernel=`sysctl -n kern.bootfile` ; \ 13285909Simp if [ "$$thiskernel" = ${DESTDIR}${KODIR}.old/${KERNEL_KO} ] ; then \ 13385909Simp chflags -R noschg ${DESTDIR}${KODIR} ; \ 13485909Simp rm -rf ${DESTDIR}${KODIR} ; \ 13585909Simp else \ 13685909Simp if [ -d ${DESTDIR}${KODIR}.old ] ; then \ 13785909Simp chflags -R noschg ${DESTDIR}${KODIR}.old ; \ 13885909Simp rm -rf ${DESTDIR}${KODIR}.old ; \ 13985909Simp fi ; \ 14085909Simp mv ${DESTDIR}${KODIR} ${DESTDIR}${KODIR}.old ; \ 14185909Simp if [ "$$thiskernel" = ${DESTDIR}${KODIR}/${KERNEL_KO} ] ; then \ 14285909Simp sysctl -w kern.bootfile=${DESTDIR}${KODIR}.old/${KERNEL_KO} ; \ 14385909Simp fi; \ 14485909Simp fi 14585909Simp.endif 14685909Simp mkdir -p ${DESTDIR}${KODIR} 14785909Simp install -c -m 555 -o root -g wheel \ 14885909Simp ${KERNEL_KO}${.TARGET:S/kernel-install//} ${DESTDIR}${KODIR} 14985909Simp 15085909Simpkernel-reinstall kernel-reinstall.debug: 15185909Simp @-chflags -R noschg ${DESTDIR}${KODIR} 15285909Simp install -c -m 555 -o root -g wheel \ 15385909Simp ${KERNEL_KO}${.TARGET:S/kernel-reinstall//} ${DESTDIR}${KODIR} 15485909Simp 15585909Simp.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists($S/modules) 15685909Simpall: modules 15785909Simpdepend: modules-depend 15885909Simpclean: modules-clean 15985909Simpcleandepend: modules-cleandepend 16085909Simpcleandir: modules-cleandir 16185909Simpclobber: modules-clobber 16285909Simptags: modules-tags 16385909Simpinstall: modules-install 16485909Simpinstall.debug: modules-install.debug 16585909Simpreinstall: modules-reinstall 16685909Simpreinstall.debug: modules-reinstall.debug 16785909Simp.endif 16885909Simp 16985909SimpMKMODULESENV= MAKEOBJDIRPREFIX=${.OBJDIR}/modules KMODDIR=${KODIR} 17085909Simp.if defined(MODULES_OVERRIDE) 17185909SimpMKMODULESENV+= MODULES_OVERRIDE="${MODULES_OVERRIDE}" 17285909Simp.endif 17385909Simp.if defined(DEBUG) 17485909SimpMKMODULESENV+= DEBUG="${DEBUG}" DEBUG_FLAGS="${DEBUG}" 17585909Simp.endif 17685909Simp 17785909Simpmodules: 17885909Simp @mkdir -p ${.OBJDIR}/modules 17985909Simp cd $S/modules ; env ${MKMODULESENV} ${MAKE} obj ; \ 18085909Simp env ${MKMODULESENV} ${MAKE} all 18185909Simp 18285909Simpmodules-depend: 18385909Simp @mkdir -p ${.OBJDIR}/modules 18485909Simp cd $S/modules ; env ${MKMODULESENV} ${MAKE} obj ; \ 18585909Simp env ${MKMODULESENV} ${MAKE} depend 18685909Simp 18785909Simpmodules-clean: 18885909Simp cd $S/modules ; env ${MKMODULESENV} ${MAKE} clean 18985909Simp 19085909Simpmodules-cleandepend: 19185909Simp cd $S/modules ; env ${MKMODULESENV} ${MAKE} cleandepend 19285909Simp 19385909Simpmodules-clobber: modules-clean 19485909Simp rm -rf ${MKMODULESENV} 19585909Simp 19685909Simpmodules-cleandir: 19785909Simp cd $S/modules ; env ${MKMODULESENV} ${MAKE} cleandir 19885909Simp 19985909Simpmodules-tags: 20085909Simp cd $S/modules ; env ${MKMODULESENV} ${MAKE} tags 20185909Simp 20285909Simpmodules-install modules-reinstall: 20385909Simp cd $S/modules ; env ${MKMODULESENV} ${MAKE} install 20485909Simp 20585909Simpmodules-install.debug modules-reinstall.debug: 20685909Simp cd $S/modules ; env ${MKMODULESENV} ${MAKE} install.debug 20785909Simp 20885909Simpconfig.o: 20985909Simp ${NORMAL_C} 21085909Simp 21185909Simpvers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP} 21285909Simp sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT} 21385909Simp 21485909Simp# XXX strictly, everything depends on Makefile because changes to ${PROF} 21585909Simp# only appear there, but we don't handle that. 21685909Simpvers.o: 21785909Simp ${NORMAL_C} 21885909Simp 21985909Simphints.o: hints.c 22085909Simp ${NORMAL_C} 22185909Simp 22285909Simpenv.o: env.c 22385909Simp ${NORMAL_C} 22485909Simp 22585909Simpvnode_if.c: $S/kern/vnode_if.pl $S/kern/vnode_if.src 22685909Simp perl5 $S/kern/vnode_if.pl -c $S/kern/vnode_if.src 22785909Simp 22885909Simpvnode_if.h: $S/kern/vnode_if.pl $S/kern/vnode_if.src 22985909Simp perl5 $S/kern/vnode_if.pl -h $S/kern/vnode_if.src 23085909Simp 23185909Simpvnode_if.o: 23285909Simp ${NORMAL_C} 23385909Simp 23485909Simp# Commented out for now pending a better solution. 23585909Simp# How do we pick up compiler version specific flags?? 23685909Simp#.if exists($S/../share/mk) 23785909Simp#.include "$S/../share/mk/bsd.kern.mk" 23885909Simp#.else 23985909Simp.include <bsd.kern.mk> 24085909Simp#.endif 241