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