xref: /netbsd-src/share/mk/bsd.own.mk (revision 96230fab84e26a6435963032070e916a951a8b2e)
1#	$NetBSD: bsd.own.mk,v 1.535 2008/10/19 19:44:47 apb Exp $
2
3.if !defined(_BSD_OWN_MK_)
4_BSD_OWN_MK_=1
5
6MAKECONF?=	/etc/mk.conf
7.-include "${MAKECONF}"
8
9#
10# CPU model, derived from MACHINE_ARCH
11#
12MACHINE_CPU=	${MACHINE_ARCH:C/mipse[bl]/mips/:C/mips64e[bl]/mips/:C/sh3e[bl]/sh3/:S/m68000/m68k/:S/armeb/arm/}
13
14#
15# Subdirectory used below ${RELEASEDIR} when building a release
16#
17RELEASEMACHINEDIR?=	${MACHINE}
18
19#
20# Subdirectory or path component used for the following paths:
21#   distrib/${RELEASEMACHINE}
22#   distrib/notes/${RELEASEMACHINE}
23#   etc/etc.${RELEASEMACHINE}
24# Used when building a release.
25#
26RELEASEMACHINE?=	${MACHINE}
27
28#
29# NEED_OWN_INSTALL_TARGET is set to "no" by pkgsrc/mk/bsd.pkg.mk to
30# ensure that things defined by <bsd.own.mk> (default targets,
31# INSTALL_FILE, etc.) are not conflicting with bsd.pkg.mk.
32#
33NEED_OWN_INSTALL_TARGET?=	yes
34
35#
36# This lists the platforms which do not have working in-tree toolchains.
37# For the in-tree gcc 3.3.2 toolchain, this list is empty.
38# If some future port is not supported by the in-tree toolchain, this
39# should be set to "yes" for that port only.
40#
41TOOLCHAIN_MISSING?=	no
42
43# default to GCC4
44.if !defined(HAVE_GCC) && !defined(HAVE_PCC)
45HAVE_GCC=	4
46.endif
47
48# default to GDB6
49HAVE_GDB?=	6
50
51CPPFLAG_ISYSTEM=	-isystem
52.if defined(HAVE_GCC)
53.if ${HAVE_GCC} == 3
54CPPFLAG_ISYSTEMXX=	-isystem-cxx
55.else	# GCC 4
56CPPFLAG_ISYSTEMXX=	-cxx-isystem
57.endif
58.endif
59
60.if empty(.MAKEFLAGS:M-V*)
61.if defined(MAKEOBJDIRPREFIX) || defined(MAKEOBJDIR)
62PRINTOBJDIR=	${MAKE} -r -V .OBJDIR -f /dev/null xxx
63.else
64PRINTOBJDIR=	${MAKE} -V .OBJDIR
65.endif
66.else
67PRINTOBJDIR=	echo # prevent infinite recursion
68.endif
69
70#
71# Determine if running in the NetBSD source tree by checking for the
72# existence of build.sh and tools/ in the current or a parent directory,
73# and setting _SRC_TOP_ to the result.
74#
75.if !defined(_SRC_TOP_)			# {
76_SRC_TOP_!= cd ${.CURDIR}; while :; do \
77		here=`pwd`; \
78		[ -f build.sh  ] && [ -d tools ] && { echo $$here; break; }; \
79		case $$here in /) echo ""; break;; esac; \
80		cd ..; done
81
82.MAKEOVERRIDES+=	_SRC_TOP_
83
84.endif					# }
85
86#
87# If _SRC_TOP_ != "", we're within the NetBSD source tree, so set
88# defaults for NETBSDSRCDIR and _SRC_TOP_OBJ_.
89#
90.if (${_SRC_TOP_} != "")		# {
91
92NETBSDSRCDIR?=	${_SRC_TOP_}
93
94.if !defined(_SRC_TOP_OBJ_)
95_SRC_TOP_OBJ_!=		cd ${_SRC_TOP_} && ${PRINTOBJDIR}
96.MAKEOVERRIDES+=	_SRC_TOP_OBJ_
97.endif
98
99.endif	# _SRC_TOP_ != ""		# }
100
101
102.if (${_SRC_TOP_} != "") && \
103    (${TOOLCHAIN_MISSING} == "no" || defined(EXTERNAL_TOOLCHAIN))
104USETOOLS?=	yes
105.endif
106USETOOLS?=	no
107
108
109.if ${MACHINE_ARCH} == "mips" || ${MACHINE_ARCH} == "mips64" || \
110    ${MACHINE_ARCH} == "sh3"
111.BEGIN:
112	@echo "Must set MACHINE_ARCH to one of ${MACHINE_ARCH}eb or ${MACHINE_ARCH}el"
113	@false
114.elif defined(REQUIRETOOLS) && \
115      (${TOOLCHAIN_MISSING} == "no" || defined(EXTERNAL_TOOLCHAIN)) && \
116      ${USETOOLS} == "no"
117.BEGIN:
118	@echo "USETOOLS=no, but this component requires a version-specific host toolchain"
119	@false
120.endif
121
122#
123# Host platform information; may be overridden
124#
125.if !defined(HOST_OSTYPE)
126_HOST_OSNAME!=	uname -s
127_HOST_OSREL!=	uname -r
128_HOST_ARCH!=	uname -p 2>/dev/null || uname -m
129HOST_OSTYPE:=	${_HOST_OSNAME}-${_HOST_OSREL:C/\([^\)]*\)//g:[*]:C/ /_/g}-${_HOST_ARCH:C/\([^\)]*\)//g:[*]:C/ /_/g}
130.MAKEOVERRIDES+= HOST_OSTYPE
131.endif
132HOST_CYGWIN=	${HOST_OSTYPE:MCYGWIN*}
133
134.if ${USETOOLS} == "yes"						# {
135
136#
137# Provide a default for TOOLDIR.
138#
139.if !defined(TOOLDIR)
140TOOLDIR:=	${_SRC_TOP_OBJ_}/tooldir.${HOST_OSTYPE}
141.MAKEOVERRIDES+= TOOLDIR
142.endif
143
144#
145# This is the prefix used for the NetBSD-sourced tools.
146#
147_TOOL_PREFIX?=	nb
148
149#
150# If an external toolchain base is specified, use it.
151#
152.if defined(EXTERNAL_TOOLCHAIN)						# {
153AR=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-ar
154AS=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-as
155LD=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-ld
156NM=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-nm
157OBJCOPY=	${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-objcopy
158OBJDUMP=	${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-objdump
159RANLIB=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-ranlib
160SIZE=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-size
161STRIP=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-strip
162
163CC=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-gcc
164CPP=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-cpp
165CXX=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-c++
166FC=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-g77
167OBJC=		${EXTERNAL_TOOLCHAIN}/bin/${MACHINE_GNU_PLATFORM}-gcc
168.else									# } {
169# Define default locations for common tools.
170.if ${USETOOLS_BINUTILS:Uyes} == "yes"					#  {
171AR=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-ar
172AS=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-as
173LD=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-ld
174NM=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-nm
175OBJCOPY=	${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-objcopy
176OBJDUMP=	${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-objdump
177RANLIB=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-ranlib
178SIZE=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-size
179STRIP=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-strip
180.endif									#  }
181
182.if defined(HAVE_GCC) && ${USETOOLS_GCC:Uyes} == "yes"			#  {
183CC=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-gcc
184CPP=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-cpp
185CXX=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-c++
186FC=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-g77
187OBJC=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-gcc
188.endif									#  }
189
190.if defined(HAVE_PCC) && ${USETOOLS_PCC:Uyes} == "yes"
191CC=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-pcc
192CPP=		${TOOLDIR}/libexec/${MACHINE_GNU_PLATFORM}-cpp
193CXX=		false
194FC=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-f77
195OBJC=		false
196.endif
197
198.endif	# EXTERNAL_TOOLCHAIN						# }
199
200HOST_MKDEP=	${TOOLDIR}/bin/${_TOOL_PREFIX}host-mkdep
201
202DBSYM=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-dbsym
203ELF2ECOFF=	${TOOLDIR}/bin/${_TOOL_PREFIX}mips-elf2ecoff
204INSTALL=	${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-install
205LEX=		${TOOLDIR}/bin/${_TOOL_PREFIX}lex
206LINT=		CC=${CC:Q} ${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-lint
207LORDER=		NM=${NM:Q} MKTEMP=${TOOL_MKTEMP:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}lorder
208MKDEP=		CC=${CC:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}mkdep
209PAXCTL=		${TOOLDIR}/bin/${_TOOL_PREFIX}paxctl
210TSORT=		${TOOLDIR}/bin/${_TOOL_PREFIX}tsort -q
211YACC=		${TOOLDIR}/bin/${_TOOL_PREFIX}yacc
212
213TOOL_AMIGAAOUT2BB=	${TOOLDIR}/bin/${_TOOL_PREFIX}amiga-aout2bb
214TOOL_AMIGAELF2BB=	${TOOLDIR}/bin/${_TOOL_PREFIX}amiga-elf2bb
215TOOL_AMIGATXLT=		${TOOLDIR}/bin/${_TOOL_PREFIX}amiga-txlt
216TOOL_ASN1_COMPILE=	${TOOLDIR}/bin/${_TOOL_PREFIX}asn1_compile
217TOOL_ATF_COMPILE=	${TOOLDIR}/bin/${_TOOL_PREFIX}atf-compile
218TOOL_AWK=		${TOOLDIR}/bin/${_TOOL_PREFIX}awk
219TOOL_CAP_MKDB=		${TOOLDIR}/bin/${_TOOL_PREFIX}cap_mkdb
220TOOL_CAT=		${TOOLDIR}/bin/${_TOOL_PREFIX}cat
221TOOL_CKSUM=		${TOOLDIR}/bin/${_TOOL_PREFIX}cksum
222TOOL_COMPILE_ET=	${TOOLDIR}/bin/${_TOOL_PREFIX}compile_et
223TOOL_CONFIG=		${TOOLDIR}/bin/${_TOOL_PREFIX}config
224TOOL_CRUNCHGEN=		MAKE=${.MAKE:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}crunchgen
225TOOL_CTAGS=		${TOOLDIR}/bin/${_TOOL_PREFIX}ctags
226TOOL_DB=		${TOOLDIR}/bin/${_TOOL_PREFIX}db
227TOOL_DISKLABEL=		${TOOLDIR}/bin/nbdisklabel-${MAKEWRAPPERMACHINE}
228TOOL_EQN=		${TOOLDIR}/bin/${_TOOL_PREFIX}eqn
229TOOL_FDISK=		${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-fdisk
230TOOL_FGEN=		${TOOLDIR}/bin/${_TOOL_PREFIX}fgen
231TOOL_GENASSYM=		${TOOLDIR}/bin/${_TOOL_PREFIX}genassym
232TOOL_GENCAT=		${TOOLDIR}/bin/${_TOOL_PREFIX}gencat
233TOOL_GMAKE=		${TOOLDIR}/bin/${_TOOL_PREFIX}gmake
234TOOL_GROFF=		PATH=${TOOLDIR}/lib/groff:$${PATH} ${TOOLDIR}/bin/${_TOOL_PREFIX}groff
235TOOL_HEXDUMP=		${TOOLDIR}/bin/${_TOOL_PREFIX}hexdump
236TOOL_HP300MKBOOT=	${TOOLDIR}/bin/${_TOOL_PREFIX}hp300-mkboot
237TOOL_HP700MKBOOT=	${TOOLDIR}/bin/${_TOOL_PREFIX}hp700-mkboot
238TOOL_INDXBIB=		${TOOLDIR}/bin/${_TOOL_PREFIX}indxbib
239TOOL_INSTALLBOOT=	${TOOLDIR}/bin/${_TOOL_PREFIX}installboot
240TOOL_INSTALL_INFO=	${TOOLDIR}/bin/${_TOOL_PREFIX}install-info
241TOOL_JOIN=		${TOOLDIR}/bin/${_TOOL_PREFIX}join
242TOOL_M4=		${TOOLDIR}/bin/${_TOOL_PREFIX}m4
243TOOL_MACPPCFIXCOFF=	${TOOLDIR}/bin/${_TOOL_PREFIX}macppc-fixcoff
244TOOL_MAKEFS=		${TOOLDIR}/bin/${_TOOL_PREFIX}makefs
245TOOL_MAKEINFO=		${TOOLDIR}/bin/${_TOOL_PREFIX}makeinfo
246TOOL_MAKEWHATIS=	${TOOLDIR}/bin/${_TOOL_PREFIX}makewhatis
247TOOL_MDSETIMAGE=	${TOOLDIR}/bin/${MACHINE_GNU_PLATFORM}-mdsetimage
248TOOL_MENUC=		MENUDEF=${TOOLDIR}/share/misc ${TOOLDIR}/bin/${_TOOL_PREFIX}menuc
249TOOL_MIPSELF2ECOFF=	${TOOLDIR}/bin/${_TOOL_PREFIX}mips-elf2ecoff
250TOOL_MKCSMAPPER=	${TOOLDIR}/bin/${_TOOL_PREFIX}mkcsmapper
251TOOL_MKESDB=		${TOOLDIR}/bin/${_TOOL_PREFIX}mkesdb
252TOOL_MKLOCALE=		${TOOLDIR}/bin/${_TOOL_PREFIX}mklocale
253TOOL_MKMAGIC=		${TOOLDIR}/bin/${_TOOL_PREFIX}file
254TOOL_MKTEMP=		${TOOLDIR}/bin/${_TOOL_PREFIX}mktemp
255TOOL_MSGC=		MSGDEF=${TOOLDIR}/share/misc ${TOOLDIR}/bin/${_TOOL_PREFIX}msgc
256TOOL_MTREE=		${TOOLDIR}/bin/${_TOOL_PREFIX}mtree
257TOOL_PAX=		${TOOLDIR}/bin/${_TOOL_PREFIX}pax
258TOOL_PIC=		${TOOLDIR}/bin/${_TOOL_PREFIX}pic
259TOOL_POWERPCMKBOOTIMAGE=${TOOLDIR}/bin/${_TOOL_PREFIX}powerpc-mkbootimage
260TOOL_PWD_MKDB=		${TOOLDIR}/bin/${_TOOL_PREFIX}pwd_mkdb
261TOOL_REFER=		${TOOLDIR}/bin/${_TOOL_PREFIX}refer
262TOOL_ROFF_ASCII=	PATH=${TOOLDIR}/lib/groff:$${PATH} ${TOOLDIR}/bin/${_TOOL_PREFIX}nroff
263TOOL_ROFF_DVI=		${TOOL_GROFF} -Tdvi
264TOOL_ROFF_HTML=		${TOOL_GROFF} -Tlatin1 -mdoc2html
265TOOL_ROFF_PS=		${TOOL_GROFF} -Tps
266TOOL_ROFF_RAW=		${TOOL_GROFF} -Z
267TOOL_RPCGEN=		RPCGEN_CPP=${CPP:Q} ${TOOLDIR}/bin/${_TOOL_PREFIX}rpcgen
268TOOL_SED=		${TOOLDIR}/bin/${_TOOL_PREFIX}sed
269TOOL_SOELIM=		${TOOLDIR}/bin/${_TOOL_PREFIX}soelim
270TOOL_SPARKCRC=		${TOOLDIR}/bin/${_TOOL_PREFIX}sparkcrc
271TOOL_STAT=		${TOOLDIR}/bin/${_TOOL_PREFIX}stat
272TOOL_STRFILE=		${TOOLDIR}/bin/${_TOOL_PREFIX}strfile
273TOOL_SUNLABEL=		${TOOLDIR}/bin/${_TOOL_PREFIX}sunlabel
274TOOL_TBL=		${TOOLDIR}/bin/${_TOOL_PREFIX}tbl
275TOOL_UUDECODE=		${TOOLDIR}/bin/${_TOOL_PREFIX}uudecode
276TOOL_VGRIND=		${TOOLDIR}/bin/${_TOOL_PREFIX}vgrind -f
277TOOL_ZIC=		${TOOLDIR}/bin/${_TOOL_PREFIX}zic
278
279.endif	# USETOOLS == yes						# }
280
281#
282# Targets to check if DESTDIR or RELEASEDIR is provided
283#
284.if !target(check_DESTDIR)
285check_DESTDIR: .PHONY .NOTMAIN
286.if !defined(DESTDIR)
287	@echo "setenv DESTDIR before doing that!"
288	@false
289.else
290	@true
291.endif
292.endif
293
294.if !target(check_RELEASEDIR)
295check_RELEASEDIR: .PHONY .NOTMAIN
296.if !defined(RELEASEDIR)
297	@echo "setenv RELEASEDIR before doing that!"
298	@false
299.else
300	@true
301.endif
302.endif
303
304
305.if ${USETOOLS} == "yes"						# {
306#
307# Make sure DESTDIR is set, so that builds with these tools always
308# get appropriate -nostdinc, -nostdlib, etc. handling.  The default is
309# <empty string>, meaning start from /, the root directory.
310#
311DESTDIR?=
312.endif									# }
313
314#
315# Build a dynamically linked /bin and /sbin, with the necessary shared
316# libraries moved from /usr/lib to /lib and the shared linker moved
317# from /usr/libexec to /lib
318#
319# Note that if the BINDIR is not /bin or /sbin, then we always use the
320# non-DYNAMICROOT behavior (i.e. it is only enabled for programs in /bin
321# and /sbin).  See <bsd.shlib.mk>.
322#
323MKDYNAMICROOT?=	yes
324
325#
326# Where the system object and source trees are kept; can be configurable
327# by the user in case they want them in ~/foosrc and ~/fooobj (for example).
328#
329BSDSRCDIR?=	/usr/src
330BSDOBJDIR?=	/usr/obj
331NETBSDSRCDIR?=	${BSDSRCDIR}
332
333BINGRP?=	wheel
334BINOWN?=	root
335BINMODE?=	555
336NONBINMODE?=	444
337
338MANDIR?=	/usr/share/man
339MANGRP?=	wheel
340MANOWN?=	root
341MANMODE?=	${NONBINMODE}
342MANINSTALL?=	catinstall htmlinstall maninstall
343
344INFODIR?=	/usr/share/info
345INFOGRP?=	wheel
346INFOOWN?=	root
347INFOMODE?=	${NONBINMODE}
348
349LIBDIR?=	/usr/lib
350
351LINTLIBDIR?=	/usr/libdata/lint
352LIBGRP?=	${BINGRP}
353LIBOWN?=	${BINOWN}
354LIBMODE?=	${NONBINMODE}
355
356DOCDIR?=	/usr/share/doc
357HTMLDOCDIR?=	/usr/share/doc/html
358DOCGRP?=	wheel
359DOCOWN?=	root
360DOCMODE?=	${NONBINMODE}
361
362NLSDIR?=	/usr/share/nls
363NLSGRP?=	wheel
364NLSOWN?=	root
365NLSMODE?=	${NONBINMODE}
366
367KMODDIR?=	/usr/lkm
368KMODGRP?=	wheel
369KMODOWN?=	root
370KMODMODE?=	${NONBINMODE}
371
372KMODULEGRP?=	wheel
373KMODULEOWN?=	root
374KMODULEMODE?=	${NONBINMODE}
375
376LOCALEDIR?=	/usr/share/locale
377LOCALEGRP?=	wheel
378LOCALEOWN?=	root
379LOCALEMODE?=	${NONBINMODE}
380
381FIRMWAREDIR?=	/libdata/firmware
382FIRMWAREGRP?=	wheel
383FIRMWAREOWN?=	root
384FIRMWAREMODE?=	${NONBINMODE}
385
386DEBUGDIR?=	/usr/libdata/debug
387DEBUGGRP?=	wheel
388DEBUGOWN?=	root
389DEBUGMODE?=	${NONBINMODE}
390
391#
392# Data-driven table using make variables to control how
393# toolchain-dependent targets and shared libraries are built
394# for different platforms and object formats.
395#
396# OBJECT_FMT:		currently either "ELF" or "a.out".
397#
398# All platforms are ELF.
399#
400OBJECT_FMT=	ELF
401
402#
403# If this platform's toolchain is missing, we obviously cannot build it.
404#
405.if ${TOOLCHAIN_MISSING} != "no"
406MKBFD:= no
407MKGDB:= no
408MKGCC:= no
409.endif
410
411#
412# If we are using an external toolchain, we can still build the target's
413# BFD stuff, but we cannot build GCC's support libraries, since those are
414# tightly-coupled to the version of GCC being used.
415#
416.if defined(EXTERNAL_TOOLCHAIN)
417MKGCC:= no
418.endif
419
420#
421# The m68000 port is incomplete.
422#
423.if ${MACHINE_ARCH} == "m68000"
424NOPIC=		# defined
425MKISCSI=	no
426# XXX GCC 4 outputs mcount() calling sequences that try to load values
427# from over 64KB away and this fails to assemble.
428.if defined(HAVE_GCC) && (${HAVE_GCC} == 4)
429NOPROFILE=	# defined
430.endif
431.endif
432
433#
434# The ia64 port is incomplete.
435#
436.if ${MACHINE_ARCH} == "ia64"
437MKLINT=		no
438MKGDB=		no
439.endif
440
441#
442# On the MIPS, all libs are compiled with ABIcalls (and are thus PIC),
443# not just shared libraries, so don't build the _pic version.
444#
445.if ${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb"
446MKPICLIB:=	no
447.endif
448
449#
450# On VAX using ELF, all objects are PIC, not just shared libraries,
451# so don't build the _pic version.  Unless we are using GCC3 which
452# doesn't support PIC yet.
453#
454.if ${MACHINE_ARCH} == "vax"
455MKPICLIB=	no
456.endif
457
458#
459# Location of the file that contains the major and minor numbers of the
460# version of a shared library.  If this file exists a shared library
461# will be built by <bsd.lib.mk>.
462#
463SHLIB_VERSION_FILE?= ${.CURDIR}/shlib_version
464
465#
466# GNU sources and packages sometimes see architecture names differently.
467#
468GNU_ARCH.coldfire=m68k
469GNU_ARCH.m68000=m68010
470GNU_ARCH.sh3eb=sh
471GNU_ARCH.sh3el=shle
472GNU_ARCH.mips64eb=mips64
473MACHINE_GNU_ARCH=${GNU_ARCH.${MACHINE_ARCH}:U${MACHINE_ARCH}}
474
475#
476# In order to identify NetBSD to GNU packages, we sometimes need
477# an "elf" tag for historically a.out platforms.
478#
479.if ${OBJECT_FMT} == "ELF" && \
480    (${MACHINE_GNU_ARCH} == "arm" || \
481     ${MACHINE_GNU_ARCH} == "armeb" || \
482     ${MACHINE_ARCH} == "i386" || \
483     ${MACHINE_CPU} == "m68k" || \
484     ${MACHINE_GNU_ARCH} == "sh" || \
485     ${MACHINE_GNU_ARCH} == "shle" || \
486     ${MACHINE_ARCH} == "sparc" || \
487     ${MACHINE_ARCH} == "vax")
488MACHINE_GNU_PLATFORM?=${MACHINE_GNU_ARCH}--netbsdelf
489.else
490MACHINE_GNU_PLATFORM?=${MACHINE_GNU_ARCH}--netbsd
491.endif
492
493TARGETS+=	all clean cleandir depend dependall includes \
494		install lint obj regress tags html
495PHONY_NOTMAIN =	all clean cleandir depend dependall distclean includes \
496		install lint obj regress tags beforedepend afterdepend \
497		beforeinstall afterinstall realinstall realdepend realall \
498		html subdir-all subdir-install subdir-depend
499.PHONY:		${PHONY_NOTMAIN}
500.NOTMAIN:	${PHONY_NOTMAIN}
501
502.if ${NEED_OWN_INSTALL_TARGET} != "no"
503.if !target(install)
504install:	beforeinstall .WAIT subdir-install realinstall .WAIT afterinstall
505beforeinstall:
506subdir-install:
507realinstall:
508afterinstall:
509.endif
510all:		realall subdir-all
511subdir-all:
512realall:
513depend:		realdepend subdir-depend
514subdir-depend:
515realdepend:
516distclean:	cleandir
517cleandir:	clean
518
519dependall:	.NOTMAIN realdepend .MAKE
520	@cd ${.CURDIR}; ${MAKE} realall
521.endif
522
523#
524# Define MKxxx variables (which are either yes or no) for users
525# to set in /etc/mk.conf and override in the make environment.
526# These should be tested with `== "no"' or `!= "no"'.
527# The NOxxx variables should only be set by Makefiles.
528#
529# Please keep etc/Makefile and share/man/man5/mk.conf.5 in sync
530# with changes to the MK* variables here.
531#
532
533#
534# Supported NO* options (if defined, MK* will be forced to "no",
535# regardless of user's mk.conf setting).
536#
537# Source makefiles should set NO*, and not MK*, and must do so before
538# including bsd.own.mk.
539#
540.for var in \
541	NOCRYPTO NODOC NOHTML NOINFO NOLINKLIB NOLINT NOMAN NONLS NOOBJ NOPIC \
542	NOPICINSTALL NOPROFILE NOSHARE NOSTATICLIB
543.if defined(${var})
544MK${var:S/^NO//}:=	no
545.endif
546.endfor
547
548#
549# Older-style variables that enabled behaviour when set.
550#
551.for var in MANZ UNPRIVED UPDATE
552.if defined(${var})
553MK${var}:=	yes
554.endif
555.endfor
556
557#
558# MK* options which default to "yes".
559#
560.for var in \
561	MKATF \
562	MKBFD MKBINUTILS \
563	MKCATPAGES MKCRYPTO MKCOMPLEX MKCVS \
564	MKDOC \
565	MKGCC MKGCCCMDS MKGDB \
566	MKHESIOD MKHTML \
567	MKIEEEFP MKINET6 MKINFO MKIPFILTER MKISCSI \
568	MKKERBEROS \
569	MKLDAP MKLINKLIB MKLINT \
570	MKMAN \
571	MKNLS \
572	MKOBJ \
573	MKPAM \
574	MKPF MKPIC MKPICINSTALL MKPICLIB MKPOSTFIX MKPROFILE \
575	MKSHARE MKSKEY MKSTATICLIB \
576	MKYP
577${var}?=	yes
578.endfor
579
580#
581# MK* options which default to "no".
582#
583.for var in \
584	MKCRYPTO_IDEA MKCRYPTO_MDC2 MKCRYPTO_RC5 MKDEBUG MKDEBUGLIB \
585	MKMANZ MKMODULAR MKOBJDIRS \
586	MKPCC MKPCCCMDS \
587	MKPUFFS MKSOFTFLOAT MKSTRIPIDENT \
588	MKUNPRIVED MKUPDATE MKX11 MKXORG
589${var}?=no
590.endfor
591
592#
593# Force some options off if their dependencies are off.
594#
595
596.if ${MKCRYPTO} == "no"
597MKKERBEROS:=	no
598.endif
599
600.if ${MKMAN} == "no"
601MKCATPAGES:=	no
602MKHTML:=	no
603.endif
604
605.if ${MKLINKLIB} == "no"
606MKLINT:=	no
607MKPICINSTALL:=	no
608MKPROFILE:=	no
609.endif
610
611.if ${MKPIC} == "no"
612MKPICLIB:=	no
613.endif
614
615.if ${MKOBJ} == "no"
616MKOBJDIRS:=	no
617.endif
618
619.if ${MKSHARE} == "no"
620MKCATPAGES:=	no
621MKDOC:=		no
622MKINFO:=	no
623MKHTML:=	no
624MKMAN:=		no
625MKNLS:=		no
626.endif
627
628#
629# install(1) parameters.
630#
631COPY?=		-c
632.if ${MKUPDATE} == "no"
633PRESERVE?=
634.else
635PRESERVE?=	-p
636.endif
637RENAME?=	-r
638HRDLINK?=	-l h
639SYMLINK?=	-l s
640
641METALOG?=	${DESTDIR}/METALOG
642METALOG.add?=	${TOOL_CAT} -l >> ${METALOG}
643.if (${_SRC_TOP_} != "")	# only set INSTPRIV if inside ${NETBSDSRCDIR}
644.if ${MKUNPRIVED} != "no"
645INSTPRIV.unpriv=-U -M ${METALOG} -D ${DESTDIR} -h sha1
646.else
647INSTPRIV.unpriv=
648.endif
649INSTPRIV?=	${INSTPRIV.unpriv} -N ${NETBSDSRCDIR}/etc
650.endif
651STRIPFLAG?=
652
653.if ${NEED_OWN_INSTALL_TARGET} != "no"
654INSTALL_DIR?=		${INSTALL} ${INSTPRIV} -d
655INSTALL_FILE?=		${INSTALL} ${INSTPRIV} ${COPY} ${PRESERVE} ${RENAME}
656INSTALL_LINK?=		${INSTALL} ${INSTPRIV} ${HRDLINK} ${RENAME}
657INSTALL_SYMLINK?=	${INSTALL} ${INSTPRIV} ${SYMLINK} ${RENAME}
658HOST_INSTALL_FILE?=	${INSTALL} ${COPY} ${PRESERVE} ${RENAME}
659HOST_INSTALL_DIR?=	${INSTALL} -d
660HOST_INSTALL_SYMLINK?=	${INSTALL} ${SYMLINK} ${RENAME}
661.endif
662
663#
664# Set defaults for the USE_xxx variables.
665#
666
667#
668# USE_* options which default to "no" and will be forced to "no" if their
669# corresponding MK* variable is set to "no".
670#
671.for var in USE_SKEY
672.if (${${var:S/USE_/MK/}} == "no")
673${var}:= no
674.else
675${var}?= no
676.endif
677.endfor
678
679#
680# USE_* options which default to "yes" unless their corresponding MK*
681# variable is set to "no".
682#
683.for var in USE_HESIOD USE_INET6 USE_KERBEROS USE_LDAP USE_PAM USE_YP
684.if (${${var:S/USE_/MK/}} == "no")
685${var}:= no
686.else
687${var}?= yes
688.endif
689.endfor
690
691#
692# USE_* options which default to "yes".
693#
694.for var in USE_JEMALLOC
695${var}?= yes
696.endfor
697
698#
699# USE_* options which default to "no".
700#
701#.for var in
702#${var}?= no
703#.endfor
704
705#
706# Where X11 sources are and where it is installed to.
707#
708X11SRCDIR?=		/usr/xsrc
709X11SRCDIR.xc?=		${X11SRCDIR}/xfree/xc
710X11SRCDIR.local?=	${X11SRCDIR}/local
711.if ${MKXORG} != "no"
712X11ROOTDIR?=		/usr/X11R7
713.else
714X11ROOTDIR?=		/usr/X11R6
715.endif
716X11BINDIR?=		${X11ROOTDIR}/bin
717X11ETCDIR?=		/etc/X11
718X11FONTDIR?=		${X11ROOTDIR}/lib/X11/fonts
719X11INCDIR?=		${X11ROOTDIR}/include
720X11LIBDIR?=		${X11ROOTDIR}/lib/X11
721X11MANDIR?=		${X11ROOTDIR}/man
722X11USRLIBDIR?=		${X11ROOTDIR}/lib
723
724#
725# New modular-xorg based builds
726#
727X11SRCDIRMIT?=		${X11SRCDIR}/external/mit
728.for _lib in \
729	FS ICE SM X11 XScrnSaver XTrap Xau Xcomposite Xcursor Xdamage \
730	Xdmcp Xevie Xext Xfixes Xfont Xft Xi Xinerama Xmu Xp Xpm XprintUtil \
731	Xrandr Xrender Xres Xt Xtst Xv XvMC Xxf86dga Xxf86misc Xxf86vm drm \
732	fontenc xkbfile xkbui Xaw lbxutil Xfontcache XprintAppUtil
733X11SRCDIR.${_lib}?=		${X11SRCDIRMIT}/lib${_lib}/dist
734.endfor
735
736.for _proto in \
737	xcmisc xext xf86bigfont bigreqs input kb x fonts fixes scrnsaver \
738	xinerama print render resource record video xf86dga xf86misc \
739	xf86vidmode composite damage trap gl randr fontcache xf86dri
740X11SRCDIR.${_proto}proto?=		${X11SRCDIRMIT}/${_proto}proto/dist
741.endfor
742
743.for _dir in \
744	xtrans fontconfig expat freetype evieext mkfontscale bdftopcf \
745	xkbcomp xorg-cf-files imake xorg-server xbiff xkbdata \
746	xbitmaps appres xeyes xev xedit sessreg pixman \
747	beforelight bitmap editres makedepend fonttosfnt fslsfonts \
748	fstobdf MesaDemos MesaLib ico iceauth lbxproxy listres lndir \
749	luit xproxymanagementprotocol mkfontdir oclock proxymngr rgb \
750	setxkbmap smproxy twm viewres x11perf xauth xcalc xclipboard \
751	xclock xcmsdb xconsole xcutsel xditview xdpyinfo xdriinfo xdm \
752	xfd xf86dga xfindproxy xfontsel xfwp xgamma xgc xhost xinit \
753	xkill xload xlogo xlsatoms xlsclients xlsfonts xmag xmessage \
754	xmh xmodmap xmore xman xprop xrandr xrdb xrefresh xset \
755	xsetmode xsetpointer xsetroot xsm xstdcmap xvidtune xvinfo \
756	xwininfo xwud xprehashprinterlist xplsprinters xkbprint xkbevd \
757	xterm xwd xfs xfsinfo xphelloworld xtrap xkbutils xkbcomp \
758	xkeyboard-config xinput \
759	font-adobe-100dpi font-adobe-75dpi font-adobe-utopia-100dpi \
760	font-adobe-utopia-75dpi font-adobe-utopia-type1 \
761	font-alias \
762	font-bh-100dpi font-bh-75dpi font-bh-lucidatypewriter-100dpi \
763	font-bh-lucidatypewriter-75dpi font-bh-ttf font-bh-type1 \
764	font-bitstream-100dpi font-bitstream-75dpi font-bitstream-type1 \
765	font-cursor-misc font-daewoo-misc font-dec-misc font-ibm-type1 \
766	font-isas-misc font-jis-misc font-misc-misc font-mutt-misc \
767	font-util ttf-bitstream-vera encodings
768X11SRCDIR.${_dir}?=		${X11SRCDIRMIT}/${_dir}/dist
769.endfor
770
771.for _i in \
772	keyboard mouse vmmouse void
773X11SRCDIR.xf86-input-${_i}?=	${X11SRCDIRMIT}/xf86-input-${_i}/dist
774.endfor
775
776.for _v in \
777	apm ark ast ati chips cirrus cyrix glint i128 i740 imstt intel \
778	mach64 mga neomagic nsc nv nvxbox r128 radeonhd rendition \
779	s3 s3virge savage \
780	siliconmotion sis tdfx tga trident tseng vesa vga via vmware wsfb
781X11SRCDIR.xf86-video-${_v}?=	${X11SRCDIRMIT}/xf86-video-${_v}/dist
782.endfor
783
784# Default to no old Xserver builds for now
785MKXORG_WITH_XSRC_XSERVER?=	no
786
787.if ${MKXORG} != no
788X11DRI?=			yes
789.endif
790
791X11DRI?=			no
792X11LOADABLE?=			yes
793
794
795#
796# MAKEDIRTARGET dir target [extra make(1) params]
797#	run "cd $${dir} && ${MAKE} [params] $${target}", with a pretty message
798#
799MAKEDIRTARGET=\
800	@_makedirtarget() { \
801		dir="$$1"; shift; \
802		target="$$1"; shift; \
803		case "$${dir}" in \
804		/*)	this="$${dir}/"; \
805			real="$${dir}" ;; \
806		.)	this="${_THISDIR_}"; \
807			real="${.CURDIR}" ;; \
808		*)	this="${_THISDIR_}$${dir}/"; \
809			real="${.CURDIR}/$${dir}" ;; \
810		esac; \
811		show=$${this:-.}; \
812		echo "$${target} ===> $${show%/}$${1:+	(with: $$@)}"; \
813		cd "$${real}" \
814		&& ${MAKE} _THISDIR_="$${this}" "$$@" $${target}; \
815	}; \
816	_makedirtarget
817
818#
819# MAKEVERBOSE support.  Levels are:
820#	0	No messages
821#	1	Enable info messages, suppress command output
822#	2	Enable info messages and command output
823#
824MAKEVERBOSE?=		2
825
826.if ${MAKEVERBOSE} == 0
827_MKMSG?=	@\#
828_MKSHMSG?=	: echo
829_MKSHECHO?=	: echo
830.SILENT:
831.elif ${MAKEVERBOSE} == 1
832_MKMSG?=	@echo '   '
833_MKSHMSG?=	echo '   '
834_MKSHECHO?=	: echo
835.SILENT:
836.else	# MAKEVERBOSE == 2 ?
837_MKMSG?=	@echo '\#  '
838_MKSHMSG?=	echo '\#  '
839_MKSHECHO?=	echo
840.SILENT: __makeverbose_dummy_target__
841.endif
842
843_MKMSG_BUILD?=		${_MKMSG} "  build "
844_MKMSG_CREATE?=		${_MKMSG} " create "
845_MKMSG_COMPILE?=	${_MKMSG} "compile "
846_MKMSG_FORMAT?=		${_MKMSG} " format "
847_MKMSG_INSTALL?=	${_MKMSG} "install "
848_MKMSG_LINK?=		${_MKMSG} "   link "
849_MKMSG_LEX?=		${_MKMSG} "    lex "
850_MKMSG_REMOVE?=		${_MKMSG} " remove "
851_MKMSG_YACC?=		${_MKMSG} "   yacc "
852
853_MKSHMSG_CREATE?=	${_MKSHMSG} " create "
854_MKSHMSG_INSTALL?=	${_MKSHMSG} "install "
855
856_MKTARGET_BUILD?=	${_MKMSG_BUILD} ${.CURDIR:T}/${.TARGET}
857_MKTARGET_CREATE?=	${_MKMSG_CREATE} ${.CURDIR:T}/${.TARGET}
858_MKTARGET_COMPILE?=	${_MKMSG_COMPILE} ${.CURDIR:T}/${.TARGET}
859_MKTARGET_FORMAT?=	${_MKMSG_FORMAT} ${.CURDIR:T}/${.TARGET}
860_MKTARGET_INSTALL?=	${_MKMSG_INSTALL} ${.TARGET}
861_MKTARGET_LINK?=	${_MKMSG_LINK} ${.CURDIR:T}/${.TARGET}
862_MKTARGET_LEX?=		${_MKMSG_LEX} ${.CURDIR:T}/${.TARGET}
863_MKTARGET_REMOVE?=	${_MKMSG_REMOVE} ${.TARGET}
864_MKTARGET_YACC?=	${_MKMSG_YACC} ${.CURDIR:T}/${.TARGET}
865
866.endif	# !defined(_BSD_OWN_MK_)
867