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