Makefile.params revision 1.7
11.7Sapb# $NetBSD: Makefile.params,v 1.7 2013/11/01 11:09:05 apb 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.7Sapb.include <bsd.sys.mk> # for more variables 401.5Sapb 411.1SapbRELEASEVARS= BSDOBJDIR BSDSRCDIR BUILDID \ 421.1Sapb DESTDIR DISTRIBVER EXTERNAL_TOOLCHAIN HAVE_GCC HAVE_GDB \ 431.3Snjoly HAVE_LLVM HAVE_PCC INSTALLWORLDDIR \ 441.1Sapb KERNARCHDIR KERNCONFDIR KERNOBJDIR KERNSRCDIR \ 451.1Sapb MACHINE MACHINE_ARCH MAKE MAKECONF MAKEFLAGS \ 461.1Sapb MAKEOBJDIR MAKEOBJDIRPREFIX MAKEVERBOSE \ 471.2Sjmmv MKATF MKBFD MKBINUTILS MKCATPAGES \ 481.1Sapb MKCRYPTO MKCRYPTO_RC5 MKCVS \ 491.1Sapb MKDEBUG MKDEBUGLIB MKDOC MKDTRACE MKDYNAMICROOT \ 501.1Sapb MKGCC MKGCCCMDS MKGDB \ 511.1Sapb MKHESIOD MKHTML MKIEEEFP MKINET6 MKINFO MKIPFILTER \ 521.3Snjoly MKKERBEROS MKKYUA MKLDAP MKLINKLIB MKLINT MKLLVM \ 531.1Sapb MKMAN MKMANZ MKMDNS MKNLS MKNPF MKOBJ MKOBJDIRS \ 541.3Snjoly MKPAM MKPCC MKPF MKPIC MKPICINSTALL MKPICLIB MKPOSTFIX \ 551.3Snjoly MKPROFILE \ 561.1Sapb MKSHARE MKSKEY MKSOFTFLOAT MKSTATICLIB \ 571.1Sapb MKUNPRIVED MKUPDATE MKX11 MKYP \ 581.1Sapb NBUILDJOBS NETBSDSRCDIR \ 591.1Sapb NOCLEANDIR NODISTRIBDIRS NOINCLUDES \ 601.1Sapb OBJMACHINE \ 611.1Sapb RELEASEDIR RELEASEMACHINEDIR TOOLCHAIN_MISSING TOOLDIR \ 621.1Sapb USE_HESIOD USE_INET6 USE_JEMALLOC USE_KERBEROS USE_LDAP \ 631.1Sapb USE_PAM USE_SKEY USE_YP \ 641.1Sapb USETOOLS USR_OBJMACHINE \ 651.1Sapb X11SRCDIR X11FLAVOUR 661.1Sapb 671.5Sapb 681.5Sapb# 691.5Sapb# Duplicate the DISTRIBVER setting from src/etc/Makefile. 701.5Sapb# 711.5Sapb.ifndef DISTRIBVER 721.7SapbDISTRIBVER!= ${HOST_SH} ${NETBSDSRCDIR}/sys/conf/osrelease.sh 731.5Sapb.endif 741.5Sapb 751.5Sapb# 761.5Sapb# _params does the printing. 771.5Sapb# 781.4Sapb_params_redirect?= # empty 791.1Sapb 801.1Sapb_params: .PHONY 811.1Sapb.for var in ${RELEASEVARS} 821.1Sapb.if defined(${var}) 831.4Sapb @printf "%20s = '%-s'\n" ${var} ${${var}:C/'/'\\\\''/gW:Q} \ 841.4Sapb ${_params_redirect} 851.1Sapb.else 861.5Sapb @printf "%20s = (undefined)\n" ${var} \ 871.4Sapb ${_params_redirect} 881.1Sapb.endif 891.1Sapb.endfor 901.1Sapb 911.4Sapb# PRINT_PARAMS: 921.1Sapb# 931.1Sapb# The output from the "make _params" can include the following types of 941.1Sapb# unwanted lines: 951.1Sapb# 961.4Sapb# make -j prints "--- _params ---"; 971.1Sapb# 981.1Sapb# if MAKEVERBOSE is set to 3 or more then make prints each "printf" 991.1Sapb# command in addition to executing it; 1001.1Sapb# 1011.1Sapb# if MAKEVERBOSE is set to 4 then the shell prints each command 1021.1Sapb# (prefixed with "+"). 1031.1Sapb# 1041.1Sapb# So the resulting output can look like this: 1051.1Sapb# 1061.4Sapb# --- _params --- 1071.1Sapb# + echo 'printf "%20s = '\''%-s'\''\n" BSDOBJDIR /usr/obj' 1081.1Sapb# printf "%20s = '%-s'\n" BSDOBJDIR /usr/obj 1091.1Sapb# + printf '%20s = '\''%-s'\''\n' BSDOBJDIR /usr/obj 1101.1Sapb# BSDOBJDIR = '/usr/obj' 1111.1Sapb# + echo 'printf "%20s = '\''%-s'\''\n" BSDSRCDIR /usr/src' 1121.1Sapb# printf "%20s = '%-s'\n" BSDSRCDIR /usr/src 1131.1Sapb# + printf '%20s = '\''%-s'\''\n' BSDSRCDIR /usr/src 1141.1Sapb# BSDSRCDIR = '/usr/src' 1151.1Sapb# [...] 1161.1Sapb# 1171.1Sapb# where what we want is just this: 1181.1Sapb# 1191.1Sapb# BSDOBJDIR = '/usr/obj' 1201.1Sapb# BSDSRCDIR = '/usr/src' 1211.1Sapb# [...] 1221.1Sapb# 1231.4Sapb# The shell redirections in ${PRINT_PARAMS} ensure that the unwanted 1241.4Sapb# noise is discarded (via ">/dev/null"), while the desired information 1251.4Sapb# ends up on the subshell's stdout (via ">&3" and "3>&1"). The value 1261.4Sapb# of _params_redirect is passed in the environment instead of on the 1271.4Sapb# command line, to prevent it from appearing in MAKEFLAGS (which would 1281.4Sapb# appear in the output). 1291.4Sapb# 1301.4SapbPRINT_PARAMS:= (_params_redirect='>&3' ${MAKE} -f ${.PARSEDIR:Q}/${.PARSEFILE:Q} _params 3>&1 >/dev/null) 131