[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ]

FreeBSD/Linux Kernel Cross Reference
sys/conf/kmod.mk

Version: -  FREEBSD  -  FREEBSD7  -  FREEBSD70  -  FREEBSD6  -  FREEBSD63  -  FREEBSD62  -  FREEBSD61  -  FREEBSD60  -  FREEBSD5  -  FREEBSD55  -  FREEBSD54  -  FREEBSD53  -  FREEBSD52  -  FREEBSD51  -  FREEBSD50  -  FREEBSD4  -  FREEBSD3  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  OPENSOLARIS  -  minix-3-1-1  -  TRUSTEDBSD-SEBSD  -  FREEBSD-LIBC  -  FREEBSD7-LIBC  -  FREEBSD6-LIBC  -  GLIBC27 
SearchContext: -  none  -  excerpts  -  bigexcerpts 

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

[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.