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-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 #       From: @(#)bsd.prog.mk   5.26 (Berkeley) 6/25/91
    2 # $FreeBSD: releng/6.2/sys/conf/kmod.mk 164286 2006-11-14 20:42:41Z cvs2svn $
    3 #
    4 # The include file <bsd.kmod.mk> handles building and installing loadable
    5 # kernel modules.
    6 #
    7 #
    8 # +++ variables +++
    9 #
   10 # CLEANFILES    Additional files to remove for the clean and cleandir targets.
   11 #
   12 # EXPORT_SYMS   A list of symbols that should be exported from the module,
   13 #               or the name of a file containing a list of symbols, or YES
   14 #               to export all symbols.  If not defined, no symbols are
   15 #               exported.
   16 #
   17 # KMOD          The name of the kernel module to build.
   18 #
   19 # KMODDIR       Base path for kernel modules (see kld(4)). [/boot/kernel]
   20 #
   21 # KMODOWN       Module file owner. [${BINOWN}]
   22 #
   23 # KMODGRP       Module file group. [${BINGRP}]
   24 #
   25 # KMODMODE      Module file mode. [${BINMODE}]
   26 #
   27 # KMODLOAD      Command to load a kernel module [/sbin/kldload]
   28 #
   29 # KMODUNLOAD    Command to unload a kernel module [/sbin/kldunload]
   30 #
   31 # MFILES        Optionally a list of interfaces used by the module.
   32 #               This file contains a default list of interfaces.
   33 #
   34 # PROG          The name of the kernel module to build.
   35 #               If not supplied, ${KMOD}.ko is used.
   36 #
   37 # SRCS          List of source files.
   38 #
   39 # FIRMWS        List of firmware images in format filename:shortname:version
   40 #
   41 # DESTDIR       The tree where the module gets installed. [not set]
   42 #
   43 # +++ targets +++
   44 #
   45 #       install:
   46 #               install the kernel module; if the Makefile
   47 #               does not itself define the target install, the targets
   48 #               beforeinstall and afterinstall may also be used to cause
   49 #               actions immediately before and after the install target
   50 #               is executed.
   51 #
   52 #       load:
   53 #               Load a module.
   54 #
   55 #       unload:
   56 #               Unload a module.
   57 #
   58 
   59 AWK?=           awk
   60 KMODLOAD?=      /sbin/kldload
   61 KMODUNLOAD?=    /sbin/kldunload
   62 OBJCOPY?=       objcopy
   63 
   64 .if defined(KMODDEPS)
   65 .error "Do not use KMODDEPS on 5.0+; use MODULE_VERSION/MODULE_DEPEND"
   66 .endif
   67 
   68 .include <bsd.init.mk>
   69 
   70 .SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S
   71 
   72 .if ${CC} == "icc"
   73 CFLAGS:=        ${CFLAGS:C/(-x[^M^K^W]+)[MKW]+|-x[MKW]+/\1/}
   74 .else
   75 . if !empty(CFLAGS:M-O[23s]) && empty(CFLAGS:M-fno-strict-aliasing)
   76 CFLAGS+=        -fno-strict-aliasing
   77 . endif
   78 WERROR?=        -Werror
   79 .endif
   80 CFLAGS+=        ${WERROR}
   81 CFLAGS+=        -D_KERNEL
   82 CFLAGS+=        -DKLD_MODULE
   83 
   84 # Don't use any standard or source-relative include directories.
   85 .if ${CC} == "icc"
   86 NOSTDINC=       -X
   87 .else
   88 NOSTDINC=       -nostdinc
   89 .endif
   90 CFLAGS:=        ${CFLAGS:N-I*} ${NOSTDINC} -I- ${INCLMAGIC} ${CFLAGS:M-I*}
   91 .if defined(KERNBUILDDIR)
   92 CFLAGS+=        -DHAVE_KERNEL_OPTION_HEADERS -include ${KERNBUILDDIR}/opt_global.h
   93 .endif
   94 
   95 # Add -I paths for system headers.  Individual module makefiles don't
   96 # need any -I paths for this.  Similar defaults for .PATH can't be
   97 # set because there are no standard paths for non-headers.
   98 CFLAGS+=        -I. -I@
   99 
  100 # Add -I path for altq headers as they are included via net/if_var.h
  101 # for example.
  102 CFLAGS+=        -I@/contrib/altq
  103 
  104 # Add a -I path to standard headers like <stddef.h>.  Use a relative
  105 # path to src/include if possible.  If the @ symlink hasn't been built
  106 # yet, then we can't tell if the relative path exists.  Add both the
  107 # potential relative path and an absolute path in that case.
  108 .if exists(@)
  109 .if exists(@/../include)
  110 CFLAGS+=        -I@/../include
  111 .else
  112 CFLAGS+=        -I${DESTDIR}/usr/include
  113 .endif
  114 .else # !@
  115 CFLAGS+=        -I@/../include -I${DESTDIR}/usr/include
  116 .endif # @
  117 
  118 .if ${CC} != "icc"
  119 CFLAGS+=        -finline-limit=${INLINE_LIMIT}
  120 .endif
  121 
  122 # Disallow common variables, and if we end up with commons from
  123 # somewhere unexpected, allocate storage for them in the module itself.
  124 .if ${CC} != "icc"
  125 CFLAGS+=        -fno-common
  126 .endif
  127 LDFLAGS+=       -d -warn-common
  128 
  129 CFLAGS+=        ${DEBUG_FLAGS}
  130 .if ${MACHINE_ARCH} == amd64
  131 CFLAGS+=        -fno-omit-frame-pointer
  132 .endif
  133 
  134 .if ${MACHINE_ARCH} == "powerpc"
  135 CFLAGS+=        -mlongcall -fno-omit-frame-pointer
  136 .endif
  137 
  138 .if defined(FIRMWS)
  139 .if !exists(@)
  140 ${KMOD:S/$/.c/}: @
  141 .else
  142 ${KMOD:S/$/.c/}: @/tools/fw_stub.awk
  143 .endif
  144         ${AWK} -f @/tools/fw_stub.awk ${FIRMWS} -m${KMOD} -c${KMOD:S/$/.c/g}
  145 
  146 SRCS+=  ${KMOD:S/$/.c/}
  147 CLEANFILES+=    ${KMOD:S/$/.c/}
  148 
  149 .for _firmw in ${FIRMWS}
  150 ${_firmw:C/\:.*$/.fwo/}:        ${_firmw:C/\:.*$//}
  151         @${ECHO} ${_firmw:C/\:.*$//} ${.ALLSRC:M*${_firmw:C/\:.*$//}}
  152         @if [ -e ${_firmw:C/\:.*$//} ]; then                    \
  153                 ${LD} -b binary ${LDFLAGS} -r -d -o ${.TARGET}  \
  154                     ${_firmw:C/\:.*$//};                        \
  155         else                                                    \
  156                 ln -s ${.ALLSRC:M*${_firmw:C/\:.*$//}} ${_firmw:C/\:.*$//}; \
  157                 ${LD} -b binary ${LDFLAGS} -r -d -o ${.TARGET}  \
  158                     ${_firmw:C/\:.*$//};                        \
  159                 rm ${_firmw:C/\:.*$//};                         \
  160         fi
  161 
  162 OBJS+=  ${_firmw:C/\:.*$/.fwo/}
  163 .endfor
  164 .endif
  165 
  166 OBJS+=  ${SRCS:N*.h:R:S/$/.o/g}
  167 
  168 .if !defined(PROG)
  169 PROG=   ${KMOD}.ko
  170 .endif
  171 
  172 .if !defined(DEBUG_FLAGS)
  173 FULLPROG=       ${PROG}
  174 .else
  175 FULLPROG=       ${PROG}.debug
  176 ${PROG}: ${FULLPROG}
  177         ${OBJCOPY} --strip-debug ${FULLPROG} ${PROG}
  178 .endif
  179 
  180 .if ${MACHINE_ARCH} != amd64
  181 ${FULLPROG}: ${KMOD}.kld
  182         ${LD} -Bshareable ${LDFLAGS} -o ${.TARGET} ${KMOD}.kld
  183 .if !defined(DEBUG_FLAGS)
  184         ${OBJCOPY} --strip-debug ${.TARGET}
  185 .endif
  186 .endif
  187 
  188 EXPORT_SYMS?=   NO
  189 .if ${EXPORT_SYMS} != YES
  190 CLEANFILES+=    export_syms
  191 .endif
  192 
  193 .if ${MACHINE_ARCH} != amd64
  194 ${KMOD}.kld: ${OBJS}
  195 .else
  196 ${FULLPROG}: ${OBJS}
  197 .endif
  198         ${LD} ${LDFLAGS} -r -d -o ${.TARGET} ${OBJS}
  199 .if defined(EXPORT_SYMS)
  200 .if ${EXPORT_SYMS} != YES
  201 .if ${EXPORT_SYMS} == NO
  202         :> export_syms
  203 .elif !exists(${.CURDIR}/${EXPORT_SYMS})
  204         echo ${EXPORT_SYMS} > export_syms
  205 .else
  206         grep -v '^#' < ${EXPORT_SYMS} > export_syms
  207 .endif
  208         awk -f ${SYSDIR}/conf/kmod_syms.awk ${.TARGET} \
  209             export_syms | xargs -J% ${OBJCOPY} % ${.TARGET}
  210 .endif
  211 .endif
  212 .if !defined(DEBUG_FLAGS) && ${MACHINE_ARCH} == amd64
  213         ${OBJCOPY} --strip-debug ${.TARGET}
  214 .endif
  215 
  216 _ILINKS=@ machine
  217 .if ${MACHINE} != ${MACHINE_ARCH}
  218 _ILINKS+=${MACHINE_ARCH}
  219 .endif
  220 
  221 all: objwarn ${PROG}
  222 
  223 beforedepend: ${_ILINKS}
  224 
  225 # Ensure that the links exist without depending on it when it exists which
  226 # causes all the modules to be rebuilt when the directory pointed to changes.
  227 .for _link in ${_ILINKS}
  228 .if !exists(${.OBJDIR}/${_link})
  229 ${OBJS}: ${_link}
  230 .endif
  231 .endfor
  232 
  233 # Search for kernel source tree in standard places.
  234 .for _dir in ${.CURDIR}/../.. ${.CURDIR}/../../.. /sys /usr/src/sys
  235 .if !defined(SYSDIR) && exists(${_dir}/kern/)
  236 SYSDIR= ${_dir}
  237 .endif
  238 .endfor
  239 .if !defined(SYSDIR) || !exists(${SYSDIR}/kern/)
  240 .error "can't find kernel source tree"
  241 .endif
  242 
  243 ${_ILINKS}:
  244         @case ${.TARGET} in \
  245         ${MACHINE_ARCH}) \
  246                 path=${SYSDIR}/${MACHINE_ARCH}/include ;; \
  247         machine) \
  248                 path=${SYSDIR}/${MACHINE}/include ;; \
  249         @) \
  250                 path=${SYSDIR} ;; \
  251         esac ; \
  252         path=`(cd $$path && /bin/pwd)` ; \
  253         ${ECHO} ${.TARGET} "->" $$path ; \
  254         ln -s $$path ${.TARGET}
  255 
  256 CLEANFILES+= ${PROG} ${KMOD}.kld ${OBJS} ${_ILINKS}
  257 
  258 .if defined(DEBUG_FLAGS)
  259 CLEANFILES+= ${FULLPROG}
  260 .endif
  261 
  262 .if !target(install)
  263 
  264 _INSTALLFLAGS:= ${INSTALLFLAGS}
  265 .for ie in ${INSTALLFLAGS_EDIT}
  266 _INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
  267 .endfor
  268 
  269 .if !target(install.debug) && defined(DEBUG_FLAGS)
  270 install.debug:
  271         cd ${.CURDIR}; ${MAKE} -DINSTALL_DEBUG install
  272 .endif
  273 
  274 .if !target(realinstall)
  275 realinstall: _kmodinstall
  276 .ORDER: beforeinstall _kmodinstall
  277 _kmodinstall:
  278 .if defined(DEBUG_FLAGS) && defined(INSTALL_DEBUG)
  279         ${INSTALL} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
  280             ${_INSTALLFLAGS} ${FULLPROG} ${DESTDIR}${KMODDIR}
  281 .else
  282         ${INSTALL} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
  283             ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${KMODDIR}
  284 
  285 .include <bsd.links.mk>
  286 
  287 .if !defined(NO_XREF)
  288 afterinstall: _kldxref
  289 .ORDER: realinstall _kldxref
  290 .ORDER: _installlinks _kldxref
  291 _kldxref:
  292         @if type kldxref >/dev/null 2>&1; then \
  293                 ${ECHO} kldxref ${DESTDIR}${KMODDIR}; \
  294                 kldxref ${DESTDIR}${KMODDIR}; \
  295         fi
  296 .endif
  297 .endif
  298 .endif # !target(realinstall)
  299 
  300 .endif # !target(install)
  301 
  302 .if !target(load)
  303 load: ${PROG}
  304         ${KMODLOAD} -v ${.OBJDIR}/${PROG}
  305 .endif
  306 
  307 .if !target(unload)
  308 unload:
  309         ${KMODUNLOAD} -v ${PROG}
  310 .endif
  311 
  312 .if defined(KERNBUILDDIR)
  313 .PATH: ${KERNBUILDDIR}
  314 CFLAGS+=        -I${KERNBUILDDIR}
  315 .for _src in ${SRCS:Mopt_*.h}
  316 CLEANFILES+=    ${_src}
  317 .if !target(${_src})
  318 ${_src}:
  319         ln -s ${KERNBUILDDIR}/${_src} ${.TARGET}
  320 .endif
  321 .endfor
  322 .else
  323 .for _src in ${SRCS:Mopt_*.h}
  324 CLEANFILES+=    ${_src}
  325 .if !target(${_src})
  326 ${_src}:
  327         :> ${.TARGET}
  328 .endif
  329 .endfor
  330 .endif
  331 
  332 MFILES?= dev/acpica/acpi_if.m dev/ata/ata_if.m dev/eisa/eisa_if.m \
  333         dev/iicbus/iicbb_if.m dev/iicbus/iicbus_if.m \
  334         dev/mii/miibus_if.m dev/ofw/ofw_bus_if.m \
  335         dev/pccard/card_if.m dev/pccard/power_if.m dev/pci/pci_if.m \
  336         dev/pci/pcib_if.m dev/ppbus/ppbus_if.m dev/smbus/smbus_if.m \
  337         dev/sound/pcm/ac97_if.m dev/sound/pcm/channel_if.m \
  338         dev/sound/pcm/feeder_if.m dev/sound/pcm/mixer_if.m dev/uart/uart_if.m \
  339         dev/usb/usb_if.m isa/isa_if.m \
  340         kern/bus_if.m kern/cpufreq_if.m kern/device_if.m \
  341         libkern/iconv_converter_if.m opencrypto/crypto_if.m \
  342         pc98/pc98/canbus_if.m pci/agp_if.m
  343 
  344 .for _srcsrc in ${MFILES}
  345 .for _ext in c h
  346 .for _src in ${SRCS:M${_srcsrc:T:R}.${_ext}}
  347 CLEANFILES+=    ${_src}
  348 .if !target(${_src})
  349 .if !exists(@)
  350 ${_src}: @
  351 .else
  352 ${_src}: @/tools/makeobjops.awk @/${_srcsrc}
  353 .endif
  354         ${AWK} -f @/tools/makeobjops.awk @/${_srcsrc} -${_ext}
  355 .endif
  356 .endfor # _src
  357 .endfor # _ext
  358 .endfor # _srcsrc
  359 
  360 .if ${SRCS:Mvnode_if.c} != ""
  361 CLEANFILES+=    vnode_if.c
  362 .if !exists(@)
  363 vnode_if.c: @
  364 .else
  365 vnode_if.c: @/tools/vnode_if.awk @/kern/vnode_if.src
  366 .endif
  367         ${AWK} -f @/tools/vnode_if.awk @/kern/vnode_if.src -c
  368 .endif
  369 
  370 .if ${SRCS:Mvnode_if.h} != ""
  371 CLEANFILES+=    vnode_if.h vnode_if_newproto.h vnode_if_typedef.h
  372 .if !exists(@)
  373 vnode_if.h vnode_if_newproto.h vnode_if_typedef.h: @
  374 .else
  375 vnode_if.h vnode_if_newproto.h vnode_if_typedef.h: @/tools/vnode_if.awk \
  376     @/kern/vnode_if.src
  377 .endif
  378 vnode_if.h: vnode_if_newproto.h vnode_if_typedef.h
  379         ${AWK} -f @/tools/vnode_if.awk @/kern/vnode_if.src -h
  380 vnode_if_newproto.h:
  381         ${AWK} -f @/tools/vnode_if.awk @/kern/vnode_if.src -p
  382 vnode_if_typedef.h:
  383         ${AWK} -f @/tools/vnode_if.awk @/kern/vnode_if.src -q
  384 .endif
  385 
  386 .for _i in mii pccard
  387 .if ${SRCS:M${_i}devs.h} != ""
  388 CLEANFILES+=    ${_i}devs.h
  389 .if !exists(@)
  390 ${_i}devs.h: @
  391 .else
  392 ${_i}devs.h: @/tools/${_i}devs2h.awk @/dev/${_i}/${_i}devs
  393 .endif
  394         ${AWK} -f @/tools/${_i}devs2h.awk @/dev/${_i}/${_i}devs
  395 .endif
  396 .endfor # _i
  397 
  398 .if ${SRCS:Musbdevs.h} != ""
  399 CLEANFILES+=    usbdevs.h
  400 .if !exists(@)
  401 usbdevs.h: @
  402 .else
  403 usbdevs.h: @/tools/usbdevs2h.awk @/dev/usb/usbdevs
  404 .endif
  405         ${AWK} -f @/tools/usbdevs2h.awk @/dev/usb/usbdevs -h
  406 .endif
  407 
  408 .if ${SRCS:Musbdevs_data.h} != ""
  409 CLEANFILES+=    usbdevs_data.h
  410 .if !exists(@)
  411 usbdevs_data.h: @
  412 .else
  413 usbdevs_data.h: @/tools/usbdevs2h.awk @/dev/usb/usbdevs
  414 .endif
  415         ${AWK} -f @/tools/usbdevs2h.awk @/dev/usb/usbdevs -d
  416 .endif
  417 
  418 .if ${SRCS:Macpi_quirks.h} != ""
  419 CLEANFILES+=    acpi_quirks.h
  420 .if !exists(@)
  421 acpi_quirks.h: @
  422 .else
  423 acpi_quirks.h: @/tools/acpi_quirks2h.awk @/dev/acpica/acpi_quirks
  424 .endif
  425         ${AWK} -f @/tools/acpi_quirks2h.awk @/dev/acpica/acpi_quirks
  426 .endif
  427 
  428 .if ${SRCS:Massym.s} != ""
  429 CLEANFILES+=    assym.s genassym.o
  430 assym.s: genassym.o
  431 .if !exists(@)
  432 assym.s: @
  433 .else
  434 assym.s: @/kern/genassym.sh
  435 .endif
  436         sh @/kern/genassym.sh genassym.o > ${.TARGET}
  437 .if exists(@)
  438 genassym.o: @/${MACHINE_ARCH}/${MACHINE_ARCH}/genassym.c
  439 .endif
  440 genassym.o: @ machine ${SRCS:Mopt_*.h}
  441         ${CC} -c ${CFLAGS:N-fno-common} \
  442             @/${MACHINE_ARCH}/${MACHINE_ARCH}/genassym.c
  443 .endif
  444 
  445 lint: ${SRCS}
  446         ${LINT} ${LINTKERNFLAGS} ${CFLAGS:M-[DILU]*} ${.ALLSRC:M*.c}
  447 
  448 .include <bsd.dep.mk>
  449 
  450 .if !exists(${.OBJDIR}/${DEPENDFILE})
  451 ${OBJS}: ${SRCS:M*.h}
  452 .endif
  453 
  454 .include <bsd.obj.mk>
  455 .include "kern.mk"

Cache object: 913c0239b5a0ad8335abcc9dd43efff5


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