summaryrefslogtreecommitdiff
path: root/etc/Makefile.params
blob: 927147c7cdb45c9c3a98e19b68f21b2f715086a8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#	$NetBSD: Makefile.params,v 1.13 2015/07/23 08:03:25 mrg Exp $
#
# Makefile fragment for printing build parameters.
#
# Public variables:
#	RELEASEVARS
#		List of variables whose value should be printed.
#
#	PRINT_PARAMS
#		A command to print the desired variables and values
#		to stdout, without any additional debugging information.
#		Values are printed as single-quoted strings, with
#		embedded quotes and newlines escaped in a way that's
#		acceptable to sh(1).  Undefined values are printed
#		as "(undefined)" (without quotation marks).
#
# Internal targets:
# 	_params:
#		Prints the names and values of all the variables
#		listed in ${RELEASEVARS}.  The desired results may be
#		redirected somewhere other than stdout, for example by
#		setting _params_redirect='>&3'.	 stdout and stderr may
#		contain unwanted debugging information, from make and
#		the shell.
#
# Internal variables:
#	_params_redirect:
#		If set, this should be a shell redirection specification, such
#		as '>&3', controlling where the output from "make _params" will
#		be sent.
#
# Example:
#	. ${NETBSDSRCDIR}/etc/Makefile.params
#	show-params: .MAKE .PHONY # print params to stdout
#		@${PRINT_PARAMS}
#

.include <bsd.own.mk>	# for some variables

RELEASEVARS=	BSDOBJDIR BSDSRCDIR BUILDID BUILDINFO BUILDSEED \
		DESTDIR DISTRIBVER EXTERNAL_TOOLCHAIN HAVE_GCC HAVE_GDB \
		HAVE_LLVM HAVE_PCC INSTALLWORLDDIR \
		KERNARCHDIR KERNCONFDIR KERNOBJDIR KERNSRCDIR \
		MACHINE MACHINE_ARCH MAKE MAKECONF MAKEFLAGS \
		MAKEOBJDIR MAKEOBJDIRPREFIX MAKEVERBOSE \
		MKARZERO MKATF MKBFD MKBINUTILS MKCATPAGES \
		MKCRYPTO MKCRYPTO_RC5 MKCTF MKCVS \
		MKDEBUG MKDEBUGLIB MKDOC MKDTRACE MKDYNAMICROOT \
		MKGCC MKGCCCMDS MKGDB \
		MKHESIOD MKHTML MKIEEEFP MKINET6 MKINFO MKIPFILTER \
		MKKERBEROS MKKYUA MKLDAP MKLINKLIB MKLINT MKLLVM \
		MKMAN MKMANZ MKMDNS MKNLS MKNPF MKOBJ MKOBJDIRS \
		MKPAM MKPCC MKPF MKPIC MKPICINSTALL MKPICLIB MKPOSTFIX \
		MKPROFILE MKREPRO \
		MKSHARE MKSKEY MKSOFTFLOAT MKSTATICLIB \
		MKUNPRIVED MKUPDATE MKX11 MKYP \
		NBUILDJOBS NETBSDSRCDIR \
		NOCLEANDIR NODISTRIBDIRS NOINCLUDES \
		OBJMACHINE \
		RELEASEDIR RELEASEMACHINEDIR TOOLCHAIN_MISSING TOOLDIR \
		USE_HESIOD USE_INET6 USE_JEMALLOC USE_KERBEROS USE_LDAP \
		USE_PAM USE_SKEY USE_YP \
		USETOOLS USR_OBJMACHINE \
		X11SRCDIR


#
# Duplicate the DISTRIBVER setting from src/etc/Makefile.
#
.ifndef DISTRIBVER
DISTRIBVER!=	${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh
.endif

#
# _params does the printing.
#
_params_redirect?= # empty

_params: .PHONY
.for var in ${RELEASEVARS}
.if defined(${var})
	@printf "%20s = '%-s'\n" ${var} ${${var}:C/'/'\\\\''/gW:Q} \
	    ${_params_redirect}
.else
	@printf "%20s = (undefined)\n" ${var} \
	    ${_params_redirect}
.endif
.endfor

# PRINT_PARAMS:
#
# The output from the "make _params" can include the following types of
# unwanted lines:
#
#     make -j prints "--- _params ---";
#
#     if MAKEVERBOSE is set to 3 or more then make prints each "printf"
#     command in addition to executing it;
#
#     if MAKEVERBOSE is set to 4 then the shell prints each command
#     (prefixed with "+").
#
# So the resulting output can look like this:
#
#	--- _params ---
#	+ echo 'printf "%20s = '\''%-s'\''\n" BSDOBJDIR /usr/obj'
#	printf "%20s = '%-s'\n" BSDOBJDIR /usr/obj
#	+ printf '%20s = '\''%-s'\''\n' BSDOBJDIR /usr/obj
#	           BSDOBJDIR = '/usr/obj'
#	+ echo 'printf "%20s = '\''%-s'\''\n" BSDSRCDIR /usr/src'
#	printf "%20s = '%-s'\n" BSDSRCDIR /usr/src
#	+ printf '%20s = '\''%-s'\''\n' BSDSRCDIR /usr/src
#	           BSDSRCDIR = '/usr/src'
#	[...]
#
# where what we want is just this:
#
#	           BSDOBJDIR = '/usr/obj'
#	           BSDSRCDIR = '/usr/src'
#	           [...]
#
# The shell redirections in ${PRINT_PARAMS} ensure that the unwanted
# noise is discarded (via ">/dev/null"), while the desired information
# ends up on the subshell's stdout (via ">&3" and "3>&1").  The value
# of _params_redirect is passed in the environment instead of on the
# command line, to prevent it from appearing in MAKEFLAGS (which would
# appear in the output).
#
PRINT_PARAMS:=	(_params_redirect='>&3' ${MAKE} -f ${.PARSEDIR:Q}/${.PARSEFILE:Q} _params 3>&1 >/dev/null)