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: src/sys/conf/kmod.mk,v 1.82.2.15 2003/02/10 13:11:50 nyan Exp $
    3 #
    4 # The include file <bsd.kmod.mk> handles installing Kernel Loadable Device
    5 # drivers (KLD's).
    6 #
    7 #
    8 # +++ variables +++
    9 # CLEANFILES    Additional files to remove for the clean and cleandir targets.
   10 #
   11 # KMOD          The name of the kernel module to build.
   12 #
   13 # KMODDIR       Base path for kernel modules (see kld(4)).
   14 #               [${DESTKERNDIR}]
   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 # DESTKERNDIR   Change the tree where the kernel and the modules get
   32 #               installed. [/boot]  ${DESTDIR} changes the root of the tree
   33 #               pointed to by ${DESTKERNDIR}.
   34 #
   35 # MFILES        Optionally a list of interfaces used by the module.
   36 #               This file contains a default list of interfaces.
   37 #
   38 # FIRMWS        List of firmware images in format filename:shortname:version
   39 #
   40 # FIRMWARE_LICENSE
   41 #               Set to the name of the license the user has to agree on in
   42 #               order to use this firmware. See /usr/share/doc/legal
   43 #
   44 # +++ targets +++
   45 #
   46 #       install:
   47 #               install the kernel module and its manual pages; if the Makefile
   48 #               does not itself define the target install, the targets
   49 #               beforeinstall and afterinstall may also be used to cause
   50 #               actions immediately before and after the install target
   51 #               is executed.
   52 #
   53 #       load:
   54 #               Load KLD.
   55 #
   56 #       unload:
   57 #               Unload KLD.
   58 #
   59 # bsd.obj.mk: clean, cleandir and obj
   60 # bsd.dep.mk: cleandepend, depend and tags
   61 #
   62 
   63 OBJCOPY?=       objcopy
   64 KMODLOAD?=      /sbin/kldload
   65 KMODUNLOAD?=    /sbin/kldunload
   66 
   67 # KERNEL is needed when running make install directly from
   68 # the obj directory.
   69 KERNEL?=        kernel
   70 
   71 KMODDIR?=       ${DESTKERNDIR}
   72 KMODOWN?=       ${BINOWN}
   73 KMODGRP?=       ${BINGRP}
   74 KMODMODE?=      ${BINMODE}
   75 
   76 .include <bsd.init.mk>
   77 
   78 .SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S
   79 
   80 CFLAGS+=        ${COPTS} -D_KERNEL ${CWARNFLAGS}
   81 CFLAGS+=        -DKLD_MODULE
   82 
   83 # Don't use any standard include directories.
   84 # Since -nostdinc will annull any previous -I paths, we repeat all
   85 # such paths after -nostdinc.  It doesn't seem to be possible to
   86 # add to the front of `make' variable.
   87 #
   88 # Don't use -I- anymore, source-relative includes are desireable.
   89 _ICFLAGS:=      ${CFLAGS:M-I*}
   90 CFLAGS+=        -nostdinc ${_ICFLAGS}
   91 
   92 # Add -I paths for system headers.  Individual KLD makefiles don't
   93 # need any -I paths for this.  Similar defaults for .PATH can't be
   94 # set because there are no standard paths for non-headers.
   95 #
   96 # NOTE!  Traditional architecture paths such as <i386/i386/blah.h>
   97 # must run through the "machine_base" softlink using 
   98 # <machine_base/i386/blah.h>.  An explicit cross-architecture path must
   99 # operate relative to /usr/src/sys using e.g. <arch/i386/i386/blah.h>
  100 #
  101 CFLAGS+=        -I. -I@
  102 
  103 # Add -I paths for headers in the kernel build directory
  104 #
  105 .if defined(BUILDING_WITH_KERNEL)
  106 CFLAGS+=        -I${BUILDING_WITH_KERNEL}
  107 _MACHINE_FWD=   ${BUILDING_WITH_KERNEL}
  108 .else
  109 .if defined(MAKEOBJDIRPREFIX)
  110 _MACHINE_FWD=   ${MAKEOBJDIRPREFIX}/${SYSDIR}/forwarder_${MACHINE_ARCH}
  111 .else
  112 _MACHINE_FWD=   ${.OBJDIR}/forwarder_${MACHINE_ARCH}
  113 CLEANDIRS+=     ${_MACHINE_FWD}
  114 .endif
  115 .endif
  116 CFLAGS+=        -I${_MACHINE_FWD}/include
  117 .include "kern.fwd.mk"
  118 
  119 # Add a -I path to standard headers like <stddef.h>.  Use a relative
  120 # path to src/include if possible.  If the @ symlink hasn't been built
  121 # yet, then we can't tell if the relative path exists.  Add both the
  122 # potential relative path and an absolute path in that case.
  123 .if exists(@)
  124 .if exists(@/../include)
  125 CFLAGS+=        -I@/../include
  126 .else
  127 CFLAGS+=        -I${DESTDIR}/usr/include
  128 .endif
  129 .else # !@
  130 CFLAGS+=        -I@/../include -I${DESTDIR}/usr/include
  131 .endif # @
  132 
  133 .if defined(BUILDING_WITH_KERNEL) && \
  134     exists(${BUILDING_WITH_KERNEL}/opt_global.h)
  135 CFLAGS+=        -include ${BUILDING_WITH_KERNEL}/opt_global.h
  136 .endif
  137 
  138 CFLAGS+=        ${DEBUG_FLAGS}
  139 .if ${MACHINE_ARCH} == x86_64
  140 CFLAGS+=        -fno-omit-frame-pointer
  141 .endif
  142 
  143 .include <bsd.patch.mk>
  144 
  145 .if defined(FIRMWS)
  146 AWK=/usr/bin/awk
  147 .if !exists(@)
  148 ${KMOD:S/$/.c/}: @
  149 .else
  150 ${KMOD:S/$/.c/}: @/tools/fw_stub.awk
  151 .endif
  152         ${AWK} -f @/tools/fw_stub.awk ${FIRMWS} -m${KMOD} -c${KMOD:S/$/.c/g} \
  153             ${FIRMWARE_LICENSE:C/.+/-l/}${FIRMWARE_LICENSE}
  154 
  155 SRCS+=  ${KMOD:S/$/.c/}
  156 CLEANFILES+=    ${KMOD:S/$/.c/}
  157 
  158 .for _firmw in ${FIRMWS}
  159 ${_firmw:C/\:.*$/.fwo/}:        ${_firmw:C/\:.*$//}
  160         @${ECHO} ${_firmw:C/\:.*$//} ${.ALLSRC:M*${_firmw:C/\:.*$//}}
  161         @if [ -e ${_firmw:C/\:.*$//} ]; then                    \
  162                 ${LD} -b binary --no-warn-mismatch ${LDFLAGS}   \
  163                     -r -d -o ${.TARGET} ${_firmw:C/\:.*$//};    \
  164         else                                                    \
  165                 ln -s ${.ALLSRC:M*${_firmw:C/\:.*$//}} ${_firmw:C/\:.*$//}; \
  166                 ${LD} -b binary --no-warn-mismatch ${LDFLAGS}   \
  167                     -r -d -o ${.TARGET} ${_firmw:C/\:.*$//};    \
  168                 rm ${_firmw:C/\:.*$//};                         \
  169         fi
  170 
  171 OBJS+=  ${_firmw:C/\:.*$/.fwo/}
  172 .endfor
  173 .endif
  174 
  175 OBJS+=  ${SRCS:N*.h:N*.patch:R:S/$/.o/g}
  176 
  177 .if !defined(PROG)
  178 PROG=   ${KMOD}.ko
  179 .endif
  180 
  181 .if ${MACHINE_ARCH} != x86_64
  182 ${PROG}: ${KMOD}.kld
  183         ${LD} -Bshareable ${LDFLAGS} -o ${.TARGET} ${KMOD}.kld
  184 .endif
  185 
  186 .if ${MACHINE_ARCH} != x86_64
  187 ${KMOD}.kld: ${OBJS}
  188         ${LD} ${LDFLAGS} -r -o ${.TARGET} ${OBJS}
  189 .else
  190 ${PROG}: ${OBJS}
  191         ${LD} ${LDFLAGS} -r -d -o ${.TARGET} ${OBJS}
  192 .endif
  193 
  194 # links to platform and cpu architecture include files.  If we are
  195 # building with a kernel these already exist in the kernel build dir.
  196 # '@' is a link to the system source.
  197 .if defined(BUILDING_WITH_KERNEL)
  198 _ILINKS=@
  199 .else
  200 _ILINKS=@ machine_base machine cpu_base cpu
  201 .endif
  202 
  203 .if defined(ARCH)
  204 _ILINKS+=${ARCH}
  205 .endif
  206 
  207 all: objwarn fwheaders ${PROG}
  208 
  209 beforedepend: fwheaders
  210 fwheaders: ${_ILINKS} ${FORWARD_HEADERS_COOKIE}
  211 # Ensure that the links exist without depending on it when it exists which
  212 # causes all the modules to be rebuilt when the directory pointed to changes.
  213 .for _link in ${_ILINKS}
  214 .if !exists(${.OBJDIR}/${_link})
  215 ${OBJS}: ${_link}
  216 .endif
  217 .endfor
  218 
  219 # Search for kernel source tree in standard places.
  220 .for _dir in ${.CURDIR}/../.. ${.CURDIR}/../../.. ${.CURDIR}/../../../.. /sys /usr/src/sys
  221 .if !defined(SYSDIR) && exists(${_dir}/kern/)
  222 SYSDIR= ${_dir}
  223 .endif
  224 .endfor
  225 .if !defined(SYSDIR) || !exists(${SYSDIR}/kern)
  226 .error "can't find kernel source tree"
  227 .endif
  228 S=      ${SYSDIR}
  229 
  230 #       path=`(cd $$path && /bin/pwd)` ; 
  231 
  232 ${_ILINKS}:
  233         @case ${.TARGET} in \
  234         machine) \
  235                 path=${SYSDIR}/platform/${MACHINE_PLATFORM}/include ;; \
  236         machine_base) \
  237                 path=${SYSDIR}/platform/${MACHINE_PLATFORM} ;; \
  238         cpu) \
  239                 path=${SYSDIR}/cpu/${MACHINE_ARCH}/include ;; \
  240         cpu_base) \
  241                 path=${SYSDIR}/cpu/${MACHINE_ARCH} ;; \
  242         @) \
  243                 path=${SYSDIR} ;; \
  244         arch_*) \
  245                 path=${.CURDIR}/${MACHINE_ARCH} ;; \
  246         esac ; \
  247         ${ECHO} ${.TARGET} "->" $$path ; \
  248         ${LN} -s $$path ${.TARGET}
  249 
  250 CLEANFILES+= ${PROG} ${KMOD}.kld ${OBJS} ${_ILINKS} symb.tmp tmp.o
  251 
  252 .if !target(install)
  253 
  254 _INSTALLFLAGS:= ${INSTALLFLAGS}
  255 .for ie in ${INSTALLFLAGS_EDIT}
  256 _INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
  257 .endfor
  258 
  259 .if !target(realinstall)
  260 realinstall: _kmodinstall
  261 .ORDER: beforeinstall _kmodinstall
  262 _kmodinstall:
  263 .if defined(INSTALLSTRIPPEDMODULES)
  264         ${INSTALL} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
  265             ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${KMODDIR}
  266         ${OBJCOPY} --strip-debug ${DESTDIR}${KMODDIR}/${PROG}
  267 .else
  268         ${INSTALL} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
  269             ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${KMODDIR}
  270 .endif
  271 .endif # !target(realinstall)
  272 
  273 .include <bsd.links.mk>
  274 
  275 .endif # !target(install)
  276 
  277 .if !target(load)
  278 load:   ${PROG}
  279         ${KMODLOAD} -v ./${KMOD}.ko
  280 .endif
  281 
  282 .if !target(unload)
  283 unload:
  284         ${KMODUNLOAD} -v ${KMOD}
  285 .endif
  286 
  287 .for _src in ${SRCS:Mopt_*.h} ${SRCS:Muse_*.h}
  288 CLEANFILES+=    ${_src}
  289 .if !target(${_src})
  290 .if defined(BUILDING_WITH_KERNEL) && exists(${BUILDING_WITH_KERNEL}/${_src})
  291 ${_src}: ${BUILDING_WITH_KERNEL}/${_src}
  292 # we do not have to copy these files any more, the kernel build
  293 # directory is included in the path now.
  294 #       cp ${BUILDING_WITH_KERNEL}/${_src} ${.TARGET}
  295 .else
  296 ${_src}:
  297         touch ${.TARGET}
  298 .endif  # BUILDING_WITH_KERNEL
  299 .endif
  300 .endfor
  301 
  302 MFILES?= kern/bus_if.m kern/device_if.m bus/iicbus/iicbb_if.m \
  303     bus/iicbus/iicbus_if.m bus/isa/isa_if.m dev/netif/mii_layer/miibus_if.m \
  304     bus/pccard/card_if.m bus/pccard/power_if.m bus/pci/pci_if.m \
  305     bus/pci/pcib_if.m \
  306     bus/ppbus/ppbus_if.m bus/smbus/smbus_if.m \
  307     dev/acpica/acpi_if.m dev/acpica/acpi_wmi_if.m dev/disk/nata/ata_if.m \
  308     dev/sound/pcm/ac97_if.m dev/sound/pcm/channel_if.m \
  309     dev/sound/pcm/feeder_if.m dev/sound/pcm/mixer_if.m \
  310     libiconv/iconv_converter_if.m dev/agp/agp_if.m opencrypto/cryptodev_if.m \
  311     bus/mmc/mmcbus_if.m bus/mmc/mmcbr_if.m \
  312     dev/virtual/virtio/virtio/virtio_bus_if.m \
  313     dev/virtual/virtio/virtio/virtio_if.m
  314 
  315 .if defined(WANT_USB4BSD)
  316 MFILES+=bus/u4b/usb_if.m
  317 .else
  318 MFILES+=bus/usb/usb_if.m
  319 .endif
  320 
  321 .for _srcsrc in ${MFILES}
  322 .for _ext in c h
  323 .for _src in ${SRCS:M${_srcsrc:T:R}.${_ext}}
  324 CLEANFILES+=    ${_src}
  325 .if !target(${_src})
  326 ${_src}: @
  327 .if exists(@)
  328 ${_src}: @/tools/makeobjops.awk @/${_srcsrc}
  329 .endif
  330 
  331 .if defined(BUILDING_WITH_KERNEL) && \
  332     exists(${BUILDING_WITH_KERNEL}/${_src})
  333 .else
  334         awk -f @/tools/makeobjops.awk -- -${_ext} @/${_srcsrc}
  335 .endif
  336 .endif
  337 .endfor # _src
  338 .endfor # _ext
  339 .endfor # _srcsrc
  340 
  341 #.for _ext in c h
  342 #.if ${SRCS:Mvnode_if.${_ext}} != ""
  343 #CLEANFILES+=   vnode_if.${_ext}
  344 #vnode_if.${_ext}: @
  345 #.if exists(@)
  346 #vnode_if.${_ext}: @/tools/vnode_if.awk @/kern/vnode_if.src
  347 #.endif
  348 #       awk -f @/tools/vnode_if.awk -- -${_ext} @/kern/vnode_if.src
  349 #.endif
  350 #.endfor
  351 
  352 .if !empty(SRCS:Mmiidevs.h)
  353 CLEANFILES+=    miidevs.h
  354 .if !exists(@)
  355 miidevs.h: @
  356 .else
  357 miidevs.h: @/tools/miidevs2h.awk @/dev/netif/mii_layer/miidevs
  358 .endif
  359         ${AWK} -f @/tools/miidevs2h.awk @/dev/netif/mii_layer/miidevs
  360 .endif
  361 
  362 .if !empty(SRCS:Mpccarddevs.h)
  363 CLEANFILES+=    pccarddevs.h
  364 .if !exists(@)
  365 pccarddevs.h: @
  366 .else
  367 pccarddevs.h: @/tools/pccarddevs2h.awk @/bus/pccard/pccarddevs
  368 .endif
  369         ${AWK} -f @/tools/pccarddevs2h.awk @/bus/pccard/pccarddevs
  370 .endif
  371 
  372 .if !empty(SRCS:Mpcidevs.h)
  373 CLEANFILES+=    pcidevs.h
  374 .if !exists(@)
  375 pcidevs.h: @
  376 .else
  377 pcidevs.h: @/tools/pcidevs2h.awk @/bus/pci/pcidevs
  378 .endif
  379         ${AWK} -f @/tools/pcidevs2h.awk @/bus/pci/pcidevs
  380 .endif
  381 
  382 .if !empty(SRCS:Musbdevs.h)
  383 CLEANFILES+=    usbdevs.h
  384 .if !exists(@)
  385 usbdevs.h: @
  386 .else
  387 usbdevs.h: @/tools/usbdevs2h.awk @/bus/u4b/usbdevs
  388 .endif
  389         ${AWK} -f @/tools/usbdevs2h.awk @/bus/u4b/usbdevs -h
  390 .endif
  391 
  392 .if !empty(SRCS:Musbdevs_data.h)
  393 CLEANFILES+=    usbdevs_data.h
  394 .if !exists(@)
  395 usbdevs_data.h: @
  396 .else
  397 usbdevs_data.h: @/tools/usbdevs2h.awk @/bus/u4b/usbdevs
  398 .endif
  399         ${AWK} -f @/tools/usbdevs2h.awk @/bus/u4b/usbdevs -d
  400 .endif
  401 
  402 .if !empty(SRCS:Massym.s)
  403 CLEANFILES+=    assym.s genassym.o
  404 assym.s: genassym.o
  405 .if defined(BUILDING_WITH_KERNEL)
  406 genassym.o: opt_global.h
  407 .endif
  408 .if !exists(@)
  409 assym.s: @
  410 .else
  411 assym.s: @/kern/genassym.sh
  412 .endif
  413         sh @/kern/genassym.sh genassym.o > ${.TARGET}
  414 .if exists(@)
  415 genassym.o: @/platform/${MACHINE_PLATFORM}/${MACHINE_ARCH}/genassym.c          
  416 .endif
  417 genassym.o: @ ${SRCS:Mopt_*.h}
  418         ${CC} -c ${CFLAGS:N-fno-common:N-mcmodel=small} ${WERROR} \
  419         @/platform/${MACHINE_PLATFORM}/${MACHINE_ARCH}/genassym.c
  420 .endif
  421 
  422 regress:
  423 
  424 .include <bsd.dep.mk>
  425 
  426 .if !exists(${DEPENDFILE})
  427 ${OBJS}: ${SRCS:M*.h}
  428 .endif
  429 
  430 .include <bsd.obj.mk>
  431 .include "bsd.kern.mk"
  432 
  433 # Behaves like MODULE_OVERRIDE
  434 .if defined(KLD_DEPS)
  435 all: _kdeps_all
  436 _kdeps_all: @
  437 .for _mdep in ${KLD_DEPS}
  438         cd ${SYSDIR}/${_mdep} && make all
  439 .endfor
  440 depend: _kdeps_depend
  441 _kdeps_depend: @
  442 .for _mdep in ${KLD_DEPS}
  443         cd ${SYSDIR}/${_mdep} && make depend
  444 .endfor
  445 install: _kdeps_install
  446 _kdeps_install: @
  447 .for _mdep in ${KLD_DEPS}
  448         cd ${SYSDIR}/${_mdep} && make install
  449 .endfor
  450 clean: _kdeps_clean
  451 _kdeps_clean: @
  452 .for _mdep in ${KLD_DEPS}
  453         cd ${SYSDIR}/${_mdep} && make clean
  454 .endfor
  455 .endif

Cache object: 091de99a2cd9ad5fee4fd5c88eca4ad8


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