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