Merge ^/head r305892 through r306302.
[freebsd.git] / share / mk / src.opts.mk
1 # $FreeBSD$
2 #
3 # Option file for FreeBSD /usr/src builds.
4 #
5 # Users define WITH_FOO and WITHOUT_FOO on the command line or in /etc/src.conf
6 # and /etc/make.conf files. These translate in the build system to MK_FOO={yes,no}
7 # with sensible (usually) defaults.
8 #
9 # Makefiles must include bsd.opts.mk after defining specific MK_FOO options that
10 # are applicable for that Makefile (typically there are none, but sometimes there
11 # are exceptions). Recursive makes usually add MK_FOO=no for options that they wish
12 # to omit from that make.
13 #
14 # Makefiles must include bsd.mkopt.mk before they test the value of any MK_FOO
15 # variable.
16 #
17 # Makefiles may also assume that this file is included by src.opts.mk should it
18 # need variables defined there prior to the end of the Makefile where
19 # bsd.{subdir,lib.bin}.mk is traditionally included.
20 #
21 # The old-style YES_FOO and NO_FOO are being phased out. No new instances of them
22 # should be added. Old instances should be removed since they were just to
23 # bridge the gap between FreeBSD 4 and FreeBSD 5.
24 #
25 # Makefiles should never test WITH_FOO or WITHOUT_FOO directly (although an
26 # exception is made for _WITHOUT_SRCONF which turns off this mechanism
27 # completely inside bsd.*.mk files).
28 #
29
30 .if !target(__<src.opts.mk>__)
31 __<src.opts.mk>__:
32
33 .include <bsd.own.mk>
34
35 #
36 # Define MK_* variables (which are either "yes" or "no") for users
37 # to set via WITH_*/WITHOUT_* in /etc/src.conf and override in the
38 # make(1) environment.
39 # These should be tested with `== "no"' or `!= "no"' in makefiles.
40 # The NO_* variables should only be set by makefiles for variables
41 # that haven't been converted over.
42 #
43
44 # These options are used by src the builds
45
46 __DEFAULT_YES_OPTIONS = \
47     ACCT \
48     ACPI \
49     AMD \
50     APM \
51     AT \
52     ATM \
53     AUDIT \
54     AUTHPF \
55     AUTOFS \
56     BHYVE \
57     BINUTILS \
58     BINUTILS_BOOTSTRAP \
59     BLACKLIST \
60     BLUETOOTH \
61     BOOT \
62     BOOTPARAMD \
63     BOOTPD \
64     BSD_CPIO \
65     BSDINSTALL \
66     BSNMP \
67     BZIP2 \
68     CALENDAR \
69     CAPSICUM \
70     CASPER \
71     CCD \
72     CDDL \
73     CPP \
74     CROSS_COMPILER \
75     CRYPT \
76     CTM \
77     CUSE \
78     CXX \
79     DICT \
80     DMAGENT \
81     DYNAMICROOT \
82     ED_CRYPTO \
83     EE \
84     ELFCOPY_AS_OBJCOPY \
85     ELFTOOLCHAIN_BOOTSTRAP \
86     EXAMPLES \
87     FDT \
88     FILE \
89     FINGER \
90     FLOPPY \
91     FMTREE \
92     FORTH \
93     FP_LIBC \
94     FREEBSD_UPDATE \
95     FTP \
96     GAMES \
97     GCOV \
98     GDB \
99     GNU \
100     GNU_GREP_COMPAT \
101     GPIO \
102     GPL_DTC \
103     GROFF \
104     HAST \
105     HTML \
106     HYPERV \
107     ICONV \
108     INET \
109     INET6 \
110     INETD \
111     IPFILTER \
112     IPFW \
113     ISCSI \
114     JAIL \
115     KDUMP \
116     KVM \
117     LDNS \
118     LDNS_UTILS \
119     LEGACY_CONSOLE \
120     LIB32 \
121     LIBPTHREAD \
122     LIBTHR \
123     LOCALES \
124     LOCATE \
125     LPR \
126     LS_COLORS \
127     LZMA_SUPPORT \
128     MAIL \
129     MAILWRAPPER \
130     MAKE \
131     MANDOCDB \
132     NDIS \
133     NETCAT \
134     NETGRAPH \
135     NLS_CATALOGS \
136     NS_CACHING \
137     NTP \
138     OPENSSL \
139     PAM \
140     PC_SYSINSTALL \
141     PF \
142     PKGBOOTSTRAP \
143     PMC \
144     PORTSNAP \
145     PPP \
146     QUOTAS \
147     RADIUS_SUPPORT \
148     RCMDS \
149     RBOOTD \
150     RESCUE \
151     ROUTED \
152     SENDMAIL \
153     SETUID_LOGIN \
154     SHAREDOCS \
155     SOURCELESS \
156     SOURCELESS_HOST \
157     SOURCELESS_UCODE \
158     SVNLITE \
159     SYSCONS \
160     SYSTEM_COMPILER \
161     TALK \
162     TCP_WRAPPERS \
163     TCSH \
164     TELNET \
165     TESTS \
166     TEXTPROC \
167     TFTP \
168     TIMED \
169     UNBOUND \
170     USB \
171     UTMPX \
172     VI \
173     VT \
174     WIRELESS \
175     WPA_SUPPLICANT_EAPOL \
176     ZFS \
177     ZONEINFO
178
179 __DEFAULT_NO_OPTIONS = \
180     BSD_GREP \
181     CLANG_EXTRAS \
182     DTRACE_TESTS \
183     EISA \
184     HESIOD \
185     LIBSOFT \
186     NAND \
187     OFED \
188     OPENLDAP \
189     RCS \
190     SHARED_TOOLCHAIN \
191     SORT_THREADS \
192     SVN \
193
194
195 #
196 # Default behaviour of some options depends on the architecture.  Unfortunately
197 # this means that we have to test TARGET_ARCH (the buildworld case) as well
198 # as MACHINE_ARCH (the non-buildworld case).  Normally TARGET_ARCH is not
199 # used at all in bsd.*.mk, but we have to make an exception here if we want
200 # to allow defaults for some things like clang to vary by target architecture.
201 # Additional, per-target behavior should be rarely added only after much
202 # gnashing of teeth and grinding of gears.
203 #
204 .if defined(TARGET_ARCH)
205 __T=${TARGET_ARCH}
206 .else
207 __T=${MACHINE_ARCH}
208 .endif
209 .if defined(TARGET)
210 __TT=${TARGET}
211 .else
212 __TT=${MACHINE}
213 .endif
214
215 .include <bsd.compiler.mk>
216 # If the compiler is not C++11 capable, disable Clang and use GCC instead.
217 # This means that architectures that have GCC 4.2 as default can not
218 # build Clang without using an external compiler.
219
220 .if ${COMPILER_FEATURES:Mc++11} && (${__T} == "aarch64" || \
221     ${__T} == "amd64" || ${__TT} == "arm" || ${__T} == "i386")
222 # Clang is enabled, and will be installed as the default /usr/bin/cc.
223 __DEFAULT_YES_OPTIONS+=CLANG CLANG_BOOTSTRAP CLANG_FULL CLANG_IS_CC
224 __DEFAULT_NO_OPTIONS+=GCC GCC_BOOTSTRAP GNUCXX
225 .elif ${COMPILER_FEATURES:Mc++11} && ${__T:Mpowerpc*}
226 # On powerpc, if an external compiler that supports C++11 is used as ${CC},
227 # then Clang is enabled, but GCC is installed as the default /usr/bin/cc.
228 __DEFAULT_YES_OPTIONS+=CLANG CLANG_FULL GCC GCC_BOOTSTRAP GNUCXX
229 __DEFAULT_NO_OPTIONS+=CLANG_BOOTSTRAP CLANG_IS_CC
230 .else
231 # Everything else disables Clang, and uses GCC instead.
232 __DEFAULT_YES_OPTIONS+=GCC GCC_BOOTSTRAP GNUCXX
233 __DEFAULT_NO_OPTIONS+=CLANG CLANG_BOOTSTRAP CLANG_FULL CLANG_IS_CC
234 .endif
235 # In-tree binutils/gcc are older versions without modern architecture support.
236 .if ${__T} == "aarch64" || ${__T} == "riscv64"
237 BROKEN_OPTIONS+=BINUTILS BINUTILS_BOOTSTRAP GCC GCC_BOOTSTRAP GDB
238 .endif
239 .if ${__T} == "riscv64"
240 BROKEN_OPTIONS+=PROFILE # "sorry, unimplemented: profiler support for RISC-V"
241 BROKEN_OPTIONS+=TESTS   # "undefined reference to `_Unwind_Resume'"
242 BROKEN_OPTIONS+=CXX     # "libcxxrt.so: undefined reference to `_Unwind_Resume_or_Rethrow'"
243 .endif
244 .if ${__T} == "aarch64" || ${__T} == "amd64" || ${__T} == "i386" || \
245     ${__T} == "riscv64"
246 __DEFAULT_YES_OPTIONS+=LLVM_LIBUNWIND
247 .else
248 __DEFAULT_NO_OPTIONS+=LLVM_LIBUNWIND
249 .endif
250 .if ${__T} == "aarch64" || ${__T} == "amd64"
251 __DEFAULT_YES_OPTIONS+=LLD LLDB
252 .else
253 __DEFAULT_NO_OPTIONS+=LLD LLDB
254 .endif
255 # LLVM lacks support for FreeBSD 64-bit atomic operations for ARMv4/ARMv5
256 .if ${__T} == "arm" || ${__T} == "armeb"
257 BROKEN_OPTIONS+=LLDB
258 .endif
259 # Only doing soft float API stuff on armv6
260 .if ${__T} != "armv6"
261 BROKEN_OPTIONS+=LIBSOFT
262 .endif
263
264 .include <bsd.mkopt.mk>
265
266 #
267 # MK_* options that default to "yes" if the compiler is a C++11 compiler.
268 #
269 .for var in \
270     LIBCPLUSPLUS
271 .if !defined(MK_${var})
272 .if ${COMPILER_FEATURES:Mc++11}
273 .if defined(WITHOUT_${var})
274 MK_${var}:=     no
275 .else
276 MK_${var}:=     yes
277 .endif
278 .else
279 .if defined(WITH_${var})
280 MK_${var}:=     yes
281 .else
282 MK_${var}:=     no
283 .endif
284 .endif
285 .endif
286 .endfor
287
288 #
289 # Force some options off if their dependencies are off.
290 # Order is somewhat important.
291 #
292 .if !${COMPILER_FEATURES:Mc++11}
293 MK_LLVM_LIBUNWIND:=     no
294 .endif
295
296 .if ${MK_LIBPTHREAD} == "no"
297 MK_LIBTHR:=     no
298 .endif
299
300 .if ${MK_LDNS} == "no"
301 MK_LDNS_UTILS:= no
302 MK_UNBOUND:= no
303 .endif
304
305 .if ${MK_SOURCELESS} == "no"
306 MK_SOURCELESS_HOST:=    no
307 MK_SOURCELESS_UCODE:= no
308 .endif
309
310 .if ${MK_CDDL} == "no"
311 MK_ZFS:=        no
312 MK_CTF:=        no
313 .endif
314
315 .if ${MK_CRYPT} == "no"
316 MK_OPENSSL:=    no
317 MK_OPENSSH:=    no
318 MK_KERBEROS:=   no
319 .endif
320
321 .if ${MK_CXX} == "no"
322 MK_CLANG:=      no
323 MK_GROFF:=      no
324 MK_GNUCXX:=     no
325 MK_TESTS:=      no
326 .endif
327
328 .if ${MK_MAIL} == "no"
329 MK_MAILWRAPPER:= no
330 MK_SENDMAIL:=   no
331 MK_DMAGENT:=    no
332 .endif
333
334 .if ${MK_NETGRAPH} == "no"
335 MK_ATM:=        no
336 MK_BLUETOOTH:=  no
337 .endif
338
339 .if ${MK_OPENSSL} == "no"
340 MK_OPENSSH:=    no
341 MK_KERBEROS:=   no
342 .endif
343
344 .if ${MK_PF} == "no"
345 MK_AUTHPF:=     no
346 .endif
347
348 .if ${MK_TESTS} == "no"
349 MK_DTRACE_TESTS:= no
350 .endif
351
352 .if ${MK_TEXTPROC} == "no"
353 MK_GROFF:=      no
354 .endif
355
356 .if ${MK_CROSS_COMPILER} == "no"
357 MK_BINUTILS_BOOTSTRAP:= no
358 MK_CLANG_BOOTSTRAP:= no
359 MK_ELFTOOLCHAIN_BOOTSTRAP:= no
360 MK_GCC_BOOTSTRAP:= no
361 .endif
362
363 .if ${MK_TOOLCHAIN} == "no"
364 MK_BINUTILS:=   no
365 MK_CLANG:=      no
366 MK_GCC:=        no
367 MK_GDB:=        no
368 MK_INCLUDES:=   no
369 MK_LLDB:=       no
370 .endif
371
372 .if ${MK_CLANG} == "no"
373 MK_CLANG_EXTRAS:= no
374 MK_CLANG_FULL:= no
375 .endif
376
377 #
378 # Set defaults for the MK_*_SUPPORT variables.
379 #
380
381 #
382 # MK_*_SUPPORT options which default to "yes" unless their corresponding
383 # MK_* variable is set to "no".
384 #
385 .for var in \
386     BLACKLIST \
387     BZIP2 \
388     GNU \
389     INET \
390     INET6 \
391     KERBEROS \
392     KVM \
393     NETGRAPH \
394     PAM \
395     TESTS \
396     WIRELESS
397 .if defined(WITHOUT_${var}_SUPPORT) || ${MK_${var}} == "no"
398 MK_${var}_SUPPORT:= no
399 .else
400 MK_${var}_SUPPORT:= yes
401 .endif
402 .endfor
403
404 #
405 # MK_* options whose default value depends on another option.
406 #
407 .for vv in \
408     GSSAPI/KERBEROS \
409     MAN_UTILS/MAN
410 .if defined(WITH_${vv:H})
411 MK_${vv:H}:=    yes
412 .elif defined(WITHOUT_${vv:H})
413 MK_${vv:H}:=    no
414 .else
415 MK_${vv:H}:=    ${MK_${vv:T}}
416 .endif
417 .endfor
418
419 .if !${COMPILER_FEATURES:Mc++11}
420 MK_LLDB:=       no
421 .endif
422
423 # gcc 4.8 and newer supports libc++, so suppress gnuc++ in that case.
424 # while in theory we could build it with that, we don't want to do
425 # that since it creates too much confusion for too little gain.
426 # XXX: This is incomplete and needs X_COMPILER_TYPE/VERSION checks too
427 #      to prevent Makefile.inc1 from bootstrapping unneeded dependencies
428 #      and to support 'make delete-old' when supplying an external toolchain.
429 .if ${COMPILER_TYPE} == "gcc" && ${COMPILER_VERSION} >= 40800
430 MK_GNUCXX:=no
431 MK_GCC:=no
432 .endif
433
434 .endif #  !target(__<src.opts.mk>__)