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$
    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)). [/modules]
   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 # NOMAN         KLD does not have a manual page if set.
   27 #
   28 # PROG          The name of the kernel module to build.
   29 #               If not supplied, ${KMOD}.o is used.
   30 #
   31 # SRCS          List of source files
   32 #
   33 # KMODDEPS      List of modules which this one is dependant on
   34 #
   35 # DESTDIR       Change the tree where the module gets installed. [not set]
   36 #
   37 # MFILES        Optionally a list of interfaces used by the module.
   38 #               This file contains a default list of interfaces.
   39 #
   40 # +++ targets +++
   41 #
   42 #       install:
   43 #               install the kernel module and its manual pages; if the Makefile
   44 #               does not itself define the target install, the targets
   45 #               beforeinstall and afterinstall may also be used to cause
   46 #               actions immediately before and after the install target
   47 #               is executed.
   48 #
   49 #       load:
   50 #               Load KLD.
   51 #
   52 #       unload:
   53 #               Unload KLD.
   54 #
   55 # bsd.obj.mk: clean, cleandir and obj
   56 # bsd.dep.mk: cleandepend, depend and tags
   57 # bsd.man.mk: maninstall
   58 #
   59 
   60 KMODLOAD?=      /sbin/kldload
   61 KMODUNLOAD?=    /sbin/kldunload
   62 
   63 .include <bsd.init.mk>
   64 
   65 .SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S
   66 
   67 CFLAGS+=        ${COPTS} -D_KERNEL ${CWARNFLAGS}
   68 CFLAGS+=        -DKLD_MODULE
   69 
   70 # Don't use any standard or source-relative include directories.
   71 # Since -nostdinc will annull any previous -I paths, we repeat all
   72 # such paths after -nostdinc.  It doesn't seem to be possible to
   73 # add to the front of `make' variable.
   74 _ICFLAGS:=      ${CFLAGS:M-I*}
   75 CFLAGS+=        -nostdinc -I- ${_ICFLAGS}
   76 
   77 # Add -I paths for system headers.  Individual KLD makefiles don't
   78 # need any -I paths for this.  Similar defaults for .PATH can't be
   79 # set because there are no standard paths for non-headers.
   80 CFLAGS+=        -I. -I@
   81 
   82 # Add a -I path to standard headers like <stddef.h>.  Use a relative
   83 # path to src/include if possible.  If the @ symlink hasn't been built
   84 # yet, then we can't tell if the relative path exists.  Add both the
   85 # potential relative path and an absolute path in that case.
   86 .if exists(@)
   87 .if exists(@/../include)
   88 CFLAGS+=        -I@/../include
   89 .else
   90 CFLAGS+=        -I${DESTDIR}/usr/include
   91 .endif
   92 .else # !@
   93 CFLAGS+=        -I@/../include -I${DESTDIR}/usr/include
   94 .endif # @
   95 
   96 CFLAGS+=        ${DEBUG_FLAGS}
   97 
   98 .if ${OBJFORMAT} == elf
   99 CLEANFILES+=    setdef0.c setdef1.c setdefs.h
  100 CLEANFILES+=    setdef0.o setdef1.o
  101 .endif
  102 
  103 OBJS+=  ${SRCS:N*.h:R:S/$/.o/g}
  104 
  105 .if !defined(PROG)
  106 PROG=   ${KMOD}.ko
  107 .endif
  108 
  109 ${PROG}: ${KMOD}.kld ${KMODDEPS}
  110 .if ${OBJFORMAT} == elf
  111         gensetdefs ${KMOD}.kld
  112         ${CC} ${CFLAGS} -c setdef0.c
  113         ${CC} ${CFLAGS} -c setdef1.c
  114         ${LD} -Bshareable ${LDFLAGS} -o ${.TARGET} setdef0.o ${KMOD}.kld setdef1.o ${KMODDEPS}
  115 .else
  116         ${LD} -Bshareable ${LDFLAGS} -o ${.TARGET} ${KMOD}.kld ${KMODDEPS}
  117 .endif
  118 
  119 .if defined(KMODDEPS)
  120 .for dep in ${KMODDEPS}
  121 CLEANFILES+=    ${dep} __${dep}_hack_dep.c
  122 
  123 ${dep}:
  124         touch __${dep}_hack_dep.c
  125         ${CC} -shared ${CFLAGS} -o ${dep} __${dep}_hack_dep.c
  126 .endfor
  127 .endif
  128 
  129 ${KMOD}.kld: ${OBJS}
  130         ${LD} ${LDFLAGS} -r -o ${.TARGET} ${OBJS}
  131 
  132 .if !defined(NOMAN)
  133 .include <bsd.man.mk>
  134 .endif
  135 
  136 _ILINKS=@ machine
  137 
  138 all: objwarn ${PROG}
  139 .if !defined(NOMAN)
  140 all: _manpages
  141 .endif
  142 
  143 beforedepend: ${_ILINKS}
  144 # Ensure that the links exist without depending on it when it exists which
  145 # causes all the modules to be rebuilt when the directory pointed to changes.
  146 .for _link in ${_ILINKS}
  147 .if !exists(${.OBJDIR}/${_link})
  148 ${OBJS}: ${_link}
  149 .endif
  150 .endfor
  151 
  152 # Search for kernel source tree in standard places.
  153 .for _dir in ${.CURDIR}/../.. ${.CURDIR}/../../.. /sys /usr/src/sys
  154 .if !defined(SYSDIR) && exists(${_dir}/kern/)
  155 SYSDIR= ${_dir}
  156 .endif
  157 .endfor
  158 .if !defined(SYSDIR) || !exists(${SYSDIR}/kern)
  159 .error "can't find kernel source tree"
  160 .endif
  161 
  162 ${_ILINKS}:
  163         @case ${.TARGET} in \
  164         machine) \
  165                 path=${SYSDIR}/${MACHINE_ARCH}/include ;; \
  166         @) \
  167                 path=${SYSDIR} ;; \
  168         esac ; \
  169         path=`(cd $$path && /bin/pwd)` ; \
  170         ${ECHO} ${.TARGET} "->" $$path ; \
  171         ln -s $$path ${.TARGET}
  172 
  173 CLEANFILES+= ${PROG} ${KMOD}.kld ${OBJS} ${_ILINKS} symb.tmp tmp.o
  174 
  175 .if !target(install)
  176 
  177 _INSTALLFLAGS:= ${INSTALLFLAGS}
  178 .for ie in ${INSTALLFLAGS_EDIT}
  179 _INSTALLFLAGS:= ${_INSTALLFLAGS${ie}}
  180 .endfor
  181 
  182 .if !target(realinstall)
  183 realinstall: _kmodinstall
  184 .ORDER: beforeinstall _kmodinstall
  185 _kmodinstall:
  186         ${INSTALL} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
  187             ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${KMODDIR}
  188 .endif !target(realinstall)
  189 
  190 .include <bsd.links.mk>
  191 
  192 .if !defined(NOMAN)
  193 realinstall: _maninstall
  194 .ORDER: beforeinstall _maninstall
  195 .endif
  196 
  197 .endif !target(install)
  198 
  199 .if !target(load)
  200 load:   ${PROG}
  201         ${KMODLOAD} -v ./${KMOD}.ko
  202 .endif
  203 
  204 .if !target(unload)
  205 unload:
  206         ${KMODUNLOAD} -v ${KMOD}
  207 .endif
  208 
  209 .for _src in ${SRCS:Mopt_*.h}
  210 CLEANFILES+=    ${_src}
  211 .if !target(${_src})
  212 ${_src}:
  213         touch ${.TARGET}
  214 .endif
  215 .endfor
  216 
  217 MFILES?= kern/bus_if.m kern/device_if.m dev/iicbus/iicbb_if.m \
  218     dev/iicbus/iicbus_if.m isa/isa_if.m dev/mii/miibus_if.m \
  219     dev/pccard/card_if.m dev/pccard/power_if.m pci/pci_if.m \
  220     dev/ppbus/ppbus_if.m dev/smbus/smbus_if.m dev/usb/usb_if.m \
  221     dev/sound/pcm/ac97_if.m dev/sound/pcm/channel_if.m \
  222     dev/sound/pcm/feeder_if.m dev/sound/pcm/mixer_if.m \
  223     libkern/iconv_converter_if.m pci/agp_if.m opencrypto/crypto_if.m \
  224     pc98/pc98/canbus_if.m
  225 
  226 .for _srcsrc in ${MFILES}
  227 .for _ext in c h
  228 .for _src in ${SRCS:M${_srcsrc:T:R}.${_ext}}
  229 CLEANFILES+=    ${_src}
  230 .if !target(${_src})
  231 ${_src}: @
  232 .if exists(@)
  233 ${_src}: @/kern/makeops.pl @/${_srcsrc}
  234 .endif
  235         perl @/kern/makeops.pl -${_ext} @/${_srcsrc}
  236 .endif
  237 .endfor # _src
  238 .endfor # _ext
  239 .endfor # _srcsrc
  240 
  241 .for _ext in c h
  242 .if ${SRCS:Mvnode_if.${_ext}} != ""
  243 CLEANFILES+=    vnode_if.${_ext}
  244 vnode_if.${_ext}: @
  245 .if exists(@)
  246 vnode_if.${_ext}: @/kern/vnode_if.pl @/kern/vnode_if.src
  247 .endif
  248         perl @/kern/vnode_if.pl -${_ext} @/kern/vnode_if.src
  249 .endif
  250 .endfor
  251 
  252 regress:
  253 
  254 .include <bsd.dep.mk>
  255 
  256 .if !exists(${DEPENDFILE})
  257 ${OBJS}: ${SRCS:M*.h}
  258 .endif
  259 
  260 .include <bsd.obj.mk>
  261 .include <bsd.kern.mk>

Cache object: 73c796c752c44cdfc1459e035ffebb5d


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