xref: /freebsd/sys/conf/kmod.mk (revision 8b3ae668b13db776ced151f20e9ad3d23eca545d)
1639a2e50SGarrett Wollman#	From: @(#)bsd.prog.mk	5.26 (Berkeley) 6/25/91
27f3dea24SPeter Wemm# $FreeBSD$
353996fadSWolfram Schneider#
41f089616SRuslan Ermilov# The include file <bsd.kmod.mk> handles building and installing loadable
51f089616SRuslan Ermilov# kernel modules.
653996fadSWolfram Schneider#
753996fadSWolfram Schneider#
853996fadSWolfram Schneider# +++ variables +++
953996fadSWolfram Schneider#
1053996fadSWolfram Schneider# CLEANFILES	Additional files to remove for the clean and cleandir targets.
1153996fadSWolfram Schneider#
121f089616SRuslan Ermilov# EXPORT_SYMS	A list of symbols that should be exported from the module,
131f089616SRuslan Ermilov#		or the name of a file containing a list of symbols, or YES
141f089616SRuslan Ermilov#		to export all symbols.  If not defined, no symbols are
151f089616SRuslan Ermilov#		exported.
161f089616SRuslan Ermilov#
17fe3cac87SNick Hibma# KMOD		The name of the kernel module to build.
1853996fadSWolfram Schneider#
193bdfa9e5SDavid E. O'Brien# KMODDIR	Base path for kernel modules (see kld(4)). [/boot/kernel]
2053996fadSWolfram Schneider#
211f089616SRuslan Ermilov# KMODOWN	Module file owner. [${BINOWN}]
2253996fadSWolfram Schneider#
231f089616SRuslan Ermilov# KMODGRP	Module file group. [${BINGRP}]
2453996fadSWolfram Schneider#
251f089616SRuslan Ermilov# KMODMODE	Module file mode. [${BINMODE}]
2653996fadSWolfram Schneider#
27fe3cac87SNick Hibma# KMODLOAD	Command to load a kernel module [/sbin/kldload]
287bc830bbSWolfram Schneider#
29fe3cac87SNick Hibma# KMODUNLOAD	Command to unload a kernel module [/sbin/kldunload]
307bc830bbSWolfram Schneider#
317fecffecSDoug Rabson# MFILES	Optionally a list of interfaces used by the module.
327fecffecSDoug Rabson#		This file contains a default list of interfaces.
3353996fadSWolfram Schneider#
341f089616SRuslan Ermilov# PROG		The name of the kernel module to build.
351f089616SRuslan Ermilov#		If not supplied, ${KMOD}.ko is used.
361f089616SRuslan Ermilov#
371f089616SRuslan Ermilov# SRCS		List of source files.
381f089616SRuslan Ermilov#
396aec1278SMax Laier# FIRMWS	List of firmware images in format filename:shortname:version
406aec1278SMax Laier#
411f089616SRuslan Ermilov# DESTDIR	The tree where the module gets installed. [not set]
420b3178a4SMike Smith#
4353996fadSWolfram Schneider# +++ targets +++
4453996fadSWolfram Schneider#
4553996fadSWolfram Schneider# 	install:
4617d6c636SRuslan Ermilov#               install the kernel module; if the Makefile
4753996fadSWolfram Schneider#               does not itself define the target install, the targets
4853996fadSWolfram Schneider#               beforeinstall and afterinstall may also be used to cause
4953996fadSWolfram Schneider#               actions immediately before and after the install target
5053996fadSWolfram Schneider#		is executed.
5153996fadSWolfram Schneider#
5253996fadSWolfram Schneider# 	load:
531f089616SRuslan Ermilov#		Load a module.
5453996fadSWolfram Schneider#
5553996fadSWolfram Schneider# 	unload:
561f089616SRuslan Ermilov#		Unload a module.
5753996fadSWolfram Schneider#
58639a2e50SGarrett Wollman
59b7bbb709SDavid E. O'BrienAWK?=		awk
60fe3cac87SNick HibmaKMODLOAD?=	/sbin/kldload
61fe3cac87SNick HibmaKMODUNLOAD?=	/sbin/kldunload
62f6611608SSheldon HearnOBJCOPY?=	objcopy
637bc830bbSWolfram Schneider
6406639be7SPeter Wemm.if defined(KMODDEPS)
651f089616SRuslan Ermilov.error "Do not use KMODDEPS on 5.0+; use MODULE_VERSION/MODULE_DEPEND"
6606639be7SPeter Wemm.endif
6706639be7SPeter Wemm
680ac2fc87SRuslan Ermilov.include <bsd.init.mk>
69639a2e50SGarrett Wollman
70639a2e50SGarrett Wollman.SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S
71639a2e50SGarrett Wollman
7206d6e4fcSTom Rhodes.if ${CC} == "icc"
735a19f6d9STom RhodesCFLAGS:=	${CFLAGS:C/(-x[^M^K^W]+)[MKW]+|-x[MKW]+/\1/}
74daaea395SWarner Losh.else
75f165cb7cSRuslan Ermilov. if !empty(CFLAGS:M-O[23s]) && empty(CFLAGS:M-fno-strict-aliasing)
76db0cd7e1SDavid E. O'BrienCFLAGS+=	-fno-strict-aliasing
77db0cd7e1SDavid E. O'Brien. endif
78daaea395SWarner LoshWERROR?=	-Werror
7906d6e4fcSTom Rhodes.endif
80daaea395SWarner LoshCFLAGS+=	${WERROR}
8148aea4daSRuslan ErmilovCFLAGS+=	-D_KERNEL
828fe644b2SMike SmithCFLAGS+=	-DKLD_MODULE
834a2d2630SBruce Evans
84021886ffSBruce Evans# Don't use any standard or source-relative include directories.
8506d6e4fcSTom Rhodes.if ${CC} == "icc"
8606d6e4fcSTom RhodesNOSTDINC=	-X
8706d6e4fcSTom Rhodes.else
88732be1f2SJung-uk KimC_DIALECT=	-std=c99
8906d6e4fcSTom RhodesNOSTDINC=	-nostdinc
9006d6e4fcSTom Rhodes.endif
91732be1f2SJung-uk KimCFLAGS+=	${C_DIALECT}
92e6cb7d6cSRuslan ErmilovCFLAGS:=	${CFLAGS:N-I*} ${NOSTDINC} -I- ${INCLMAGIC} ${CFLAGS:M-I*}
938fa793d0SBrian Feldman.if defined(KERNBUILDDIR)
940c063641SGleb SmirnoffCFLAGS+=	-DHAVE_KERNEL_OPTION_HEADERS -include ${KERNBUILDDIR}/opt_global.h
958fa793d0SBrian Feldman.endif
96021886ffSBruce Evans
971f089616SRuslan Ermilov# Add -I paths for system headers.  Individual module makefiles don't
98021886ffSBruce Evans# need any -I paths for this.  Similar defaults for .PATH can't be
99021886ffSBruce Evans# set because there are no standard paths for non-headers.
10074455e55SWarner LoshCFLAGS+=	-I. -I@
1014a2d2630SBruce Evans
10202b199f1SMax Laier# Add -I path for altq headers as they are included via net/if_var.h
10302b199f1SMax Laier# for example.
10402b199f1SMax LaierCFLAGS+=	-I@/contrib/altq
10502b199f1SMax Laier
10606d6e4fcSTom Rhodes.if ${CC} != "icc"
107a92a2144SPeter WemmCFLAGS+=	-finline-limit=${INLINE_LIMIT}
10885aa25caSWarner LoshCFLAGS+= --param inline-unit-growth=100
10985aa25caSWarner LoshCFLAGS+= --param large-function-growth=1000
11006d6e4fcSTom Rhodes.endif
1112a51529fSPeter Wemm
1120b3178a4SMike Smith# Disallow common variables, and if we end up with commons from
1130b3178a4SMike Smith# somewhere unexpected, allocate storage for them in the module itself.
11406d6e4fcSTom Rhodes.if ${CC} != "icc"
1150b3178a4SMike SmithCFLAGS+=	-fno-common
11606d6e4fcSTom Rhodes.endif
1170b3178a4SMike SmithLDFLAGS+=	-d -warn-common
1180b3178a4SMike Smith
1199e4be63dSBruce EvansCFLAGS+=	${DEBUG_FLAGS}
12083c457dcSIan Dowse.if ${MACHINE_ARCH} == amd64
12183c457dcSIan DowseCFLAGS+=	-fno-omit-frame-pointer
12283c457dcSIan Dowse.endif
1239e4be63dSBruce Evans
124fded756eSPeter Grehan.if ${MACHINE_ARCH} == "powerpc"
12555a5dcc8SPeter GrehanCFLAGS+=	-mlongcall -fno-omit-frame-pointer
126fded756eSPeter Grehan.endif
127fded756eSPeter Grehan
1286aec1278SMax Laier.if defined(FIRMWS)
1296aec1278SMax Laier.if !exists(@)
1306aec1278SMax Laier${KMOD:S/$/.c/}: @
1316aec1278SMax Laier.else
1326aec1278SMax Laier${KMOD:S/$/.c/}: @/tools/fw_stub.awk
1336aec1278SMax Laier.endif
1346aec1278SMax Laier	${AWK} -f @/tools/fw_stub.awk ${FIRMWS} -m${KMOD} -c${KMOD:S/$/.c/g}
1356aec1278SMax Laier
1366aec1278SMax LaierSRCS+=	${KMOD:S/$/.c/}
1376aec1278SMax LaierCLEANFILES+=	${KMOD:S/$/.c/}
1386aec1278SMax Laier
1396aec1278SMax Laier.for _firmw in ${FIRMWS}
1406aec1278SMax Laier${_firmw:C/\:.*$/.fwo/}:	${_firmw:C/\:.*$//}
1416aec1278SMax Laier	@${ECHO} ${_firmw:C/\:.*$//} ${.ALLSRC:M*${_firmw:C/\:.*$//}}
142009b3d3dSMax Laier	@if [ -e ${_firmw:C/\:.*$//} ]; then			\
143ff8e7669SMax Laier		${LD} -b binary ${LDFLAGS} -r -d -o ${.TARGET}	\
144ff8e7669SMax Laier		    ${_firmw:C/\:.*$//};			\
145ff8e7669SMax Laier	else							\
146ff8e7669SMax Laier		ln -s ${.ALLSRC:M*${_firmw:C/\:.*$//}} ${_firmw:C/\:.*$//}; \
147ff8e7669SMax Laier		${LD} -b binary ${LDFLAGS} -r -d -o ${.TARGET}	\
148ff8e7669SMax Laier		    ${_firmw:C/\:.*$//};			\
149ff8e7669SMax Laier		rm ${_firmw:C/\:.*$//};				\
150ff8e7669SMax Laier	fi
1516aec1278SMax Laier
1526aec1278SMax LaierOBJS+=	${_firmw:C/\:.*$/.fwo/}
1536aec1278SMax Laier.endfor
1546aec1278SMax Laier.endif
1556aec1278SMax Laier
156639a2e50SGarrett WollmanOBJS+=	${SRCS:N*.h:R:S/$/.o/g}
157639a2e50SGarrett Wollman
158639a2e50SGarrett Wollman.if !defined(PROG)
15990f60fc9SMike SmithPROG=	${KMOD}.ko
16090f60fc9SMike Smith.endif
161639a2e50SGarrett Wollman
162817b59bfSRuslan Ermilov.if !defined(DEBUG_FLAGS)
163f6611608SSheldon HearnFULLPROG=	${PROG}
164f6611608SSheldon Hearn.else
165f6611608SSheldon HearnFULLPROG=	${PROG}.debug
1661558abf6SRuslan Ermilov${PROG}: ${FULLPROG} ${PROG}.symbols
1671558abf6SRuslan Ermilov	${OBJCOPY} --strip-debug --add-gnu-debuglink=${PROG}.symbols\
16898b45a8fSRuslan Ermilov	    ${FULLPROG} ${.TARGET}
1691558abf6SRuslan Ermilov${PROG}.symbols: ${FULLPROG}
17098b45a8fSRuslan Ermilov	${OBJCOPY} --only-keep-debug ${FULLPROG} ${.TARGET}
171f6611608SSheldon Hearn.endif
172f6611608SSheldon Hearn
1734d6bcc83SPeter Wemm.if ${MACHINE_ARCH} != amd64
174f6611608SSheldon Hearn${FULLPROG}: ${KMOD}.kld
17509be11baSPeter Wemm	${LD} -Bshareable ${LDFLAGS} -o ${.TARGET} ${KMOD}.kld
176817b59bfSRuslan Ermilov.if !defined(DEBUG_FLAGS)
177817b59bfSRuslan Ermilov	${OBJCOPY} --strip-debug ${.TARGET}
1784c293d35SRuslan Ermilov.endif
1794d6bcc83SPeter Wemm.endif
18009be11baSPeter Wemm
18193f03548SMike SmithEXPORT_SYMS?=	NO
18293f03548SMike Smith.if ${EXPORT_SYMS} != YES
1831f089616SRuslan ErmilovCLEANFILES+=	export_syms
1840b3178a4SMike Smith.endif
1850b3178a4SMike Smith
1864d6bcc83SPeter Wemm.if ${MACHINE_ARCH} != amd64
18709be11baSPeter Wemm${KMOD}.kld: ${OBJS}
1884d6bcc83SPeter Wemm.else
1894d6bcc83SPeter Wemm${FULLPROG}: ${OBJS}
1904d6bcc83SPeter Wemm.endif
1910b3178a4SMike Smith	${LD} ${LDFLAGS} -r -d -o ${.TARGET} ${OBJS}
1920b3178a4SMike Smith.if defined(EXPORT_SYMS)
19393f03548SMike Smith.if ${EXPORT_SYMS} != YES
1940b3178a4SMike Smith.if ${EXPORT_SYMS} == NO
1958b3ae668SDag-Erling Smørgrav	:> export_syms
1960b3178a4SMike Smith.elif !exists(${.CURDIR}/${EXPORT_SYMS})
1971f089616SRuslan Ermilov	echo ${EXPORT_SYMS} > export_syms
1980b3178a4SMike Smith.else
1991f089616SRuslan Ermilov	grep -v '^#' < ${EXPORT_SYMS} > export_syms
2000b3178a4SMike Smith.endif
2010b3178a4SMike Smith	awk -f ${SYSDIR}/conf/kmod_syms.awk ${.TARGET} \
2021f089616SRuslan Ermilov	    export_syms | xargs -J% ${OBJCOPY} % ${.TARGET}
20393f03548SMike Smith.endif
2040b3178a4SMike Smith.endif
2054d6bcc83SPeter Wemm.if !defined(DEBUG_FLAGS) && ${MACHINE_ARCH} == amd64
2064d6bcc83SPeter Wemm	${OBJCOPY} --strip-debug ${.TARGET}
2074d6bcc83SPeter Wemm.endif
2080b3178a4SMike Smith
2094a2d2630SBruce Evans_ILINKS=@ machine
210df3a103dSWarner Losh.if ${MACHINE} != ${MACHINE_ARCH}
211df3a103dSWarner Losh_ILINKS+=${MACHINE_ARCH}
212df3a103dSWarner Losh.endif
213639a2e50SGarrett Wollman
214b25a566dSRuslan Ermilovall: objwarn ${PROG}
2154a2d2630SBruce Evans
216db00e6c5SDavid E. O'Brienbeforedepend: ${_ILINKS}
217985f41afSWarner Losh
218f3cc9575SWarner Losh# Ensure that the links exist without depending on it when it exists which
219f3cc9575SWarner Losh# causes all the modules to be rebuilt when the directory pointed to changes.
220f3cc9575SWarner Losh.for _link in ${_ILINKS}
221f3cc9575SWarner Losh.if !exists(${.OBJDIR}/${_link})
222f3cc9575SWarner Losh${OBJS}: ${_link}
223f3cc9575SWarner Losh.endif
224f3cc9575SWarner Losh.endfor
2254a2d2630SBruce Evans
2269a8631b3SWarner Losh# Search for kernel source tree in standard places.
2279a8631b3SWarner Losh.for _dir in ${.CURDIR}/../.. ${.CURDIR}/../../.. /sys /usr/src/sys
228776f50b9SRuslan Ermilov.if !defined(SYSDIR) && exists(${_dir}/kern/)
2299a8631b3SWarner LoshSYSDIR=	${_dir}
2309a8631b3SWarner Losh.endif
2319a8631b3SWarner Losh.endfor
232776f50b9SRuslan Ermilov.if !defined(SYSDIR) || !exists(${SYSDIR}/kern/)
2339a8631b3SWarner Losh.error "can't find kernel source tree"
2349a8631b3SWarner Losh.endif
2359a8631b3SWarner Losh
2364a2d2630SBruce Evans${_ILINKS}:
2379a8631b3SWarner Losh	@case ${.TARGET} in \
238df3a103dSWarner Losh	${MACHINE_ARCH}) \
2399a8631b3SWarner Losh		path=${SYSDIR}/${MACHINE_ARCH}/include ;; \
240df3a103dSWarner Losh	machine) \
241df3a103dSWarner Losh		path=${SYSDIR}/${MACHINE}/include ;; \
24208a04a89SPeter Wemm	@) \
2439a8631b3SWarner Losh		path=${SYSDIR} ;; \
24408a04a89SPeter Wemm	esac ; \
24508a04a89SPeter Wemm	path=`(cd $$path && /bin/pwd)` ; \
24608a04a89SPeter Wemm	${ECHO} ${.TARGET} "->" $$path ; \
24740244cc2SDavid E. O'Brien	ln -sf $$path ${.TARGET}
2484a2d2630SBruce Evans
2491f089616SRuslan ErmilovCLEANFILES+= ${PROG} ${KMOD}.kld ${OBJS} ${_ILINKS}
250361186e5SMaxime Henrion
251817b59bfSRuslan Ermilov.if defined(DEBUG_FLAGS)
2521558abf6SRuslan ErmilovCLEANFILES+= ${FULLPROG} ${PROG}.symbols
253361186e5SMaxime Henrion.endif
254639a2e50SGarrett Wollman
255639a2e50SGarrett Wollman.if !target(install)
256639a2e50SGarrett Wollman
257ea87b3cbSDavid E. O'Brien_INSTALLFLAGS:=	${INSTALLFLAGS}
258e902c1bbSTim Vanderhoek.for ie in ${INSTALLFLAGS_EDIT}
259e902c1bbSTim Vanderhoek_INSTALLFLAGS:=	${_INSTALLFLAGS${ie}}
260e902c1bbSTim Vanderhoek.endfor
261e902c1bbSTim Vanderhoek
2622b06260dSRuslan Ermilov.if !target(realinstall)
2632b06260dSRuslan Ermilovrealinstall: _kmodinstall
2642b06260dSRuslan Ermilov.ORDER: beforeinstall _kmodinstall
2652b06260dSRuslan Ermilov_kmodinstall:
266d2893b16SRuslan Ermilov	${INSTALL} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
2672b06260dSRuslan Ermilov	    ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${KMODDIR}
26898b45a8fSRuslan Ermilov.if defined(DEBUG_FLAGS) && !defined(INSTALL_NODEBUG)
26998b45a8fSRuslan Ermilov	${INSTALL} -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
2701558abf6SRuslan Ermilov	    ${_INSTALLFLAGS} ${PROG}.symbols ${DESTDIR}${KMODDIR}
271d24864f7SRuslan Ermilov.endif
2722b06260dSRuslan Ermilov
2732b06260dSRuslan Ermilov.include <bsd.links.mk>
2742b06260dSRuslan Ermilov
2754875819cSJake Burkholder.if !defined(NO_XREF)
2762b06260dSRuslan Ermilovafterinstall: _kldxref
2772b06260dSRuslan Ermilov.ORDER: realinstall _kldxref
2782b06260dSRuslan Ermilov.ORDER: _installlinks _kldxref
2792b06260dSRuslan Ermilov_kldxref:
280be1d673dSRuslan Ermilov	@if type kldxref >/dev/null 2>&1; then \
281be1d673dSRuslan Ermilov		${ECHO} kldxref ${DESTDIR}${KMODDIR}; \
282be1d673dSRuslan Ermilov		kldxref ${DESTDIR}${KMODDIR}; \
283be1d673dSRuslan Ermilov	fi
284505222d3SPeter Wemm.endif
28522a8b405SMaxime Henrion.endif # !target(realinstall)
286639a2e50SGarrett Wollman
28722a8b405SMaxime Henrion.endif # !target(install)
288639a2e50SGarrett Wollman
289639a2e50SGarrett Wollman.if !target(load)
2909a8631b3SWarner Loshload: ${PROG}
2911f089616SRuslan Ermilov	${KMODLOAD} -v ${.OBJDIR}/${PROG}
292639a2e50SGarrett Wollman.endif
293639a2e50SGarrett Wollman
294639a2e50SGarrett Wollman.if !target(unload)
295fe3cac87SNick Hibmaunload:
2961f089616SRuslan Ermilov	${KMODUNLOAD} -v ${PROG}
29708a04a89SPeter Wemm.endif
2981aa57be3SGarrett Wollman
2996b1bb559SWarner Losh.if defined(KERNBUILDDIR)
3006b1bb559SWarner Losh.PATH: ${KERNBUILDDIR}
3016b1bb559SWarner LoshCFLAGS+=	-I${KERNBUILDDIR}
3026b1bb559SWarner Losh.for _src in ${SRCS:Mopt_*.h}
3036b1bb559SWarner LoshCLEANFILES+=	${_src}
3046b1bb559SWarner Losh.if !target(${_src})
3056b1bb559SWarner Losh${_src}:
30640244cc2SDavid E. O'Brien	ln -sf ${KERNBUILDDIR}/${_src} ${.TARGET}
3076b1bb559SWarner Losh.endif
3086b1bb559SWarner Losh.endfor
3096b1bb559SWarner Losh.else
3104fea6704SBruce Evans.for _src in ${SRCS:Mopt_*.h}
3114fea6704SBruce EvansCLEANFILES+=	${_src}
3124fea6704SBruce Evans.if !target(${_src})
3134fea6704SBruce Evans${_src}:
3148b3ae668SDag-Erling Smørgrav	:> ${.TARGET}
3154fea6704SBruce Evans.endif
3164fea6704SBruce Evans.endfor
3176b1bb559SWarner Losh.endif
3184fea6704SBruce Evans
3198ca4df32SSøren SchmidtMFILES?= dev/acpica/acpi_if.m dev/ata/ata_if.m dev/eisa/eisa_if.m \
3208ca4df32SSøren Schmidt	dev/iicbus/iicbb_if.m dev/iicbus/iicbus_if.m \
3218ca4df32SSøren Schmidt	dev/mii/miibus_if.m dev/ofw/ofw_bus_if.m \
3227e820aaaSMike Smith	dev/pccard/card_if.m dev/pccard/power_if.m dev/pci/pci_if.m \
3237e820aaaSMike Smith	dev/pci/pcib_if.m dev/ppbus/ppbus_if.m dev/smbus/smbus_if.m \
324268597acSMarcel Moolenaar	dev/sound/pcm/ac97_if.m dev/sound/pcm/channel_if.m \
3259465d7f1SMarcel Moolenaar	dev/sound/pcm/feeder_if.m dev/sound/pcm/mixer_if.m \
326206b17d7SAlexander Leidinger	dev/sound/midi/mpu_if.m dev/sound/midi/mpufoi_if.m \
327206b17d7SAlexander Leidinger	dev/sound/midi/synth_if.m dev/usb/usb_if.m isa/isa_if.m \
328206b17d7SAlexander Leidinger	kern/bus_if.m kern/cpufreq_if.m kern/device_if.m kern/serdev_if.m \
329268597acSMarcel Moolenaar	libkern/iconv_converter_if.m opencrypto/crypto_if.m \
33021a0216eSMarius Strobl	pc98/pc98/canbus_if.m pci/agp_if.m
3317fecffecSDoug Rabson
3327fecffecSDoug Rabson.for _srcsrc in ${MFILES}
3334fea6704SBruce Evans.for _ext in c h
3344fea6704SBruce Evans.for _src in ${SRCS:M${_srcsrc:T:R}.${_ext}}
3354fea6704SBruce EvansCLEANFILES+=	${_src}
3364fea6704SBruce Evans.if !target(${_src})
337f3cc9575SWarner Losh.if !exists(@)
3384fea6704SBruce Evans${_src}: @
3399f73f0e8SRuslan Ermilov.else
3409fa411aeSDavid E. O'Brien${_src}: @/tools/makeobjops.awk @/${_srcsrc}
3414fea6704SBruce Evans.endif
3429fa411aeSDavid E. O'Brien	${AWK} -f @/tools/makeobjops.awk @/${_srcsrc} -${_ext}
3434fea6704SBruce Evans.endif
3444fea6704SBruce Evans.endfor # _src
3454fea6704SBruce Evans.endfor # _ext
3464fea6704SBruce Evans.endfor # _srcsrc
3474fea6704SBruce Evans
348a7d30e5fSDavid E. O'Brien.if !empty(SRCS:Mvnode_if.c)
34978b2c868SBrian FeldmanCLEANFILES+=	vnode_if.c
350f3cc9575SWarner Losh.if !exists(@)
35178b2c868SBrian Feldmanvnode_if.c: @
3529f73f0e8SRuslan Ermilov.else
35378b2c868SBrian Feldmanvnode_if.c: @/tools/vnode_if.awk @/kern/vnode_if.src
3544fea6704SBruce Evans.endif
35578b2c868SBrian Feldman	${AWK} -f @/tools/vnode_if.awk @/kern/vnode_if.src -c
3564fea6704SBruce Evans.endif
35778b2c868SBrian Feldman
358a7d30e5fSDavid E. O'Brien.if !empty(SRCS:Mvnode_if.h)
3599f73f0e8SRuslan ErmilovCLEANFILES+=	vnode_if.h vnode_if_newproto.h vnode_if_typedef.h
36078b2c868SBrian Feldman.if !exists(@)
3619f73f0e8SRuslan Ermilovvnode_if.h vnode_if_newproto.h vnode_if_typedef.h: @
3629f73f0e8SRuslan Ermilov.else
3639f73f0e8SRuslan Ermilovvnode_if.h vnode_if_newproto.h vnode_if_typedef.h: @/tools/vnode_if.awk \
3649f73f0e8SRuslan Ermilov    @/kern/vnode_if.src
36578b2c868SBrian Feldman.endif
3669f73f0e8SRuslan Ermilovvnode_if.h: vnode_if_newproto.h vnode_if_typedef.h
36778b2c868SBrian Feldman	${AWK} -f @/tools/vnode_if.awk @/kern/vnode_if.src -h
3689f73f0e8SRuslan Ermilovvnode_if_newproto.h:
36978b2c868SBrian Feldman	${AWK} -f @/tools/vnode_if.awk @/kern/vnode_if.src -p
3709f73f0e8SRuslan Ermilovvnode_if_typedef.h:
37178b2c868SBrian Feldman	${AWK} -f @/tools/vnode_if.awk @/kern/vnode_if.src -q
37278b2c868SBrian Feldman.endif
3731aa57be3SGarrett Wollman
3744e91eaf2SWarner Losh.for _i in mii pccard
375a7d30e5fSDavid E. O'Brien.if !empty(SRCS:M${_i}devs.h)
376dba6dd17SWarner LoshCLEANFILES+=	${_i}devs.h
3772d3ce713SDavid E. O'Brien.if !exists(@)
378dba6dd17SWarner Losh${_i}devs.h: @
3799f73f0e8SRuslan Ermilov.else
380dba6dd17SWarner Losh${_i}devs.h: @/tools/${_i}devs2h.awk @/dev/${_i}/${_i}devs
3812d3ce713SDavid E. O'Brien.endif
382dba6dd17SWarner Losh	${AWK} -f @/tools/${_i}devs2h.awk @/dev/${_i}/${_i}devs
3832d3ce713SDavid E. O'Brien.endif
384dba6dd17SWarner Losh.endfor # _i
3852d3ce713SDavid E. O'Brien
386a7d30e5fSDavid E. O'Brien.if !empty(SRCS:Musbdevs.h)
3874e91eaf2SWarner LoshCLEANFILES+=	usbdevs.h
3884e91eaf2SWarner Losh.if !exists(@)
3894e91eaf2SWarner Loshusbdevs.h: @
3904e91eaf2SWarner Losh.else
3914e91eaf2SWarner Loshusbdevs.h: @/tools/usbdevs2h.awk @/dev/usb/usbdevs
3924e91eaf2SWarner Losh.endif
3934e91eaf2SWarner Losh	${AWK} -f @/tools/usbdevs2h.awk @/dev/usb/usbdevs -h
3944e91eaf2SWarner Losh.endif
3954e91eaf2SWarner Losh
396a7d30e5fSDavid E. O'Brien.if !empty(SRCS:Musbdevs_data.h)
3974e91eaf2SWarner LoshCLEANFILES+=	usbdevs_data.h
3984e91eaf2SWarner Losh.if !exists(@)
3994e91eaf2SWarner Loshusbdevs_data.h: @
4004e91eaf2SWarner Losh.else
4014e91eaf2SWarner Loshusbdevs_data.h: @/tools/usbdevs2h.awk @/dev/usb/usbdevs
4024e91eaf2SWarner Losh.endif
4034e91eaf2SWarner Losh	${AWK} -f @/tools/usbdevs2h.awk @/dev/usb/usbdevs -d
4044e91eaf2SWarner Losh.endif
4054e91eaf2SWarner Losh
406a7d30e5fSDavid E. O'Brien.if !empty(SRCS:Macpi_quirks.h)
407684c1c1dSNate LawsonCLEANFILES+=	acpi_quirks.h
408684c1c1dSNate Lawson.if !exists(@)
409684c1c1dSNate Lawsonacpi_quirks.h: @
4109f73f0e8SRuslan Ermilov.else
411684c1c1dSNate Lawsonacpi_quirks.h: @/tools/acpi_quirks2h.awk @/dev/acpica/acpi_quirks
412684c1c1dSNate Lawson.endif
413684c1c1dSNate Lawson	${AWK} -f @/tools/acpi_quirks2h.awk @/dev/acpica/acpi_quirks
414684c1c1dSNate Lawson.endif
415684c1c1dSNate Lawson
416a7d30e5fSDavid E. O'Brien.if !empty(SRCS:Massym.s)
417705d63cdSIan DowseCLEANFILES+=	assym.s genassym.o
418705d63cdSIan Dowseassym.s: genassym.o
419705d63cdSIan Dowse.if !exists(@)
420705d63cdSIan Dowseassym.s: @
421705d63cdSIan Dowse.else
422705d63cdSIan Dowseassym.s: @/kern/genassym.sh
423705d63cdSIan Dowse.endif
424705d63cdSIan Dowse	sh @/kern/genassym.sh genassym.o > ${.TARGET}
4257751015fSRuslan Ermilov.if exists(@)
4267751015fSRuslan Ermilovgenassym.o: @/${MACHINE_ARCH}/${MACHINE_ARCH}/genassym.c
4277751015fSRuslan Ermilov.endif
4287751015fSRuslan Ermilovgenassym.o: @ machine ${SRCS:Mopt_*.h}
429705d63cdSIan Dowse	${CC} -c ${CFLAGS:N-fno-common} \
430705d63cdSIan Dowse	    @/${MACHINE_ARCH}/${MACHINE_ARCH}/genassym.c
431705d63cdSIan Dowse.endif
432705d63cdSIan Dowse
433766f7d6eSMark Murraylint: ${SRCS}
434bbb467cdSRuslan Ermilov	${LINT} ${LINTKERNFLAGS} ${CFLAGS:M-[DILU]*} ${.ALLSRC:M*.c}
435766f7d6eSMark Murray
43668e00b92SJordan K. Hubbard.include <bsd.dep.mk>
43747da63c3SBruce Evans
438f2bffe0fSRuslan Ermilov.if !exists(${.OBJDIR}/${DEPENDFILE})
439589d9341SBruce Evans${OBJS}: ${SRCS:M*.h}
44047da63c3SBruce Evans.endif
44147da63c3SBruce Evans
442afba897fSBruce Evans.include <bsd.obj.mk>
443ddc474a8SRuslan Ermilov.include "kern.mk"
444