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/8.4/sys/conf/kmod.mk 241728 2012-10-19 11:01:39Z jhb $
    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 ${MACHINE_ARCH} == "mips"
  132 CFLAGS+=        -G0 -fno-pic -mno-abicalls -mlong-calls
  133 .endif
  134 
  135 .if defined(DEBUG) || defined(DEBUG_FLAGS)
  136 CTFFLAGS+=      -g
  137 .endif
  138 
  139 .if defined(FIRMWS)
  140 .if !exists(@)
  141 ${KMOD:S/$/.c/}: @
  142 .else
  143 ${KMOD:S/$/.c/}: @/tools/fw_stub.awk
  144 .endif
  145         ${AWK} -f @/tools/fw_stub.awk ${FIRMWS} -m${KMOD} -c${KMOD:S/$/.c/g} \
  146             ${FIRMWARE_LICENSE:C/.+/-l/}${FIRMWARE_LICENSE}
  147 
  148 SRCS+=  ${KMOD:S/$/.c/}
  149 CLEANFILES+=    ${KMOD:S/$/.c/}
  150 
  151 .for _firmw in ${FIRMWS}
  152 ${_firmw:C/\:.*$/.fwo/}:        ${_firmw:C/\:.*$//}
  153         @${ECHO} ${_firmw:C/\:.*$//} ${.ALLSRC:M*${_firmw:C/\:.*$//}}
  154         @if [ -e ${_firmw:C/\:.*$//} ]; then                    \
  155                 ${LD} -b binary --no-warn-mismatch ${LDFLAGS}   \
  156                     -r -d -o ${.TARGET} ${_firmw:C/\:.*$//};    \
  157         else                                                    \
  158                 ln -s ${.ALLSRC:M*${_firmw:C/\:.*$//}} ${_firmw:C/\:.*$//}; \
  159                 ${LD} -b binary --no-warn-mismatch ${LDFLAGS}   \
  160                     -r -d -o ${.TARGET} ${_firmw:C/\:.*$//};    \
  161                 rm ${_firmw:C/\:.*$//};                         \
  162         fi
  163 
  164 OBJS+=  ${_firmw:C/\:.*$/.fwo/}
  165 .endfor
  166 .endif
  167 
  168 OBJS+=  ${SRCS:N*.h:R:S/$/.o/g}
  169 
  170 .if !defined(PROG)
  171 PROG=   ${KMOD}.ko
  172 .endif
  173 
  174 .if !defined(DEBUG_FLAGS)
  175 FULLPROG=       ${PROG}
  176 .else
  177 FULLPROG=       ${PROG}.debug
  178 ${PROG}: ${FULLPROG} ${PROG}.symbols
  179         ${OBJCOPY} --strip-debug --add-gnu-debuglink=${PROG}.symbols\
  180             ${FULLPROG} ${.TARGET}
  181 ${PROG}.symbols: ${FULLPROG}
  182         ${OBJCOPY} --only-keep-debug ${FULLPROG} ${.TARGET}
  183 .endif
  184 
  185 .if ${MACHINE_ARCH} != amd64 && ${MACHINE_ARCH} != mips
  186 ${FULLPROG}: ${KMOD}.kld
  187         ${LD} -Bshareable ${LDFLAGS} -o ${.TARGET} ${KMOD}.kld
  188 .if !defined(DEBUG_FLAGS)
  189         ${OBJCOPY} --strip-debug ${.TARGET}
  190 .endif
  191 .endif
  192 
  193 EXPORT_SYMS?=   NO
  194 .if ${EXPORT_SYMS} != YES
  195 CLEANFILES+=    export_syms
  196 .endif
  197 
  198 .if ${MACHINE_ARCH} != amd64 && ${MACHINE_ARCH} != mips
  199 ${KMOD}.kld: ${OBJS}
  200 .else
  201 ${FULLPROG}: ${OBJS}
  202 .endif
  203         ${LD} ${LDFLAGS} -r -d -o ${.TARGET} ${OBJS}
  204 .if defined(MK_CTF) && ${MK_CTF} != "no"
  205         ${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS}
  206 .endif
  207 .if defined(EXPORT_SYMS)
  208 .if ${EXPORT_SYMS} != YES
  209 .if ${EXPORT_SYMS} == NO
  210         :> export_syms
  211 .elif !exists(${.CURDIR}/${EXPORT_SYMS})
  212         echo ${EXPORT_SYMS} > export_syms
  213 .else
  214         grep -v '^#' < ${EXPORT_SYMS} > export_syms
  215 .endif
  216         awk -f ${SYSDIR}/conf/kmod_syms.awk ${.TARGET} \
  217             export_syms | xargs -J% ${OBJCOPY} % ${.TARGET}
  218 .endif
  219 .endif
  220 .if !defined(DEBUG_FLAGS) && \
  221     (${MACHINE_ARCH} == amd64 || ${MACHINE_ARCH} == mips)
  222         ${OBJCOPY} --strip-debug ${.TARGET}
  223 .endif
  224 
  225 _ILINKS=@ machine
  226 .if ${MACHINE} != ${MACHINE_ARCH}
  227 _ILINKS+=${MACHINE_ARCH}
  228 .endif
  229 
  230 all: objwarn ${PROG}
  231 
  232 beforedepend: ${_ILINKS}
  233 
  234 # Ensure that the links exist without depending on it when it exists which
  235 # causes all the modules to be rebuilt when the directory pointed to changes.
  236 .for _link in ${_ILINKS}
  237 .if !exists(${.OBJDIR}/${_link})
  238 ${OBJS}: ${_link}
  239 .endif
  240 .endfor
  241 
  242 # Search for kernel source tree in standard places.
  243 .for _dir in ${.CURDIR}/../.. ${.CURDIR}/../../.. /sys /usr/src/sys
  244 .if !defined(SYSDIR) && exists(${_dir}/kern/)
  245 SYSDIR= ${_dir}
  246 .endif
  247 .endfor
  248 .if !defined(SYSDIR) || !exists(${SYSDIR}/kern/)
  249 .error "can't find kernel source tree"
  250 .endif
  251 
  252 ${_ILINKS}:
  253         @case ${.TARGET} in \
  254         ${MACHINE_ARCH}) \
  255                 path=${SYSDIR}/${MACHINE_ARCH}/include ;; \
  256         machine) \
  257                 path=${SYSDIR}/${MACHINE}/include ;; \
  258         @) \
  259                 path=${SYSDIR} ;; \
  260         esac ; \
  261         path=`(cd $$path && /bin/pwd)` ; \
  262         ${ECHO} ${.TARGET} "->" $$path ; \
  263         ln -sf $$path ${.TARGET}
  264 
  265 CLEANFILES+= ${PROG} ${KMOD}.kld ${OBJS}
  266 
  267 .if defined(DEBUG_FLAGS)
  268 CLEANFILES+= ${FULLPROG} ${PROG}.symbols
  269 .endif
  270 
  271 .if !target(install)
  272 
  273 _INSTALLFLAGS:= ${INSTALLFLAGS}
  274 .for ie in ${INSTALLFLAGS_EDIT}
  275 _INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
  276 .endfor
  277 
  278 .if !target(realinstall)
  279 realinstall: _kmodinstall
  280 .ORDER: beforeinstall _kmodinstall
  281 _kmodinstall:
  282         ${INSTALL} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
  283             ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${KMODDIR}
  284 .if defined(DEBUG_FLAGS) && !defined(INSTALL_NODEBUG)
  285         ${INSTALL} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
  286             ${_INSTALLFLAGS} ${PROG}.symbols ${DESTDIR}${KMODDIR}
  287 .endif
  288 
  289 .include <bsd.links.mk>
  290 
  291 .if !defined(NO_XREF)
  292 afterinstall: _kldxref
  293 .ORDER: realinstall _kldxref
  294 .ORDER: _installlinks _kldxref
  295 _kldxref:
  296         @if type kldxref >/dev/null 2>&1; then \
  297                 ${ECHO} kldxref ${DESTDIR}${KMODDIR}; \
  298                 kldxref ${DESTDIR}${KMODDIR}; \
  299         fi
  300 .endif
  301 .endif # !target(realinstall)
  302 
  303 .endif # !target(install)
  304 
  305 .if !target(load)
  306 load: ${PROG}
  307         ${KMODLOAD} -v ${.OBJDIR}/${PROG}
  308 .endif
  309 
  310 .if !target(unload)
  311 unload:
  312         ${KMODUNLOAD} -v ${PROG}
  313 .endif
  314 
  315 .if defined(KERNBUILDDIR)
  316 .PATH: ${KERNBUILDDIR}
  317 CFLAGS+=        -I${KERNBUILDDIR}
  318 .for _src in ${SRCS:Mopt_*.h}
  319 CLEANFILES+=    ${_src}
  320 .if !target(${_src})
  321 ${_src}:
  322         ln -sf ${KERNBUILDDIR}/${_src} ${.TARGET}
  323 .endif
  324 .endfor
  325 .else
  326 .for _src in ${SRCS:Mopt_*.h}
  327 CLEANFILES+=    ${_src}
  328 .if !target(${_src})
  329 ${_src}:
  330         :> ${.TARGET}
  331 .endif
  332 .endfor
  333 .endif
  334 
  335 MFILES?= dev/acpica/acpi_if.m dev/acpi_support/acpi_wmi_if.m \
  336         dev/agp/agp_if.m dev/ata/ata_if.m dev/eisa/eisa_if.m \
  337         dev/iicbus/iicbb_if.m dev/iicbus/iicbus_if.m \
  338         dev/mmc/mmcbr_if.m dev/mmc/mmcbus_if.m \
  339         dev/mii/miibus_if.m dev/mvs/mvs_if.m dev/ofw/ofw_bus_if.m \
  340         dev/pccard/card_if.m dev/pccard/power_if.m dev/pci/pci_if.m \
  341         dev/pci/pcib_if.m dev/ppbus/ppbus_if.m dev/smbus/smbus_if.m \
  342         dev/sound/pci/hda/hdac_if.m \
  343         dev/sound/pcm/ac97_if.m dev/sound/pcm/channel_if.m \
  344         dev/sound/pcm/feeder_if.m dev/sound/pcm/mixer_if.m \
  345         dev/sound/midi/mpu_if.m dev/sound/midi/mpufoi_if.m \
  346         dev/sound/midi/synth_if.m dev/usb/usb_if.m isa/isa_if.m \
  347         kern/bus_if.m kern/clock_if.m \
  348         kern/cpufreq_if.m kern/device_if.m kern/serdev_if.m \
  349         libkern/iconv_converter_if.m opencrypto/cryptodev_if.m \
  350         pc98/pc98/canbus_if.m
  351 
  352 .for _srcsrc in ${MFILES}
  353 .for _ext in c h
  354 .for _src in ${SRCS:M${_srcsrc:T:R}.${_ext}}
  355 CLEANFILES+=    ${_src}
  356 .if !target(${_src})
  357 .if !exists(@)
  358 ${_src}: @
  359 .else
  360 ${_src}: @/tools/makeobjops.awk @/${_srcsrc}
  361 .endif
  362         ${AWK} -f @/tools/makeobjops.awk @/${_srcsrc} -${_ext}
  363 .endif
  364 .endfor # _src
  365 .endfor # _ext
  366 .endfor # _srcsrc
  367 
  368 .if !empty(SRCS:Mvnode_if.c)
  369 CLEANFILES+=    vnode_if.c
  370 .if !exists(@)
  371 vnode_if.c: @
  372 .else
  373 vnode_if.c: @/tools/vnode_if.awk @/kern/vnode_if.src
  374 .endif
  375         ${AWK} -f @/tools/vnode_if.awk @/kern/vnode_if.src -c
  376 .endif
  377 
  378 .if !empty(SRCS:Mvnode_if.h)
  379 CLEANFILES+=    vnode_if.h vnode_if_newproto.h vnode_if_typedef.h
  380 .if !exists(@)
  381 vnode_if.h vnode_if_newproto.h vnode_if_typedef.h: @
  382 .else
  383 vnode_if.h vnode_if_newproto.h vnode_if_typedef.h: @/tools/vnode_if.awk \
  384     @/kern/vnode_if.src
  385 .endif
  386 vnode_if.h: vnode_if_newproto.h vnode_if_typedef.h
  387         ${AWK} -f @/tools/vnode_if.awk @/kern/vnode_if.src -h
  388 vnode_if_newproto.h:
  389         ${AWK} -f @/tools/vnode_if.awk @/kern/vnode_if.src -p
  390 vnode_if_typedef.h:
  391         ${AWK} -f @/tools/vnode_if.awk @/kern/vnode_if.src -q
  392 .endif
  393 
  394 .for _i in mii pccard
  395 .if !empty(SRCS:M${_i}devs.h)
  396 CLEANFILES+=    ${_i}devs.h
  397 .if !exists(@)
  398 ${_i}devs.h: @
  399 .else
  400 ${_i}devs.h: @/tools/${_i}devs2h.awk @/dev/${_i}/${_i}devs
  401 .endif
  402         ${AWK} -f @/tools/${_i}devs2h.awk @/dev/${_i}/${_i}devs
  403 .endif
  404 .endfor # _i
  405 
  406 .if !empty(SRCS:Musbdevs.h)
  407 CLEANFILES+=    usbdevs.h
  408 .if !exists(@)
  409 usbdevs.h: @
  410 .else
  411 usbdevs.h: @/tools/usbdevs2h.awk @/dev/usb/usbdevs
  412 .endif
  413         ${AWK} -f @/tools/usbdevs2h.awk @/dev/usb/usbdevs -h
  414 .endif
  415 
  416 .if !empty(SRCS:Musbdevs_data.h)
  417 CLEANFILES+=    usbdevs_data.h
  418 .if !exists(@)
  419 usbdevs_data.h: @
  420 .else
  421 usbdevs_data.h: @/tools/usbdevs2h.awk @/dev/usb/usbdevs
  422 .endif
  423         ${AWK} -f @/tools/usbdevs2h.awk @/dev/usb/usbdevs -d
  424 .endif
  425 
  426 .if !empty(SRCS:Macpi_quirks.h)
  427 CLEANFILES+=    acpi_quirks.h
  428 .if !exists(@)
  429 acpi_quirks.h: @
  430 .else
  431 acpi_quirks.h: @/tools/acpi_quirks2h.awk @/dev/acpica/acpi_quirks
  432 .endif
  433         ${AWK} -f @/tools/acpi_quirks2h.awk @/dev/acpica/acpi_quirks
  434 .endif
  435 
  436 .if !empty(SRCS:Massym.s)
  437 CLEANFILES+=    assym.s genassym.o
  438 assym.s: genassym.o
  439 .if defined(KERNBUILDDIR)
  440 genassym.o: opt_global.h
  441 .endif
  442 .if !exists(@)
  443 assym.s: @
  444 .else
  445 assym.s: @/kern/genassym.sh
  446 .endif
  447         sh @/kern/genassym.sh genassym.o > ${.TARGET}
  448 .if exists(@)
  449 genassym.o: @/${MACHINE_ARCH}/${MACHINE_ARCH}/genassym.c
  450 .endif
  451 genassym.o: @ machine ${SRCS:Mopt_*.h}
  452         ${CC} -c ${CFLAGS:N-fno-common} \
  453             @/${MACHINE_ARCH}/${MACHINE_ARCH}/genassym.c
  454 .endif
  455 
  456 lint: ${SRCS}
  457         ${LINT} ${LINTKERNFLAGS} ${CFLAGS:M-[DILU]*} ${.ALLSRC:M*.c}
  458 
  459 .if defined(KERNBUILDDIR)
  460 ${OBJS}: opt_global.h
  461 .endif
  462 
  463 .include <bsd.dep.mk>
  464 
  465 cleandepend: cleanilinks
  466 # .depend needs include links so we remove them only together.
  467 cleanilinks:
  468         rm -f ${_ILINKS}
  469 
  470 .if !exists(${.OBJDIR}/${DEPENDFILE})
  471 ${OBJS}: ${SRCS:M*.h}
  472 .endif
  473 
  474 .include <bsd.obj.mk>
  475 .include "kern.mk"

Cache object: 6caf77b8c6e67c22cf769207510f4f5f


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