xref: /freebsd/sys/conf/kmod.mk (revision a2f733abcff64628b7771a47089628b7327a88bd)
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	@if type kldxref >/dev/null 2>&1; then \
363		${ECHO} ${KLDXREF_CMD} ${DESTDIR}${KMODDIR}; \
364		${KLDXREF_CMD} ${DESTDIR}${KMODDIR}; \
365	fi
366.endif
367.endif # !target(realinstall)
368
369.endif # !target(install)
370
371.if !target(load)
372load: ${PROG} .PHONY
373	${KMODLOAD} -v ${.OBJDIR}/${PROG}
374.endif
375
376.if !target(unload)
377unload: .PHONY
378	if ${KMODISLOADED} ${PROG} ; then ${KMODUNLOAD} -v ${PROG} ; fi
379.endif
380
381.if !target(reload)
382reload: unload load .PHONY
383.endif
384
385.if defined(KERNBUILDDIR)
386.PATH: ${KERNBUILDDIR}
387CFLAGS+=	-I${KERNBUILDDIR}
388.for _src in ${SRCS:Mopt_*.h}
389CLEANFILES+=	${_src}
390.if !target(${_src})
391${_src}:
392	ln -sf ${KERNBUILDDIR}/${_src} ${.TARGET}
393.endif
394.endfor
395.else
396.for _src in ${SRCS:Mopt_*.h}
397CLEANFILES+=	${_src}
398.if !target(${_src})
399${_src}:
400	:> ${.TARGET}
401.endif
402.endfor
403.endif
404
405# Add the sanitizer C flags
406CFLAGS+=	${SAN_CFLAGS}
407
408# Add the gcov flags
409CFLAGS+=	${GCOV_CFLAGS}
410
411# Respect configuration-specific C flags.
412CFLAGS+=	${ARCH_FLAGS} ${CONF_CFLAGS}
413
414.if !empty(SRCS:Mvnode_if.c)
415CLEANFILES+=	vnode_if.c
416vnode_if.c: ${SYSDIR}/tools/vnode_if.awk ${SYSDIR}/kern/vnode_if.src
417	${AWK} -f ${SYSDIR}/tools/vnode_if.awk ${SYSDIR}/kern/vnode_if.src -c
418.endif
419
420.if !empty(SRCS:Mvnode_if.h)
421CLEANFILES+=	vnode_if.h vnode_if_newproto.h vnode_if_typedef.h
422vnode_if.h vnode_if_newproto.h vnode_if_typedef.h: ${SYSDIR}/tools/vnode_if.awk \
423    ${SYSDIR}/kern/vnode_if.src
424vnode_if.h: vnode_if_newproto.h vnode_if_typedef.h
425	${AWK} -f ${SYSDIR}/tools/vnode_if.awk ${SYSDIR}/kern/vnode_if.src -h
426vnode_if_newproto.h:
427	${AWK} -f ${SYSDIR}/tools/vnode_if.awk ${SYSDIR}/kern/vnode_if.src -p
428vnode_if_typedef.h:
429	${AWK} -f ${SYSDIR}/tools/vnode_if.awk ${SYSDIR}/kern/vnode_if.src -q
430.endif
431
432# Build _if.[ch] from _if.m, and clean them when we're done.
433# __MPATH defined in config.mk
434_MFILES=${__MPATH:T:O}
435_MPATH=${__MPATH:H:O:u}
436.PATH.m: ${_MPATH}
437.for _i in ${SRCS:M*_if.[ch]}
438_MATCH=M${_i:R:S/$/.m/}
439_MATCHES=${_MFILES:${_MATCH}}
440.if !empty(_MATCHES)
441CLEANFILES+=	${_i}
442.endif
443.endfor # _i
444.m.c:	${SYSDIR}/tools/makeobjops.awk
445	${AWK} -f ${SYSDIR}/tools/makeobjops.awk ${.IMPSRC} -c
446
447.m.h:	${SYSDIR}/tools/makeobjops.awk
448	${AWK} -f ${SYSDIR}/tools/makeobjops.awk ${.IMPSRC} -h
449
450.for _i in mii pccard
451.if !empty(SRCS:M${_i}devs.h)
452CLEANFILES+=	${_i}devs.h
453${_i}devs.h: ${SYSDIR}/tools/${_i}devs2h.awk ${SYSDIR}/dev/${_i}/${_i}devs
454	${AWK} -f ${SYSDIR}/tools/${_i}devs2h.awk ${SYSDIR}/dev/${_i}/${_i}devs
455.endif
456.endfor # _i
457
458.if !empty(SRCS:Mbhnd_nvram_map.h)
459CLEANFILES+=	bhnd_nvram_map.h
460bhnd_nvram_map.h: ${SYSDIR}/dev/bhnd/tools/nvram_map_gen.awk \
461    ${SYSDIR}/dev/bhnd/tools/nvram_map_gen.sh \
462    ${SYSDIR}/dev/bhnd/nvram/nvram_map
463bhnd_nvram_map.h:
464	sh ${SYSDIR}/dev/bhnd/tools/nvram_map_gen.sh \
465	    ${SYSDIR}/dev/bhnd/nvram/nvram_map -h
466.endif
467
468.if !empty(SRCS:Mbhnd_nvram_map_data.h)
469CLEANFILES+=	bhnd_nvram_map_data.h
470bhnd_nvram_map_data.h: ${SYSDIR}/dev/bhnd/tools/nvram_map_gen.awk \
471    ${SYSDIR}/dev/bhnd/tools/nvram_map_gen.sh \
472    ${SYSDIR}/dev/bhnd/nvram/nvram_map
473bhnd_nvram_map_data.h:
474	sh ${SYSDIR}/dev/bhnd/tools/nvram_map_gen.sh \
475	    ${SYSDIR}/dev/bhnd/nvram/nvram_map -d
476.endif
477
478.if !empty(SRCS:Musbdevs.h)
479CLEANFILES+=	usbdevs.h
480usbdevs.h: ${SYSDIR}/tools/usbdevs2h.awk ${SYSDIR}/dev/usb/usbdevs
481	${AWK} -f ${SYSDIR}/tools/usbdevs2h.awk ${SYSDIR}/dev/usb/usbdevs -h
482.endif
483
484.if !empty(SRCS:Musbdevs_data.h)
485CLEANFILES+=	usbdevs_data.h
486usbdevs_data.h: ${SYSDIR}/tools/usbdevs2h.awk ${SYSDIR}/dev/usb/usbdevs
487	${AWK} -f ${SYSDIR}/tools/usbdevs2h.awk ${SYSDIR}/dev/usb/usbdevs -d
488.endif
489
490.if !empty(SRCS:Msdiodevs.h)
491CLEANFILES+=	sdiodevs.h
492sdiodevs.h: ${SYSDIR}/tools/sdiodevs2h.awk ${SYSDIR}/dev/sdio/sdiodevs
493	${AWK} -f ${SYSDIR}/tools/sdiodevs2h.awk ${SYSDIR}/dev/sdio/sdiodevs -h
494.endif
495
496.if !empty(SRCS:Msdiodevs_data.h)
497CLEANFILES+=	sdiodevs_data.h
498sdiodevs_data.h: ${SYSDIR}/tools/sdiodevs2h.awk ${SYSDIR}/dev/sdio/sdiodevs
499	${AWK} -f ${SYSDIR}/tools/sdiodevs2h.awk ${SYSDIR}/dev/sdio/sdiodevs -d
500.endif
501
502.if !empty(SRCS:Macpi_quirks.h)
503CLEANFILES+=	acpi_quirks.h
504acpi_quirks.h: ${SYSDIR}/tools/acpi_quirks2h.awk ${SYSDIR}/dev/acpica/acpi_quirks
505	${AWK} -f ${SYSDIR}/tools/acpi_quirks2h.awk ${SYSDIR}/dev/acpica/acpi_quirks
506.endif
507
508.if !empty(SRCS:Massym.inc) || !empty(DPSRCS:Massym.inc)
509CLEANFILES+=	assym.inc genassym.o
510DEPENDOBJS+=	genassym.o
511DPSRCS+=	offset.inc
512.endif
513.if defined(MODULE_TIED)
514DPSRCS+=	offset.inc
515.endif
516.if !empty(SRCS:Moffset.inc) || !empty(DPSRCS:Moffset.inc)
517CLEANFILES+=	offset.inc genoffset.o
518DEPENDOBJS+=	genoffset.o
519.endif
520assym.inc: genassym.o
521offset.inc: genoffset.o
522assym.inc: ${SYSDIR}/kern/genassym.sh
523	sh ${SYSDIR}/kern/genassym.sh genassym.o > ${.TARGET}
524genassym.o: ${SYSDIR}/${MACHINE}/${MACHINE}/genassym.c offset.inc
525genassym.o: ${SRCS:Mopt_*.h}
526	${CC} -c ${CFLAGS:N-flto:N-fno-common} -fcommon \
527	    ${SYSDIR}/${MACHINE}/${MACHINE}/genassym.c
528offset.inc: ${SYSDIR}/kern/genoffset.sh genoffset.o
529	sh ${SYSDIR}/kern/genoffset.sh genoffset.o > ${.TARGET}
530genoffset.o: ${SYSDIR}/kern/genoffset.c
531genoffset.o: ${SRCS:Mopt_*.h}
532	${CC} -c ${CFLAGS:N-flto:N-fno-common} -fcommon \
533	    ${SYSDIR}/kern/genoffset.c
534
535CLEANDEPENDFILES+=	${_ILINKS}
536# .depend needs include links so we remove them only together.
537cleanilinks:
538	rm -f ${_ILINKS}
539
540OBJS_DEPEND_GUESS+= ${SRCS:M*.h}
541.if defined(KERNBUILDDIR)
542OBJS_DEPEND_GUESS+= opt_global.h
543.endif
544
545ZINCDIR=${SYSDIR}/contrib/openzfs/include
546OPENZFS_CFLAGS=     \
547	-D_SYS_VMEM_H_  \
548	-D__KERNEL__ \
549	-nostdinc \
550	-DSMP \
551	-I${ZINCDIR}  \
552	-I${ZINCDIR}/os/freebsd \
553	-I${ZINCDIR}/os/freebsd/spl \
554	-I${ZINCDIR}/os/freebsd/zfs \
555	-I${SYSDIR}/cddl/compat/opensolaris \
556	-I${SYSDIR}/cddl/contrib/opensolaris/uts/common \
557	-include ${ZINCDIR}/os/freebsd/spl/sys/ccompile.h
558
559.include <bsd.dep.mk>
560.include <bsd.clang-analyze.mk>
561.include <bsd.obj.mk>
562.include "kern.mk"
563