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