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