The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/conf/kern.post.mk

Version: -  FREEBSD  -  FREEBSD11  -  FREEBSD10  -  FREEBSD9  -  FREEBSD92  -  FREEBSD91  -  FREEBSD90  -  FREEBSD8  -  FREEBSD82  -  FREEBSD81  -  FREEBSD80  -  FREEBSD7  -  FREEBSD74  -  FREEBSD73  -  FREEBSD72  -  FREEBSD71  -  FREEBSD70  -  FREEBSD6  -  FREEBSD64  -  FREEBSD63  -  FREEBSD62  -  FREEBSD61  -  FREEBSD60  -  FREEBSD5  -  FREEBSD55  -  FREEBSD54  -  FREEBSD53  -  FREEBSD52  -  FREEBSD51  -  FREEBSD50  -  FREEBSD4  -  FREEBSD3  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 # $FreeBSD: stable/8/sys/conf/kern.post.mk 241728 2012-10-19 11:01:39Z jhb $
    2 
    3 # Part of a unified Makefile for building kernels.  This part includes all
    4 # the definitions that need to be after all the % directives except %RULES
    5 # and ones that act like they are part of %RULES.
    6 #
    7 # Most make variables should not be defined in this file.  Instead, they
    8 # should be defined in the kern.pre.mk so that port makefiles can
    9 # override or augment them.
   10 
   11 # In case the config had a makeoptions DESTDIR...
   12 .if defined(DESTDIR)
   13 MKMODULESENV+=  DESTDIR="${DESTDIR}"
   14 .endif
   15 SYSDIR?= ${S:C;^[^/];${.CURDIR}/&;}
   16 MKMODULESENV+=  KERNBUILDDIR="${.CURDIR}" SYSDIR="${SYSDIR}"
   17 
   18 .if defined(WITH_CTF)
   19 MKMODULESENV+=  WITH_CTF="${WITH_CTF}"
   20 .endif
   21 
   22 .MAIN: all
   23 
   24 .for target in all clean cleandepend cleandir clobber depend install \
   25     obj reinstall tags
   26 ${target}: kernel-${target}
   27 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists($S/modules)
   28 ${target}: modules-${target}
   29 modules-${target}:
   30         cd $S/modules; ${MKMODULESENV} ${MAKE} \
   31             ${target:S/^reinstall$/install/:S/^clobber$/cleandir/}
   32 .endif
   33 .endfor
   34 
   35 # Handle ports (as defined by the user) that build kernel modules
   36 .if !defined(NO_MODULES) && defined(PORTS_MODULES)
   37 #
   38 # The ports tree needs some environment variables defined to match the new kernel
   39 #
   40 # Ports search for some dependencies in PATH, so add the location of the installed files
   41 LOCALBASE?=     /usr/local
   42 # SRC_BASE is how the ports tree refers to the location of the base source files
   43 .if !defined(SRC_BASE)
   44 SRC_BASE!=      realpath "${SYSDIR:H}/"
   45 .endif
   46 # OSVERSION is used by some ports to determine build options
   47 .if !defined(OSRELDATE)
   48 # Definition copied from src/Makefile.inc1
   49 OSRELDATE!=     awk '/^\#define[[:space:]]*__FreeBSD_version/ { print $$3 }' \
   50                     ${MAKEOBJDIRPREFIX}${SRC_BASE}/include/osreldate.h
   51 .endif
   52 # Keep the related ports builds in the obj directory so that they are only rebuilt once per kernel build
   53 WRKDIRPREFIX?=  ${MAKEOBJDIRPREFIX}${SRC_BASE}/sys/${KERNCONF}
   54 PORTSMODULESENV=\
   55         PATH=${PATH}:${LOCALBASE}/bin:${LOCALBASE}/sbin \
   56         SRC_BASE=${SRC_BASE} \
   57         OSVERSION=${OSRELDATE} \
   58         WRKDIRPREFIX=${WRKDIRPREFIX}
   59 
   60 # The WRKDIR needs to be cleaned before building, and trying to change the target
   61 # with a :C pattern below results in install -> instclean
   62 all:
   63 .for __i in ${PORTS_MODULES}
   64         @${ECHO} "===> Ports module ${__i} (all)"
   65         cd $${PORTSDIR:-/usr/ports}/${__i}; ${PORTSMODULESENV} ${MAKE} -B clean all
   66 .endfor
   67 
   68 .for __target in install reinstall clean
   69 ${__target}: ports-${__target}
   70 ports-${__target}:
   71 .for __i in ${PORTS_MODULES}
   72         @${ECHO} "===> Ports module ${__i} (${__target})"
   73         cd $${PORTSDIR:-/usr/ports}/${__i}; ${PORTSMODULESENV} ${MAKE} -B ${__target:C/install/deinstall reinstall/:C/reinstall/deinstall reinstall/}
   74 .endfor
   75 .endfor
   76 .endif
   77 
   78 .ORDER: kernel-install modules-install
   79 
   80 kernel-all: ${KERNEL_KO} ${KERNEL_EXTRA}
   81 
   82 kernel-cleandir: kernel-clean kernel-cleandepend
   83 
   84 kernel-clobber:
   85         find . -maxdepth 1 ! -type d ! -name version -delete
   86 
   87 kernel-obj:
   88 
   89 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists($S/modules)
   90 modules: modules-all
   91 
   92 .if !defined(NO_MODULES_OBJ)
   93 modules-all modules-depend: modules-obj
   94 .endif
   95 .endif
   96 
   97 .if !defined(DEBUG)
   98 FULLKERNEL=     ${KERNEL_KO}
   99 .else
  100 FULLKERNEL=     ${KERNEL_KO}.debug
  101 ${KERNEL_KO}: ${FULLKERNEL} ${KERNEL_KO}.symbols
  102         ${OBJCOPY} --strip-debug --add-gnu-debuglink=${KERNEL_KO}.symbols\
  103             ${FULLKERNEL} ${.TARGET}
  104 ${KERNEL_KO}.symbols: ${FULLKERNEL}
  105         ${OBJCOPY} --only-keep-debug ${FULLKERNEL} ${.TARGET}
  106 install.debug reinstall.debug: gdbinit
  107         cd ${.CURDIR}; ${MAKE} ${.TARGET:R}
  108 
  109 # Install gdbinit files for kernel debugging.
  110 gdbinit:
  111         grep -v '# XXX' ${S}/../tools/debugscripts/dot.gdbinit | \
  112             sed "s:MODPATH:${.OBJDIR}/modules:" > .gdbinit
  113         cp ${S}/../tools/debugscripts/gdbinit.kernel ${.CURDIR}
  114 .if exists(${S}/../tools/debugscripts/gdbinit.${MACHINE_ARCH})
  115         cp ${S}/../tools/debugscripts/gdbinit.${MACHINE_ARCH} \
  116             ${.CURDIR}/gdbinit.machine
  117 .endif
  118 .endif
  119 
  120 ${FULLKERNEL}: ${SYSTEM_DEP} vers.o
  121         @rm -f ${.TARGET}
  122         @echo linking ${.TARGET}
  123         ${SYSTEM_LD}
  124 .if ${MK_CTF} != "no"
  125         ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${SYSTEM_OBJS} vers.o
  126 .endif
  127 .if !defined(DEBUG)
  128         ${OBJCOPY} --strip-debug ${.TARGET}
  129 .endif
  130         ${SYSTEM_LD_TAIL}
  131 .if defined(MFS_IMAGE)
  132         @sh ${S}/tools/embed_mfs.sh ${FULLKERNEL} ${MFS_IMAGE}
  133 .endif
  134 
  135 .if !exists(${.OBJDIR}/.depend)
  136 ${SYSTEM_OBJS}: assym.s vnode_if.h ${BEFORE_DEPEND:M*.h} ${MFILES:T:S/.m$/.h/}
  137 .endif
  138 
  139 LNFILES=        ${CFILES:T:S/.c$/.ln/}
  140 
  141 .for mfile in ${MFILES}
  142 # XXX the low quality .m.o rules gnerated by config are normally used
  143 # instead of the .m.c rules here.
  144 ${mfile:T:S/.m$/.c/}: ${mfile}
  145         ${AWK} -f $S/tools/makeobjops.awk ${mfile} -c
  146 ${mfile:T:S/.m$/.h/}: ${mfile}
  147         ${AWK} -f $S/tools/makeobjops.awk ${mfile} -h
  148 .endfor
  149 
  150 kernel-clean:
  151         rm -f *.o *.so *.So *.ko *.s eddep errs \
  152             ${FULLKERNEL} ${KERNEL_KO} ${KERNEL_KO}.symbols \
  153             linterrs makelinks tags vers.c \
  154             vnode_if.c vnode_if.h vnode_if_newproto.h vnode_if_typedef.h \
  155             ${MFILES:T:S/.m$/.c/} ${MFILES:T:S/.m$/.h/} \
  156             ${CLEAN}
  157 
  158 lint: ${LNFILES}
  159         ${LINT} ${LINTKERNFLAGS} ${CFLAGS:M-[DILU]*} ${.ALLSRC} 2>&1 | \
  160             tee -a linterrs
  161 
  162 # This is a hack.  BFD "optimizes" away dynamic mode if there are no
  163 # dynamic references.  We could probably do a '-Bforcedynamic' mode like
  164 # in the a.out ld.  For now, this works.
  165 HACK_EXTRA_FLAGS?= -shared
  166 hack.So: Makefile
  167         :> hack.c
  168         ${CC} ${HACK_EXTRA_FLAGS} -nostdlib hack.c -o hack.So
  169         rm -f hack.c
  170 
  171 # This rule stops ./assym.s in .depend from causing problems.
  172 ./assym.s: assym.s
  173 
  174 assym.s: $S/kern/genassym.sh genassym.o
  175         NM='${NM}' sh $S/kern/genassym.sh genassym.o > ${.TARGET}
  176 
  177 genassym.o: $S/$M/$M/genassym.c
  178         ${CC} -c ${CFLAGS:N-fno-common} $S/$M/$M/genassym.c
  179 
  180 ${SYSTEM_OBJS} genassym.o vers.o: opt_global.h
  181 
  182 kernel-depend: .depend
  183 # The argument list can be very long, so use make -V and xargs to
  184 # pass it to mkdep.
  185 SRCS=   assym.s vnode_if.h ${BEFORE_DEPEND} ${CFILES} \
  186         ${SYSTEM_CFILES} ${GEN_CFILES} ${SFILES} \
  187         ${MFILES:T:S/.m$/.h/}
  188 .depend: .PRECIOUS ${SRCS}
  189         rm -f .newdep
  190         ${MAKE} -V CFILES -V SYSTEM_CFILES -V GEN_CFILES | \
  191             MKDEP_CPP="${CC} -E" CC="${CC}" xargs mkdep -a -f .newdep ${CFLAGS}
  192         ${MAKE} -V SFILES | \
  193             MKDEP_CPP="${CC} -E" xargs mkdep -a -f .newdep ${ASM_CFLAGS}
  194         rm -f .depend
  195         mv .newdep .depend
  196 
  197 _ILINKS= machine
  198 .if ${MACHINE} != ${MACHINE_ARCH}
  199 _ILINKS+= ${MACHINE_ARCH}
  200 .endif
  201 
  202 # Ensure that the link exists without depending on it when it exists.
  203 .for _link in ${_ILINKS}
  204 .if !exists(${.OBJDIR}/${_link})
  205 ${SRCS}: ${_link}
  206 .endif
  207 .endfor
  208 
  209 ${_ILINKS}:
  210         @case ${.TARGET} in \
  211         machine) \
  212                 path=${S}/${MACHINE}/include ;; \
  213         ${MACHINE_ARCH}) \
  214                 path=${S}/${MACHINE_ARCH}/include ;; \
  215         esac ; \
  216         ${ECHO} ${.TARGET} "->" $$path ; \
  217         ln -s $$path ${.TARGET}
  218 
  219 # .depend needs include links so we remove them only together.
  220 kernel-cleandepend:
  221         rm -f .depend ${_ILINKS}
  222 
  223 links:
  224         egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
  225             sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
  226         ${MAKE} -V CFILES | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
  227             sort -u | comm -23 - dontlink | \
  228             sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks
  229         sh makelinks; rm -f dontlink
  230 
  231 kernel-tags:
  232         @[ -f .depend ] || { echo "you must make depend first"; exit 1; }
  233         sh $S/conf/systags.sh
  234 
  235 kernel-install:
  236         @if [ ! -f ${KERNEL_KO} ] ; then \
  237                 echo "You must build a kernel first." ; \
  238                 exit 1 ; \
  239         fi
  240 .if exists(${DESTDIR}${KODIR})
  241         -thiskernel=`sysctl -n kern.bootfile` ; \
  242         if [ ! "`dirname "$$thiskernel"`" -ef ${DESTDIR}${KODIR} ] ; then \
  243                 chflags -R noschg ${DESTDIR}${KODIR} ; \
  244                 rm -rf ${DESTDIR}${KODIR} ; \
  245         else \
  246                 if [ -d ${DESTDIR}${KODIR}.old ] ; then \
  247                         chflags -R noschg ${DESTDIR}${KODIR}.old ; \
  248                         rm -rf ${DESTDIR}${KODIR}.old ; \
  249                 fi ; \
  250                 mv ${DESTDIR}${KODIR} ${DESTDIR}${KODIR}.old ; \
  251                 sysctl kern.bootfile=${DESTDIR}${KODIR}.old/"`basename "$$thiskernel"`" ; \
  252         fi
  253 .endif
  254         mkdir -p ${DESTDIR}${KODIR}
  255         ${INSTALL} -p -m 555 -o ${KMODOWN} -g ${KMODGRP} ${KERNEL_KO} ${DESTDIR}${KODIR}
  256 .if defined(DEBUG) && !defined(INSTALL_NODEBUG)
  257         ${INSTALL} -p -m 555 -o ${KMODOWN} -g ${KMODGRP} ${KERNEL_KO}.symbols ${DESTDIR}${KODIR}
  258 .endif
  259 .if defined(KERNEL_EXTRA_INSTALL)
  260         ${INSTALL} -p -m 555 -o ${KMODOWN} -g ${KMODGRP} ${KERNEL_EXTRA_INSTALL} ${DESTDIR}${KODIR}
  261 .endif
  262 
  263 
  264 
  265 kernel-reinstall:
  266         @-chflags -R noschg ${DESTDIR}${KODIR}
  267         ${INSTALL} -p -m 555 -o ${KMODOWN} -g ${KMODGRP} ${KERNEL_KO} ${DESTDIR}${KODIR}
  268 .if defined(DEBUG) && !defined(INSTALL_NODEBUG)
  269         ${INSTALL} -p -m 555 -o ${KMODOWN} -g ${KMODGRP} ${KERNEL_KO}.symbols ${DESTDIR}${KODIR}
  270 .endif
  271 
  272 config.o env.o hints.o vers.o vnode_if.o:
  273         ${NORMAL_C}
  274         ${NORMAL_CTFCONVERT}
  275 
  276 config.ln env.ln hints.ln vers.ln vnode_if.ln:
  277         ${NORMAL_LINT}
  278 
  279 vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP}
  280         MAKE=${MAKE} sh $S/conf/newvers.sh ${KERN_IDENT}
  281 
  282 vnode_if.c: $S/tools/vnode_if.awk $S/kern/vnode_if.src
  283         ${AWK} -f $S/tools/vnode_if.awk $S/kern/vnode_if.src -c
  284 
  285 vnode_if.h vnode_if_newproto.h vnode_if_typedef.h: $S/tools/vnode_if.awk \
  286     $S/kern/vnode_if.src
  287 vnode_if.h: vnode_if_newproto.h vnode_if_typedef.h
  288         ${AWK} -f $S/tools/vnode_if.awk $S/kern/vnode_if.src -h
  289 vnode_if_newproto.h:
  290         ${AWK} -f $S/tools/vnode_if.awk $S/kern/vnode_if.src -p
  291 vnode_if_typedef.h:
  292         ${AWK} -f $S/tools/vnode_if.awk $S/kern/vnode_if.src -q
  293 
  294 # XXX strictly, everything depends on Makefile because changes to ${PROF}
  295 # only appear there, but we don't handle that.
  296 
  297 .include "kern.mk"

Cache object: 9f379e754aef8eafdae1061726719cdd


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.