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

Cache object: f5857f35b9b94a9b33e700b63409c75f


[ 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.