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

Cache object: 9304e52300b500f6567e5601a4333b33


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