1*0a6a1f1dSLionel Sambuc# $NetBSD: Makefile.params,v 1.13 2015/07/23 08:03:25 mrg Exp $ 284d9c625SLionel Sambuc# 384d9c625SLionel Sambuc# Makefile fragment for printing build parameters. 484d9c625SLionel Sambuc# 584d9c625SLionel Sambuc# Public variables: 684d9c625SLionel Sambuc# RELEASEVARS 784d9c625SLionel Sambuc# List of variables whose value should be printed. 884d9c625SLionel Sambuc# 984d9c625SLionel Sambuc# PRINT_PARAMS 1084d9c625SLionel Sambuc# A command to print the desired variables and values 1184d9c625SLionel Sambuc# to stdout, without any additional debugging information. 1284d9c625SLionel Sambuc# Values are printed as single-quoted strings, with 1384d9c625SLionel Sambuc# embedded quotes and newlines escaped in a way that's 1484d9c625SLionel Sambuc# acceptable to sh(1). Undefined values are printed 1584d9c625SLionel Sambuc# as "(undefined)" (without quotation marks). 1684d9c625SLionel Sambuc# 1784d9c625SLionel Sambuc# Internal targets: 1884d9c625SLionel Sambuc# _params: 1984d9c625SLionel Sambuc# Prints the names and values of all the variables 2084d9c625SLionel Sambuc# listed in ${RELEASEVARS}. The desired results may be 2184d9c625SLionel Sambuc# redirected somewhere other than stdout, for example by 2284d9c625SLionel Sambuc# setting _params_redirect='>&3'. stdout and stderr may 2384d9c625SLionel Sambuc# contain unwanted debugging information, from make and 2484d9c625SLionel Sambuc# the shell. 2584d9c625SLionel Sambuc# 2684d9c625SLionel Sambuc# Internal variables: 2784d9c625SLionel Sambuc# _params_redirect: 2884d9c625SLionel Sambuc# If set, this should be a shell redirection specification, such 2984d9c625SLionel Sambuc# as '>&3', controlling where the output from "make _params" will 3084d9c625SLionel Sambuc# be sent. 3184d9c625SLionel Sambuc# 3284d9c625SLionel Sambuc# Example: 3384d9c625SLionel Sambuc# . ${NETBSDSRCDIR}/etc/Makefile.params 3484d9c625SLionel Sambuc# show-params: .MAKE .PHONY # print params to stdout 3584d9c625SLionel Sambuc# @${PRINT_PARAMS} 3684d9c625SLionel Sambuc# 3784d9c625SLionel Sambuc 3884d9c625SLionel Sambuc.include <bsd.own.mk> # for some variables 3984d9c625SLionel Sambuc 40*0a6a1f1dSLionel SambucRELEASEVARS= BSDOBJDIR BSDSRCDIR BUILDID BUILDINFO BUILDSEED \ 4184d9c625SLionel Sambuc DESTDIR DISTRIBVER EXTERNAL_TOOLCHAIN HAVE_GCC HAVE_GDB \ 4284d9c625SLionel Sambuc HAVE_LLVM HAVE_PCC INSTALLWORLDDIR \ 4384d9c625SLionel Sambuc KERNARCHDIR KERNCONFDIR KERNOBJDIR KERNSRCDIR \ 4484d9c625SLionel Sambuc MACHINE MACHINE_ARCH MAKE MAKECONF MAKEFLAGS \ 4584d9c625SLionel Sambuc MAKEOBJDIR MAKEOBJDIRPREFIX MAKEVERBOSE \ 46*0a6a1f1dSLionel Sambuc MKARZERO MKATF MKBFD MKBINUTILS MKCATPAGES \ 47*0a6a1f1dSLionel Sambuc MKCRYPTO MKCRYPTO_RC5 MKCTF MKCVS \ 4884d9c625SLionel Sambuc MKDEBUG MKDEBUGLIB MKDOC MKDTRACE MKDYNAMICROOT \ 4984d9c625SLionel Sambuc MKGCC MKGCCCMDS MKGDB \ 5084d9c625SLionel Sambuc MKHESIOD MKHTML MKIEEEFP MKINET6 MKINFO MKIPFILTER \ 5184d9c625SLionel Sambuc MKKERBEROS MKKYUA MKLDAP MKLINKLIB MKLINT MKLLVM \ 5284d9c625SLionel Sambuc MKMAN MKMANZ MKMDNS MKNLS MKNPF MKOBJ MKOBJDIRS \ 5384d9c625SLionel Sambuc MKPAM MKPCC MKPF MKPIC MKPICINSTALL MKPICLIB MKPOSTFIX \ 54*0a6a1f1dSLionel Sambuc MKPROFILE MKREPRO \ 5584d9c625SLionel Sambuc MKSHARE MKSKEY MKSOFTFLOAT MKSTATICLIB \ 5684d9c625SLionel Sambuc MKUNPRIVED MKUPDATE MKX11 MKYP \ 5784d9c625SLionel Sambuc NBUILDJOBS NETBSDSRCDIR \ 5884d9c625SLionel Sambuc NOCLEANDIR NODISTRIBDIRS NOINCLUDES \ 5984d9c625SLionel Sambuc OBJMACHINE \ 6084d9c625SLionel Sambuc RELEASEDIR RELEASEMACHINEDIR TOOLCHAIN_MISSING TOOLDIR \ 6184d9c625SLionel Sambuc USE_HESIOD USE_INET6 USE_JEMALLOC USE_KERBEROS USE_LDAP \ 6284d9c625SLionel Sambuc USE_PAM USE_SKEY USE_YP \ 6384d9c625SLionel Sambuc USETOOLS USR_OBJMACHINE \ 64*0a6a1f1dSLionel Sambuc X11SRCDIR 6584d9c625SLionel Sambuc 6684d9c625SLionel Sambuc 6784d9c625SLionel Sambuc# 6884d9c625SLionel Sambuc# Duplicate the DISTRIBVER setting from src/etc/Makefile. 6984d9c625SLionel Sambuc# 7084d9c625SLionel Sambuc.ifndef DISTRIBVER 7184d9c625SLionel SambucDISTRIBVER!= ${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh 7284d9c625SLionel Sambuc.endif 7384d9c625SLionel Sambuc 7484d9c625SLionel Sambuc# 7584d9c625SLionel Sambuc# _params does the printing. 7684d9c625SLionel Sambuc# 7784d9c625SLionel Sambuc_params_redirect?= # empty 7884d9c625SLionel Sambuc 7984d9c625SLionel Sambuc_params: .PHONY 8084d9c625SLionel Sambuc.for var in ${RELEASEVARS} 8184d9c625SLionel Sambuc.if defined(${var}) 8284d9c625SLionel Sambuc @printf "%20s = '%-s'\n" ${var} ${${var}:C/'/'\\\\''/gW:Q} \ 8384d9c625SLionel Sambuc ${_params_redirect} 8484d9c625SLionel Sambuc.else 8584d9c625SLionel Sambuc @printf "%20s = (undefined)\n" ${var} \ 8684d9c625SLionel Sambuc ${_params_redirect} 8784d9c625SLionel Sambuc.endif 8884d9c625SLionel Sambuc.endfor 8984d9c625SLionel Sambuc 9084d9c625SLionel Sambuc# PRINT_PARAMS: 9184d9c625SLionel Sambuc# 9284d9c625SLionel Sambuc# The output from the "make _params" can include the following types of 9384d9c625SLionel Sambuc# unwanted lines: 9484d9c625SLionel Sambuc# 9584d9c625SLionel Sambuc# make -j prints "--- _params ---"; 9684d9c625SLionel Sambuc# 9784d9c625SLionel Sambuc# if MAKEVERBOSE is set to 3 or more then make prints each "printf" 9884d9c625SLionel Sambuc# command in addition to executing it; 9984d9c625SLionel Sambuc# 10084d9c625SLionel Sambuc# if MAKEVERBOSE is set to 4 then the shell prints each command 10184d9c625SLionel Sambuc# (prefixed with "+"). 10284d9c625SLionel Sambuc# 10384d9c625SLionel Sambuc# So the resulting output can look like this: 10484d9c625SLionel Sambuc# 10584d9c625SLionel Sambuc# --- _params --- 10684d9c625SLionel Sambuc# + echo 'printf "%20s = '\''%-s'\''\n" BSDOBJDIR /usr/obj' 10784d9c625SLionel Sambuc# printf "%20s = '%-s'\n" BSDOBJDIR /usr/obj 10884d9c625SLionel Sambuc# + printf '%20s = '\''%-s'\''\n' BSDOBJDIR /usr/obj 10984d9c625SLionel Sambuc# BSDOBJDIR = '/usr/obj' 11084d9c625SLionel Sambuc# + echo 'printf "%20s = '\''%-s'\''\n" BSDSRCDIR /usr/src' 11184d9c625SLionel Sambuc# printf "%20s = '%-s'\n" BSDSRCDIR /usr/src 11284d9c625SLionel Sambuc# + printf '%20s = '\''%-s'\''\n' BSDSRCDIR /usr/src 11384d9c625SLionel Sambuc# BSDSRCDIR = '/usr/src' 11484d9c625SLionel Sambuc# [...] 11584d9c625SLionel Sambuc# 11684d9c625SLionel Sambuc# where what we want is just this: 11784d9c625SLionel Sambuc# 11884d9c625SLionel Sambuc# BSDOBJDIR = '/usr/obj' 11984d9c625SLionel Sambuc# BSDSRCDIR = '/usr/src' 12084d9c625SLionel Sambuc# [...] 12184d9c625SLionel Sambuc# 12284d9c625SLionel Sambuc# The shell redirections in ${PRINT_PARAMS} ensure that the unwanted 12384d9c625SLionel Sambuc# noise is discarded (via ">/dev/null"), while the desired information 12484d9c625SLionel Sambuc# ends up on the subshell's stdout (via ">&3" and "3>&1"). The value 12584d9c625SLionel Sambuc# of _params_redirect is passed in the environment instead of on the 12684d9c625SLionel Sambuc# command line, to prevent it from appearing in MAKEFLAGS (which would 12784d9c625SLionel Sambuc# appear in the output). 12884d9c625SLionel Sambuc# 12984d9c625SLionel SambucPRINT_PARAMS:= (_params_redirect='>&3' ${MAKE} -f ${.PARSEDIR:Q}/${.PARSEFILE:Q} _params 3>&1 >/dev/null) 130