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-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 # $FreeBSD: releng/8.0/sys/conf/kern.post.mk 191794 2009-05-04 20:25:56Z 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 .MAIN: all
   19 
   20 .for target in all clean cleandepend cleandir clobber depend install \
   21     obj reinstall tags
   22 ${target}: kernel-${target}
   23 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists($S/modules)
   24 ${target}: modules-${target}
   25 modules-${target}:
   26         cd $S/modules; ${MKMODULESENV} ${MAKE} \
   27             ${target:S/^reinstall$/install/:S/^clobber$/cleandir/}
   28 .endif
   29 .endfor
   30 
   31 # Handle out of tree ports 
   32 .if !defined(NO_MODULES) && defined(PORTS_MODULES)
   33 PORTSMODULESENV=SYSDIR=${SYSDIR}
   34 .for __target in all install reinstall clean
   35 ${__target}: ports-${__target}
   36 ports-${__target}:
   37 .for __i in ${PORTS_MODULES}
   38         cd $${PORTSDIR:-/usr/ports}/${__i}; ${PORTSMODULESENV} ${MAKE} -B ${__target:C/install/deinstall reinstall/:C/reinstall/deinstall reinstall/}
   39 .endfor
   40 .endfor
   41 .endif
   42 
   43 .ORDER: kernel-install modules-install
   44 
   45 kernel-all: ${KERNEL_KO} ${KERNEL_EXTRA}
   46 
   47 kernel-cleandir: kernel-clean kernel-cleandepend
   48 
   49 kernel-clobber:
   50         find . -maxdepth 1 ! -type d ! -name version -delete
   51 
   52 kernel-obj:
   53 
   54 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists($S/modules)
   55 modules: modules-all
   56 
   57 .if !defined(NO_MODULES_OBJ)
   58 modules-all modules-depend: modules-obj
   59 .endif
   60 .endif
   61 
   62 .if !defined(DEBUG)
   63 FULLKERNEL=     ${KERNEL_KO}
   64 .else
   65 FULLKERNEL=     ${KERNEL_KO}.debug
   66 ${KERNEL_KO}: ${FULLKERNEL} ${KERNEL_KO}.symbols
   67         ${OBJCOPY} --strip-debug --add-gnu-debuglink=${KERNEL_KO}.symbols\
   68             ${FULLKERNEL} ${.TARGET}
   69 ${KERNEL_KO}.symbols: ${FULLKERNEL}
   70         ${OBJCOPY} --only-keep-debug ${FULLKERNEL} ${.TARGET}
   71 install.debug reinstall.debug: gdbinit
   72         cd ${.CURDIR}; ${MAKE} ${.TARGET:R}
   73 
   74 # Install gdbinit files for kernel debugging.
   75 gdbinit:
   76         grep -v '# XXX' ${S}/../tools/debugscripts/dot.gdbinit | \
   77             sed "s:MODPATH:${.OBJDIR}/modules:" > .gdbinit
   78         cp ${S}/../tools/debugscripts/gdbinit.kernel ${.CURDIR}
   79 .if exists(${S}/../tools/debugscripts/gdbinit.${MACHINE_ARCH})
   80         cp ${S}/../tools/debugscripts/gdbinit.${MACHINE_ARCH} \
   81             ${.CURDIR}/gdbinit.machine
   82 .endif
   83 .endif
   84 
   85 ${FULLKERNEL}: ${SYSTEM_DEP} vers.o
   86         @rm -f ${.TARGET}
   87         @echo linking ${.TARGET}
   88         ${SYSTEM_LD}
   89 .if defined(CTFMERGE)
   90         ${SYSTEM_CTFMERGE}
   91 .endif
   92 .if !defined(DEBUG)
   93         ${OBJCOPY} --strip-debug ${.TARGET}
   94 .endif
   95         ${SYSTEM_LD_TAIL}
   96 .if defined(MFS_IMAGE)
   97         @sh ${S}/tools/embed_mfs.sh ${FULLKERNEL} ${MFS_IMAGE}
   98 .endif
   99 
  100 .if !exists(${.OBJDIR}/.depend)
  101 ${SYSTEM_OBJS}: assym.s vnode_if.h ${BEFORE_DEPEND:M*.h} ${MFILES:T:S/.m$/.h/}
  102 .endif
  103 
  104 LNFILES=        ${CFILES:T:S/.c$/.ln/}
  105 
  106 .for mfile in ${MFILES}
  107 # XXX the low quality .m.o rules gnerated by config are normally used
  108 # instead of the .m.c rules here.
  109 ${mfile:T:S/.m$/.c/}: ${mfile}
  110         ${AWK} -f $S/tools/makeobjops.awk ${mfile} -c
  111 ${mfile:T:S/.m$/.h/}: ${mfile}
  112         ${AWK} -f $S/tools/makeobjops.awk ${mfile} -h
  113 .endfor
  114 
  115 kernel-clean:
  116         rm -f *.o *.so *.So *.ko *.s eddep errs \
  117             ${FULLKERNEL} ${KERNEL_KO} ${KERNEL_KO}.symbols \
  118             linterrs makelinks tags vers.c \
  119             vnode_if.c vnode_if.h vnode_if_newproto.h vnode_if_typedef.h \
  120             ${MFILES:T:S/.m$/.c/} ${MFILES:T:S/.m$/.h/} \
  121             ${CLEAN}
  122 
  123 lint: ${LNFILES}
  124         ${LINT} ${LINTKERNFLAGS} ${CFLAGS:M-[DILU]*} ${.ALLSRC} 2>&1 | \
  125             tee -a linterrs
  126 
  127 # This is a hack.  BFD "optimizes" away dynamic mode if there are no
  128 # dynamic references.  We could probably do a '-Bforcedynamic' mode like
  129 # in the a.out ld.  For now, this works.
  130 HACK_EXTRA_FLAGS?= -shared
  131 hack.So: Makefile
  132         :> hack.c
  133         ${CC} ${HACK_EXTRA_FLAGS} -nostdlib hack.c -o hack.So
  134         rm -f hack.c
  135 
  136 # This rule stops ./assym.s in .depend from causing problems.
  137 ./assym.s: assym.s
  138 
  139 assym.s: $S/kern/genassym.sh genassym.o
  140         NM='${NM}' sh $S/kern/genassym.sh genassym.o > ${.TARGET}
  141 
  142 genassym.o: $S/$M/$M/genassym.c
  143         ${CC} -c ${CFLAGS:N-fno-common} $S/$M/$M/genassym.c
  144 
  145 ${SYSTEM_OBJS} genassym.o vers.o: opt_global.h
  146 
  147 kernel-depend: .depend
  148 # The argument list can be very long, so use make -V and xargs to
  149 # pass it to mkdep.
  150 SRCS=   assym.s vnode_if.h ${BEFORE_DEPEND} ${CFILES} \
  151         ${SYSTEM_CFILES} ${GEN_CFILES} ${SFILES} \
  152         ${MFILES:T:S/.m$/.h/}
  153 .depend: .PRECIOUS ${SRCS}
  154         rm -f .newdep
  155         ${MAKE} -V CFILES -V SYSTEM_CFILES -V GEN_CFILES | \
  156             MKDEP_CPP="${CC} -E" CC="${CC}" xargs mkdep -a -f .newdep ${CFLAGS}
  157         ${MAKE} -V SFILES | \
  158             MKDEP_CPP="${CC} -E" xargs mkdep -a -f .newdep ${ASM_CFLAGS}
  159         rm -f .depend
  160         mv .newdep .depend
  161 
  162 _ILINKS= machine
  163 .if ${MACHINE} != ${MACHINE_ARCH}
  164 _ILINKS+= ${MACHINE_ARCH}
  165 .endif
  166 
  167 # Ensure that the link exists without depending on it when it exists.
  168 .for _link in ${_ILINKS}
  169 .if !exists(${.OBJDIR}/${_link})
  170 ${SRCS}: ${_link}
  171 .endif
  172 .endfor
  173 
  174 ${_ILINKS}:
  175         @case ${.TARGET} in \
  176         machine) \
  177                 path=${S}/${MACHINE}/include ;; \
  178         ${MACHINE_ARCH}) \
  179                 path=${S}/${MACHINE_ARCH}/include ;; \
  180         esac ; \
  181         ${ECHO} ${.TARGET} "->" $$path ; \
  182         ln -s $$path ${.TARGET}
  183 
  184 # .depend needs include links so we remove them only together.
  185 kernel-cleandepend:
  186         rm -f .depend ${_ILINKS}
  187 
  188 links:
  189         egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
  190             sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
  191         ${MAKE} -V CFILES | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
  192             sort -u | comm -23 - dontlink | \
  193             sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks
  194         sh makelinks; rm -f dontlink
  195 
  196 kernel-tags:
  197         @[ -f .depend ] || { echo "you must make depend first"; exit 1; }
  198         sh $S/conf/systags.sh
  199 
  200 kernel-install:
  201         @if [ ! -f ${KERNEL_KO} ] ; then \
  202                 echo "You must build a kernel first." ; \
  203                 exit 1 ; \
  204         fi
  205 .if exists(${DESTDIR}${KODIR})
  206         -thiskernel=`sysctl -n kern.bootfile` ; \
  207         if [ ! "`dirname "$$thiskernel"`" -ef ${DESTDIR}${KODIR} ] ; then \
  208                 chflags -R noschg ${DESTDIR}${KODIR} ; \
  209                 rm -rf ${DESTDIR}${KODIR} ; \
  210         else \
  211                 if [ -d ${DESTDIR}${KODIR}.old ] ; then \
  212                         chflags -R noschg ${DESTDIR}${KODIR}.old ; \
  213                         rm -rf ${DESTDIR}${KODIR}.old ; \
  214                 fi ; \
  215                 mv ${DESTDIR}${KODIR} ${DESTDIR}${KODIR}.old ; \
  216                 sysctl kern.bootfile=${DESTDIR}${KODIR}.old/"`basename "$$thiskernel"`" ; \
  217         fi
  218 .endif
  219         mkdir -p ${DESTDIR}${KODIR}
  220         ${INSTALL} -p -m 555 -o ${KMODOWN} -g ${KMODGRP} ${KERNEL_KO} ${DESTDIR}${KODIR}
  221 .if defined(DEBUG) && !defined(INSTALL_NODEBUG)
  222         ${INSTALL} -p -m 555 -o ${KMODOWN} -g ${KMODGRP} ${KERNEL_KO}.symbols ${DESTDIR}${KODIR}
  223 .endif
  224 .if defined(KERNEL_EXTRA_INSTALL)
  225         ${INSTALL} -p -m 555 -o ${KMODOWN} -g ${KMODGRP} ${KERNEL_EXTRA_INSTALL} ${DESTDIR}${KODIR}
  226 .endif
  227 
  228 
  229 
  230 kernel-reinstall:
  231         @-chflags -R noschg ${DESTDIR}${KODIR}
  232         ${INSTALL} -p -m 555 -o ${KMODOWN} -g ${KMODGRP} ${KERNEL_KO} ${DESTDIR}${KODIR}
  233 .if defined(DEBUG) && !defined(INSTALL_NODEBUG)
  234         ${INSTALL} -p -m 555 -o ${KMODOWN} -g ${KMODGRP} ${KERNEL_KO}.symbols ${DESTDIR}${KODIR}
  235 .endif
  236 
  237 config.o env.o hints.o vers.o vnode_if.o:
  238         ${NORMAL_C}
  239 .if defined(CTFCONVERT)
  240         ${CTFCONVERT} ${CTFFLAGS} ${.TARGET}
  241 .endif
  242 
  243 config.ln env.ln hints.ln vers.ln vnode_if.ln:
  244         ${NORMAL_LINT}
  245 
  246 vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP}
  247         MAKE=${MAKE} sh $S/conf/newvers.sh ${KERN_IDENT}
  248 
  249 vnode_if.c: $S/tools/vnode_if.awk $S/kern/vnode_if.src
  250         ${AWK} -f $S/tools/vnode_if.awk $S/kern/vnode_if.src -c
  251 
  252 vnode_if.h vnode_if_newproto.h vnode_if_typedef.h: $S/tools/vnode_if.awk \
  253     $S/kern/vnode_if.src
  254 vnode_if.h: vnode_if_newproto.h vnode_if_typedef.h
  255         ${AWK} -f $S/tools/vnode_if.awk $S/kern/vnode_if.src -h
  256 vnode_if_newproto.h:
  257         ${AWK} -f $S/tools/vnode_if.awk $S/kern/vnode_if.src -p
  258 vnode_if_typedef.h:
  259         ${AWK} -f $S/tools/vnode_if.awk $S/kern/vnode_if.src -q
  260 
  261 # XXX strictly, everything depends on Makefile because changes to ${PROF}
  262 # only appear there, but we don't handle that.
  263 
  264 .include "kern.mk"

Cache object: 972c67836a1bc9cf50f1806bf858359b


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