1#
2# Common code to marry kernel config(8) goo and module building goo.
3#
4
5# Generate options files that otherwise would be built
6# in substantially similar ways through the tree. Move
7# the code here when they all produce identical results
8# (or should)
9.if !defined(KERNBUILDDIR)
10opt_global.h:
11	touch ${.TARGET}
12	@echo "#define SMP 1" >> ${.TARGET}
13	@echo "#define MAC 1" >> ${.TARGET}
14	@echo "#define VIMAGE 1" >> ${.TARGET}
15# Note: Define 'options' in DEFAULTS to 1. For simplicity, no check if the
16# option is in opt_global.h. Nearly all the options in DEFAUlTS today are in
17# opt_global.h with GEOM_* being the main exceptions. Move any options from
18# GENERIC or std.* files to DEFAULTS to get this treatment for untied builds.
19	@awk '$$1 == "options" && $$2 !~ "GEOM_" { print "#define ", $$2, " 1"; }' \
20		< ${SYSDIR}/${MACHINE}/conf/DEFAULTS \
21		>>  ${.TARGET}
22.if ${MK_BHYVE_SNAPSHOT} != "no"
23opt_bhyve_snapshot.h:
24	@echo "#define BHYVE_SNAPSHOT 1" > ${.TARGET}
25.endif
26opt_bpf.h:
27	echo "#define DEV_BPF 1" > ${.TARGET}
28.if ${MK_INET_SUPPORT} != "no"
29opt_inet.h:
30	@echo "#define INET 1" > ${.TARGET}
31	@echo "#define TCP_OFFLOAD 1" >> ${.TARGET}
32.endif
33.if ${MK_INET6_SUPPORT} != "no"
34opt_inet6.h:
35	@echo "#define INET6 1" > ${.TARGET}
36.endif
37.if ${MK_IPSEC_SUPPORT} != "no"
38opt_ipsec.h:
39	@echo "#define IPSEC_SUPPORT 1" > ${.TARGET}
40.endif
41.if ${MK_RATELIMIT} != "no"
42opt_ratelimit.h:
43	@echo "#define RATELIMIT 1" > ${.TARGET}
44.endif
45opt_mrouting.h:
46	@echo "#define MROUTING 1" > ${.TARGET}
47.if ${MK_FDT} != "no"
48opt_platform.h:
49	@echo "#define FDT 1" > ${.TARGET}
50.endif
51opt_printf.h:
52	echo "#define PRINTF_BUFR_SIZE 128" > ${.TARGET}
53opt_scsi.h:
54	echo "#define SCSI_DELAY 15000" > ${.TARGET}
55.if ${MK_SCTP_SUPPORT} != "no"
56opt_sctp.h:
57	@echo "#define SCTP_SUPPORT 1" > ${.TARGET}
58.endif
59opt_wlan.h:
60	echo "#define IEEE80211_DEBUG 1" > ${.TARGET}
61	echo "#define IEEE80211_SUPPORT_MESH 1" >> ${.TARGET}
62KERN_OPTS.i386=NEW_PCIB DEV_PCI
63KERN_OPTS.amd64=NEW_PCIB DEV_PCI
64KERN_OPTS.powerpc=NEW_PCIB DEV_PCI
65KERN_OPTS=MROUTING IEEE80211_DEBUG \
66	IEEE80211_SUPPORT_MESH DEV_BPF \
67	${KERN_OPTS.${MACHINE}} ${KERN_OPTS_EXTRA}
68.if ${MK_BHYVE_SNAPSHOT} != "no"
69KERN_OPTS+= BHYVE_SNAPSHOT
70.endif
71.if ${MK_INET_SUPPORT} != "no"
72KERN_OPTS+= INET TCP_OFFLOAD
73.endif
74.if ${MK_INET6_SUPPORT} != "no"
75KERN_OPTS+= INET6
76.endif
77.if ${MK_IPSEC_SUPPORT} != "no"
78KERN_OPTS+= IPSEC_SUPPORT
79.endif
80.if ${MK_SCTP_SUPPORT} != "no"
81KERN_OPTS+= SCTP_SUPPORT
82.endif
83.elif !defined(KERN_OPTS)
84# Add all the options that are mentioned in any opt_*.h file when we
85# have a kernel build directory to pull them from.
86KERN_OPTS!=cat ${KERNBUILDDIR}/opt*.h | awk '{print $$2;}' | sort -u
87.export KERN_OPTS
88.endif
89
90.if !defined(NO_MODULES) && !defined(__MPATH) && !make(install) && \
91    (empty(.MAKEFLAGS:M-V) || defined(NO_SKIP_MPATH))
92__MPATH!=find ${SYSDIR:tA}/ -name \*_if.m
93.export __MPATH
94.endif
95