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/kmod.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 #       From: @(#)bsd.prog.mk   5.26 (Berkeley) 6/25/91
    2 # $FreeBSD: releng/5.1/sys/conf/kmod.mk 111851 2003-03-03 22:51:22Z ru $
    3 #
    4 # The include file <bsd.kmod.mk> handles installing Kernel Loadable Device
    5 # drivers (KLD's).
    6 #
    7 #
    8 # +++ variables +++
    9 #
   10 # CLEANFILES    Additional files to remove for the clean and cleandir targets.
   11 #
   12 # KMOD          The name of the kernel module to build.
   13 #
   14 # KMODDIR       Base path for kernel modules (see kld(4)). [/boot/kernel]
   15 #
   16 # KMODOWN       KLD owner. [${BINOWN}]
   17 #
   18 # KMODGRP       KLD group. [${BINGRP}]
   19 #
   20 # KMODMODE      KLD mode. [${BINMODE}]
   21 #
   22 # KMODLOAD      Command to load a kernel module [/sbin/kldload]
   23 #
   24 # KMODUNLOAD    Command to unload a kernel module [/sbin/kldunload]
   25 #
   26 # PROG          The name of the kernel module to build.
   27 #               If not supplied, ${KMOD}.o is used.
   28 #
   29 # SRCS          List of source files
   30 #
   31 # DESTDIR       Change the tree where the module gets installed. [not set]
   32 #
   33 # MFILES        Optionally a list of interfaces used by the module.
   34 #               This file contains a default list of interfaces.
   35 #
   36 # EXPORT_SYMS   A list of symbols that should be exported from the module,
   37 #               or the name of a file containing a list of symbols, or YES
   38 #               to export all symbols.  If not defined, no symbols are
   39 #               exported.
   40 #
   41 # +++ targets +++
   42 #
   43 #       install:
   44 #               install the kernel module; if the Makefile
   45 #               does not itself define the target install, the targets
   46 #               beforeinstall and afterinstall may also be used to cause
   47 #               actions immediately before and after the install target
   48 #               is executed.
   49 #
   50 #       load:
   51 #               Load KLD.
   52 #
   53 #       unload:
   54 #               Unload KLD.
   55 #
   56 # bsd.obj.mk: clean, cleandir and obj
   57 # bsd.dep.mk: cleandepend, depend and tags
   58 #
   59 
   60 AWK?=           awk
   61 KMODLOAD?=      /sbin/kldload
   62 KMODUNLOAD?=    /sbin/kldunload
   63 OBJCOPY?=       objcopy
   64 
   65 .if defined(KMODDEPS)
   66 .error "Do not use KMODDEPS on 5.0+, use MODULE_VERSION/MODULE_DEPEND"
   67 .endif
   68 
   69 .include <bsd.init.mk>
   70 
   71 .SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S
   72 
   73 CFLAGS+=        ${COPTS} -D_KERNEL ${CWARNFLAGS}
   74 CFLAGS+=        -DKLD_MODULE
   75 
   76 # Don't use any standard or source-relative include directories.
   77 # Since -nostdinc will annull any previous -I paths, we repeat all
   78 # such paths after -nostdinc.  It doesn't seem to be possible to
   79 # add to the front of `make' variable.
   80 _ICFLAGS:=      ${CFLAGS:M-I*}
   81 CFLAGS+=        -nostdinc -I- ${INCLMAGIC} ${_ICFLAGS}
   82 
   83 # Add -I paths for system headers.  Individual KLD makefiles don't
   84 # need any -I paths for this.  Similar defaults for .PATH can't be
   85 # set because there are no standard paths for non-headers.
   86 CFLAGS+=        -I. -I@ -I@/dev
   87 
   88 # Add a -I path to standard headers like <stddef.h>.  Use a relative
   89 # path to src/include if possible.  If the @ symlink hasn't been built
   90 # yet, then we can't tell if the relative path exists.  Add both the
   91 # potential relative path and an absolute path in that case.
   92 .if exists(@)
   93 .if exists(@/../include)
   94 CFLAGS+=        -I@/../include
   95 .else
   96 CFLAGS+=        -I${DESTDIR}/usr/include
   97 .endif
   98 .else # !@
   99 CFLAGS+=        -I@/../include -I${DESTDIR}/usr/include
  100 .endif # @
  101 
  102 # Disallow common variables, and if we end up with commons from
  103 # somewhere unexpected, allocate storage for them in the module itself.
  104 CFLAGS+=        -fno-common
  105 LDFLAGS+=       -d -warn-common
  106 
  107 CFLAGS+=        ${DEBUG_FLAGS}
  108 
  109 OBJS+=  ${SRCS:N*.h:R:S/$/.o/g}
  110 
  111 .if !defined(PROG)
  112 PROG=   ${KMOD}.ko
  113 .endif
  114 
  115 .if !defined(DEBUG)
  116 FULLPROG=       ${PROG}
  117 .else
  118 FULLPROG=       ${PROG}.debug
  119 ${PROG}: ${FULLPROG}
  120         ${OBJCOPY} --strip-debug ${FULLPROG} ${PROG}
  121 .endif
  122 
  123 ${FULLPROG}: ${KMOD}.kld
  124         ${LD} -Bshareable ${LDFLAGS} -o ${.TARGET} ${KMOD}.kld
  125 
  126 EXPORT_SYMS?=   NO
  127 .if ${EXPORT_SYMS} != YES
  128 CLEANFILES+=    ${.OBJDIR}/export_syms
  129 .endif
  130 
  131 ${KMOD}.kld: ${OBJS}
  132         ${LD} ${LDFLAGS} -r -d -o ${.TARGET} ${OBJS}
  133 .if defined(EXPORT_SYMS)
  134 .if ${EXPORT_SYMS} != YES
  135 .if ${EXPORT_SYMS} == NO
  136         touch ${.OBJDIR}/export_syms
  137 .elif !exists(${.CURDIR}/${EXPORT_SYMS})
  138         echo ${EXPORT_SYMS} > ${.OBJDIR}/export_syms
  139 .else
  140         grep -v '^#' < ${EXPORT_SYMS} >  ${.OBJDIR}/export_syms
  141 .endif
  142         awk -f ${SYSDIR}/conf/kmod_syms.awk ${.TARGET} \
  143                 ${.OBJDIR}/export_syms | \
  144         xargs -J% ${OBJCOPY} % ${.TARGET}
  145 .endif
  146 .endif
  147 
  148 _ILINKS=@ machine
  149 
  150 all: objwarn ${PROG}
  151 
  152 beforedepend: ${_ILINKS}
  153         @rm -f .depend
  154 
  155 # Ensure that the links exist without depending on it when it exists which
  156 # causes all the modules to be rebuilt when the directory pointed to changes.
  157 .for _link in ${_ILINKS}
  158 .if !exists(${.OBJDIR}/${_link})
  159 ${OBJS}: ${_link}
  160 .endif
  161 .endfor
  162 
  163 # Search for kernel source tree in standard places.
  164 .for _dir in ${.CURDIR}/../.. ${.CURDIR}/../../.. /sys /usr/src/sys
  165 .if !defined(SYSDIR) && exists(${_dir}/kern/)
  166 SYSDIR= ${_dir}
  167 .endif
  168 .endfor
  169 .if !defined(SYSDIR) || !exists(${SYSDIR}/kern)
  170 .error "can't find kernel source tree"
  171 .endif
  172 
  173 ${_ILINKS}:
  174         @case ${.TARGET} in \
  175         machine) \
  176                 path=${SYSDIR}/${MACHINE_ARCH}/include ;; \
  177         @) \
  178                 path=${SYSDIR} ;; \
  179         esac ; \
  180         path=`(cd $$path && /bin/pwd)` ; \
  181         ${ECHO} ${.TARGET} "->" $$path ; \
  182         ln -s $$path ${.TARGET}
  183 
  184 CLEANFILES+= ${PROG} ${KMOD}.kld ${OBJS} ${_ILINKS} symb.tmp tmp.o
  185 
  186 .if defined(DEBUG)
  187 CLEANFILES+= ${FULLPROG}
  188 .endif
  189 
  190 .if !target(install)
  191 
  192 _INSTALLFLAGS:= ${INSTALLFLAGS}
  193 .for ie in ${INSTALLFLAGS_EDIT}
  194 _INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
  195 .endfor
  196 
  197 .if defined(DEBUG)
  198 install.debug:
  199         cd ${.CURDIR}; ${MAKE} -DINSTALL_DEBUG install
  200 .endif
  201 
  202 .if !target(realinstall)
  203 realinstall: _kmodinstall
  204 .ORDER: beforeinstall _kmodinstall
  205 .if defined(DEBUG) && defined(INSTALL_DEBUG)
  206 _kmodinstall:
  207         ${INSTALL} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
  208             ${_INSTALLFLAGS} ${FULLPROG} ${DESTDIR}${KMODDIR}
  209 .else
  210 _kmodinstall:
  211         ${INSTALL} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
  212             ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${KMODDIR}
  213 
  214 .include <bsd.links.mk>
  215 
  216 .if !defined(NO_XREF)
  217 afterinstall: _kldxref
  218 .ORDER: realinstall _kldxref
  219 .ORDER: _installlinks _kldxref
  220 _kldxref:
  221         @if type kldxref >/dev/null 2>&1; then \
  222                 ${ECHO} kldxref ${DESTDIR}${KMODDIR}; \
  223                 kldxref ${DESTDIR}${KMODDIR}; \
  224         fi
  225 .endif
  226 .endif
  227 .endif !target(realinstall)
  228 
  229 .endif !target(install)
  230 
  231 .if !target(load)
  232 load:   ${PROG}
  233         ${KMODLOAD} -v ${.OBJDIR}/${KMOD}.ko
  234 .endif
  235 
  236 .if !target(unload)
  237 unload:
  238         ${KMODUNLOAD} -v ${KMOD}
  239 .endif
  240 
  241 .for _src in ${SRCS:Mopt_*.h}
  242 CLEANFILES+=    ${_src}
  243 .if !target(${_src})
  244 ${_src}:
  245         touch ${.TARGET}
  246 .endif
  247 .endfor
  248 
  249 MFILES?= kern/bus_if.m kern/device_if.m dev/iicbus/iicbb_if.m \
  250     dev/iicbus/iicbus_if.m isa/isa_if.m \
  251     libkern/iconv_converter_if.m \
  252     dev/mii/miibus_if.m \
  253     dev/pccard/card_if.m dev/pccard/power_if.m dev/pci/pci_if.m \
  254     dev/pci/pcib_if.m dev/ppbus/ppbus_if.m dev/smbus/smbus_if.m \
  255     dev/usb/usb_if.m dev/sound/pcm/ac97_if.m dev/sound/pcm/channel_if.m \
  256     dev/sound/pcm/feeder_if.m dev/sound/pcm/mixer_if.m pci/agp_if.m \
  257     opencrypto/crypto_if.m pc98/pc98/canbus_if.m
  258 
  259 .for _srcsrc in ${MFILES}
  260 .for _ext in c h
  261 .for _src in ${SRCS:M${_srcsrc:T:R}.${_ext}}
  262 CLEANFILES+=    ${_src}
  263 .if !target(${_src})
  264 .if !exists(@)
  265 ${_src}: @
  266 .endif
  267 .if exists(@)
  268 ${_src}: @/tools/makeobjops.awk @/${_srcsrc}
  269 .endif
  270         ${AWK} -f @/tools/makeobjops.awk @/${_srcsrc} -${_ext}
  271 .endif
  272 .endfor # _src
  273 .endfor # _ext
  274 .endfor # _srcsrc
  275 
  276 .for _ext in c h
  277 .if ${SRCS:Mvnode_if.${_ext}} != ""
  278 CLEANFILES+=    vnode_if.${_ext}
  279 .if !exists(@)
  280 vnode_if.${_ext}: @
  281 .endif
  282 .if exists(@)
  283 vnode_if.${_ext}: @/tools/vnode_if.awk @/kern/vnode_if.src
  284 .endif
  285         ${AWK} -f @/tools/vnode_if.awk @/kern/vnode_if.src -${_ext}
  286 .endif
  287 .endfor
  288 
  289 .if ${SRCS:Mmiidevs.h} != ""
  290 CLEANFILES+=    miidevs.h
  291 .if !exists(@)
  292 miidevs.h: @
  293 .endif
  294 .if exists(@)
  295 miidevs.h: @/tools/devlist2h.awk @/dev/mii/miidevs
  296 .endif
  297         ${AWK} -f @/tools/devlist2h.awk @/dev/mii/miidevs
  298 .endif
  299 
  300 regress:
  301 
  302 lint: ${SRCS}
  303         ${LINT} ${LINTKERNFLAGS} ${CFLAGS:M-[DILU]*} ${.ALLSRC:M*.c}
  304 
  305 .include <bsd.dep.mk>
  306 
  307 .if !exists(${.OBJDIR}/${DEPENDFILE})
  308 ${OBJS}: ${SRCS:M*.h}
  309 .endif
  310 
  311 .include <bsd.obj.mk>
  312 .include "kern.mk"

Cache object: f0a6ce2202cc92bdb18a101d4b8d84c9


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