kern.post.mk revision 92491
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# 788893Simp# Most make variables should not be defined in this file. Instead, they 888893Simp# should be defined in the kern.pre.mk so that port makefiles can 988969Simp# override or augment them. 1088893Simp# 1185909Simp# $FreeBSD: head/sys/conf/kern.post.mk 92491 2002-03-17 10:05:57Z markm $ 1285909Simp# 1385909Simp 1485909Simp.PHONY: all modules 1585909Simp 1685909Simpdepend: kernel-depend 1785909Simpclean: kernel-clean 1885909Simpcleandepend: kernel-cleandepend 1985909Simpclobber: kernel-clobber 2085909Simptags: kernel-tags 2185909Simpinstall: kernel-install 2285909Simpinstall.debug: kernel-install.debug 2385909Simpreinstall: kernel-reinstall 2485909Simpreinstall.debug: kernel-reinstall.debug 2585909Simp 2685909Simp.if !defined(DEBUG) 2785909SimpFULLKERNEL= ${KERNEL_KO} 2885909Simp.else 2985909SimpFULLKERNEL= ${KERNEL_KO}.debug 3085909Simp${KERNEL_KO}: ${FULLKERNEL} 3185909Simp ${OBJCOPY} --strip-debug ${FULLKERNEL} ${KERNEL_KO} 3285909Simp.endif 3385909Simp 3485909Simp${FULLKERNEL}: ${SYSTEM_DEP} vers.o 3585909Simp @rm -f ${.TARGET} 3685909Simp @echo linking ${.TARGET} 3785909Simp ${SYSTEM_LD} 3885909Simp ${SYSTEM_LD_TAIL} 3985909Simp 4085909Simp.if !exists(.depend) 4185909Simp${SYSTEM_OBJS}: vnode_if.h ${BEFORE_DEPEND:M*.h} ${MFILES:T:S/.m$/.h/} 4285909Simp.endif 4385909Simp 4485909Simp.for mfile in ${MFILES} 4585909Simp${mfile:T:S/.m$/.h/}: ${mfile} 4685909Simp perl5 $S/kern/makeobjops.pl -h ${mfile} 4785909Simp.endfor 4885909Simp 4985909Simpkernel-clean: 5085909Simp rm -f *.o *.so *.So *.ko *.s eddep errs \ 5185909Simp ${FULLKERNEL} ${KERNEL_KO} linterrs makelinks \ 5285909Simp setdef[01].c setdefs.h tags \ 5385909Simp vers.c vnode_if.c vnode_if.h \ 5485909Simp ${MFILES:T:S/.m$/.c/} ${MFILES:T:S/.m$/.h/} \ 5585909Simp ${CLEAN} 5685909Simp 5785909Simpkernel-clobber: 5885909Simp find . -type f ! -name version -delete 5985909Simp 6092491Smarkmlint: ${CFILES} 6192491Smarkm ${LINT} ${LINTKERNFLAGS} ${CFLAGS:M-[DILU]*} ${.ALLSRC} | more 2>&1 6292491Smarkm 6385909Simplocore.o: $S/$M/$M/locore.s assym.s 6485909Simp ${NORMAL_S} 6585909Simp 6685909Simp# This is a hack. BFD "optimizes" away dynamic mode if there are no 6785909Simp# dynamic references. We could probably do a '-Bforcedynamic' mode like 6885909Simp# in the a.out ld. For now, this works. 6985909SimpHACK_EXTRA_FLAGS?= -shared 7085909Simphack.So: Makefile 7185909Simp touch hack.c 7285909Simp ${CC} ${FMT} ${HACK_EXTRA_FLAGS} -nostdlib hack.c -o hack.So 7385909Simp rm -f hack.c 7485909Simp 7585909Simp# this rule stops ./assym.s in .depend from causing problems 7685909Simp./assym.s: assym.s 7785909Simp 7885909Simpassym.s: $S/kern/genassym.sh genassym.o 7985909Simp NM=${NM} OBJFORMAT=elf sh $S/kern/genassym.sh genassym.o > ${.TARGET} 8085909Simp 8185909Simpgenassym.o: $S/$M/$M/genassym.c 8289180Smsmith ${CC} -c ${CFLAGS:N-fno-common} $S/$M/$M/genassym.c 8385909Simp 8485909Simp${SYSTEM_OBJS} genassym.o vers.o: opt_global.h 8585909Simp 8685909Simpkernel-depend: 8786048Simp.if defined(EXTRA_KERNELDEP) 8886048Simp ${EXTRA_KERNELDEP} 8986048Simp.endif 9085909Simp rm -f .olddep 9185909Simp if [ -f .depend ]; then mv .depend .olddep; fi 9285909Simp ${MAKE} _kernel-depend 9385909Simp 9491104Sjake# The argument list can be very long, use make -V and xargs to 9591104Sjake# pass it to mkdep. 9685909Simp_kernel-depend: assym.s vnode_if.h ${BEFORE_DEPEND} \ 9785909Simp ${CFILES} ${SYSTEM_CFILES} ${GEN_CFILES} ${SFILES} \ 9885909Simp ${SYSTEM_SFILES} ${MFILES:T:S/.m$/.h/} 9985909Simp if [ -f .olddep ]; then mv .olddep .depend; fi 10085909Simp rm -f .newdep 10191046Sluigi ${MAKE} -V CFILES -V SYSTEM_CFILES -V GEN_CFILES | xargs \ 10291046Sluigi env MKDEP_CPP="${CC} -E" CC="${CC}" mkdep -a -f .newdep ${CFLAGS} 10391046Sluigi ${MAKE} -V SFILES -V SYSTEM_SFILES | xargs \ 10491046Sluigi env MKDEP_CPP="${CC} -E" mkdep -a -f .newdep ${ASM_CFLAGS} 10585909Simp rm -f .depend 10685909Simp mv .newdep .depend 10785909Simp 10885909Simpkernel-cleandepend: 10985909Simp rm -f .depend 11085909Simp 11185909Simplinks: 11285909Simp egrep '#if' ${CFILES} | sed -f $S/conf/defines | \ 11385909Simp sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink 11491046Sluigi ${MAKE} -V CFILES | tr -s ' ' '\12' | sed 's/\.c/.o/' | \ 11585909Simp sort -u | comm -23 - dontlink | \ 11685909Simp sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks 11785909Simp sh makelinks; rm -f dontlink 11885909Simp 11985909Simpkernel-tags: 12085909Simp @[ -f .depend ] || { echo "you must make depend first"; exit 1; } 12185909Simp sh $S/conf/systags.sh 12285909Simp rm -f tags1 12385909Simp sed -e 's, ../, ,' tags > tags1 12485909Simp 12585909Simpkernel-install kernel-install.debug: 12685909Simp.if exists(${DESTDIR}/boot) 12785909Simp @if [ ! -f ${DESTDIR}/boot/device.hints ] ; then \ 12885909Simp echo "You must set up a ${DESTDIR}/boot/device.hints file first." ; \ 12985909Simp exit 1 ; \ 13085909Simp fi 13185909Simp @if [ x"`grep device.hints ${DESTDIR}/boot/defaults/loader.conf ${DESTDIR}/boot/loader.conf`" = "x" ]; then \ 13285909Simp echo "You must activate /boot/device.hints in loader.conf." ; \ 13385909Simp exit 1 ; \ 13485909Simp fi 13585909Simp.endif 13685909Simp @if [ ! -f ${KERNEL_KO}${.TARGET:S/kernel-install//} ] ; then \ 13785909Simp echo "You must build a kernel first." ; \ 13885909Simp exit 1 ; \ 13985909Simp fi 14085909Simp.if exists(${DESTDIR}${KODIR}) 14185909Simp -thiskernel=`sysctl -n kern.bootfile` ; \ 14285909Simp if [ "$$thiskernel" = ${DESTDIR}${KODIR}.old/${KERNEL_KO} ] ; then \ 14385909Simp chflags -R noschg ${DESTDIR}${KODIR} ; \ 14485909Simp rm -rf ${DESTDIR}${KODIR} ; \ 14585909Simp else \ 14685909Simp if [ -d ${DESTDIR}${KODIR}.old ] ; then \ 14785909Simp chflags -R noschg ${DESTDIR}${KODIR}.old ; \ 14885909Simp rm -rf ${DESTDIR}${KODIR}.old ; \ 14985909Simp fi ; \ 15085909Simp mv ${DESTDIR}${KODIR} ${DESTDIR}${KODIR}.old ; \ 15185909Simp if [ "$$thiskernel" = ${DESTDIR}${KODIR}/${KERNEL_KO} ] ; then \ 15285909Simp sysctl -w kern.bootfile=${DESTDIR}${KODIR}.old/${KERNEL_KO} ; \ 15385909Simp fi; \ 15485909Simp fi 15585909Simp.endif 15685909Simp mkdir -p ${DESTDIR}${KODIR} 15785909Simp install -c -m 555 -o root -g wheel \ 15885909Simp ${KERNEL_KO}${.TARGET:S/kernel-install//} ${DESTDIR}${KODIR} 15985909Simp 16085909Simpkernel-reinstall kernel-reinstall.debug: 16185909Simp @-chflags -R noschg ${DESTDIR}${KODIR} 16285909Simp install -c -m 555 -o root -g wheel \ 16385909Simp ${KERNEL_KO}${.TARGET:S/kernel-reinstall//} ${DESTDIR}${KODIR} 16485909Simp 16585909Simp.if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists($S/modules) 16685909Simpall: modules 16785909Simpdepend: modules-depend 16885909Simpclean: modules-clean 16985909Simpcleandepend: modules-cleandepend 17085909Simpcleandir: modules-cleandir 17185909Simpclobber: modules-clobber 17285909Simptags: modules-tags 17385909Simpinstall: modules-install 17485909Simpinstall.debug: modules-install.debug 17585909Simpreinstall: modules-reinstall 17685909Simpreinstall.debug: modules-reinstall.debug 17785909Simp.endif 17885909Simp 17985909Simpmodules: 18085909Simp @mkdir -p ${.OBJDIR}/modules 18185909Simp cd $S/modules ; env ${MKMODULESENV} ${MAKE} obj ; \ 18285909Simp env ${MKMODULESENV} ${MAKE} all 18385909Simp 18485909Simpmodules-depend: 18585909Simp @mkdir -p ${.OBJDIR}/modules 18685909Simp cd $S/modules ; env ${MKMODULESENV} ${MAKE} obj ; \ 18785909Simp env ${MKMODULESENV} ${MAKE} depend 18885909Simp 18985909Simpmodules-clean: 19085909Simp cd $S/modules ; env ${MKMODULESENV} ${MAKE} clean 19185909Simp 19285909Simpmodules-cleandepend: 19385909Simp cd $S/modules ; env ${MKMODULESENV} ${MAKE} cleandepend 19485909Simp 19585909Simpmodules-clobber: modules-clean 19685909Simp rm -rf ${MKMODULESENV} 19785909Simp 19885909Simpmodules-cleandir: 19985909Simp cd $S/modules ; env ${MKMODULESENV} ${MAKE} cleandir 20085909Simp 20185909Simpmodules-tags: 20285909Simp cd $S/modules ; env ${MKMODULESENV} ${MAKE} tags 20385909Simp 20485909Simpmodules-install modules-reinstall: 20585909Simp cd $S/modules ; env ${MKMODULESENV} ${MAKE} install 20685909Simp 20785909Simpmodules-install.debug modules-reinstall.debug: 20885909Simp cd $S/modules ; env ${MKMODULESENV} ${MAKE} install.debug 20985909Simp 21085909Simpconfig.o: 21185909Simp ${NORMAL_C} 21285909Simp 21385909Simpvers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP} 21485909Simp sh $S/conf/newvers.sh ${KERN_IDENT} ${IDENT} 21585909Simp 21685909Simp# XXX strictly, everything depends on Makefile because changes to ${PROF} 21785909Simp# only appear there, but we don't handle that. 21885909Simpvers.o: 21985909Simp ${NORMAL_C} 22085909Simp 22185909Simphints.o: hints.c 22285909Simp ${NORMAL_C} 22385909Simp 22485909Simpenv.o: env.c 22585909Simp ${NORMAL_C} 22685909Simp 22791512Sobrienvnode_if.c: $S/tools/vnode_if.awk $S/kern/vnode_if.src 22891512Sobrien ${AWK} -f $S/tools/vnode_if.awk $S/kern/vnode_if.src -c 22985909Simp 23091512Sobrienvnode_if.h: $S/tools/vnode_if.awk $S/kern/vnode_if.src 23191512Sobrien ${AWK} -f $S/tools/vnode_if.awk $S/kern/vnode_if.src -h 23285909Simp 23385909Simpvnode_if.o: 23485909Simp ${NORMAL_C} 23585909Simp 23685909Simp.include <bsd.kern.mk> 237