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