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.4/sys/conf/kmod.mk 145335 2005-04-20 19:11:07Z cvs2svn $
    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 .if ${CC} == "icc"
   74 CFLAGS:=        ${CFLAGS:C/(-x[^M^K^W]+)[MKW]+|-x[MKW]+/\1/}
   75 .endif
   76 . if !empty(CFLAGS:M-O[23s]) && empty(CFLAGS:M-fno-strict-aliasing)
   77 CFLAGS+=        -fno-strict-aliasing
   78 . endif
   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+=       -include ${KERNBUILDDIR}/opt_global.h
   95 .endif
   96 
   97 # Add -I paths for system headers.  Individual KLD 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 
  133 OBJS+=  ${SRCS:N*.h:R:S/$/.o/g}
  134 
  135 .if !defined(PROG)
  136 PROG=   ${KMOD}.ko
  137 .endif
  138 
  139 .if !defined(DEBUG_FLAGS)
  140 FULLPROG=       ${PROG}
  141 .else
  142 FULLPROG=       ${PROG}.debug
  143 ${PROG}: ${FULLPROG}
  144         ${OBJCOPY} --strip-debug ${FULLPROG} ${PROG}
  145 .endif
  146 
  147 .if ${MACHINE_ARCH} != amd64
  148 ${FULLPROG}: ${KMOD}.kld
  149         ${LD} -Bshareable ${LDFLAGS} -o ${.TARGET} ${KMOD}.kld
  150 .if !defined(DEBUG_FLAGS)
  151         ${OBJCOPY} --strip-debug ${.TARGET}
  152 .endif
  153 .endif
  154 
  155 EXPORT_SYMS?=   NO
  156 .if ${EXPORT_SYMS} != YES
  157 CLEANFILES+=    ${.OBJDIR}/export_syms
  158 .endif
  159 
  160 .if ${MACHINE_ARCH} != amd64
  161 ${KMOD}.kld: ${OBJS}
  162 .else
  163 ${FULLPROG}: ${OBJS}
  164 .endif
  165         ${LD} ${LDFLAGS} -r -d -o ${.TARGET} ${OBJS}
  166 .if defined(EXPORT_SYMS)
  167 .if ${EXPORT_SYMS} != YES
  168 .if ${EXPORT_SYMS} == NO
  169         touch ${.OBJDIR}/export_syms
  170 .elif !exists(${.CURDIR}/${EXPORT_SYMS})
  171         echo ${EXPORT_SYMS} > ${.OBJDIR}/export_syms
  172 .else
  173         grep -v '^#' < ${EXPORT_SYMS} >  ${.OBJDIR}/export_syms
  174 .endif
  175         awk -f ${SYSDIR}/conf/kmod_syms.awk ${.TARGET} \
  176                 ${.OBJDIR}/export_syms | \
  177         xargs -J% ${OBJCOPY} % ${.TARGET}
  178 .endif
  179 .endif
  180 .if !defined(DEBUG_FLAGS) && ${MACHINE_ARCH} == amd64
  181         ${OBJCOPY} --strip-debug ${.TARGET}
  182 .endif
  183 
  184 _ILINKS=@ machine
  185 
  186 all: objwarn ${PROG}
  187 
  188 beforedepend: ${_ILINKS}
  189         @rm -f .depend
  190 
  191 # Ensure that the links exist without depending on it when it exists which
  192 # causes all the modules to be rebuilt when the directory pointed to changes.
  193 .for _link in ${_ILINKS}
  194 .if !exists(${.OBJDIR}/${_link})
  195 ${OBJS}: ${_link}
  196 .endif
  197 .endfor
  198 
  199 # Search for kernel source tree in standard places.
  200 .for _dir in ${.CURDIR}/../.. ${.CURDIR}/../../.. /sys /usr/src/sys
  201 .if !defined(SYSDIR) && exists(${_dir}/kern/)
  202 SYSDIR= ${_dir}
  203 .endif
  204 .endfor
  205 .if !defined(SYSDIR) || !exists(${SYSDIR}/kern/)
  206 .error "can't find kernel source tree"
  207 .endif
  208 
  209 ${_ILINKS}:
  210         @case ${.TARGET} in \
  211         machine) \
  212                 path=${SYSDIR}/${MACHINE_ARCH}/include ;; \
  213         @) \
  214                 path=${SYSDIR} ;; \
  215         esac ; \
  216         path=`(cd $$path && /bin/pwd)` ; \
  217         ${ECHO} ${.TARGET} "->" $$path ; \
  218         ln -s $$path ${.TARGET}
  219 
  220 CLEANFILES+= ${PROG} ${KMOD}.kld ${OBJS} ${_ILINKS} symb.tmp tmp.o
  221 
  222 .if defined(DEBUG_FLAGS)
  223 CLEANFILES+= ${FULLPROG}
  224 .endif
  225 
  226 .if !target(install)
  227 
  228 _INSTALLFLAGS:= ${INSTALLFLAGS}
  229 .for ie in ${INSTALLFLAGS_EDIT}
  230 _INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
  231 .endfor
  232 
  233 .if defined(DEBUG_FLAGS)
  234 install.debug:
  235         cd ${.CURDIR}; ${MAKE} -DINSTALL_DEBUG install
  236 .endif
  237 
  238 .if !target(realinstall)
  239 realinstall: _kmodinstall
  240 .ORDER: beforeinstall _kmodinstall
  241 _kmodinstall:
  242 .if defined(DEBUG_FLAGS) && defined(INSTALL_DEBUG)
  243         ${INSTALL} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
  244             ${_INSTALLFLAGS} ${FULLPROG} ${DESTDIR}${KMODDIR}
  245 .else
  246         ${INSTALL} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
  247             ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${KMODDIR}
  248 
  249 .include <bsd.links.mk>
  250 
  251 .if !defined(NO_XREF)
  252 afterinstall: _kldxref
  253 .ORDER: realinstall _kldxref
  254 .ORDER: _installlinks _kldxref
  255 _kldxref:
  256         @if type kldxref >/dev/null 2>&1; then \
  257                 ${ECHO} kldxref ${DESTDIR}${KMODDIR}; \
  258                 kldxref ${DESTDIR}${KMODDIR}; \
  259         fi
  260 .endif
  261 .endif
  262 .endif !target(realinstall)
  263 
  264 .endif !target(install)
  265 
  266 .if !target(load)
  267 load:   ${PROG}
  268         ${KMODLOAD} -v ${.OBJDIR}/${KMOD}.ko
  269 .endif
  270 
  271 .if !target(unload)
  272 unload:
  273         ${KMODUNLOAD} -v ${KMOD}
  274 .endif
  275 
  276 .if defined(KERNBUILDDIR)
  277 .PATH: ${KERNBUILDDIR}
  278 CFLAGS += -I${KERNBUILDDIR}
  279 .for _src in ${SRCS:Mopt_*.h}
  280 CLEANFILES+=    ${_src}
  281 .if !target(${_src})
  282 ${_src}:
  283         ln -s ${KERNBUILDDIR}/${_src} ${.TARGET}
  284 .endif
  285 .endfor
  286 .else
  287 .for _src in ${SRCS:Mopt_*.h}
  288 CLEANFILES+=    ${_src}
  289 .if !target(${_src})
  290 ${_src}:
  291         touch ${.TARGET}
  292 .endif
  293 .endfor
  294 .endif
  295 
  296 MFILES?= dev/acpica/acpi_if.m dev/eisa/eisa_if.m dev/iicbus/iicbb_if.m \
  297         dev/iicbus/iicbus_if.m dev/mii/miibus_if.m dev/ofw/ofw_bus_if.m \
  298         dev/pccard/card_if.m dev/pccard/power_if.m dev/pci/pci_if.m \
  299         dev/pci/pcib_if.m dev/ppbus/ppbus_if.m dev/smbus/smbus_if.m \
  300         dev/sound/pcm/ac97_if.m dev/sound/pcm/channel_if.m \
  301         dev/sound/pcm/feeder_if.m dev/sound/pcm/mixer_if.m dev/uart/uart_if.m \
  302         dev/usb/usb_if.m isa/isa_if.m \
  303         kern/bus_if.m kern/cpufreq_if.m kern/device_if.m \
  304         libkern/iconv_converter_if.m opencrypto/crypto_if.m \
  305         pc98/pc98/canbus_if.m pci/agp_if.m sparc64/pci/ofw_pci_if.m
  306 
  307 .for _srcsrc in ${MFILES}
  308 .for _ext in c h
  309 .for _src in ${SRCS:M${_srcsrc:T:R}.${_ext}}
  310 CLEANFILES+=    ${_src}
  311 .if !target(${_src})
  312 .if !exists(@)
  313 ${_src}: @
  314 .endif
  315 .if exists(@)
  316 ${_src}: @/tools/makeobjops.awk @/${_srcsrc}
  317 .endif
  318         ${AWK} -f @/tools/makeobjops.awk @/${_srcsrc} -${_ext}
  319 .endif
  320 .endfor # _src
  321 .endfor # _ext
  322 .endfor # _srcsrc
  323 
  324 .for _ext in c h
  325 .if ${SRCS:Mvnode_if.${_ext}} != ""
  326 CLEANFILES+=    vnode_if.${_ext}
  327 .if !exists(@)
  328 vnode_if.${_ext}: @
  329 .endif
  330 .if exists(@)
  331 vnode_if.${_ext}: @/tools/vnode_if.awk @/kern/vnode_if.src
  332 .endif
  333         ${AWK} -f @/tools/vnode_if.awk @/kern/vnode_if.src -${_ext}
  334 .endif
  335 .endfor
  336 
  337 .for _i in mii pccard usb
  338 .if ${SRCS:M${_i}devs.h} != ""
  339 CLEANFILES+=    ${_i}devs.h
  340 .if !exists(@)
  341 ${_i}devs.h: @
  342 .endif
  343 .if exists(@)
  344 ${_i}devs.h: @/tools/${_i}devs2h.awk @/dev/${_i}/${_i}devs
  345 .endif
  346         ${AWK} -f @/tools/${_i}devs2h.awk @/dev/${_i}/${_i}devs
  347 .endif
  348 .endfor # _i
  349 
  350 .if ${SRCS:Macpi_quirks.h} != ""
  351 CLEANFILES+=    acpi_quirks.h
  352 .if !exists(@)
  353 acpi_quirks.h: @
  354 .endif
  355 .if exists(@)
  356 acpi_quirks.h: @/tools/acpi_quirks2h.awk @/dev/acpica/acpi_quirks
  357 .endif
  358         ${AWK} -f @/tools/acpi_quirks2h.awk @/dev/acpica/acpi_quirks
  359 .endif
  360 
  361 regress:
  362 
  363 lint: ${SRCS}
  364         ${LINT} ${LINTKERNFLAGS} ${CFLAGS:M-[DILU]*} ${.ALLSRC:M*.c}
  365 
  366 .include <bsd.dep.mk>
  367 
  368 .if !exists(${.OBJDIR}/${DEPENDFILE})
  369 ${OBJS}: ${SRCS:M*.h}
  370 .endif
  371 
  372 .include <bsd.obj.mk>
  373 .include "kern.mk"

Cache object: e16aef7f6ae52460a7798f5f6b7acd94


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