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