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