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