1#	$NetBSD: bsd.own.mk,v 1.1376 2024/06/08 13:03:41 tsutsui Exp $
2
3# This needs to be before bsd.init.mk
4.if defined(BSD_MK_COMPAT_FILE)
5.include <${BSD_MK_COMPAT_FILE}>
6.endif
7
8.if !defined(_BSD_OWN_MK_)
9_BSD_OWN_MK_=1
10
11MAKECONF?=	/etc/mk.conf
12.-include "${MAKECONF}"
13
14#
15# CPU model, derived from MACHINE_ARCH
16#
17MACHINE_CPU=	${MACHINE_ARCH:C/mips.*e[bl]/mips/:C/sh3e[bl]/sh3/:S/coldfire/m68k/:S/m68000/m68k/:C/e?arm.*/arm/:S/powerpc64/powerpc/:S/aarch64eb/aarch64/:S/or1knd/or1k/:C/riscv../riscv/}
18
19.if (${MACHINE_ARCH} == "mips64el" || \
20     ${MACHINE_ARCH} == "mips64eb" || \
21     ${MACHINE_ARCH} == "mipsn64el" || \
22     ${MACHINE_ARCH} == "mipsn64eb")
23MACHINE_MIPS64= 	1
24.else
25MACHINE_MIPS64= 	0
26.endif
27
28#
29# Subdirectory used below ${RELEASEDIR} when building a release
30#
31.if \
32    ${MACHINE:Mevbarm} || \
33    ${MACHINE:Mevbmips} || \
34    ${MACHINE:Mevbsh3} || \
35    ${MACHINE:Mriscv}
36RELEASEMACHINEDIR?=	${MACHINE}-${MACHINE_ARCH}
37.else
38RELEASEMACHINEDIR?=	${MACHINE}
39.endif
40
41#
42# Subdirectory or path component used for the following paths:
43#   distrib/${RELEASEMACHINE}
44#   distrib/notes/${RELEASEMACHINE}
45#   etc/etc.${RELEASEMACHINE}
46# Used when building a release.
47#
48RELEASEMACHINE?=	${MACHINE}
49
50#
51# NEED_OWN_INSTALL_TARGET is set to "no" by pkgsrc/mk/bsd.pkg.mk to
52# ensure that things defined by <bsd.own.mk> (default targets,
53# INSTALL_FILE, etc.) are not conflicting with bsd.pkg.mk.
54#
55NEED_OWN_INSTALL_TARGET?=	yes
56
57#
58# This lists the platforms which do not have working in-tree toolchains.  For
59# the in-tree gcc toolchain, this list is empty.
60#
61# If some future port is not supported by the in-tree toolchain, this should
62# be set to "yes" for that port only.
63#
64# .if ${MACHINE} == "playstation2"
65# TOOLCHAIN_MISSING?=	yes
66# .endif
67
68TOOLCHAIN_MISSING?=	no
69
70#
71# GCC Using platforms.
72#
73.if ${MKGCC:Uyes} != "no"						# {
74
75#
76# What GCC is used?
77#
78HAVE_GCC?=	10
79
80#
81# Platforms that can't run a modern GCC natively
82.if ${MACHINE_ARCH} == "m68000"
83MKGCCCMDS?=	no
84.endif
85
86#
87# We import the old gcc as "gcc.old" when upgrading.  EXTERNAL_GCC_SUBDIR is
88# set to the relevant subdirectory in src/external/gpl3 for his HAVE_GCC.
89#
90.if ${HAVE_GCC} == 10
91EXTERNAL_GCC_SUBDIR?=	gcc.old
92.elif ${HAVE_GCC} == 12
93EXTERNAL_GCC_SUBDIR?=	gcc
94.else
95EXTERNAL_GCC_SUBDIR?=	/does/not/exist
96.endif
97
98.else	# MKGCC == no							# } {
99MKGCCCMDS?=	no
100.endif	# MKGCC == no							# }
101
102#
103# What binutils is used?
104#
105HAVE_BINUTILS?=	239
106
107.if ${HAVE_BINUTILS} == 239
108EXTERNAL_BINUTILS_SUBDIR=	binutils
109.elif ${HAVE_BINUTILS} == 234
110EXTERNAL_BINUTILS_SUBDIR=	binutils.old
111.else
112EXTERNAL_BINUTILS_SUBDIR=	/does/not/exist
113.endif
114
115#
116# What GDB is used?
117#
118HAVE_GDB?=	1320
119
120.if ${HAVE_GDB} == 1320
121EXTERNAL_GDB_SUBDIR=		gdb
122.elif ${HAVE_GDB} == 1100
123EXTERNAL_GDB_SUBDIR=		gdb.old
124.else
125EXTERNAL_GDB_SUBDIR=		/does/not/exist
126.endif
127
128#
129# What OpenSSL is used?
130#
131HAVE_OPENSSL?=	30
132
133.if ${HAVE_OPENSSL} == 30
134EXTERNAL_OPENSSL_SUBDIR=openssl
135.elif ${HAVE_OPENSSL} == 11
136EXTERNAL_OPENSSL_SUBDIR=openssl.old
137.else
138EXTERNAL_OPENSSL_SUBDIR=/does/not/exist
139.endif
140
141#
142# Does the platform support ACPI?
143#
144.if ${MACHINE} == "i386" || \
145    ${MACHINE} == "amd64" || \
146    ${MACHINE} == "ia64" || \
147    ${MACHINE_ARCH:Maarch64*}
148HAVE_ACPI=	yes
149.else
150HAVE_ACPI=	no
151.endif
152
153#
154# Does the platform support UEFI?
155#
156.if ${MACHINE} == "i386" || \
157    ${MACHINE} == "amd64" || \
158    ${MACHINE} == "ia64" || \
159    ${MACHINE_ARCH:Mearmv7*} || \
160    ${MACHINE_ARCH:Maarch64*} || \
161    ${MACHINE_ARCH} == "riscv64"
162HAVE_UEFI=	yes
163.else
164HAVE_UEFI=	no
165.endif
166
167#
168# Does the platform support NVMM?
169#
170.if ${MACHINE_ARCH} == "x86_64"
171HAVE_NVMM=	yes
172.else
173HAVE_NVMM=	no
174.endif
175
176
177.if ${MACHINE_ARCH:Mearm*}
178_LIBC_COMPILER_RT.${MACHINE_ARCH}=	yes
179.endif
180
181_LIBC_COMPILER_RT.aarch64=	yes
182_LIBC_COMPILER_RT.aarch64eb=	yes
183_LIBC_COMPILER_RT.i386=		yes
184_LIBC_COMPILER_RT.powerpc=	yes
185_LIBC_COMPILER_RT.powerpc64=	yes
186_LIBC_COMPILER_RT.sparc=	yes
187_LIBC_COMPILER_RT.sparc64=	yes
188_LIBC_COMPILER_RT.x86_64=	yes
189
190.if ${HAVE_LLVM:Uno} == "yes" && ${_LIBC_COMPILER_RT.${MACHINE_ARCH}:Uno} == "yes"
191HAVE_LIBGCC?=	no
192.else
193HAVE_LIBGCC?=	yes
194.endif
195
196
197# Should libgcc have unwinding code?
198.if ${HAVE_LLVM:Uno} == "yes" || ${MACHINE_ARCH:Mearm*}
199HAVE_LIBGCC_EH?=	no
200.else
201HAVE_LIBGCC_EH?=	yes
202.endif
203
204# Coverity does not like SSP
205.if defined(COVERITY_TOP_CONFIG) || \
206    ${MACHINE} == "alpha" || \
207    ${MACHINE} == "hppa" || \
208    ${MACHINE} == "ia64" || \
209    ${MACHINE_CPU} == "mips"
210HAVE_SSP?=	no
211.else
212HAVE_SSP?=	yes
213.if !defined(NOFORT) && ${USE_FORT:Uno} != "no"
214USE_SSP?=	yes
215.endif
216.endif
217
218#
219# What version of jemalloc we use (100 is the one
220# built-in to libc from 2005 (pre version 3).
221#
222.if ${MACHINE_ARCH} == "vax" || ${MACHINE} == "sun2"
223HAVE_JEMALLOC?=		100
224.else
225HAVE_JEMALLOC?=		510
226.endif
227
228.if empty(.MAKEFLAGS:tW:M*-V .OBJDIR*)
229.if defined(MAKEOBJDIRPREFIX) || defined(MAKEOBJDIR)
230PRINTOBJDIR=	${MAKE} -r -V .OBJDIR -f /dev/null xxx
231.else
232PRINTOBJDIR=	${MAKE} -V .OBJDIR
233.endif
234.else
235PRINTOBJDIR=	echo /error/bsd.own.mk/PRINTOBJDIR # avoid infinite recursion
236.endif
237
238#
239# Make sure we set _NETBSD_REVISIONID in CPPFLAGS if requested.
240#
241.ifdef NETBSD_REVISIONID
242_NETBSD_REVISIONID_STR=	"${NETBSD_REVISIONID}"
243CPPFLAGS+=	-D_NETBSD_REVISIONID=${_NETBSD_REVISIONID_STR:Q}
244.endif
245
246#
247# Determine if running in the NetBSD source tree by checking for the
248# existence of build.sh and tools/ in the current or a parent directory,
249# and setting _SRC_TOP_ to the result.
250#
251.if !defined(_SRC_TOP_)			# {
252_SRC_TOP_!= cd "${.CURDIR}"; while :; do \
253		here=$$(pwd); \
254		[ -f build.sh  ] && [ -d tools ] && { echo $$here; break; }; \
255		case $$here in /) echo ""; break;; esac; \
256		cd ..; done
257
258.MAKEOVERRIDES+=	_SRC_TOP_
259
260.endif					# }
261
262#
263# If _SRC_TOP_ != "", we're within the NetBSD source tree.
264# * Set defaults for NETBSDSRCDIR and _SRC_TOP_OBJ_.
265# * Define _NETBSD_VERSION_DEPENDS.  Targets that depend on the
266#   NetBSD version, or on variables defined at build time, can
267#   declare a dependency on ${_NETBSD_VERSION_DEPENDS}.
268#
269.if (${_SRC_TOP_} != "")		# {
270
271NETBSDSRCDIR?=	${_SRC_TOP_}
272
273.if !defined(_SRC_TOP_OBJ_)
274_SRC_TOP_OBJ_!=		cd "${_SRC_TOP_}" && ${PRINTOBJDIR}
275.MAKEOVERRIDES+=	_SRC_TOP_OBJ_
276.endif
277
278_NETBSD_VERSION_DEPENDS=	${_SRC_TOP_OBJ_}/params
279_NETBSD_VERSION_DEPENDS+=	${NETBSDSRCDIR}/sys/sys/param.h
280_NETBSD_VERSION_DEPENDS+=	${NETBSDSRCDIR}/sys/conf/newvers.sh
281_NETBSD_VERSION_DEPENDS+=	${NETBSDSRCDIR}/sys/conf/osrelease.sh
282${_SRC_TOP_OBJ_}/params: .NOTMAIN .OPTIONAL # created by top level "make build"
283
284.endif	# _SRC_TOP_ != ""		# }
285
286
287.if (${_SRC_TOP_} != "") && \
288    (${TOOLCHAIN_MISSING} == "no" || defined(EXTERNAL_TOOLCHAIN))
289USETOOLS?=	yes
290.endif
291USETOOLS?=	no
292
293
294.if ${MACHINE_ARCH} == "mips" || ${MACHINE_ARCH} == "mips64" || \
295    ${MACHINE_ARCH} == "sh3"
296.BEGIN:
297	@echo "Must set MACHINE_ARCH to one of ${MACHINE_ARCH}eb or ${MACHINE_ARCH}el"
298	@false
299.elif defined(REQUIRETOOLS) && \
300      (${TOOLCHAIN_MISSING} == "no" || defined(EXTERNAL_TOOLCHAIN)) && \
301      ${USETOOLS} == "no"
302.BEGIN:
303	@echo "USETOOLS=no, but this component requires a version-specific host toolchain"
304	@false
305.endif
306
307#
308# Host platform information; may be overridden
309#
310.include <bsd.host.mk>
311
312.if ${USETOOLS} == "yes"						# {
313
314#
315# Provide a default for TOOLDIR.
316#
317.if !defined(TOOLDIR)
318TOOLDIR:=	${_SRC_TOP_OBJ_}/tooldir.${HOST_OSTYPE}
319.MAKEOVERRIDES+= TOOLDIR
320.endif
321
322#
323# This is the prefix used for the NetBSD-sourced tools.
324#
325_TOOL_PREFIX?=	nb
326
327#
328# If an external toolchain base is specified, use it.
329#
330.if defined(EXTERNAL_TOOLCHAIN)						# {
331AR=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-ar
332AS=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-as
333ELFEDIT=	${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-elfedit
334LD=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-ld
335NM=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-nm
336OBJCOPY=	${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-objcopy
337OBJDUMP=	${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-objdump
338RANLIB=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-ranlib
339READELF=	${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-readelf
340SIZE=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-size
341STRINGS=	${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-strings
342STRIP=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-strip
343
344TOOL_CC.gcc=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-gcc
345TOOL_CPP.gcc=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-cpp
346TOOL_CXX.gcc=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-c++
347TOOL_FC.gcc=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-gfortran
348TOOL_OBJC.gcc=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-gcc
349
350TOOL_CC.clang=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-clang
351TOOL_CPP.clang=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-clang-cpp
352TOOL_CXX.clang=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-clang++
353TOOL_OBJC.clang=	${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-clang
354.else									# } {
355# Define default locations for common tools.
356.if ${USETOOLS_BINUTILS:Uyes} == "yes"					#  {
357AR=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-ar
358AS=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-as
359ELFEDIT=	${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-elfedit
360LD=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-ld
361NM=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-nm
362OBJCOPY=	${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-objcopy
363OBJDUMP=	${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-objdump
364RANLIB=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-ranlib
365READELF=	${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-readelf
366SIZE=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-size
367STRINGS=	${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-strings
368STRIP=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-strip
369
370# GCC supports C, C++, Fortran and Objective C
371TOOL_CC.gcc=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-gcc
372TOOL_CPP.gcc=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-cpp
373TOOL_CXX.gcc=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-c++
374TOOL_FC.gcc=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-gfortran
375TOOL_OBJC.gcc=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-gcc
376.endif									#  }
377
378# Clang supports C, C++ and Objective C
379TOOL_CC.clang=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-clang
380TOOL_CPP.clang=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-clang-cpp
381TOOL_CXX.clang=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-clang++
382TOOL_OBJC.clang=	${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-clang
383
384# PCC supports C and Fortran
385TOOL_CC.pcc=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-pcc
386TOOL_CPP.pcc=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-pcpp
387TOOL_CXX.pcc=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-p++
388.endif	# EXTERNAL_TOOLCHAIN						# }
389
390#
391# Make sure DESTDIR is set, so that builds with these tools always
392# get appropriate -nostdinc, -nostdlib, etc. handling.  The default is
393# <empty string>, meaning start from /, the root directory.
394#
395DESTDIR?=
396
397# Don't append another copy of sysroot (coming from COMPATCPPFLAGS etc.)
398# because it confuses Coverity. Still we need to cov-configure specially
399# for each specific sysroot argument.
400# Also don't add a sysroot at all if a rumpkernel build.
401.if !defined(HOSTPROG) && !defined(HOSTLIB) && !defined(RUMPRUN)
402.  if ${DESTDIR} != ""
403.	if empty(CPPFLAGS:M*--sysroot=*)
404CPPFLAGS+=	--sysroot=${DESTDIR}
405.	endif
406LDFLAGS+=	--sysroot=${DESTDIR}
407.  else
408.	if empty(CPPFLAGS:M*--sysroot=*)
409CPPFLAGS+=	--sysroot=/
410.	endif
411LDFLAGS+=	--sysroot=/
412.  endif
413.endif
414
415DBSYM=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-dbsym
416ARM_ELF2AOUT=	${TOOLDIR}/bin/${_TOOL_PREFIX}arm-elf2aout
417M68K_ELF2AOUT=	${TOOLDIR}/bin/${_TOOL_PREFIX}m68k-elf2aout
418MIPS_ELF2ECOFF=	${TOOLDIR}/bin/${_TOOL_PREFIX}mips-elf2ecoff
419INSTALL=	${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-install
420LEX=		${TOOLDIR}/bin/${_TOOL_PREFIX}lex
421LINT=		CC=${CC:Q} ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-lint
422LORDER=		NM=${NM:Q} MKTEMP=${TOOL_MKTEMP:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}lorder
423MKDEP=		CC=${CC:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}mkdep
424MKDEPCXX=	CC=${CXX:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}mkdep
425PAXCTL=		${TOOLDIR}/bin/${_TOOL_PREFIX}paxctl
426TSORT=		${TOOLDIR}/bin/${_TOOL_PREFIX}tsort -q
427YACC=		${TOOLDIR}/bin/${_TOOL_PREFIX}yacc
428
429TOOL_AMIGAAOUT2BB=	${TOOLDIR}/bin/${_TOOL_PREFIX}amiga-aout2bb
430TOOL_AMIGAELF2BB=	${TOOLDIR}/bin/${_TOOL_PREFIX}amiga-elf2bb
431TOOL_AMIGATXLT=		${TOOLDIR}/bin/${_TOOL_PREFIX}amiga-txlt
432TOOL_ASN1_COMPILE=	${TOOLDIR}/bin/${_TOOL_PREFIX}asn1_compile
433TOOL_AWK=		${TOOLDIR}/bin/${_TOOL_PREFIX}awk
434TOOL_CAP_MKDB=		${TOOLDIR}/bin/${_TOOL_PREFIX}cap_mkdb
435TOOL_CAT=		${TOOLDIR}/bin/${_TOOL_PREFIX}cat
436TOOL_CKSUM=		${TOOLDIR}/bin/${_TOOL_PREFIX}cksum
437TOOL_CLANG_TBLGEN=	${TOOLDIR}/bin/${_TOOL_PREFIX}clang-tblgen
438TOOL_COMPILE_ET=	${TOOLDIR}/bin/${_TOOL_PREFIX}compile_et
439TOOL_CONFIG=		${TOOLDIR}/bin/${_TOOL_PREFIX}config
440TOOL_CRUNCHGEN=		MAKE=${.MAKE:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}crunchgen
441TOOL_CTAGS=		${TOOLDIR}/bin/${_TOOL_PREFIX}ctags
442TOOL_CTFCONVERT=	${TOOLDIR}/bin/${_TOOL_PREFIX}ctfconvert
443TOOL_CTFMERGE=		${TOOLDIR}/bin/${_TOOL_PREFIX}ctfmerge
444TOOL_CVSLATEST=		${TOOLDIR}/bin/${_TOOL_PREFIX}cvslatest
445TOOL_DATE=		${TOOLDIR}/bin/${_TOOL_PREFIX}date
446TOOL_DB=		${TOOLDIR}/bin/${_TOOL_PREFIX}db
447TOOL_DISKLABEL=		${TOOLDIR}/bin/${_TOOL_PREFIX}disklabel
448TOOL_DTC=		${TOOLDIR}/bin/${_TOOL_PREFIX}dtc
449TOOL_EQN=		${TOOLDIR}/bin/${_TOOL_PREFIX}eqn
450TOOL_FDISK=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-fdisk
451TOOL_FGEN=		${TOOLDIR}/bin/${_TOOL_PREFIX}fgen
452TOOL_GENASSYM=		${TOOLDIR}/bin/${_TOOL_PREFIX}genassym
453TOOL_GENCAT=		${TOOLDIR}/bin/${_TOOL_PREFIX}gencat
454TOOL_GMAKE=		${TOOLDIR}/bin/${_TOOL_PREFIX}gmake
455TOOL_GPT=		${TOOLDIR}/bin/${_TOOL_PREFIX}gpt
456TOOL_GREP=		${TOOLDIR}/bin/${_TOOL_PREFIX}grep
457GROFF_SHARE_PATH=	${TOOLDIR}/share/groff
458TOOL_GROFF_ENV= \
459    GROFF_ENCODING= \
460    GROFF_BIN_PATH=${TOOLDIR}/lib/groff \
461    GROFF_FONT_PATH=${GROFF_SHARE_PATH}/site-font:${GROFF_SHARE_PATH}/font \
462    GROFF_TMAC_PATH=${GROFF_SHARE_PATH}/site-tmac:${GROFF_SHARE_PATH}/tmac
463TOOL_GROFF=		${TOOL_GROFF_ENV} ${TOOLDIR}/bin/${_TOOL_PREFIX}groff ${GROFF_FLAGS}
464TOOL_GROPS=		${TOOL_GROFF_ENV} ${TOOLDIR}/lib/groff/grops
465
466TOOL_HEXDUMP=		${TOOLDIR}/bin/${_TOOL_PREFIX}hexdump
467TOOL_HP300MKBOOT=	${TOOLDIR}/bin/${_TOOL_PREFIX}hp300-mkboot
468TOOL_HPPAMKBOOT=	${TOOLDIR}/bin/${_TOOL_PREFIX}hppa-mkboot
469TOOL_INDXBIB=		${TOOLDIR}/bin/${_TOOL_PREFIX}indxbib
470TOOL_INSTALLBOOT=	${TOOLDIR}/bin/${_TOOL_PREFIX}installboot
471TOOL_INSTALL_INFO=	${TOOLDIR}/bin/${_TOOL_PREFIX}install-info
472TOOL_JOIN=		${TOOLDIR}/bin/${_TOOL_PREFIX}join
473TOOL_LLVM_TBLGEN=	${TOOLDIR}/bin/${_TOOL_PREFIX}llvm-tblgen
474TOOL_M4=		${TOOLDIR}/bin/${_TOOL_PREFIX}m4
475TOOL_MACPPCFIXCOFF=	${TOOLDIR}/bin/${_TOOL_PREFIX}macppc-fixcoff
476TOOL_MACPPCINSTALLBOOT=	${TOOLDIR}/bin/${_TOOL_PREFIX}macppc_installboot
477TOOL_MAKEFS=		${TOOLDIR}/bin/${_TOOL_PREFIX}makefs
478TOOL_MAKEINFO=		${TOOLDIR}/bin/${_TOOL_PREFIX}makeinfo
479TOOL_MAKEKEYS=		${TOOLDIR}/bin/${_TOOL_PREFIX}makekeys
480TOOL_MAKESTRS=		${TOOLDIR}/bin/${_TOOL_PREFIX}makestrs
481TOOL_MAKEWHATIS=	${TOOLDIR}/bin/${_TOOL_PREFIX}makewhatis
482TOOL_MANDOC_ASCII=	${TOOLDIR}/bin/${_TOOL_PREFIX}mandoc -Tascii
483TOOL_MANDOC_HTML=	${TOOLDIR}/bin/${_TOOL_PREFIX}mandoc -Thtml
484TOOL_MANDOC_LINT=	${TOOLDIR}/bin/${_TOOL_PREFIX}mandoc -Tlint
485TOOL_MDSETIMAGE=	${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-mdsetimage
486TOOL_MENUC=		MENUDEF=${TOOLDIR}/share/misc ${TOOLDIR}/bin/${_TOOL_PREFIX}menuc
487TOOL_ARMELF2AOUT=	${TOOLDIR}/bin/${_TOOL_PREFIX}arm-elf2aout
488TOOL_M68KELF2AOUT=	${TOOLDIR}/bin/${_TOOL_PREFIX}m68k-elf2aout
489TOOL_MIPSELF2ECOFF=	${TOOLDIR}/bin/${_TOOL_PREFIX}mips-elf2ecoff
490TOOL_MKCSMAPPER=	${TOOLDIR}/bin/${_TOOL_PREFIX}mkcsmapper
491TOOL_MKESDB=		${TOOLDIR}/bin/${_TOOL_PREFIX}mkesdb
492TOOL_MKHYBRID=		${TOOLDIR}/bin/${_TOOL_PREFIX}mkhybrid
493TOOL_MKLOCALE=		${TOOLDIR}/bin/${_TOOL_PREFIX}mklocale
494TOOL_MKMAGIC=		${TOOLDIR}/bin/${_TOOL_PREFIX}file
495TOOL_MKNOD=		${TOOLDIR}/bin/${_TOOL_PREFIX}mknod
496TOOL_MKTEMP=		${TOOLDIR}/bin/${_TOOL_PREFIX}mktemp
497TOOL_MKUBOOTIMAGE=	${TOOLDIR}/bin/${_TOOL_PREFIX}mkubootimage
498TOOL_ELFTOSB=		${TOOLDIR}/bin/${_TOOL_PREFIX}elftosb
499TOOL_MSGC=		MSGDEF=${TOOLDIR}/share/misc ${TOOLDIR}/bin/${_TOOL_PREFIX}msgc
500TOOL_MTREE=		${TOOLDIR}/bin/${_TOOL_PREFIX}mtree
501TOOL_MVME68KWRTVID=	${TOOLDIR}/bin/${_TOOL_PREFIX}mvme68k-wrtvid
502TOOL_NBPERF=		${TOOLDIR}/bin/${_TOOL_PREFIX}perf
503TOOL_NCDCS=		${TOOLDIR}/bin/${_TOOL_PREFIX}ibmnws-ncdcs
504TOOL_PAX=		${TOOLDIR}/bin/${_TOOL_PREFIX}pax
505TOOL_PIC=		${TOOLDIR}/bin/${_TOOL_PREFIX}pic
506TOOL_PIGZ=		${TOOLDIR}/bin/${_TOOL_PREFIX}pigz
507TOOL_XZ=		${TOOLDIR}/bin/${_TOOL_PREFIX}xz
508TOOL_PKG_CREATE=	${TOOLDIR}/bin/${_TOOL_PREFIX}pkg_create
509TOOL_POWERPCMKBOOTIMAGE=${TOOLDIR}/bin/${_TOOL_PREFIX}powerpc-mkbootimage
510TOOL_PWD_MKDB=		${TOOLDIR}/bin/${_TOOL_PREFIX}pwd_mkdb
511TOOL_REFER=		${TOOLDIR}/bin/${_TOOL_PREFIX}refer
512TOOL_ROFF_ASCII=	${TOOL_GROFF_ENV} ${TOOLDIR}/bin/${_TOOL_PREFIX}nroff
513TOOL_ROFF_DOCASCII=	${TOOL_GROFF} -Tascii
514TOOL_ROFF_DOCHTML=	${TOOL_GROFF} -Thtml
515TOOL_ROFF_DVI=		${TOOL_GROFF} -Tdvi ${ROFF_PAGESIZE}
516TOOL_ROFF_HTML=		${TOOL_GROFF} -Tlatin1 -mdoc2html
517TOOL_ROFF_PS=		${TOOL_GROFF} -Tps ${ROFF_PAGESIZE}
518TOOL_ROFF_RAW=		${TOOL_GROFF} -Z
519TOOL_RPCGEN=		RPCGEN_CPP=${CPP:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}rpcgen
520TOOL_SED=		${TOOLDIR}/bin/${_TOOL_PREFIX}sed
521TOOL_SLC=		${TOOLDIR}/bin/${_TOOL_PREFIX}slc
522TOOL_SOELIM=		${TOOLDIR}/bin/${_TOOL_PREFIX}soelim
523TOOL_SORTINFO=		${TOOLDIR}/bin/${_TOOL_PREFIX}sortinfo
524TOOL_SPARKCRC=		${TOOLDIR}/bin/${_TOOL_PREFIX}sparkcrc
525TOOL_STAT=		${TOOLDIR}/bin/${_TOOL_PREFIX}stat
526TOOL_STRFILE=		${TOOLDIR}/bin/${_TOOL_PREFIX}strfile
527TOOL_SUNLABEL=		${TOOLDIR}/bin/${_TOOL_PREFIX}sunlabel
528TOOL_TBL=		${TOOLDIR}/bin/${_TOOL_PREFIX}tbl
529TOOL_TIC=		${TOOLDIR}/bin/${_TOOL_PREFIX}tic
530TOOL_UUDECODE=		${TOOLDIR}/bin/${_TOOL_PREFIX}uudecode
531TOOL_VGRIND=		${TOOLDIR}/bin/${_TOOL_PREFIX}vgrind -f
532TOOL_VFONTEDPR=		${TOOLDIR}/libexec/${_TOOL_PREFIX}vfontedpr
533TOOL_ZIC=		${TOOLDIR}/bin/${_TOOL_PREFIX}zic
534
535.else	# USETOOLS != yes						# } {
536
537# Clang supports C, C++ and Objective C
538TOOL_CC.clang=		clang
539TOOL_CPP.clang=		clang-cpp
540TOOL_CXX.clang=		clang++
541TOOL_OBJC.clang=	clang
542
543# GCC supports C, C++, Fortran and Objective C
544TOOL_CC.gcc=		gcc
545TOOL_CPP.gcc=		cpp
546TOOL_CXX.gcc=		c++
547TOOL_FC.gcc=		gfortran
548TOOL_OBJC.gcc=		gcc
549
550# PCC supports C and Fortran
551TOOL_CC.pcc=		pcc
552TOOL_CPP.pcc=		pcpp
553TOOL_CXX.pcc=		p++
554
555TOOL_AMIGAAOUT2BB=	amiga-aout2bb
556TOOL_AMIGAELF2BB=	amiga-elf2bb
557TOOL_AMIGATXLT=		amiga-txlt
558TOOL_ASN1_COMPILE=	asn1_compile
559TOOL_AWK=		awk
560TOOL_CAP_MKDB=		cap_mkdb
561TOOL_CAT=		cat
562TOOL_CKSUM=		cksum
563TOOL_CLANG_TBLGEN=	clang-tblgen
564TOOL_COMPILE_ET=	compile_et
565TOOL_CONFIG=		config
566TOOL_CRUNCHGEN=		crunchgen
567TOOL_CTAGS=		ctags
568TOOL_CTFCONVERT=	ctfconvert
569TOOL_CTFMERGE=		ctfmerge
570TOOL_CVSLATEST=		cvslatest
571TOOL_DATE=		date
572TOOL_DB=		db
573TOOL_DISKLABEL=		disklabel
574TOOL_DTC=		dtc
575TOOL_EQN=		eqn
576TOOL_FDISK=		fdisk
577TOOL_FGEN=		fgen
578TOOL_GENASSYM=		genassym
579TOOL_GENCAT=		gencat
580TOOL_GMAKE=		gmake
581TOOL_GPT=		gpt
582TOOL_GREP=		grep
583TOOL_GROFF=		groff
584TOOL_GROPS=		grops
585TOOL_HEXDUMP=		hexdump
586TOOL_HP300MKBOOT=	hp300-mkboot
587TOOL_HPPAMKBOOT=	hppa-mkboot
588TOOL_INDXBIB=		indxbib
589TOOL_INSTALLBOOT=	installboot
590TOOL_INSTALL_INFO=	install-info
591TOOL_JOIN=		join
592TOOL_LLVM_TBLGEN=	llvm-tblgen
593TOOL_M4=		m4
594TOOL_MACPPCFIXCOFF=	macppc-fixcoff
595TOOL_MAKEFS=		makefs
596TOOL_MAKEINFO=		makeinfo
597TOOL_MAKEKEYS=		makekeys
598TOOL_MAKESTRS=		makestrs
599TOOL_MAKEWHATIS=	/usr/libexec/makewhatis
600TOOL_MANDOC_ASCII=	mandoc -Tascii
601TOOL_MANDOC_HTML=	mandoc -Thtml
602TOOL_MANDOC_LINT=	mandoc -Tlint
603TOOL_MDSETIMAGE=	mdsetimage
604TOOL_MENUC=		menuc
605TOOL_ARMELF2AOUT=	arm-elf2aout
606TOOL_M68KELF2AOUT=	m68k-elf2aout
607TOOL_MIPSELF2ECOFF=	mips-elf2ecoff
608TOOL_MKCSMAPPER=	mkcsmapper
609TOOL_MKESDB=		mkesdb
610TOOL_MKLOCALE=		mklocale
611TOOL_MKMAGIC=		file
612TOOL_MKNOD=		mknod
613TOOL_MKTEMP=		mktemp
614TOOL_MKUBOOTIMAGE=	mkubootimage
615TOOL_ELFTOSB=		elftosb
616TOOL_MSGC=		msgc
617TOOL_MTREE=		mtree
618TOOL_MVME68KWRTVID=	wrtvid
619TOOL_NBPERF=		nbperf
620TOOL_NCDCS=		ncdcs
621TOOL_PAX=		pax
622TOOL_PIC=		pic
623TOOL_PIGZ=		pigz
624TOOL_XZ=		xz
625TOOL_PKG_CREATE=	pkg_create
626TOOL_POWERPCMKBOOTIMAGE=powerpc-mkbootimage
627TOOL_PWD_MKDB=		pwd_mkdb
628TOOL_REFER=		refer
629TOOL_ROFF_ASCII=	nroff
630TOOL_ROFF_DOCASCII=	${TOOL_GROFF} -Tascii
631TOOL_ROFF_DOCHTML=	${TOOL_GROFF} -Thtml
632TOOL_ROFF_DVI=		${TOOL_GROFF} -Tdvi ${ROFF_PAGESIZE}
633TOOL_ROFF_HTML=		${TOOL_GROFF} -Tlatin1 -mdoc2html
634TOOL_ROFF_PS=		${TOOL_GROFF} -Tps ${ROFF_PAGESIZE}
635TOOL_ROFF_RAW=		${TOOL_GROFF} -Z
636TOOL_RPCGEN=		rpcgen
637TOOL_SED=		sed
638TOOL_SOELIM=		soelim
639TOOL_SORTINFO=		sortinfo
640TOOL_SPARKCRC=		sparkcrc
641TOOL_STAT=		stat
642TOOL_STRFILE=		strfile
643TOOL_SUNLABEL=		sunlabel
644TOOL_TBL=		tbl
645TOOL_TIC=		tic
646TOOL_UUDECODE=		uudecode
647TOOL_VGRIND=		vgrind -f
648TOOL_VFONTEDPR=		/usr/libexec/vfontedpr
649TOOL_ZIC=		zic
650
651.endif	# USETOOLS != yes						# }
652
653# Standalone code should not be compiled with PIE or CTF
654# Should create a better test
655.if defined(BINDIR) && ${BINDIR} == "/usr/mdec"
656NOPIE=			# defined
657NOCTF=			# defined
658.elif ${MACHINE} == "sun2"
659NOPIE=			# we don't have PIC, so no PIE
660.endif
661
662# Fallback to ensure that all variables are defined to something
663TOOL_CC.false=		false
664TOOL_CPP.false=		false
665TOOL_CXX.false=		false
666TOOL_FC.false=		false
667TOOL_OBJC.false=	false
668
669AVAILABLE_COMPILER?=	${HAVE_PCC:Dpcc} ${HAVE_LLVM:Dclang} ${HAVE_GCC:Dgcc} false
670
671.for _t in CC CPP CXX FC OBJC
672ACTIVE_${_t}=	${AVAILABLE_COMPILER:@.c.@ ${ !defined(UNSUPPORTED_COMPILER.${.c.}) && defined(TOOL_${_t}.${.c.}) :? ${.c.} : }@:[1]}
673SUPPORTED_${_t}=${AVAILABLE_COMPILER:Nfalse:@.c.@ ${ !defined(UNSUPPORTED_COMPILER.${.c.}) && defined(TOOL_${_t}.${.c.}) :? ${.c.} : }@}
674.endfor
675# make bugs prevent moving this into the .for loop
676CC=		${TOOL_CC.${ACTIVE_CC}}
677CPP=		${TOOL_CPP.${ACTIVE_CPP}}
678CXX=		${TOOL_CXX.${ACTIVE_CXX}}
679FC=		${TOOL_FC.${ACTIVE_FC}}
680OBJC=		${TOOL_OBJC.${ACTIVE_OBJC}}
681
682#
683# Clang and GCC compiler-specific options, usually to disable warnings.
684# The naming convention is "CC" + the compiler flag converted
685# to upper case, with '-' and '=' changed to '_' a la `tr -=a-z __A-Z`.
686# For variable naming purposes, treat -Werror=FLAG as -WFLAG,
687# and -Wno-error=FLAG as -Wno-FLAG (usually from Clang).
688#
689# E.g., CC_WNO_ADDRESS_OF_PACKED_MEMBER contains
690# both -Wno-error=address-of-packed-member for Clang,
691# and -Wno-address-of-packed-member for GCC 9+.
692#
693# Use these with e.g.
694#	COPTS.foo.c+= ${CC_WNO_ADDRESS_OF_PACKED_MEMBER}
695#
696CC_WNO_ADDRESS_OF_PACKED_MEMBER=${${ACTIVE_CC} == "clang" :? -Wno-error=address-of-packed-member :} \
697				${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 9:? -Wno-address-of-packed-member :}
698
699CC_WNO_ARRAY_BOUNDS=		${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 12:? -Wno-array-bounds :}
700CC_WNO_CAST_FUNCTION_TYPE=	${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 8:? -Wno-cast-function-type :}
701CC_WNO_FORMAT_OVERFLOW=		${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 7:? -Wno-format-overflow :}
702CC_WNO_FORMAT_TRUNCATION=	${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 7:? -Wno-format-truncation :}
703CC_WNO_IMPLICIT_FALLTHROUGH=	${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 7:? -Wno-implicit-fallthrough :}
704CC_WNO_MAYBE_UNINITIALIZED=	${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 10:? -Wno-maybe-uninitialized :}
705CC_WNO_MISSING_TEMPLATE_KEYWORD=${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 12:? -Wno-missing-template-keyword :}
706CC_WNO_REGISTER=		${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 12:? -Wno-register :}
707CC_WNO_RETURN_LOCAL_ADDR=	${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 10:? -Wno-return-local-addr :}
708CC_WNO_STRINGOP_OVERFLOW=	${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 7:? -Wno-stringop-overflow :}
709CC_WNO_STRINGOP_OVERREAD=	${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 12:? -Wno-stringop-overread :}
710CC_WNO_STRINGOP_TRUNCATION=	${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 8:? -Wno-stringop-truncation :}
711
712# For each ${MACHINE_CPU}, list the ports that use it.
713MACHINES.aarch64=	evbarm
714MACHINES.alpha=		alpha
715MACHINES.arm=		acorn32 cats epoc32 evbarm hpcarm \
716			iyonix netwinder shark zaurus
717MACHINES.coldfire=	evbcf
718MACHINES.i386=		i386
719MACHINES.ia64=		ia64
720MACHINES.hppa=		hppa
721MACHINES.m68000=	sun2
722MACHINES.m68k=		amiga atari cesfic hp300 luna68k mac68k \
723			mvme68k news68k next68k sun3 virt68k x68k
724MACHINES.mips=		algor arc cobalt emips evbmips ews4800mips \
725			hpcmips mipsco newsmips pmax sbmips sgimips
726MACHINES.or1k=		or1k
727MACHINES.powerpc=	amigappc bebox evbppc ibmnws macppc mvmeppc \
728			ofppc prep rs6000 sandpoint
729MACHINES.riscv=		riscv
730MACHINES.sh3=		dreamcast evbsh3 hpcsh landisk mmeye
731MACHINES.sparc=		sparc sparc64
732MACHINES.sparc64=	sparc64
733MACHINES.vax=		vax
734MACHINES.x86_64=	amd64
735
736# OBJCOPY flags to create a.out binaries for old firmware
737# shared among src/distrib and ${MACHINE}/conf/Makefile.${MACHINE}.inc
738.if ${MACHINE_CPU} == "arm"
739OBJCOPY_ELF2AOUT_FLAGS?=	\
740	-O a.out-arm-netbsd	\
741	-R .ident		\
742	-R .ARM.attributes	\
743	-R .ARM.exidx		\
744	-R .ARM.extab		\
745	-R .SUNW_ctf		\
746	-R .arm.atpcs		\
747	-R .comment		\
748	-R .debug_abbrev	\
749	-R .debug_aranges	\
750	-R .debug_info		\
751	-R .debug_line		\
752	-R .debug_frame		\
753	-R .debug_loc		\
754	-R .debug_pubnames	\
755	-R .debug_pubtypes	\
756	-R .debug_ranges	\
757	-R .debug_str		\
758	-R .debug_macinfo	\
759	-R .eh_frame		\
760	-R .note.netbsd.ident
761.endif
762
763#
764# Targets to check if DESTDIR or RELEASEDIR is provided
765#
766.if !target(check_DESTDIR)
767check_DESTDIR: .PHONY .NOTMAIN
768.if !defined(DESTDIR)
769	@echo "setenv DESTDIR before doing that!"
770	@false
771.else
772	@true
773.endif
774.endif
775
776.if !target(check_RELEASEDIR)
777check_RELEASEDIR: .PHONY .NOTMAIN
778.if !defined(RELEASEDIR)
779	@echo "setenv RELEASEDIR before doing that!"
780	@false
781.else
782	@true
783.endif
784.endif
785
786#
787# Where the system object and source trees are kept; can be configurable
788# by the user in case they want them in ~/foosrc and ~/fooobj (for example).
789#
790BSDSRCDIR?=	/usr/src
791BSDOBJDIR?=	/usr/obj
792NETBSDSRCDIR?=	${BSDSRCDIR}
793
794BINGRP?=	wheel
795BINOWN?=	root
796BINMODE?=	555
797NONBINMODE?=	444
798
799# These are here mainly because we don't want suid root in case
800# a Makefile defines BINMODE.
801RUMPBINGRP?=	wheel
802RUMPBINOWN?=	root
803RUMPBINMODE?=	555
804RUMPNONBINMODE?=444
805
806MANDIR?=	/usr/share/man
807MANGRP?=	wheel
808MANOWN?=	root
809MANMODE?=	${NONBINMODE}
810MANINSTALL?=	${_MANINSTALL}
811
812INFODIR?=	/usr/share/info
813INFOGRP?=	wheel
814INFOOWN?=	root
815INFOMODE?=	${NONBINMODE}
816
817LIBDIR?=	/usr/lib
818
819LINTLIBDIR?=	/usr/libdata/lint
820LIBGRP?=	${BINGRP}
821LIBOWN?=	${BINOWN}
822LIBMODE?=	${NONBINMODE}
823
824DOCDIR?=	/usr/share/doc
825DOCGRP?=	wheel
826DOCOWN?=	root
827DOCMODE?=	${NONBINMODE}
828
829NLSDIR?=	/usr/share/nls
830NLSGRP?=	wheel
831NLSOWN?=	root
832NLSMODE?=	${NONBINMODE}
833
834KMODULEGRP?=	wheel
835KMODULEOWN?=	root
836KMODULEMODE?=	${NONBINMODE}
837
838LOCALEDIR?=	/usr/share/locale
839LOCALEGRP?=	wheel
840LOCALEOWN?=	root
841LOCALEMODE?=	${NONBINMODE}
842
843FIRMWAREDIR?=	/libdata/firmware
844FIRMWAREGRP?=	wheel
845FIRMWAREOWN?=	root
846FIRMWAREMODE?=	${NONBINMODE}
847
848DEBUGDIR?=	/usr/libdata/debug
849DEBUGGRP?=	wheel
850DEBUGOWN?=	root
851DEBUGMODE?=	${NONBINMODE}
852
853DTBDIR?=	/boot/dtb
854DTBGRP?=	wheel
855DTBOWN?=	root
856DTBMODE?=	${NONBINMODE}
857
858MKDIRMODE?=	0755
859MKDIRPERM?=	-m ${MKDIRMODE}
860
861#
862# Data-driven table using make variables to control how
863# toolchain-dependent targets and shared libraries are built
864# for different platforms and object formats.
865#
866# OBJECT_FMT:		currently either "ELF" or "a.out".
867#
868# All platforms are ELF.
869#
870OBJECT_FMT=	ELF
871
872#
873# If this platform's toolchain is missing, we obviously cannot build it.
874#
875.if ${TOOLCHAIN_MISSING} != "no"
876MKBINUTILS:= no
877MKGDB:= no
878MKGCC:= no
879.endif
880
881#
882# If we are using an external toolchain, we can still build the target's
883# binutils, but we cannot build GCC's support libraries, since those are
884# tightly-coupled to the version of GCC being used.
885#
886.if defined(EXTERNAL_TOOLCHAIN)
887MKGCC:= no
888.endif
889
890MKGDB.or1k=	no
891
892# No kernel modules for or1k or riscv (yet)
893MKKMOD.or1k=	no
894
895# No profiling for or1k (yet)
896MKPROFILE.or1k=	no
897MKPROFILE.riscv32=no
898MKPROFILE.riscv64=no
899
900#
901# The m68000 port is incomplete.
902#
903.if ${MACHINE_ARCH} == "m68000"
904NOPIC=		# defined
905MKISCSI=	no
906# XXX GCC 4 outputs mcount() calling sequences that try to load values
907# from over 64KB away and this fails to assemble.
908.if defined(HAVE_GCC)
909NOPROFILE=	# defined
910.endif
911.endif
912
913#
914# The ia64 port is incomplete.
915#
916MKGDB.ia64=	no
917
918#
919# On VAX using ELF, all objects are PIC, not just shared libraries,
920# so don't build the _pic version. VAX has no native TLS support either,
921# so differences between TLS models are not relevant.
922#
923MKPICLIB.vax=	no
924
925#
926# Location of the file that contains the major and minor numbers of the
927# version of a shared library.  If this file exists a shared library
928# will be built by <bsd.lib.mk>.
929#
930SHLIB_VERSION_FILE?= ${.CURDIR}/shlib_version
931
932#
933# GNU sources and packages sometimes see architecture names differently.
934#
935GNU_ARCH.aarch64eb=aarch64_be
936GNU_ARCH.coldfire=m5407
937GNU_ARCH.earm=arm
938GNU_ARCH.earmhf=arm
939GNU_ARCH.earmeb=armeb
940GNU_ARCH.earmhfeb=armeb
941GNU_ARCH.earmv4=armv4
942GNU_ARCH.earmv4eb=armv4eb
943GNU_ARCH.earmv5=arm
944GNU_ARCH.earmv5hf=arm
945GNU_ARCH.earmv5eb=armeb
946GNU_ARCH.earmv5hfeb=armeb
947GNU_ARCH.earmv6=armv6
948GNU_ARCH.earmv6hf=armv6
949GNU_ARCH.earmv6eb=armv6eb
950GNU_ARCH.earmv6hfeb=armv6eb
951GNU_ARCH.earmv7=armv7
952GNU_ARCH.earmv7hf=armv7
953GNU_ARCH.earmv7eb=armv7eb
954GNU_ARCH.earmv7hfeb=armv7eb
955GNU_ARCH.i386=i486
956GCC_CONFIG_ARCH.i386=i486
957GCC_CONFIG_TUNE.i386=nocona
958GCC_CONFIG_TUNE.x86_64=nocona
959GNU_ARCH.m68000=m68010
960GNU_ARCH.sh3eb=sh
961GNU_ARCH.sh3el=shle
962GNU_ARCH.mips64eb=mips64
963MACHINE_GNU_ARCH=${GNU_ARCH.${MACHINE_ARCH}:U${MACHINE_ARCH}}
964
965#
966# In order to identify NetBSD to GNU packages, we sometimes need
967# an "elf" tag for historically a.out platforms.
968#
969.if (${MACHINE_ARCH:Mearm*})
970MACHINE_GNU_PLATFORM?=${MACHINE_GNU_ARCH}--netbsdelf-${MACHINE_ARCH:C/eb//:C/v[4-7]//:S/earm/eabi/}
971.elif (${MACHINE_GNU_ARCH} == "arm" || \
972     ${MACHINE_GNU_ARCH} == "armeb" || \
973     ${MACHINE_ARCH} == "i386" || \
974     ${MACHINE_CPU} == "m68k" || \
975     ${MACHINE_GNU_ARCH} == "sh" || \
976     ${MACHINE_GNU_ARCH} == "shle" || \
977     ${MACHINE_ARCH} == "sparc" || \
978     ${MACHINE_ARCH} == "vax")
979MACHINE_GNU_PLATFORM?=${MACHINE_GNU_ARCH}--netbsdelf
980.else
981MACHINE_GNU_PLATFORM?=${MACHINE_GNU_ARCH}--netbsd
982.endif
983
984.if ${MACHINE_ARCH:M*arm*}
985# Flags to pass to CC for using the old APCS ABI on ARM for compat or stand.
986ARM_APCS_FLAGS=	-mabi=apcs-gnu -mfloat-abi=soft -marm
987ARM_APCS_FLAGS+= ${${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U0} >= 8:? -mno-thumb-interwork :}
988ARM_APCS_FLAGS+=${${ACTIVE_CC} == "clang":? -target ${MACHINE_GNU_ARCH}--netbsdelf -B ${TOOLDIR}/${MACHINE_GNU_PLATFORM}/bin :}
989.endif
990
991GENASSYM_CPPFLAGS+=	${${ACTIVE_CC} == "clang":? -no-integrated-as :}
992
993TARGETS+=	all clean cleandir depend dependall includes \
994		install lint obj regress tags html analyze describe \
995		rumpdescribe
996PHONY_NOTMAIN =	all clean cleandir depend dependall distclean includes \
997		install lint obj regress beforedepend afterdepend \
998		beforeinstall afterinstall realinstall realdepend realall \
999		html subdir-all subdir-install subdir-depend analyze describe \
1000		rumpdescribe
1001.PHONY:		${PHONY_NOTMAIN}
1002.NOTMAIN:	${PHONY_NOTMAIN}
1003
1004.if ${NEED_OWN_INSTALL_TARGET} != "no"
1005.if !target(install)
1006install:	beforeinstall .WAIT subdir-install realinstall .WAIT afterinstall
1007beforeinstall:
1008subdir-install:
1009realinstall:
1010afterinstall:
1011.endif
1012all:		realall subdir-all
1013subdir-all:
1014realall:
1015depend:		realdepend subdir-depend
1016subdir-depend:
1017realdepend:
1018distclean:	cleandir
1019cleandir:	clean
1020
1021dependall:	.NOTMAIN realdepend .MAKE
1022	@cd "${.CURDIR}"; ${MAKE} realall
1023.endif
1024
1025#
1026# Define MKxxx variables (which are either yes or no) for users
1027# to set in /etc/mk.conf and override in the make environment.
1028# These should be tested with `== "no"' or `!= "no"'.
1029# The NOxxx variables should only be set by Makefiles.
1030#
1031# Please keep etc/Makefile and share/man/man5/mk.conf.5 in sync
1032# with changes to the MK* variables here.
1033#
1034
1035#
1036# Supported NO* options (if defined, MK* will be forced to "no",
1037# regardless of user's mk.conf setting).
1038#
1039# Source makefiles should set NO*, and not MK*, and must do so before
1040# including bsd.own.mk.
1041# Please keep alphabetically sorted with one entry per line.
1042#
1043_NOVARS= \
1044	NOCOMPAT \
1045	NODEBUGLIB \
1046	NODOC \
1047	NOHTML \
1048	NOINFO \
1049	NOLIBCSANITIZER \
1050	NOLINKLIB \
1051	NOLINT \
1052	NOMAN \
1053	NONLS \
1054	NOOBJ \
1055	NOPIC \
1056	NOPICINSTALL \
1057	NOPROFILE \
1058	NORELRO \
1059	NOSANITIZER \
1060	NOSHARE \
1061	NOSTATICLIB
1062
1063.for var in ${_NOVARS}
1064.if defined(${var})
1065MK${var:S/^NO//}:=	no
1066.endif
1067.endfor
1068
1069#
1070# MK* options which have variable defaults.
1071#
1072
1073#
1074# aarch64eb is not yet supported for MKCOMPAT.
1075#
1076.if ${MACHINE_ARCH} == "x86_64" || \
1077    ${MACHINE_ARCH} == "sparc64" || \
1078    ${MACHINE_MIPS64} || \
1079    ${MACHINE_ARCH} == "powerpc64" || \
1080    (${MACHINE_ARCH} == "aarch64" && ${HAVE_GCC:U0} == 0) || \
1081    ${MACHINE_ARCH} == "riscv64" || \
1082    ${MACHINE_ARCH:Mearm*}
1083MKCOMPAT?=	yes
1084.else
1085# Don't let this build where it really isn't supported.
1086MKCOMPAT:=	no
1087.endif
1088
1089.if ${MKCOMPAT} == "no"
1090MKCOMPATTESTS:=	no
1091MKCOMPATX11:=	no
1092.endif
1093
1094.if ${MACHINE_MIPS64} \
1095    || (${MACHINE} == "evbppc" && ${MACHINE_ARCH} == "powerpc")
1096MKCOMPATMODULES?=	yes
1097.else
1098MKCOMPATMODULES:=	no
1099.endif
1100
1101#
1102# These platforms use softfloat by default.
1103#
1104.if ${MACHINE_MIPS64}
1105MKSOFTFLOAT?=	yes
1106.endif
1107
1108#
1109# These platforms always use softfloat.
1110#
1111.if (${MACHINE_CPU} == "arm" && ${MACHINE_ARCH:M*hf*} == "") || \
1112    ${MACHINE_ARCH} == "coldfire" || ${MACHINE_CPU} == "or1k" || \
1113    ${MACHINE} == "emips" || ${MACHINE_CPU} == "sh3"
1114MKSOFTFLOAT=	yes
1115.endif
1116
1117.if ${MACHINE} == "emips"
1118SOFTFLOAT_BITS=	32
1119.endif
1120
1121#
1122# We want to build zfs only for amd64, aarch64 and sparc64 by default for now.
1123#
1124.if ${MACHINE} == "amd64" || \
1125    ${MACHINE} == "sparc64" || \
1126    ${MACHINE_ARCH:Maarch64*}
1127MKZFS?=		yes
1128.endif
1129
1130#
1131# DTrace works on amd64, i386, aarch64, and earm*
1132#
1133.if ${MACHINE_ARCH} == "i386" || \
1134    ${MACHINE_ARCH} == "x86_64" || \
1135    ${MACHINE_ARCH} == "aarch64" || \
1136    ${MACHINE_ARCH:Mearm*}
1137MKDTRACE?=	yes
1138MKCTF?=		yes
1139.endif
1140
1141#
1142# PIE is enabled on many platforms by default.
1143#
1144# Coverity does not like PIE
1145.if !defined(COVERITY_TOP_CONFIG) && \
1146    (${MACHINE_ARCH} == "i386" || \
1147    ${MACHINE_ARCH} == "x86_64" || \
1148    ${MACHINE_ARCH:Maarch64*} || \
1149    ${MACHINE_CPU} == "arm" || \
1150    ${MACHINE_CPU} == "m68k" || \
1151    ${MACHINE_CPU} == "mips" || \
1152    ${MACHINE_CPU} == "sh3" || \
1153    ${MACHINE} == "sparc64")
1154MKPIE?=		yes
1155.else
1156MKPIE?=		no
1157.endif
1158
1159#
1160# RELRO is enabled on i386, amd64, and aarch64 by default
1161#
1162# sync with NORELRO in compat/*/*/bsd.*.mk for the relro-enabled 64-bit
1163# platforms with relro-disabled 32-bit compat
1164#
1165.if ${MACHINE} == "i386" || \
1166    ${MACHINE} == "amd64" || \
1167    ${MACHINE_ARCH:Maarch64*}
1168MKRELRO?=	partial
1169.else
1170MKRELRO?=	no
1171.endif
1172
1173.if ${MACHINE_ARCH} == "x86_64" || ${MACHINE_ARCH} == "i386"
1174MKSTATICPIE?=	yes
1175.else
1176MKSTATICPIE?=	no
1177.endif
1178
1179#
1180# MK* options which default to "yes".
1181# Please keep alphabetically sorted with one entry per line.
1182#
1183_MKVARS.yes= \
1184	MKARGON2 \
1185	MKATF \
1186	MKBINUTILS \
1187	MKBSDTAR \
1188	MKCLEANSRC \
1189	MKCLEANVERIFY \
1190	MKCOMPLEX \
1191	MKCVS \
1192	MKCXX \
1193	MKDOC \
1194	MKDTC \
1195	MKDYNAMICROOT \
1196	MKGCC \
1197	MKGDB \
1198	MKGROFF \
1199	MKHESIOD \
1200	MKHTML \
1201	MKIEEEFP \
1202	MKINET6 \
1203	MKINFO \
1204	MKIPFILTER \
1205	MKISCSI \
1206	MKKERBEROS \
1207	MKKMOD \
1208	MKLDAP \
1209	MKLIBSTDCXX \
1210	MKLINKLIB \
1211	MKLVM \
1212	MKMAKEMANDB \
1213	MKMAN \
1214	MKMANDOC \
1215	MKMDNS \
1216	MKNLS \
1217	MKNPF \
1218	MKOBJ \
1219	MKPAM \
1220	MKPF \
1221	MKPIC \
1222	MKPICLIB \
1223	MKPOSTFIX \
1224	MKPROFILE \
1225	MKRUMP \
1226	MKSHARE \
1227	MKSKEY \
1228	MKSTATICLIB \
1229	MKSTRIPSYM \
1230	MKUNBOUND \
1231	MKX11FONTS \
1232	MKYP
1233
1234.for var in ${_MKVARS.yes}
1235${var}?=	${${var}.${MACHINE_ARCH}:U${${var}.${MACHINE}:Uyes}}
1236.endfor
1237
1238#
1239# MKGCCCMDS is only valid if we are building GCC so make it dependent on that.
1240#
1241_MKVARS.yes += MKGCCCMDS
1242MKGCCCMDS?=	${MKGCC}
1243
1244#
1245# Sanitizers, only "address" and "undefined" are supported by gcc
1246#
1247MKSANITIZER?=	no
1248USE_SANITIZER?=	address
1249
1250#
1251# Sanitizers implemented in libc, only "undefined" is supported
1252#
1253MKLIBCSANITIZER?=	no
1254USE_LIBCSANITIZER?=	undefined
1255
1256#
1257# Exceptions to the above:
1258#
1259
1260# RUMP uses -nostdinc which coverity does not like
1261# It also does not use many new files, so disable it
1262.if defined(COVERITY_TOP_CONFIG)
1263MKRUMP=		no
1264.endif
1265
1266#
1267# Build a dynamically linked /bin and /sbin, with the necessary shared
1268# libraries moved from /usr/lib to /lib and the shared linker moved
1269# from /usr/libexec to /lib
1270#
1271# Note that if the BINDIR is not /bin or /sbin, then we always use the
1272# non-DYNAMICROOT behavior (i.e. it is only enabled for programs in /bin
1273# and /sbin).  See <bsd.shlib.mk>.
1274#
1275# For ia64, ld.elf_so not yet implemented
1276.if ${MACHINE_ARCH} == "ia64"
1277MKDYNAMICROOT=	no
1278.endif
1279
1280.if defined(MKREPRO)
1281MKARZERO ?= ${MKREPRO}
1282GROFF_FLAGS ?= -dpaper=letter
1283ROFF_PAGESIZE ?= -P-pletter
1284.endif
1285
1286#
1287# Install the kernel as /netbsd/kernel and the modules in /netbsd/modules
1288#
1289KERNEL_DIR?=	no
1290
1291# Only install the general firmware on some systems
1292MKFIRMWARE.amd64=		yes
1293MKFIRMWARE.cobalt=		yes
1294MKFIRMWARE.evbarm=		yes
1295MKFIRMWARE.evbmips=		yes
1296MKFIRMWARE.evbppc=		yes
1297MKFIRMWARE.hpcarm=		yes
1298MKFIRMWARE.hppa=		yes
1299MKFIRMWARE.i386=		yes
1300MKFIRMWARE.mac68k=		yes
1301MKFIRMWARE.macppc=		yes
1302MKFIRMWARE.riscv=		yes
1303MKFIRMWARE.sandpoint=		yes
1304MKFIRMWARE.sparc64=		yes
1305
1306# Only install the GPU firmware on DRM-happy systems.
1307MKNOUVEAUFIRMWARE.x86_64=	yes
1308MKNOUVEAUFIRMWARE.i386=		yes
1309MKNOUVEAUFIRMWARE.aarch64=	yes
1310MKRADEONFIRMWARE.x86_64=	yes
1311MKRADEONFIRMWARE.i386=		yes
1312MKRADEONFIRMWARE.aarch64=	yes
1313MKAMDGPUFIRMWARE.x86_64=	yes
1314
1315# Only install the tegra firmware on evbarm.
1316MKTEGRAFIRMWARE.evbarm=		yes
1317
1318# Only build devicetree (dtb) files on armv6, armv7, and aarch64.
1319MKDTB.aarch64=			yes
1320MKDTB.aarch64eb=		yes
1321MKDTB.earmv6=			yes
1322MKDTB.earmv6hf=			yes
1323MKDTB.earmv6eb=			yes
1324MKDTB.earmv6hfeb=		yes
1325MKDTB.earmv7=			yes
1326MKDTB.earmv7hf=			yes
1327MKDTB.earmv7eb=			yes
1328MKDTB.earmv7hfeb=		yes
1329MKDTB.riscv32=			yes
1330MKDTB.riscv64=			yes
1331
1332# During transition from xorg-server 1.10 to 1.20
1333.if \
1334    ${MACHINE} == "alpha"	|| \
1335    ${MACHINE} == "netwinder"	|| \
1336    ${MACHINE} == "sgimips"
1337HAVE_XORG_SERVER_VER?=110
1338.else
1339HAVE_XORG_SERVER_VER?=120
1340.endif
1341
1342# Newer Mesa does not build with old X server
1343# VAX build triggers a gcc internal error
1344.if ${HAVE_XORG_SERVER_VER} != "120" || ${MACHINE} == "vax"
1345HAVE_MESA_VER=19
1346.endif
1347
1348HAVE_MESA_VER?=	21
1349.if ${HAVE_MESA_VER} == 19
1350EXTERNAL_MESALIB_DIR?=	MesaLib.old
1351.elif ${HAVE_MESA_VER} == 21
1352EXTERNAL_MESALIB_DIR?=	MesaLib
1353.endif
1354
1355# Default to LLVM run-time if x86 or aarch64 and X11 and Mesa 18 or newer
1356# XXX This knows that MKX11=no is default below, but would
1357# require splitting the below loop in two parts.
1358.if ${MKX11:Uno} != "no" && ${HAVE_MESA_VER} >= 19
1359MKLLVMRT.amd64=		yes
1360MKLLVMRT.i386=		yes
1361MKLLVMRT.aarch64=	yes
1362.endif
1363
1364# Just-in-time compiler for bpf, npf acceleration
1365MKSLJIT.aarch64=	yes
1366MKSLJIT.i386=		yes
1367MKSLJIT.sparc=		yes
1368#MKSLJIT.sparc64=	yes	# not suppored in sljit (yet?)
1369MKSLJIT.x86_64=		yes
1370#MKSLJIT.powerpc=	yes	# XXX
1371#MKSLJIT.powerpc64=	yes	# XXX
1372#MKSLJIT.mipsel=	yes	# XXX
1373#MKSLJIT.mipseb=	yes	# XXX
1374#MKSLJIT.mips64el=	yes	# XXX
1375#MKSLJIT.mips64eb=	yes	# XXX
1376#MKSLJIT.riscv32=	yes	# not until we update sljit
1377#MKSLJIT.riscv64=	yes	# not until we update sljit
1378
1379# compat with old names
1380MKDEBUGKERNEL?=${MKKDEBUG:Uno}
1381MKDEBUGTOOLS?=${MKTOOLSDEBUG:Uno}
1382
1383#
1384# MK* options which default to "no".
1385# Note that MKZFS has a different default for some platforms, see above.
1386# Please keep alphabetically sorted with one entry per line.
1387#
1388_MKVARS.no= \
1389	MKAMDGPUFIRMWARE \
1390	MKARZERO \
1391	MKBSDGREP \
1392	MKCATPAGES \
1393	MKCOMPATTESTS \
1394	MKCOMPATX11 \
1395	MKCTF \
1396	MKDEBUG \
1397	MKDEBUGLIB \
1398	MKDEPINCLUDES \
1399	MKDTB \
1400	MKDTRACE \
1401	MKFIRMWARE \
1402	MKGROFFHTMLDOC \
1403	MKHOSTOBJ \
1404	MKKYUA \
1405	MKLIBCXX \
1406	MKLINT \
1407	MKLLVM \
1408	MKLLVMRT \
1409	MKMANZ \
1410	MKNOUVEAUFIRMWARE \
1411	MKNSD \
1412	MKOBJDIRS \
1413	MKPCC \
1414	MKPICINSTALL \
1415	MKPIGZGZIP \
1416	MKRADEONFIRMWARE \
1417	MKREPRO \
1418	MKSLJIT \
1419	MKSOFTFLOAT \
1420	MKSTRIPIDENT \
1421	MKTEGRAFIRMWARE \
1422	MKTPM \
1423	MKUNPRIVED \
1424	MKUPDATE \
1425	MKX11 \
1426	MKX11MOTIF \
1427	MKXORG_SERVER \
1428	MKZFS
1429
1430.for var in ${_MKVARS.no}
1431${var}?=	${${var}.${MACHINE_ARCH}:U${${var}.${MACHINE}:Uno}}
1432.endfor
1433
1434#
1435# Which platforms build the xorg-server drivers (as opposed
1436# to just Xnest and Xvfb.)
1437#
1438.if ${MACHINE} == "alpha"	|| \
1439    ${MACHINE} == "amd64"	|| \
1440    ${MACHINE} == "amiga"	|| \
1441    ${MACHINE} == "bebox"	|| \
1442    ${MACHINE} == "cats"	|| \
1443    ${MACHINE} == "dreamcast"	|| \
1444    ${MACHINE} == "ews4800mips"	|| \
1445    ${MACHINE} == "evbarm"	|| \
1446    ${MACHINE} == "evbmips"	|| \
1447    ${MACHINE} == "evbppc"	|| \
1448    ${MACHINE} == "hp300"	|| \
1449    ${MACHINE} == "hpcarm"	|| \
1450    ${MACHINE} == "hpcmips"	|| \
1451    ${MACHINE} == "hpcsh"	|| \
1452    ${MACHINE} == "hppa"	|| \
1453    ${MACHINE} == "i386"	|| \
1454    ${MACHINE} == "ibmnws"	|| \
1455    ${MACHINE} == "iyonix"	|| \
1456    ${MACHINE} == "luna68k"	|| \
1457    ${MACHINE} == "mac68k"	|| \
1458    ${MACHINE} == "macppc"	|| \
1459    ${MACHINE} == "netwinder"	|| \
1460    ${MACHINE} == "newsmips"	|| \
1461    ${MACHINE} == "pmax"	|| \
1462    ${MACHINE} == "prep"	|| \
1463    ${MACHINE} == "ofppc"	|| \
1464    ${MACHINE} == "sgimips"	|| \
1465    ${MACHINE} == "shark"	|| \
1466    ${MACHINE} == "sparc"	|| \
1467    ${MACHINE} == "sparc64"	|| \
1468    ${MACHINE} == "vax"		|| \
1469    ${MACHINE} == "zaurus"
1470MKXORG_SERVER=yes
1471.endif
1472
1473#
1474# Force some options off if their dependencies are off.
1475#
1476
1477.if ${MKCXX} == "no"
1478MKATF:=		no
1479MKGCCCMDS:=	no
1480MKGDB:=		no
1481MKGROFF:=	no
1482MKKYUA:=	no
1483.endif
1484
1485.if ${MKMAN} == "no"
1486MKCATPAGES:=	no
1487MKHTML:=	no
1488.endif
1489
1490_MANINSTALL=	maninstall
1491.if ${MKCATPAGES} != "no"
1492_MANINSTALL+=	catinstall
1493.endif
1494.if ${MKHTML} != "no"
1495_MANINSTALL+=	htmlinstall
1496.endif
1497
1498.if ${MKLINKLIB} == "no"
1499MKLINT:=	no
1500MKPICINSTALL:=	no
1501MKPROFILE:=	no
1502.endif
1503
1504.if ${MKPIC} == "no"
1505MKPICLIB:=	no
1506.endif
1507
1508.if ${MKOBJ} == "no"
1509MKOBJDIRS:=	no
1510.endif
1511
1512.if ${MKSHARE} == "no"
1513MKCATPAGES:=	no
1514MKDOC:=		no
1515MKINFO:=	no
1516MKHTML:=	no
1517MKMAN:=		no
1518MKNLS:=		no
1519.endif
1520
1521.if ${MACHINE_ARCH:Mearm*}
1522_NEEDS_LIBCXX.${MACHINE_ARCH}=	yes
1523.endif
1524_NEEDS_LIBCXX.aarch64=		yes
1525_NEEDS_LIBCXX.aarch64eb=	yes
1526_NEEDS_LIBCXX.i386=		yes
1527_NEEDS_LIBCXX.powerpc=		yes
1528_NEEDS_LIBCXX.powerpc64=	yes
1529_NEEDS_LIBCXX.sparc=		yes
1530_NEEDS_LIBCXX.sparc64=		yes
1531_NEEDS_LIBCXX.x86_64=		yes
1532
1533.if ${MKLLVM} == "yes" && ${_NEEDS_LIBCXX.${MACHINE_ARCH}:Uno} == "yes"
1534MKLIBCXX:=	yes
1535.endif
1536
1537#
1538# Disable MKSTRIPSYM if MKDEBUG is enabled.
1539#
1540.if ${MKDEBUG} != "no"
1541MKSTRIPSYM:=	no
1542.endif
1543
1544#
1545# install(1) parameters.
1546#
1547COPY?=		-c
1548.if ${MKUPDATE} == "no"
1549PRESERVE?=
1550.else
1551PRESERVE?=	-p
1552.endif
1553RENAME?=	-r
1554HRDLINK?=	-l h
1555SYMLINK?=	-l s
1556
1557METALOG?=	${DESTDIR}/METALOG
1558METALOG.add?=	${TOOL_CAT} -l >> ${METALOG}
1559.if (${_SRC_TOP_} != "")	# only set INSTPRIV if inside ${NETBSDSRCDIR}
1560.if ${MKUNPRIVED} != "no"
1561INSTPRIV.unpriv=-U -M ${METALOG} -D ${DESTDIR} -h sha256
1562.else
1563INSTPRIV.unpriv=
1564.endif
1565INSTPRIV?=	${INSTPRIV.unpriv} -N ${NETBSDSRCDIR}/etc
1566.endif
1567STRIPFLAG?=
1568
1569INSTALL_DIR?=		${INSTALL} ${INSTPRIV} -d
1570INSTALL_FILE?=		${INSTALL} ${INSTPRIV} ${COPY} ${PRESERVE} ${RENAME}
1571INSTALL_LINK?=		${INSTALL} ${INSTPRIV} ${HRDLINK} ${RENAME}
1572INSTALL_SYMLINK?=	${INSTALL} ${INSTPRIV} ${SYMLINK} ${RENAME}
1573
1574# for crunchide & ldd, define the OBJECT_FMTS used by a MACHINE_ARCH
1575#
1576OBJECT_FMTS=
1577.if	${MACHINE_ARCH} != "alpha" && ${MACHINE_ARCH} != "ia64"
1578OBJECT_FMTS+=	elf32
1579.endif
1580.if	${MACHINE_ARCH} == "alpha" || ${MACHINE_ARCH:M*64*} != ""
1581. if !(${MKCOMPAT:Uyes} == "no" && ${MACHINE_CPU} == "mips")
1582OBJECT_FMTS+=	elf64
1583. endif
1584.endif
1585
1586#
1587# Set defaults for the USE_xxx variables.
1588#
1589
1590#
1591# USE_* options which default to "no" and will be forced to "no" if their
1592# corresponding MK* variable is set to "no".
1593#
1594.for var in USE_SKEY
1595.if (${${var:S/USE_/MK/}} == "no")
1596${var}:= no
1597.else
1598${var}?= no
1599.endif
1600.endfor
1601
1602#
1603# USE_* options which default to "yes" unless their corresponding MK*
1604# variable is set to "no".
1605#
1606.for var in USE_HESIOD USE_INET6 USE_KERBEROS USE_LDAP USE_PAM USE_YP
1607.if (${${var:S/USE_/MK/}} == "no")
1608${var}:= no
1609.else
1610${var}?= yes
1611.endif
1612.endfor
1613
1614#
1615# USE_* options which default to "yes".
1616#
1617.for var in USE_JEMALLOC
1618${var}?= yes
1619.endfor
1620
1621#
1622# USE_* options which default to "no".
1623#
1624# For now, disable pigz as compressor by default
1625.for var in USE_PIGZGZIP
1626${var}?= no
1627.endfor
1628
1629# Default to USE_XZ_SETS on some 64bit architectures where decompressor
1630# memory will likely not be in short supply.
1631# Since pigz can not create .xz format files currently, disable .xz
1632# format if USE_PIGZGZIP is enabled.
1633.if ${USE_PIGZGZIP} == "no" && \
1634    (${MACHINE} == "amd64" || \
1635     ${MACHINE_ARCH:Maarch64*})
1636USE_XZ_SETS?= yes
1637.else
1638USE_XZ_SETS?= no
1639.endif
1640
1641#
1642# TOOL_GZIP and friends.  These might refer to TOOL_PIGZ or to the host gzip.
1643#
1644.if ${USE_PIGZGZIP} != "no"
1645TOOL_GZIP=		${TOOL_PIGZ}
1646GZIP_N_FLAG?=		-nT
1647.else
1648.if ${USETOOLS} == "yes"
1649TOOL_GZIP=		${TOOLDIR}/bin/${_TOOL_PREFIX}gzip
1650.else
1651TOOL_GZIP=		gzip
1652.endif
1653GZIP_N_FLAG?=		-n
1654.endif
1655TOOL_GZIP_N=		${TOOL_GZIP} ${GZIP_N_FLAG}
1656
1657#
1658# Where X11 sources are and where it is installed to.
1659#
1660.if !defined(X11SRCDIR)
1661.if exists(${NETBSDSRCDIR}/../xsrc)
1662X11SRCDIR!=		cd "${NETBSDSRCDIR}/../xsrc" && pwd
1663.else
1664X11SRCDIR=		/usr/xsrc
1665.endif
1666.endif # !defined(X11SRCDIR)
1667
1668X11SRCDIR.local?=	${X11SRCDIR}/local
1669X11ROOTDIR?=		/usr/X11R7
1670X11BINDIR?=		${X11ROOTDIR}/bin
1671X11ETCDIR?=		/etc/X11
1672X11FONTDIR?=		${X11ROOTDIR}/lib/X11/fonts
1673X11INCDIR?=		${X11ROOTDIR}/include
1674X11LIBDIR?=		${X11ROOTDIR}/lib/X11
1675X11MANDIR?=		${X11ROOTDIR}/man
1676X11SHAREDIR?=		${X11ROOTDIR}/share
1677X11USRLIBDIR?=		${X11ROOTDIR}/lib${MLIBDIR:D/${MLIBDIR}}
1678
1679#
1680# New modular-xorg based builds
1681#
1682X11SRCDIRMIT?=		${X11SRCDIR}/external/mit
1683.for _lib in \
1684	FS ICE SM X11 XScrnSaver XTrap Xau Xcomposite Xcursor Xdamage \
1685	Xdmcp Xevie Xext Xfixes Xfont Xfont2 Xft Xi Xinerama Xmu Xpresent Xpm \
1686	Xrandr Xrender Xres Xt Xtst Xv XvMC Xxf86dga Xxf86misc Xxf86vm drm \
1687	epoxy fontenc vdpau xkbfile xkbui Xaw pciaccess xcb xshmfence \
1688	pthread-stubs xcvt
1689X11SRCDIR.${_lib}?=		${X11SRCDIRMIT}/lib${_lib}/dist
1690.endfor
1691
1692.for _proto in \
1693	xcb- xorg
1694X11SRCDIR.${_proto}proto?=		${X11SRCDIRMIT}/${_proto}proto/dist
1695.endfor
1696
1697.if ${HAVE_XORG_SERVER_VER} == "120"
1698XORG_SERVER_SUBDIR?=xorg-server
1699. if ${MACHINE} == "amd64" || ${MACHINE} == "i386" || ${MACHINE} == "evbarm"
1700HAVE_XORG_GLAMOR?=	yes
1701. endif
1702.else
1703XORG_SERVER_SUBDIR?=xorg-server.old
1704.endif
1705
1706X11SRCDIR.xorg-server?=		${X11SRCDIRMIT}/${XORG_SERVER_SUBDIR}/dist
1707HAVE_XORG_GLAMOR?=	no
1708
1709# Build glamor extension?
1710
1711.for _dir in \
1712	xtrans fontconfig freetype evieext mkfontscale bdftopcf \
1713	xorg-cf-files imake xbiff xkeyboard-config \
1714	xcompmgr xbitmaps appres xeyes xev xedit sessreg pixman \
1715	brotli \
1716	beforelight bitmap editres makedepend fonttosfnt fslsfonts fstobdf \
1717	glu glw mesa-demos MesaGLUT MesaLib MesaLib.old MesaLib7 \
1718	ico iceauth listres lndir \
1719	luit xproxymanagementprotocol mkfontdir oclock proxymngr rgb \
1720	rstart setxkbmap showfont smproxy transset twm viewres \
1721	util-macros \
1722	x11perf xauth xcalc xclipboard \
1723	xclock xcmsdb xconsole xditview xdpyinfo xdriinfo xdm \
1724	xfd xf86dga xfindproxy xfontsel xgamma xgc xhost xinit \
1725	xkill xload xlogo xlsatoms xlsclients xlsfonts xmag xmessage \
1726	xmh xmodmap xmore xman xprop xrandr xrdb xrefresh xset \
1727	xsetmode xsetpointer xsetroot xsm xstdcmap xvidtune xvinfo \
1728	xwininfo xwud xkbprint xkbevd \
1729	xterm xwd xfs xfsinfo xtrap xkbutils xkbcomp \
1730	xinput xcb-util xorg-docs \
1731	font-adobe-100dpi font-adobe-75dpi font-adobe-utopia-100dpi \
1732	font-adobe-utopia-75dpi font-adobe-utopia-type1 \
1733	font-alias \
1734	font-bh-100dpi font-bh-75dpi font-bh-lucidatypewriter-100dpi \
1735	font-bh-lucidatypewriter-75dpi font-bh-ttf font-bh-type1 \
1736	font-bitstream-100dpi font-bitstream-75dpi font-bitstream-type1 \
1737	font-cursor-misc font-daewoo-misc font-dec-misc font-ibm-type1 \
1738	font-isas-misc font-jis-misc font-misc-misc font-mutt-misc \
1739	font-sony-misc font-util ttf-bitstream-vera encodings
1740X11SRCDIR.${_dir}?=		${X11SRCDIRMIT}/${_dir}/dist
1741.endfor
1742
1743# X11SRCDIR.Mesa points to the currently used Mesa sources
1744X11SRCDIR.Mesa?=		${X11SRCDIRMIT}/${EXTERNAL_MESALIB_DIR}/dist
1745
1746.for _i in \
1747	elographics keyboard mouse synaptics vmmouse void ws
1748X11SRCDIR.xf86-input-${_i}?=	${X11SRCDIRMIT}/xf86-input-${_i}/dist
1749.endfor
1750
1751# xf86-video-modesetting move into the server build.
1752EXTRA_DRIVERS=
1753.if ${HAVE_XORG_SERVER_VER} == "120"
1754X11SRCDIR.xf86-video-modesetting=${X11SRCDIR.xorg-server}/hw/xfree86/drivers/modesetting
1755.else
1756EXTRA_DRIVERS=	modesetting
1757.endif
1758
1759.for _v in \
1760	ag10e amdgpu apm ark ast ati ati-kms chips cirrus crime \
1761	geode glint i128 i740 igs imstt intel intel-old intel-2014 \
1762	${EXTRA_DRIVERS} mach64 mga \
1763	neomagic newport nouveau nsc nv openchrome pnozz \
1764	r128 rendition \
1765	s3 s3virge savage siliconmotion sis suncg14 \
1766	suncg6 sunffb sunleo suntcx \
1767	tdfx tga trident tseng vboxvideo vesa vga vmware wsfb xgi
1768X11SRCDIR.xf86-video-${_v}?=	${X11SRCDIRMIT}/xf86-video-${_v}/dist
1769.endfor
1770
1771
1772X11DRI?=			yes
1773X11LOADABLE?=			yes
1774
1775
1776#
1777# MAKEDIRTARGET dir target [extra make(1) params]
1778#	run "cd $${dir} && ${MAKEDIRTARGETENV} ${MAKE} [params] $${target}", with a pretty message
1779#
1780MAKEDIRTARGETENV?=
1781MAKEDIRTARGET=\
1782	@_makedirtarget() { \
1783		dir="$$1"; shift; \
1784		target="$$1"; shift; \
1785		case "$${dir}" in \
1786		/*)	this="$${dir}/"; \
1787			real="$${dir}" ;; \
1788		.)	this="${_THISDIR_}"; \
1789			real="${.CURDIR}" ;; \
1790		*)	this="${_THISDIR_}$${dir}/"; \
1791			real="${.CURDIR}/$${dir}" ;; \
1792		esac; \
1793		show=$${this:-.}; \
1794		echo "$${target} ===> $${show%/}$${1:+	(with: $$@)}"; \
1795		cd "$${real}" \
1796		&& ${MAKEDIRTARGETENV} ${MAKE} _THISDIR_="$${this}" "$$@" $${target}; \
1797	}; \
1798	_makedirtarget
1799
1800#
1801# MAKEVERBOSE support.  Levels are:
1802#	0	Minimal output ("quiet")
1803#	1	Describe what is occurring
1804#	2	Describe what is occurring and echo the actual command
1805#	3	Ignore the effect of the "@" prefix in make commands
1806#	4	Trace shell commands using the shell's -x flag
1807#
1808MAKEVERBOSE?=		2
1809
1810.if ${MAKEVERBOSE} == 0
1811_MKMSG?=	@\#
1812_MKSHMSG?=	: echo
1813_MKSHECHO?=	: echo
1814.SILENT:
1815.elif ${MAKEVERBOSE} == 1
1816_MKMSG?=	@echo '   '
1817_MKSHMSG?=	echo '   '
1818_MKSHECHO?=	: echo
1819.SILENT:
1820.else	# MAKEVERBOSE >= 2
1821_MKMSG?=	@echo '\#  '
1822_MKSHMSG?=	echo '\#  '
1823_MKSHECHO?=	echo
1824.SILENT: __makeverbose_dummy_target__
1825.endif	# MAKEVERBOSE >= 2
1826.if ${MAKEVERBOSE} >= 3
1827.MAKEFLAGS:	-dl
1828.endif	# ${MAKEVERBOSE} >= 3
1829.if ${MAKEVERBOSE} >= 4
1830.MAKEFLAGS:	-dx
1831.endif	# ${MAKEVERBOSE} >= 4
1832
1833_MKMSG_BUILD?=		${_MKMSG} "  build "
1834_MKMSG_CREATE?=		${_MKMSG} " create "
1835_MKMSG_COMPILE?=	${_MKMSG} "compile "
1836_MKMSG_EXECUTE?=	${_MKMSG} "execute "
1837_MKMSG_FORMAT?=		${_MKMSG} " format "
1838_MKMSG_INSTALL?=	${_MKMSG} "install "
1839_MKMSG_LINK?=		${_MKMSG} "   link "
1840_MKMSG_LEX?=		${_MKMSG} "    lex "
1841_MKMSG_REMOVE?=		${_MKMSG} " remove "
1842_MKMSG_REGEN?=		${_MKMSG} "  regen "
1843_MKMSG_YACC?=		${_MKMSG} "   yacc "
1844
1845_MKSHMSG_CREATE?=	${_MKSHMSG} " create "
1846_MKSHMSG_FORMAT?=	${_MKSHMSG} " format "
1847_MKSHMSG_INSTALL?=	${_MKSHMSG} "install "
1848
1849_MKTARGET_BUILD?=	${_MKMSG_BUILD} ${.CURDIR:T}/${.TARGET}
1850_MKTARGET_CREATE?=	${_MKMSG_CREATE} ${.CURDIR:T}/${.TARGET}
1851_MKTARGET_COMPILE?=	${_MKMSG_COMPILE} ${.CURDIR:T}/${.TARGET}
1852_MKTARGET_FORMAT?=	${_MKMSG_FORMAT} ${.CURDIR:T}/${.TARGET}
1853_MKTARGET_INSTALL?=	${_MKMSG_INSTALL} ${.TARGET}
1854_MKTARGET_LINK?=	${_MKMSG_LINK} ${.CURDIR:T}/${.TARGET}
1855_MKTARGET_LEX?=		${_MKMSG_LEX} ${.CURDIR:T}/${.TARGET}
1856_MKTARGET_REMOVE?=	${_MKMSG_REMOVE} ${.TARGET}
1857_MKTARGET_YACC?=	${_MKMSG_YACC} ${.CURDIR:T}/${.TARGET}
1858
1859.if ${MKMANDOC} == "yes"
1860TARGETS+=	lintmanpages
1861.endif
1862
1863TESTSBASE=	/usr/tests${MLIBDIR:D/${MLIBDIR}}
1864
1865# Override with tools versions if needed
1866.if ${MKCTF:Uno} != "no" && !defined(NOCTF) && \
1867    (exists(${TOOL_CTFCONVERT}) || exists(/usr/bin/${TOOL_CTFCONVERT}))
1868CTFCONVERT=	${TOOL_CTFCONVERT}
1869CTFMERGE=	${TOOL_CTFMERGE}
1870.endif
1871
1872.endif	# !defined(_BSD_OWN_MK_)
1873