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