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

Cache object: e46ec9c963de576a7c52d156fd1f06d8


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