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$
    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 MKMODULESENV+=  KERNBUILDDIR="${.CURDIR}"
   16 
   17 .MAIN: all
   18 
   19 .for target in all clean cleandepend cleandir clobber depend install \
   20     obj reinstall tags
   21 ${target}: kernel-${target}
   22 .if !defined(MODULES_WITH_WORLD) && !defined(NO_MODULES) && exists($S/modules)
   23 ${target}: modules-${target}
   24 modules-${target}:
   25         cd $S/modules; ${MKMODULESENV} ${MAKE} \
   26             ${target:S/^reinstall$/install/:S/^clobber$/cleandir/}
   27 .endif
   28 .endfor
   29 
   30 # Handle out of tree ports 
   31 .if !defined(NO_MODULES) && defined(PORTS_MODULES)
   32 SYSDIR?= ${S:C;^[^/];${.CURDIR}/&;}
   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         @dd if="${MFS_IMAGE}" ibs=8192 of="${FULLKERNEL}"               \
   98            obs=`strings -at d "${FULLKERNEL}" |                         \
   99                  grep "MFS Filesystem goes here" | awk '{print $$1}'`   \
  100            oseek=1 conv=notrunc 2>/dev/null &&                          \
  101          strings ${FULLKERNEL} |                                        \
  102          grep 'MFS Filesystem had better STOP here' > /dev/null ||      \
  103          (rm ${FULLKERNEL} && echo 'MFS image too large' && false)
  104 .endif
  105 
  106 .if !exists(${.OBJDIR}/.depend)
  107 ${SYSTEM_OBJS}: assym.s vnode_if.h ${BEFORE_DEPEND:M*.h} ${MFILES:T:S/.m$/.h/}
  108 .endif
  109 
  110 LNFILES=        ${CFILES:T:S/.c$/.ln/}
  111 
  112 .for mfile in ${MFILES}
  113 # XXX the low quality .m.o rules gnerated by config are normally used
  114 # instead of the .m.c rules here.
  115 ${mfile:T:S/.m$/.c/}: ${mfile}
  116         ${AWK} -f $S/tools/makeobjops.awk ${mfile} -c
  117 ${mfile:T:S/.m$/.h/}: ${mfile}
  118         ${AWK} -f $S/tools/makeobjops.awk ${mfile} -h
  119 .endfor
  120 
  121 kernel-clean:
  122         rm -f *.o *.so *.So *.ko *.s eddep errs \
  123             ${FULLKERNEL} ${KERNEL_KO} ${KERNEL_KO}.symbols \
  124             linterrs makelinks tags vers.c \
  125             vnode_if.c vnode_if.h vnode_if_newproto.h vnode_if_typedef.h \
  126             ${MFILES:T:S/.m$/.c/} ${MFILES:T:S/.m$/.h/} \
  127             ${CLEAN}
  128 
  129 lint: ${LNFILES}
  130         ${LINT} ${LINTKERNFLAGS} ${CFLAGS:M-[DILU]*} ${.ALLSRC} 2>&1 | \
  131             tee -a linterrs
  132 
  133 # This is a hack.  BFD "optimizes" away dynamic mode if there are no
  134 # dynamic references.  We could probably do a '-Bforcedynamic' mode like
  135 # in the a.out ld.  For now, this works.
  136 HACK_EXTRA_FLAGS?= -shared
  137 hack.So: Makefile
  138         :> hack.c
  139         ${CC} ${HACK_EXTRA_FLAGS} -nostdlib hack.c -o hack.So
  140         rm -f hack.c
  141 
  142 # This rule stops ./assym.s in .depend from causing problems.
  143 ./assym.s: assym.s
  144 
  145 assym.s: $S/kern/genassym.sh genassym.o
  146         NM='${NM}' sh $S/kern/genassym.sh genassym.o > ${.TARGET}
  147 
  148 genassym.o: $S/$M/$M/genassym.c
  149         ${CC} -c ${CFLAGS:N-fno-common} $S/$M/$M/genassym.c
  150 
  151 ${SYSTEM_OBJS} genassym.o vers.o: opt_global.h
  152 
  153 kernel-depend: .depend
  154 # The argument list can be very long, so use make -V and xargs to
  155 # pass it to mkdep.
  156 SRCS=   assym.s vnode_if.h ${BEFORE_DEPEND} ${CFILES} \
  157         ${SYSTEM_CFILES} ${GEN_CFILES} ${SFILES} \
  158         ${MFILES:T:S/.m$/.h/}
  159 .depend: .PRECIOUS ${SRCS}
  160         rm -f .newdep
  161         ${MAKE} -V CFILES -V SYSTEM_CFILES -V GEN_CFILES | \
  162             MKDEP_CPP="${CC} -E" CC="${CC}" xargs mkdep -a -f .newdep ${CFLAGS}
  163         ${MAKE} -V SFILES | \
  164             MKDEP_CPP="${CC} -E" xargs mkdep -a -f .newdep ${ASM_CFLAGS}
  165         rm -f .depend
  166         mv .newdep .depend
  167 
  168 _ILINKS= machine
  169 .if ${MACHINE} != ${MACHINE_ARCH}
  170 _ILINKS+= ${MACHINE_ARCH}
  171 .endif
  172 
  173 # Ensure that the link exists without depending on it when it exists.
  174 .for _link in ${_ILINKS}
  175 .if !exists(${.OBJDIR}/${_link})
  176 ${SRCS}: ${_link}
  177 .endif
  178 .endfor
  179 
  180 ${_ILINKS}:
  181         @case ${.TARGET} in \
  182         machine) \
  183                 path=${S}/${MACHINE}/include ;; \
  184         ${MACHINE_ARCH}) \
  185                 path=${S}/${MACHINE_ARCH}/include ;; \
  186         esac ; \
  187         ${ECHO} ${.TARGET} "->" $$path ; \
  188         ln -s $$path ${.TARGET}
  189 
  190 # .depend needs include links so we remove them only together.
  191 kernel-cleandepend:
  192         rm -f .depend ${_ILINKS}
  193 
  194 links:
  195         egrep '#if' ${CFILES} | sed -f $S/conf/defines | \
  196             sed -e 's/:.*//' -e 's/\.c/.o/' | sort -u > dontlink
  197         ${MAKE} -V CFILES | tr -s ' ' '\12' | sed 's/\.c/.o/' | \
  198             sort -u | comm -23 - dontlink | \
  199             sed 's,../.*/\(.*.o\),rm -f \1;ln -s ../GENERIC/\1 \1,' > makelinks
  200         sh makelinks; rm -f dontlink
  201 
  202 kernel-tags:
  203         @[ -f .depend ] || { echo "you must make depend first"; exit 1; }
  204         sh $S/conf/systags.sh
  205 
  206 kernel-install:
  207         @if [ ! -f ${KERNEL_KO} ] ; then \
  208                 echo "You must build a kernel first." ; \
  209                 exit 1 ; \
  210         fi
  211 .if exists(${DESTDIR}${KODIR})
  212         -thiskernel=`sysctl -n kern.bootfile` ; \
  213         if [ ! "`dirname "$$thiskernel"`" -ef ${DESTDIR}${KODIR} ] ; then \
  214                 chflags -R noschg ${DESTDIR}${KODIR} ; \
  215                 rm -rf ${DESTDIR}${KODIR} ; \
  216         else \
  217                 if [ -d ${DESTDIR}${KODIR}.old ] ; then \
  218                         chflags -R noschg ${DESTDIR}${KODIR}.old ; \
  219                         rm -rf ${DESTDIR}${KODIR}.old ; \
  220                 fi ; \
  221                 mv ${DESTDIR}${KODIR} ${DESTDIR}${KODIR}.old ; \
  222                 sysctl kern.bootfile=${DESTDIR}${KODIR}.old/"`basename "$$thiskernel"`" ; \
  223         fi
  224 .endif
  225         mkdir -p ${DESTDIR}${KODIR}
  226         ${INSTALL} -p -m 555 -o root -g wheel ${KERNEL_KO} ${DESTDIR}${KODIR}
  227 .if defined(DEBUG) && !defined(INSTALL_NODEBUG)
  228         ${INSTALL} -p -m 555 -o root -g wheel ${KERNEL_KO}.symbols ${DESTDIR}${KODIR}
  229 .endif
  230 .if defined(KERNEL_EXTRA_INSTALL)
  231         ${INSTALL} -p -m 555 -o root -g wheel ${KERNEL_EXTRA_INSTALL} ${DESTDIR}${KODIR}
  232 .endif
  233 
  234 
  235 
  236 kernel-reinstall:
  237         @-chflags -R noschg ${DESTDIR}${KODIR}
  238         ${INSTALL} -p -m 555 -o root -g wheel ${KERNEL_KO} ${DESTDIR}${KODIR}
  239 .if defined(DEBUG) && !defined(INSTALL_NODEBUG)
  240         ${INSTALL} -p -m 555 -o root -g wheel ${KERNEL_KO}.symbols ${DESTDIR}${KODIR}
  241 .endif
  242 
  243 config.o env.o hints.o vers.o vnode_if.o:
  244         ${NORMAL_C}
  245 
  246 config.ln env.ln hints.ln vers.ln vnode_if.ln:
  247         ${NORMAL_LINT}
  248 
  249 vers.c: $S/conf/newvers.sh $S/sys/param.h ${SYSTEM_DEP}
  250         MAKE=${MAKE} sh $S/conf/newvers.sh ${KERN_IDENT}
  251 
  252 vnode_if.c: $S/tools/vnode_if.awk $S/kern/vnode_if.src
  253         ${AWK} -f $S/tools/vnode_if.awk $S/kern/vnode_if.src -c
  254 
  255 vnode_if.h vnode_if_newproto.h vnode_if_typedef.h: $S/tools/vnode_if.awk \
  256     $S/kern/vnode_if.src
  257 vnode_if.h: vnode_if_newproto.h vnode_if_typedef.h
  258         ${AWK} -f $S/tools/vnode_if.awk $S/kern/vnode_if.src -h
  259 vnode_if_newproto.h:
  260         ${AWK} -f $S/tools/vnode_if.awk $S/kern/vnode_if.src -p
  261 vnode_if_typedef.h:
  262         ${AWK} -f $S/tools/vnode_if.awk $S/kern/vnode_if.src -q
  263 
  264 # XXX strictly, everything depends on Makefile because changes to ${PROF}
  265 # only appear there, but we don't handle that.
  266 
  267 .include "kern.mk"

Cache object: 7d4678c9a280a4808f028be08ed7c848


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