Makefile.params revision 1.15
11.15Schristos# $NetBSD: Makefile.params,v 1.15 2016/12/25 16:44:39 christos Exp $ 21.1Sapb# 31.1Sapb# Makefile fragment for printing build parameters. 41.1Sapb# 51.1Sapb# Public variables: 61.1Sapb# RELEASEVARS 71.1Sapb# List of variables whose value should be printed. 81.1Sapb# 91.1Sapb# PRINT_PARAMS 101.4Sapb# A command to print the desired variables and values 111.4Sapb# to stdout, without any additional debugging information. 121.1Sapb# Values are printed as single-quoted strings, with 131.1Sapb# embedded quotes and newlines escaped in a way that's 141.1Sapb# acceptable to sh(1). Undefined values are printed 151.1Sapb# as "(undefined)" (without quotation marks). 161.1Sapb# 171.1Sapb# Internal targets: 181.1Sapb# _params: 191.4Sapb# Prints the names and values of all the variables 201.4Sapb# listed in ${RELEASEVARS}. The desired results may be 211.4Sapb# redirected somewhere other than stdout, for example by 221.4Sapb# setting _params_redirect='>&3'. stdout and stderr may 231.4Sapb# contain unwanted debugging information, from make and 241.4Sapb# the shell. 251.1Sapb# 261.1Sapb# Internal variables: 271.4Sapb# _params_redirect: 281.4Sapb# If set, this should be a shell redirection specification, such 291.4Sapb# as '>&3', controlling where the output from "make _params" will 301.4Sapb# be sent. 311.1Sapb# 321.1Sapb# Example: 331.1Sapb# . ${NETBSDSRCDIR}/etc/Makefile.params 341.1Sapb# show-params: .MAKE .PHONY # print params to stdout 351.1Sapb# @${PRINT_PARAMS} 361.1Sapb# 371.1Sapb 381.7Sapb.include <bsd.own.mk> # for some variables 391.5Sapb 401.14SchristosRELEASEVARS= DISTRIBVER EXTERNAL_TOOLCHAIN HAVE_GCC HAVE_GDB \ 411.3Snjoly HAVE_LLVM HAVE_PCC INSTALLWORLDDIR \ 421.15Schristos MACHINE MACHINE_ARCH MAKE MAKECONF \ 431.1Sapb MAKEOBJDIR MAKEOBJDIRPREFIX MAKEVERBOSE \ 441.9Sapb MKARZERO MKATF MKBFD MKBINUTILS MKCATPAGES \ 451.11Sozaki MKCRYPTO MKCRYPTO_RC5 MKCTF MKCVS \ 461.1Sapb MKDEBUG MKDEBUGLIB MKDOC MKDTRACE MKDYNAMICROOT \ 471.1Sapb MKGCC MKGCCCMDS MKGDB \ 481.1Sapb MKHESIOD MKHTML MKIEEEFP MKINET6 MKINFO MKIPFILTER \ 491.3Snjoly MKKERBEROS MKKYUA MKLDAP MKLINKLIB MKLINT MKLLVM \ 501.1Sapb MKMAN MKMANZ MKMDNS MKNLS MKNPF MKOBJ MKOBJDIRS \ 511.3Snjoly MKPAM MKPCC MKPF MKPIC MKPICINSTALL MKPICLIB MKPOSTFIX \ 521.9Sapb MKPROFILE MKREPRO \ 531.1Sapb MKSHARE MKSKEY MKSOFTFLOAT MKSTATICLIB \ 541.1Sapb MKUNPRIVED MKUPDATE MKX11 MKYP \ 551.1Sapb NOCLEANDIR NODISTRIBDIRS NOINCLUDES \ 561.14Schristos TOOLCHAIN_MISSING \ 571.1Sapb USE_HESIOD USE_INET6 USE_JEMALLOC USE_KERBEROS USE_LDAP \ 581.1Sapb USE_PAM USE_SKEY USE_YP \ 591.14Schristos USETOOLS 601.14Schristos 611.14Schristos.if ${MKREPRO:Uno} != "yes" 621.14SchristosRELEASEVARS+= BSDOBJDIR BSDSRCDIR BUILDID BUILDINFO BUILDSEED \ 631.14Schristos DESTDIR KERNARCHDIR KERNCONFDIR KERNOBJDIR KERNSRCDIR \ 641.15Schristos MAKEFLAGS NBUILDJOBS NETBSDSRCDIR OBJMACHINE OBJMACHINE_ARCH \ 651.14Schristos RELEASEDIR RELEASEMACHINEDIR TOOLDIR USR_OBJMACHINE X11SRCDIR 661.14Schristos.endif 671.1Sapb 681.5Sapb 691.5Sapb# 701.5Sapb# Duplicate the DISTRIBVER setting from src/etc/Makefile. 711.5Sapb# 721.5Sapb.ifndef DISTRIBVER 731.7SapbDISTRIBVER!= ${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh 741.5Sapb.endif 751.5Sapb 761.5Sapb# 771.5Sapb# _params does the printing. 781.5Sapb# 791.4Sapb_params_redirect?= # empty 801.1Sapb 811.1Sapb_params: .PHONY 821.14Schristos.for var in ${RELEASEVARS:O} 831.1Sapb.if defined(${var}) 841.4Sapb @printf "%20s = '%-s'\n" ${var} ${${var}:C/'/'\\\\''/gW:Q} \ 851.4Sapb ${_params_redirect} 861.1Sapb.else 871.5Sapb @printf "%20s = (undefined)\n" ${var} \ 881.4Sapb ${_params_redirect} 891.1Sapb.endif 901.1Sapb.endfor 911.1Sapb 921.4Sapb# PRINT_PARAMS: 931.1Sapb# 941.1Sapb# The output from the "make _params" can include the following types of 951.1Sapb# unwanted lines: 961.1Sapb# 971.4Sapb# make -j prints "--- _params ---"; 981.1Sapb# 991.1Sapb# if MAKEVERBOSE is set to 3 or more then make prints each "printf" 1001.1Sapb# command in addition to executing it; 1011.1Sapb# 1021.1Sapb# if MAKEVERBOSE is set to 4 then the shell prints each command 1031.1Sapb# (prefixed with "+"). 1041.1Sapb# 1051.1Sapb# So the resulting output can look like this: 1061.1Sapb# 1071.4Sapb# --- _params --- 1081.1Sapb# + echo 'printf "%20s = '\''%-s'\''\n" BSDOBJDIR /usr/obj' 1091.1Sapb# printf "%20s = '%-s'\n" BSDOBJDIR /usr/obj 1101.1Sapb# + printf '%20s = '\''%-s'\''\n' BSDOBJDIR /usr/obj 1111.1Sapb# BSDOBJDIR = '/usr/obj' 1121.1Sapb# + echo 'printf "%20s = '\''%-s'\''\n" BSDSRCDIR /usr/src' 1131.1Sapb# printf "%20s = '%-s'\n" BSDSRCDIR /usr/src 1141.1Sapb# + printf '%20s = '\''%-s'\''\n' BSDSRCDIR /usr/src 1151.1Sapb# BSDSRCDIR = '/usr/src' 1161.1Sapb# [...] 1171.1Sapb# 1181.1Sapb# where what we want is just this: 1191.1Sapb# 1201.1Sapb# BSDOBJDIR = '/usr/obj' 1211.1Sapb# BSDSRCDIR = '/usr/src' 1221.1Sapb# [...] 1231.1Sapb# 1241.4Sapb# The shell redirections in ${PRINT_PARAMS} ensure that the unwanted 1251.4Sapb# noise is discarded (via ">/dev/null"), while the desired information 1261.4Sapb# ends up on the subshell's stdout (via ">&3" and "3>&1"). The value 1271.4Sapb# of _params_redirect is passed in the environment instead of on the 1281.4Sapb# command line, to prevent it from appearing in MAKEFLAGS (which would 1291.4Sapb# appear in the output). 1301.4Sapb# 1311.4SapbPRINT_PARAMS:= (_params_redirect='>&3' ${MAKE} -f ${.PARSEDIR:Q}/${.PARSEFILE:Q} _params 3>&1 >/dev/null) 132