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