xref: /freebsd/sys/conf/kmod.mk (revision a91a246563dffa876a52f53a98de4af9fa364c52)
1# The include file <bsd.kmod.mk> handles building and installing loadable
2# kernel modules.
3#
4#
5# +++ variables +++
6#
7# CLEANFILES	Additional files to remove for the clean and cleandir targets.
8#
9# EXPORT_SYMS	A list of symbols that should be exported from the module,
10#		or the name of a file containing a list of symbols, or YES
11#		to export all symbols.  If not defined, no symbols are
12#		exported.
13#
14# KMOD		The name of the kernel module to build.
15#
16# KMODDIR	Base path for kernel modules (see kld(4)). [/boot/kernel]
17#
18# KMODOWN	Module file owner. [${BINOWN}]
19#
20# KMODGRP	Module file group. [${BINGRP}]
21#
22# KMODMODE	Module file mode. [${BINMODE}]
23#
24# KMODLOAD	Command to load a kernel module [/sbin/kldload]
25#
26# KMODUNLOAD	Command to unload a kernel module [/sbin/kldunload]
27#
28# KMODISLOADED	Command to check whether a kernel module is
29#		loaded [/sbin/kldstat -q -n]
30#
31# PROG		The name of the kernel module to build.
32#		If not supplied, ${KMOD}.ko is used.
33#
34# SRCS		List of source files.
35#
36# FIRMWS	List of firmware images in format filename:shortname:version
37#
38# FIRMWARE_LICENSE
39#		Set to the name of the license the user has to agree on in
40#		order to use this firmware. See /usr/share/doc/legal
41#
42# DESTDIR	The tree where the module gets installed. [not set]
43#
44# KERNBUILDDIR	Set to the location of the kernel build directory where
45#		the opt_*.h files, .o's and kernel winds up.
46#
47# BLOB_OBJS	Prebuilt binary blobs .o's from the src tree to be linked into
48#		the module. These are precious and not removed in make clean.
49#
50# +++ targets +++
51#
52# 	install:
53#               install the kernel module; if the Makefile
54#               does not itself define the target install, the targets
55#               beforeinstall and afterinstall may also be used to cause
56#               actions immediately before and after the install target
57#		is executed.
58#
59# 	load:
60#		Load a module.
61#
62# 	unload:
63#		Unload a module.
64#
65#	reload:
66#		Unload if loaded, then load.
67#
68
69AWK?=		awk
70KMODLOAD?=	/sbin/kldload
71KMODUNLOAD?=	/sbin/kldunload
72KMODISLOADED?=	/sbin/kldstat -q -n
73OBJCOPY?=	objcopy
74
75.include "kmod.opts.mk"
76.include <bsd.sysdir.mk>
77
78.SUFFIXES: .out .o .c .cc .cxx .C .y .l .s .S .m
79
80# amd64 uses direct linking for kmod, all others use shared binaries
81.if ${MACHINE_CPUARCH} != amd64
82__KLD_SHARED=yes
83.else
84__KLD_SHARED=no
85.endif
86
87.if !empty(CFLAGS:M-O[23s]) && empty(CFLAGS:M-fno-strict-aliasing)
88CFLAGS+=	-fno-strict-aliasing
89.endif
90WERROR?=	-Werror
91
92LINUXKPI_GENSRCS+= \
93	backlight_if.h \
94	bus_if.h \
95	device_if.h \
96	iicbus_if.h \
97	iicbb_if.h \
98	lkpi_iic_if.c \
99	lkpi_iic_if.h \
100	pci_if.h \
101	pci_iov_if.h \
102	pcib_if.h \
103	vnode_if.h \
104	usb_if.h \
105	opt_usb.h \
106	opt_stack.h
107
108LINUXKPI_INCLUDES+= \
109	-I${SYSDIR}/compat/linuxkpi/common/include \
110	-I${SYSDIR}/compat/linuxkpi/dummy/include
111
112CFLAGS+=	${WERROR}
113CFLAGS+=	-D_KERNEL
114CFLAGS+=	-DKLD_MODULE
115.if defined(MODULE_TIED)
116CFLAGS+=	-DKLD_TIED
117.endif
118
119# Don't use any standard or source-relative include directories.
120NOSTDINC=	-nostdinc
121CFLAGS:=	${CFLAGS:N-I*} ${NOSTDINC} ${INCLMAGIC} ${CFLAGS:M-I*}
122.if defined(KERNBUILDDIR)
123CFLAGS+=	-DHAVE_KERNEL_OPTION_HEADERS -include ${KERNBUILDDIR}/opt_global.h
124.else
125SRCS+=		opt_global.h
126CFLAGS+=	-include ${.OBJDIR}/opt_global.h
127.endif
128
129# Add -I paths for system headers.  Individual module makefiles don't
130# need any -I paths for this.  Similar defaults for .PATH can't be
131# set because there are no standard paths for non-headers.
132CFLAGS+=	-I. -I${SYSDIR} -I${SYSDIR}/contrib/ck/include
133
134CFLAGS.gcc+=	-finline-limit=${INLINE_LIMIT}
135CFLAGS.gcc+=	-fms-extensions
136CFLAGS.gcc+= --param inline-unit-growth=100
137CFLAGS.gcc+= --param large-function-growth=1000
138
139# Disallow common variables, and if we end up with commons from
140# somewhere unexpected, allocate storage for them in the module itself.
141#
142# -fno-common is the default for src builds, but this should be left in place
143# until at least we catch up to GCC10/LLVM11 or otherwise enable -fno-common
144# in <bsd.sys.mk> instead.  For now, we will have duplicate -fno-common in
145# CFLAGS for in-tree module builds as they will also pick it up from
146# share/mk/src.sys.mk, but the following is important for out-of-tree modules
147# (e.g. ports).
148CFLAGS+=	-fno-common
149.if ${LINKER_TYPE} != "lld" || ${LINKER_VERSION} < 140000
150# lld >= 14 warns that -d is deprecated, and will be removed.
151LDFLAGS+=	-d
152.endif
153LDFLAGS+=	-warn-common
154
155.if defined(LINKER_FEATURES) && ${LINKER_FEATURES:Mbuild-id}
156LDFLAGS+=	--build-id=sha1
157.endif
158
159CFLAGS+=	${DEBUG_FLAGS}
160.if ${MACHINE_CPUARCH} == aarch64 || ${MACHINE_CPUARCH} == amd64 || \
161    ${MACHINE_CPUARCH} == riscv
162CFLAGS+=	-fno-omit-frame-pointer -mno-omit-leaf-frame-pointer
163.endif
164
165.if ${MACHINE_CPUARCH} == "aarch64" || ${MACHINE_CPUARCH} == "riscv" || \
166    ${MACHINE_CPUARCH} == "powerpc" || ${MACHINE_CPUARCH} == "i386"
167CFLAGS+=	-fPIC
168.endif
169
170.if ${MACHINE_CPUARCH} == "aarch64"
171# https://bugs.freebsd.org/264094
172# lld >= 14 and recent GNU ld can relax adrp+add and adrp+ldr instructions,
173# which breaks VNET.
174LDFLAGS+=	--no-relax
175.endif
176
177# Temporary workaround for PR 196407, which contains the fascinating details.
178# Don't allow clang to use fpu instructions or registers in kernel modules.
179.if ${MACHINE_CPUARCH} == arm
180CFLAGS.clang+=	-mno-movt
181CFLAGS.clang+=	-mfpu=none
182CFLAGS+=	-funwind-tables
183.endif
184
185.if ${MACHINE_CPUARCH} == powerpc
186CFLAGS+=	-mlongcall -fno-omit-frame-pointer
187.if ${LINKER_TYPE} == "lld"
188# TOC optimization in LLD (9.0) currently breaks kernel modules, so disable it
189LDFLAGS+=	--no-toc-optimize
190.endif
191.endif
192
193.if defined(DEBUG) || defined(DEBUG_FLAGS)
194CTFFLAGS+=	-g
195.endif
196
197.if defined(FIRMWS)
198${KMOD:S/$/.c/}: ${SYSDIR}/tools/fw_stub.awk
199	${AWK} -f ${SYSDIR}/tools/fw_stub.awk ${FIRMWS} -m${KMOD} -c${KMOD:S/$/.c/g} \
200	    ${FIRMWARE_LICENSE:C/.+/-l/}${FIRMWARE_LICENSE}
201
202SRCS+=	${KMOD:S/$/.c/}
203CLEANFILES+=	${KMOD:S/$/.c/}
204
205.for _firmw in ${FIRMWS}
206${_firmw:C/\:.*$/.fwo/:T}:	${_firmw:C/\:.*$//} ${SYSDIR}/kern/firmw.S
207	@${ECHO} ${_firmw:C/\:.*$//} ${.ALLSRC:M*${_firmw:C/\:.*$//}}
208	${CC:N${CCACHE_BIN}} -c -x assembler-with-cpp -DLOCORE 	\
209	    ${CFLAGS} ${WERROR} 				\
210	    -DFIRMW_FILE=\""${.ALLSRC:M*${_firmw:C/\:.*$//}}"\"	\
211	    -DFIRMW_SYMBOL="${_firmw:C/\:.*$//:C/[-.\/@]/_/g}"	\
212	    ${SYSDIR}/kern/firmw.S -o ${.TARGET}
213
214OBJS+=	${_firmw:C/\:.*$/.fwo/:T}
215.endfor
216.endif
217
218# Conditionally include SRCS based on kernel config options.
219.for _o in ${KERN_OPTS}
220SRCS+=${SRCS.${_o}}
221.endfor
222
223OBJS+=	${SRCS:N*.h:R:S/$/.o/g}
224
225.if !defined(PROG)
226PROG=	${KMOD}.ko
227.endif
228
229.if !defined(DEBUG_FLAGS) || ${MK_SPLIT_KERNEL_DEBUG} == "no"
230FULLPROG=	${PROG}
231.else
232FULLPROG=	${PROG}.full
233${PROG}: ${FULLPROG} ${PROG}.debug
234	${OBJCOPY} --strip-debug --add-gnu-debuglink=${PROG}.debug \
235	    ${FULLPROG} ${.TARGET}
236${PROG}.debug: ${FULLPROG}
237	${OBJCOPY} --only-keep-debug ${FULLPROG} ${.TARGET}
238.endif
239
240.if ${__KLD_SHARED} == yes
241${FULLPROG}: ${KMOD}.kld
242	${LD} -m ${LD_EMULATION} -Bshareable -znotext -znorelro ${_LDFLAGS} \
243	    -o ${.TARGET} ${KMOD}.kld
244.if !defined(DEBUG_FLAGS)
245	${OBJCOPY} --strip-debug ${.TARGET}
246.endif
247.endif
248
249EXPORT_SYMS?=	NO
250.if ${EXPORT_SYMS} != YES
251CLEANFILES+=	export_syms
252.endif
253
254.if exists(${SYSDIR}/conf/ldscript.kmod.${MACHINE})
255LDSCRIPT_FLAGS?= -T ${SYSDIR}/conf/ldscript.kmod.${MACHINE}
256.endif
257
258.if ${__KLD_SHARED} == yes
259${KMOD}.kld: ${OBJS} ${BLOB_OBJS}
260.else
261${FULLPROG}: ${OBJS} ${BLOB_OBJS}
262.endif
263	${LD} -m ${LD_EMULATION} ${_LDFLAGS} ${LDSCRIPT_FLAGS} -r \
264	    -o ${.TARGET} ${OBJS} ${BLOB_OBJS}
265.if ${MK_CTF} != "no"
266	${CTFMERGE} ${CTFFLAGS} -o ${.TARGET} ${OBJS} ${BLOB_OBJS}
267.endif
268.if defined(EXPORT_SYMS)
269.if ${EXPORT_SYMS} != YES
270.if ${EXPORT_SYMS} == NO
271	:> export_syms
272.elif !exists(${.CURDIR}/${EXPORT_SYMS})
273	printf '%s' "${EXPORT_SYMS:@s@$s${.newline}@}" > export_syms
274.else
275	grep -v '^#' < ${EXPORT_SYMS} > export_syms
276.endif
277	${AWK} -f ${SYSDIR}/conf/kmod_syms.awk ${.TARGET} \
278	    export_syms | xargs -J% ${OBJCOPY} % ${.TARGET}
279.endif
280.endif # defined(EXPORT_SYMS)
281.if defined(PREFIX_SYMS)
282	${AWK} -v prefix=${PREFIX_SYMS} -f ${SYSDIR}/conf/kmod_syms_prefix.awk \
283	    ${.TARGET} /dev/null | xargs -J% ${OBJCOPY} % ${.TARGET}
284.endif
285.if !defined(DEBUG_FLAGS) && ${__KLD_SHARED} == no
286	${OBJCOPY} --strip-debug ${.TARGET}
287.endif
288
289_ILINKS=machine
290.if ${MACHINE_CPUARCH} == "i386" || ${MACHINE_CPUARCH} == "amd64"
291_ILINKS+=x86
292.endif
293.if ${MACHINE_CPUARCH} == "amd64"
294_ILINKS+=i386
295.endif
296CLEANFILES+=${_ILINKS}
297
298all: ${PROG}
299
300beforedepend: ${_ILINKS}
301beforebuild: ${_ILINKS}
302
303# Ensure that the links exist without depending on it when it exists which
304# causes all the modules to be rebuilt when the directory pointed to changes.
305# Ensure that debug info references the path in the source tree.
306.for _link in ${_ILINKS}
307.if !exists(${.OBJDIR}/${_link})
308OBJS_DEPEND_GUESS+=	${_link}
309.endif
310.if ${_link} == "machine"
311CFLAGS+= -fdebug-prefix-map=./machine=${SYSDIR}/${MACHINE}/include
312.else
313CFLAGS+= -fdebug-prefix-map=./${_link}=${SYSDIR}/${_link}/include
314.endif
315.endfor
316
317.NOPATH: ${_ILINKS}
318
319${_ILINKS}:
320	@case ${.TARGET} in \
321	machine) \
322		path=${SYSDIR}/${MACHINE}/include ;; \
323	*) \
324		path=${SYSDIR}/${.TARGET:T}/include ;; \
325	esac ; \
326	path=`realpath $$path`; \
327	${ECHO} ${.TARGET:T} "->" $$path ; \
328	ln -fns $$path ${.TARGET:T}
329
330CLEANFILES+= ${PROG} ${KMOD}.kld ${OBJS}
331
332.if defined(DEBUG_FLAGS) && ${MK_SPLIT_KERNEL_DEBUG} != "no"
333CLEANFILES+= ${FULLPROG} ${PROG}.debug
334.endif
335
336.if !target(install)
337
338_INSTALLFLAGS:=	${INSTALLFLAGS}
339.for ie in ${INSTALLFLAGS_EDIT}
340_INSTALLFLAGS:=	${_INSTALLFLAGS${ie}}
341.endfor
342
343.if !target(realinstall)
344KERN_DEBUGDIR?=	${DEBUGDIR}
345realinstall: _kmodinstall
346.ORDER: beforeinstall _kmodinstall
347_kmodinstall: .PHONY
348	${INSTALL} -T release -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
349	    ${_INSTALLFLAGS} ${PROG} ${DESTDIR}${KMODDIR}/
350.if defined(DEBUG_FLAGS) && !defined(INSTALL_NODEBUG) && ${MK_KERNEL_SYMBOLS} != "no"
351	${INSTALL} -T dbg -o ${KMODOWN} -g ${KMODGRP} -m ${KMODMODE} \
352	    ${_INSTALLFLAGS} ${PROG}.debug ${DESTDIR}${KERN_DEBUGDIR}${KMODDIR}/
353.endif
354
355.include <bsd.links.mk>
356
357.if !defined(NO_XREF)
358afterinstall: _kldxref
359.ORDER: realinstall _kldxref
360.ORDER: _installlinks _kldxref
361_kldxref: .PHONY
362	${KLDXREF_CMD} ${DESTDIR}${KMODDIR}
363.if defined(NO_ROOT) && defined(METALOG)
364	echo ".${DISTBASE}${KMODDIR}/linker.hints type=file mode=0644 uname=root gname=wheel" | \
365	    cat -l >> ${METALOG}
366.endif
367.endif
368.endif # !target(realinstall)
369
370.endif # !target(install)
371
372.if !target(load)
373load: ${PROG} .PHONY
374	${KMODLOAD} -v ${.OBJDIR}/${PROG}
375.endif
376
377.if !target(unload)
378unload: .PHONY
379	if ${KMODISLOADED} ${PROG} ; then ${KMODUNLOAD} -v ${PROG} ; fi
380.endif
381
382.if !target(reload)
383reload: unload load .PHONY
384.endif
385
386.if defined(KERNBUILDDIR)
387.PATH: ${KERNBUILDDIR}
388CFLAGS+=	-I${KERNBUILDDIR}
389.for _src in ${SRCS:Mopt_*.h}
390CLEANFILES+=	${_src}
391.if !target(${_src})
392${_src}:
393	ln -sf ${KERNBUILDDIR}/${_src} ${.TARGET}
394.endif
395.endfor
396.else
397.for _src in ${SRCS:Mopt_*.h}
398CLEANFILES+=	${_src}
399.if !target(${_src})
400${_src}:
401	:> ${.TARGET}
402.endif
403.endfor
404.endif
405
406# Add the sanitizer C flags
407CFLAGS+=	${SAN_CFLAGS}
408
409# Add the gcov flags
410CFLAGS+=	${GCOV_CFLAGS}
411
412# Respect configuration-specific C flags.
413CFLAGS+=	${ARCH_FLAGS} ${CONF_CFLAGS}
414
415.if !empty(SRCS:Mvnode_if.c)
416CLEANFILES+=	vnode_if.c
417vnode_if.c: ${SYSDIR}/tools/vnode_if.awk ${SYSDIR}/kern/vnode_if.src
418	${AWK} -f ${SYSDIR}/tools/vnode_if.awk ${SYSDIR}/kern/vnode_if.src -c
419.endif
420
421.if !empty(SRCS:Mvnode_if.h)
422CLEANFILES+=	vnode_if.h vnode_if_newproto.h vnode_if_typedef.h
423vnode_if.h vnode_if_newproto.h vnode_if_typedef.h: ${SYSDIR}/tools/vnode_if.awk \
424    ${SYSDIR}/kern/vnode_if.src
425vnode_if.h: vnode_if_newproto.h vnode_if_typedef.h
426	${AWK} -f ${SYSDIR}/tools/vnode_if.awk ${SYSDIR}/kern/vnode_if.src -h
427vnode_if_newproto.h:
428	${AWK} -f ${SYSDIR}/tools/vnode_if.awk ${SYSDIR}/kern/vnode_if.src -p
429vnode_if_typedef.h:
430	${AWK} -f ${SYSDIR}/tools/vnode_if.awk ${SYSDIR}/kern/vnode_if.src -q
431.endif
432
433# Build _if.[ch] from _if.m, and clean them when we're done.
434# __MPATH defined in config.mk
435_MFILES=${__MPATH:T:O}
436_MPATH=${__MPATH:H:O:u}
437.PATH.m: ${_MPATH}
438.for _i in ${SRCS:M*_if.[ch]}
439_MATCH=M${_i:R:S/$/.m/}
440_MATCHES=${_MFILES:${_MATCH}}
441.if !empty(_MATCHES)
442CLEANFILES+=	${_i}
443.endif
444.endfor # _i
445.m.c:	${SYSDIR}/tools/makeobjops.awk
446	${AWK} -f ${SYSDIR}/tools/makeobjops.awk ${.IMPSRC} -c
447
448.m.h:	${SYSDIR}/tools/makeobjops.awk
449	${AWK} -f ${SYSDIR}/tools/makeobjops.awk ${.IMPSRC} -h
450
451.for _i in mii pccard
452.if !empty(SRCS:M${_i}devs.h)
453CLEANFILES+=	${_i}devs.h
454${_i}devs.h: ${SYSDIR}/tools/${_i}devs2h.awk ${SYSDIR}/dev/${_i}/${_i}devs
455	${AWK} -f ${SYSDIR}/tools/${_i}devs2h.awk ${SYSDIR}/dev/${_i}/${_i}devs
456.endif
457.endfor # _i
458
459.if !empty(SRCS:Mbhnd_nvram_map.h)
460CLEANFILES+=	bhnd_nvram_map.h
461bhnd_nvram_map.h: ${SYSDIR}/dev/bhnd/tools/nvram_map_gen.awk \
462    ${SYSDIR}/dev/bhnd/tools/nvram_map_gen.sh \
463    ${SYSDIR}/dev/bhnd/nvram/nvram_map
464bhnd_nvram_map.h:
465	sh ${SYSDIR}/dev/bhnd/tools/nvram_map_gen.sh \
466	    ${SYSDIR}/dev/bhnd/nvram/nvram_map -h
467.endif
468
469.if !empty(SRCS:Mbhnd_nvram_map_data.h)
470CLEANFILES+=	bhnd_nvram_map_data.h
471bhnd_nvram_map_data.h: ${SYSDIR}/dev/bhnd/tools/nvram_map_gen.awk \
472    ${SYSDIR}/dev/bhnd/tools/nvram_map_gen.sh \
473    ${SYSDIR}/dev/bhnd/nvram/nvram_map
474bhnd_nvram_map_data.h:
475	sh ${SYSDIR}/dev/bhnd/tools/nvram_map_gen.sh \
476	    ${SYSDIR}/dev/bhnd/nvram/nvram_map -d
477.endif
478
479.if !empty(SRCS:Musbdevs.h)
480CLEANFILES+=	usbdevs.h
481usbdevs.h: ${SYSDIR}/tools/usbdevs2h.awk ${SYSDIR}/dev/usb/usbdevs
482	${AWK} -f ${SYSDIR}/tools/usbdevs2h.awk ${SYSDIR}/dev/usb/usbdevs -h
483.endif
484
485.if !empty(SRCS:Musbdevs_data.h)
486CLEANFILES+=	usbdevs_data.h
487usbdevs_data.h: ${SYSDIR}/tools/usbdevs2h.awk ${SYSDIR}/dev/usb/usbdevs
488	${AWK} -f ${SYSDIR}/tools/usbdevs2h.awk ${SYSDIR}/dev/usb/usbdevs -d
489.endif
490
491.if !empty(SRCS:Msdiodevs.h)
492CLEANFILES+=	sdiodevs.h
493sdiodevs.h: ${SYSDIR}/tools/sdiodevs2h.awk ${SYSDIR}/dev/sdio/sdiodevs
494	${AWK} -f ${SYSDIR}/tools/sdiodevs2h.awk ${SYSDIR}/dev/sdio/sdiodevs -h
495.endif
496
497.if !empty(SRCS:Msdiodevs_data.h)
498CLEANFILES+=	sdiodevs_data.h
499sdiodevs_data.h: ${SYSDIR}/tools/sdiodevs2h.awk ${SYSDIR}/dev/sdio/sdiodevs
500	${AWK} -f ${SYSDIR}/tools/sdiodevs2h.awk ${SYSDIR}/dev/sdio/sdiodevs -d
501.endif
502
503.if !empty(SRCS:Macpi_quirks.h)
504CLEANFILES+=	acpi_quirks.h
505acpi_quirks.h: ${SYSDIR}/tools/acpi_quirks2h.awk ${SYSDIR}/dev/acpica/acpi_quirks
506	${AWK} -f ${SYSDIR}/tools/acpi_quirks2h.awk ${SYSDIR}/dev/acpica/acpi_quirks
507.endif
508
509.if !empty(SRCS:Massym.inc) || !empty(DPSRCS:Massym.inc)
510CLEANFILES+=	assym.inc genassym.o
511DEPENDOBJS+=	genassym.o
512DPSRCS+=	offset.inc
513.endif
514.if defined(MODULE_TIED)
515DPSRCS+=	offset.inc
516.endif
517.if !empty(SRCS:Moffset.inc) || !empty(DPSRCS:Moffset.inc)
518CLEANFILES+=	offset.inc genoffset.o
519DEPENDOBJS+=	genoffset.o
520.endif
521assym.inc: genassym.o
522offset.inc: genoffset.o
523assym.inc: ${SYSDIR}/kern/genassym.sh
524	sh ${SYSDIR}/kern/genassym.sh genassym.o > ${.TARGET}
525genassym.o: ${SYSDIR}/${MACHINE}/${MACHINE}/genassym.c offset.inc
526genassym.o: ${SRCS:Mopt_*.h}
527	${CC} -c ${CFLAGS:N-flto*:N-fno-common:N-fsanitize*:N-fno-sanitize*} -fcommon \
528	    ${SYSDIR}/${MACHINE}/${MACHINE}/genassym.c
529offset.inc: ${SYSDIR}/kern/genoffset.sh genoffset.o
530	sh ${SYSDIR}/kern/genoffset.sh genoffset.o > ${.TARGET}
531genoffset.o: ${SYSDIR}/kern/genoffset.c
532genoffset.o: ${SRCS:Mopt_*.h}
533	${CC} -c ${CFLAGS:N-flto*:N-fno-common:N-fsanitize*:N-fno-sanitize*} -fcommon \
534	    ${SYSDIR}/kern/genoffset.c
535
536CLEANDEPENDFILES+=	${_ILINKS}
537# .depend needs include links so we remove them only together.
538cleanilinks:
539	rm -f ${_ILINKS}
540
541OBJS_DEPEND_GUESS+= ${SRCS:M*.h}
542.if defined(KERNBUILDDIR)
543OBJS_DEPEND_GUESS+= opt_global.h
544.endif
545
546ZINCDIR=${SYSDIR}/contrib/openzfs/include
547OPENZFS_CFLAGS=     \
548	-D_SYS_VMEM_H_  \
549	-D__KERNEL__ \
550	-nostdinc \
551	-DSMP \
552	-I${ZINCDIR}  \
553	-I${ZINCDIR}/os/freebsd \
554	-I${ZINCDIR}/os/freebsd/spl \
555	-I${ZINCDIR}/os/freebsd/zfs \
556	-I${SYSDIR}/cddl/compat/opensolaris \
557	-I${SYSDIR}/cddl/contrib/opensolaris/uts/common \
558	-include ${ZINCDIR}/os/freebsd/spl/sys/ccompile.h
559
560.include <bsd.dep.mk>
561.include <bsd.clang-analyze.mk>
562.include <bsd.obj.mk>
563.include "kern.mk"
564