xref: /netbsd-src/etc/Makefile.params (revision 479d8f7d843cc1b22d497efdf1f27a50ee8418d4)
1#	$NetBSD: Makefile.params,v 1.15 2016/12/25 16:44:39 christos Exp $
2#
3# Makefile fragment for printing build parameters.
4#
5# Public variables:
6#	RELEASEVARS
7#		List of variables whose value should be printed.
8#
9#	PRINT_PARAMS
10#		A command to print the desired variables and values
11#		to stdout, without any additional debugging information.
12#		Values are printed as single-quoted strings, with
13#		embedded quotes and newlines escaped in a way that's
14#		acceptable to sh(1).  Undefined values are printed
15#		as "(undefined)" (without quotation marks).
16#
17# Internal targets:
18# 	_params:
19#		Prints the names and values of all the variables
20#		listed in ${RELEASEVARS}.  The desired results may be
21#		redirected somewhere other than stdout, for example by
22#		setting _params_redirect='>&3'.	 stdout and stderr may
23#		contain unwanted debugging information, from make and
24#		the shell.
25#
26# Internal variables:
27#	_params_redirect:
28#		If set, this should be a shell redirection specification, such
29#		as '>&3', controlling where the output from "make _params" will
30#		be sent.
31#
32# Example:
33#	. ${NETBSDSRCDIR}/etc/Makefile.params
34#	show-params: .MAKE .PHONY # print params to stdout
35#		@${PRINT_PARAMS}
36#
37
38.include <bsd.own.mk>	# for some variables
39
40RELEASEVARS=	DISTRIBVER EXTERNAL_TOOLCHAIN HAVE_GCC HAVE_GDB \
41		HAVE_LLVM HAVE_PCC INSTALLWORLDDIR \
42		MACHINE MACHINE_ARCH MAKE MAKECONF \
43		MAKEOBJDIR MAKEOBJDIRPREFIX MAKEVERBOSE \
44		MKARZERO MKATF MKBFD MKBINUTILS MKCATPAGES \
45		MKCRYPTO MKCRYPTO_RC5 MKCTF MKCVS \
46		MKDEBUG MKDEBUGLIB MKDOC MKDTRACE MKDYNAMICROOT \
47		MKGCC MKGCCCMDS MKGDB \
48		MKHESIOD MKHTML MKIEEEFP MKINET6 MKINFO MKIPFILTER \
49		MKKERBEROS MKKYUA MKLDAP MKLINKLIB MKLINT MKLLVM \
50		MKMAN MKMANZ MKMDNS MKNLS MKNPF MKOBJ MKOBJDIRS \
51		MKPAM MKPCC MKPF MKPIC MKPICINSTALL MKPICLIB MKPOSTFIX \
52		MKPROFILE MKREPRO \
53		MKSHARE MKSKEY MKSOFTFLOAT MKSTATICLIB \
54		MKUNPRIVED MKUPDATE MKX11 MKYP \
55		NOCLEANDIR NODISTRIBDIRS NOINCLUDES \
56		TOOLCHAIN_MISSING \
57		USE_HESIOD USE_INET6 USE_JEMALLOC USE_KERBEROS USE_LDAP \
58		USE_PAM USE_SKEY USE_YP \
59		USETOOLS
60
61.if ${MKREPRO:Uno} != "yes"
62RELEASEVARS+= 	BSDOBJDIR BSDSRCDIR BUILDID BUILDINFO BUILDSEED \
63		DESTDIR KERNARCHDIR KERNCONFDIR KERNOBJDIR KERNSRCDIR \
64		MAKEFLAGS NBUILDJOBS NETBSDSRCDIR OBJMACHINE OBJMACHINE_ARCH \
65		RELEASEDIR RELEASEMACHINEDIR TOOLDIR USR_OBJMACHINE X11SRCDIR
66.endif
67
68
69#
70# Duplicate the DISTRIBVER setting from src/etc/Makefile.
71#
72.ifndef DISTRIBVER
73DISTRIBVER!=	${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh
74.endif
75
76#
77# _params does the printing.
78#
79_params_redirect?= # empty
80
81_params: .PHONY
82.for var in ${RELEASEVARS:O}
83.if defined(${var})
84	@printf "%20s = '%-s'\n" ${var} ${${var}:C/'/'\\\\''/gW:Q} \
85	    ${_params_redirect}
86.else
87	@printf "%20s = (undefined)\n" ${var} \
88	    ${_params_redirect}
89.endif
90.endfor
91
92# PRINT_PARAMS:
93#
94# The output from the "make _params" can include the following types of
95# unwanted lines:
96#
97#     make -j prints "--- _params ---";
98#
99#     if MAKEVERBOSE is set to 3 or more then make prints each "printf"
100#     command in addition to executing it;
101#
102#     if MAKEVERBOSE is set to 4 then the shell prints each command
103#     (prefixed with "+").
104#
105# So the resulting output can look like this:
106#
107#	--- _params ---
108#	+ echo 'printf "%20s = '\''%-s'\''\n" BSDOBJDIR /usr/obj'
109#	printf "%20s = '%-s'\n" BSDOBJDIR /usr/obj
110#	+ printf '%20s = '\''%-s'\''\n' BSDOBJDIR /usr/obj
111#	           BSDOBJDIR = '/usr/obj'
112#	+ echo 'printf "%20s = '\''%-s'\''\n" BSDSRCDIR /usr/src'
113#	printf "%20s = '%-s'\n" BSDSRCDIR /usr/src
114#	+ printf '%20s = '\''%-s'\''\n' BSDSRCDIR /usr/src
115#	           BSDSRCDIR = '/usr/src'
116#	[...]
117#
118# where what we want is just this:
119#
120#	           BSDOBJDIR = '/usr/obj'
121#	           BSDSRCDIR = '/usr/src'
122#	           [...]
123#
124# The shell redirections in ${PRINT_PARAMS} ensure that the unwanted
125# noise is discarded (via ">/dev/null"), while the desired information
126# ends up on the subshell's stdout (via ">&3" and "3>&1").  The value
127# of _params_redirect is passed in the environment instead of on the
128# command line, to prevent it from appearing in MAKEFLAGS (which would
129# appear in the output).
130#
131PRINT_PARAMS:=	(_params_redirect='>&3' ${MAKE} -f ${.PARSEDIR:Q}/${.PARSEFILE:Q} _params 3>&1 >/dev/null)
132