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