]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/conf/kmod.mk
Merge llvm-project release/17.x llvmorg-17.0.6-0-g6009708b4367
[FreeBSD/FreeBSD.git] / sys / conf / kmod.mk
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
69 AWK?=           awk
70 KMODLOAD?=      /sbin/kldload
71 KMODUNLOAD?=    /sbin/kldunload
72 KMODISLOADED?=  /sbin/kldstat -q -n
73 OBJCOPY?=       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)
88 CFLAGS+=        -fno-strict-aliasing
89 .endif
90 WERROR?=        -Werror
91
92 LINUXKPI_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
108 LINUXKPI_INCLUDES+= \
109         -I${SYSDIR}/compat/linuxkpi/common/include \
110         -I${SYSDIR}/compat/linuxkpi/dummy/include
111
112 CFLAGS+=        ${WERROR}
113 CFLAGS+=        -D_KERNEL
114 CFLAGS+=        -DKLD_MODULE
115 .if defined(MODULE_TIED)
116 CFLAGS+=        -DKLD_TIED
117 .endif
118
119 # Don't use any standard or source-relative include directories.
120 NOSTDINC=       -nostdinc
121 CFLAGS:=        ${CFLAGS:N-I*} ${NOSTDINC} ${INCLMAGIC} ${CFLAGS:M-I*}
122 .if defined(KERNBUILDDIR)
123 CFLAGS+=        -DHAVE_KERNEL_OPTION_HEADERS -include ${KERNBUILDDIR}/opt_global.h
124 .else
125 SRCS+=          opt_global.h
126 CFLAGS+=        -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.
132 CFLAGS+=        -I. -I${SYSDIR} -I${SYSDIR}/contrib/ck/include
133
134 CFLAGS.gcc+=    -finline-limit=${INLINE_LIMIT}
135 CFLAGS.gcc+=    -fms-extensions
136 CFLAGS.gcc+= --param inline-unit-growth=100
137 CFLAGS.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).
148 CFLAGS+=        -fno-common
149 .if ${LINKER_TYPE} != "lld" || ${LINKER_VERSION} < 140000
150 # lld >= 14 warns that -d is deprecated, and will be removed.
151 LDFLAGS+=       -d
152 .endif
153 LDFLAGS+=       -warn-common
154
155 .if defined(LINKER_FEATURES) && ${LINKER_FEATURES:Mbuild-id}
156 LDFLAGS+=       --build-id=sha1
157 .endif
158
159 CFLAGS+=        ${DEBUG_FLAGS}
160 .if ${MACHINE_CPUARCH} == aarch64 || ${MACHINE_CPUARCH} == amd64 || \
161     ${MACHINE_CPUARCH} == riscv
162 CFLAGS+=        -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"
167 CFLAGS+=        -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.
174 LDFLAGS+=       --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
180 CFLAGS.clang+=  -mno-movt
181 CFLAGS.clang+=  -mfpu=none
182 CFLAGS+=        -funwind-tables
183 .endif
184
185 .if ${MACHINE_CPUARCH} == powerpc
186 CFLAGS+=        -mlongcall -fno-omit-frame-pointer
187 .if ${LINKER_TYPE} == "lld"
188 # TOC optimization in LLD (9.0) currently breaks kernel modules, so disable it
189 LDFLAGS+=       --no-toc-optimize
190 .endif
191 .endif
192
193 .if defined(DEBUG) || defined(DEBUG_FLAGS)
194 CTFFLAGS+=      -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
202 SRCS+=  ${KMOD:S/$/.c/}
203 CLEANFILES+=    ${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
214 OBJS+=  ${_firmw:C/\:.*$/.fwo/:T}
215 .endfor
216 .endif
217
218 # Conditionally include SRCS based on kernel config options.
219 .for _o in ${KERN_OPTS}
220 SRCS+=${SRCS.${_o}}
221 .endfor
222
223 OBJS+=  ${SRCS:N*.h:R:S/$/.o/g}
224
225 .if !defined(PROG)
226 PROG=   ${KMOD}.ko
227 .endif
228
229 .if !defined(DEBUG_FLAGS) || ${MK_SPLIT_KERNEL_DEBUG} == "no"
230 FULLPROG=       ${PROG}
231 .else
232 FULLPROG=       ${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
249 EXPORT_SYMS?=   NO
250 .if ${EXPORT_SYMS} != YES
251 CLEANFILES+=    export_syms
252 .endif
253
254 .if exists(${SYSDIR}/conf/ldscript.kmod.${MACHINE})
255 LDSCRIPT_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
296 CLEANFILES+=${_ILINKS}
297
298 all: ${PROG}
299
300 beforedepend: ${_ILINKS}
301 beforebuild: ${_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})
308 OBJS_DEPEND_GUESS+=     ${_link}
309 .endif
310 .if ${_link} == "machine"
311 CFLAGS+= -fdebug-prefix-map=./machine=${SYSDIR}/${MACHINE}/include
312 .else
313 CFLAGS+= -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
330 CLEANFILES+= ${PROG} ${KMOD}.kld ${OBJS}
331
332 .if defined(DEBUG_FLAGS) && ${MK_SPLIT_KERNEL_DEBUG} != "no"
333 CLEANFILES+= ${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)
344 KERN_DEBUGDIR?= ${DEBUGDIR}
345 realinstall: _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)
358 afterinstall: _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)
372 load: ${PROG} .PHONY
373         ${KMODLOAD} -v ${.OBJDIR}/${PROG}
374 .endif
375
376 .if !target(unload)
377 unload: .PHONY
378         if ${KMODISLOADED} ${PROG} ; then ${KMODUNLOAD} -v ${PROG} ; fi
379 .endif
380
381 .if !target(reload)
382 reload: unload load .PHONY
383 .endif
384
385 .if defined(KERNBUILDDIR)
386 .PATH: ${KERNBUILDDIR}
387 CFLAGS+=        -I${KERNBUILDDIR}
388 .for _src in ${SRCS:Mopt_*.h}
389 CLEANFILES+=    ${_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}
397 CLEANFILES+=    ${_src}
398 .if !target(${_src})
399 ${_src}:
400         :> ${.TARGET}
401 .endif
402 .endfor
403 .endif
404
405 # Add the sanitizer C flags
406 CFLAGS+=        ${SAN_CFLAGS}
407
408 # Add the gcov flags
409 CFLAGS+=        ${GCOV_CFLAGS}
410
411 # Respect configuration-specific C flags.
412 CFLAGS+=        ${ARCH_FLAGS} ${CONF_CFLAGS}
413
414 .if !empty(SRCS:Mvnode_if.c)
415 CLEANFILES+=    vnode_if.c
416 vnode_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)
421 CLEANFILES+=    vnode_if.h vnode_if_newproto.h vnode_if_typedef.h
422 vnode_if.h vnode_if_newproto.h vnode_if_typedef.h: ${SYSDIR}/tools/vnode_if.awk \
423     ${SYSDIR}/kern/vnode_if.src
424 vnode_if.h: vnode_if_newproto.h vnode_if_typedef.h
425         ${AWK} -f ${SYSDIR}/tools/vnode_if.awk ${SYSDIR}/kern/vnode_if.src -h
426 vnode_if_newproto.h:
427         ${AWK} -f ${SYSDIR}/tools/vnode_if.awk ${SYSDIR}/kern/vnode_if.src -p
428 vnode_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)
441 CLEANFILES+=    ${_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)
452 CLEANFILES+=    ${_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)
459 CLEANFILES+=    bhnd_nvram_map.h
460 bhnd_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
463 bhnd_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)
469 CLEANFILES+=    bhnd_nvram_map_data.h
470 bhnd_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
473 bhnd_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)
479 CLEANFILES+=    usbdevs.h
480 usbdevs.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)
485 CLEANFILES+=    usbdevs_data.h
486 usbdevs_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)
491 CLEANFILES+=    sdiodevs.h
492 sdiodevs.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)
497 CLEANFILES+=    sdiodevs_data.h
498 sdiodevs_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)
503 CLEANFILES+=    acpi_quirks.h
504 acpi_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)
509 CLEANFILES+=    assym.inc genassym.o
510 DEPENDOBJS+=    genassym.o
511 DPSRCS+=        offset.inc
512 .endif
513 .if defined(MODULE_TIED)
514 DPSRCS+=        offset.inc
515 .endif
516 .if !empty(SRCS:Moffset.inc) || !empty(DPSRCS:Moffset.inc)
517 CLEANFILES+=    offset.inc genoffset.o
518 DEPENDOBJS+=    genoffset.o
519 .endif
520 assym.inc: genassym.o
521 offset.inc: genoffset.o
522 assym.inc: ${SYSDIR}/kern/genassym.sh
523         sh ${SYSDIR}/kern/genassym.sh genassym.o > ${.TARGET}
524 genassym.o: ${SYSDIR}/${MACHINE}/${MACHINE}/genassym.c offset.inc
525 genassym.o: ${SRCS:Mopt_*.h}
526         ${CC} -c ${CFLAGS:N-flto:N-fno-common} -fcommon \
527             ${SYSDIR}/${MACHINE}/${MACHINE}/genassym.c
528 offset.inc: ${SYSDIR}/kern/genoffset.sh genoffset.o
529         sh ${SYSDIR}/kern/genoffset.sh genoffset.o > ${.TARGET}
530 genoffset.o: ${SYSDIR}/kern/genoffset.c
531 genoffset.o: ${SRCS:Mopt_*.h}
532         ${CC} -c ${CFLAGS:N-flto:N-fno-common} -fcommon \
533             ${SYSDIR}/kern/genoffset.c
534
535 CLEANDEPENDFILES+=      ${_ILINKS}
536 # .depend needs include links so we remove them only together.
537 cleanilinks:
538         rm -f ${_ILINKS}
539
540 OBJS_DEPEND_GUESS+= ${SRCS:M*.h}
541 .if defined(KERNBUILDDIR)
542 OBJS_DEPEND_GUESS+= opt_global.h
543 .endif
544
545 ZINCDIR=${SYSDIR}/contrib/openzfs/include
546 OPENZFS_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"