Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src Add src/etc/Makefile.params, containing the definition of the



details:   https://anonhg.NetBSD.org/src/rev/04a1b47ce5b1
branches:  trunk
changeset: 783067:04a1b47ce5b1
user:      apb <apb%NetBSD.org@localhost>
date:      Mon Dec 03 13:53:28 2012 +0000

description:
Add src/etc/Makefile.params, containing the definition of the
RELEASEVARS variable, and commands related to printing the values of
the variables whose names are in RELEASEVARS.

Add an awk script to remove noise printed by "make -j" or high levels
of MAKEVERBOSE, so we get only the variables names and values.  The
values are escaped so that variables containing embedded newlines,
quotation marks, and backslashes, are passed through safely.

Adapt src/etc/Makefile and src/Makefile to use the new ${PRINT_PARAMS}
command defined in src/etc/Makefile.params.

Now ${DESTDIR}/etc/release and the params file in the top-level
.OBJDIR should never contain unwanted noise, even after a build with
MAKEVERBOSE=4.

diffstat:

 Makefile            |   18 +++---
 etc/Makefile        |   39 +------------
 etc/Makefile.params |  149 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 161 insertions(+), 45 deletions(-)

diffs (259 lines):

diff -r 28e1e7d625e6 -r 04a1b47ce5b1 Makefile
--- a/Makefile  Mon Dec 03 12:28:06 2012 +0000
+++ b/Makefile  Mon Dec 03 13:53:28 2012 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.301 2012/11/15 23:51:53 joerg Exp $
+#      $NetBSD: Makefile,v 1.302 2012/12/03 13:53:29 apb Exp $
 
 #
 # This is the top-level makefile for building NetBSD. For an outline of
@@ -259,11 +259,11 @@
 #
 # This is referenced by _NETBSD_VERSION_DEPENDS in <bsd.own.mk>.
 #
-
+.include "${NETBSDSRCDIR}/etc/Makefile.params"
 CLEANDIRFILES+= params
 params: .EXEC
        ${_MKMSG_CREATE} params
-       @(${MAKEDIRTARGET:S/^@//} etc params) >${.TARGET}.new
+       @${PRINT_PARAMS} >${.TARGET}.new
        @if cmp -s ${.TARGET}.new ${.TARGET} > /dev/null 2>&1; then \
                : "params is unchanged" ; \
                rm ${.TARGET}.new ; \
@@ -273,6 +273,12 @@
        fi
 
 #
+# Display current make(1) parameters
+#
+show-params: .PHONY .MAKE
+       @${PRINT_PARAMS}
+
+#
 # Build the system and install into DESTDIR.
 #
 
@@ -521,9 +527,3 @@
 .include <bsd.obj.mk>
 .include <bsd.kernobj.mk>
 .include <bsd.subdir.mk>
-
-#
-# Display current make(1) parameters
-#
-show-params: .PHONY .MAKE
-       ${MAKEDIRTARGET} etc params
diff -r 28e1e7d625e6 -r 04a1b47ce5b1 etc/Makefile
--- a/etc/Makefile      Mon Dec 03 12:28:06 2012 +0000
+++ b/etc/Makefile      Mon Dec 03 13:53:28 2012 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile,v 1.400 2012/11/04 11:09:14 apb Exp $
+#      $NetBSD: Makefile,v 1.401 2012/12/03 13:53:28 apb Exp $
 #      from: @(#)Makefile      8.7 (Berkeley) 5/25/95
 
 # Environment variables without default values:
@@ -186,40 +186,7 @@
            ${TOOL_AWK} -f ${.CURDIR}/MAKEDEV.awk ${.CURDIR}/MAKEDEV.tmpl \
            > ${.TARGET}
 
-RELEASEVARS=   BSDOBJDIR BSDSRCDIR BUILDID \
-               DESTDIR DISTRIBVER EXTERNAL_TOOLCHAIN HAVE_GCC HAVE_GDB \
-               INSTALLWORLDDIR \
-               KERNARCHDIR KERNCONFDIR KERNOBJDIR KERNSRCDIR \
-               MACHINE MACHINE_ARCH MAKE MAKECONF MAKEFLAGS \
-               MAKEOBJDIR MAKEOBJDIRPREFIX MAKEVERBOSE \
-               MKBFD MKBINUTILS MKCATPAGES \
-               MKCRYPTO MKCRYPTO_RC5 MKCVS \
-               MKDEBUG MKDEBUGLIB MKDOC MKDTRACE MKDYNAMICROOT \
-               MKGCC MKGCCCMDS MKGDB \
-               MKHESIOD MKHTML MKIEEEFP MKINET6 MKINFO MKIPFILTER \
-               MKKERBEROS MKLDAP MKLINKLIB MKLINT \
-               MKMAN MKMANZ MKMDNS MKNLS MKNPF MKOBJ MKOBJDIRS \
-               MKPAM MKPF MKPIC MKPICINSTALL MKPICLIB MKPOSTFIX MKPROFILE \
-               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 X11FLAVOUR
-
-params: .PHONY
-.for var in ${RELEASEVARS}
-.if defined(${var})
-       @printf "%20s = '%-s'\n" ${var} ${${var}:Q}
-.else
-       @printf "%20s = (undefined)\n" ${var}
-.endif
-.endfor
-
+.include "${NETBSDSRCDIR}/etc/Makefile.params"
 CLEANFILES+=   etc-release
 etc-release: .EXEC .MAKE
        ${_MKTARGET_CREATE}
@@ -231,7 +198,7 @@
                printf "%20s   %s\n"  "Build date" "$$(date -u)"; \
                printf "%20s   %s\n"  "Built by" "$${USER-root}@$$(hostname)"; \
                echo ; \
-               (cd ${.CURDIR}; ${MAKE} ${MFLAGS} -j1 params); \
+               ${PRINT_PARAMS} ; \
        ) >${.OBJDIR}/${.TARGET}
 
 install-etc-release: .PHONY etc-release
diff -r 28e1e7d625e6 -r 04a1b47ce5b1 etc/Makefile.params
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/etc/Makefile.params       Mon Dec 03 13:53:28 2012 +0000
@@ -0,0 +1,149 @@
+#      $NetBSD: Makefile.params,v 1.1 2012/12/03 13:53:28 apb 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.
+#              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 output may be intermixed
+#              with debugging information, which can be removed by the
+#              ${_PARAMS_POSTPROCESS} command.
+#
+# Internal variables:
+#      _PARAMS_POSTPROCESS
+#              A command to postprocess the output from "make _params",
+#              to remove debugging information and other noise.
+#
+# Example:
+#      . ${NETBSDSRCDIR}/etc/Makefile.params
+#      show-params: .MAKE .PHONY # print params to stdout
+#              @${PRINT_PARAMS}
+#
+
+.include <bsd.sys.mk>          # for TOOL_AWK, ...
+
+RELEASEVARS=   BSDOBJDIR BSDSRCDIR BUILDID \
+               DESTDIR DISTRIBVER EXTERNAL_TOOLCHAIN HAVE_GCC HAVE_GDB \
+               INSTALLWORLDDIR \
+               KERNARCHDIR KERNCONFDIR KERNOBJDIR KERNSRCDIR \
+               MACHINE MACHINE_ARCH MAKE MAKECONF MAKEFLAGS \
+               MAKEOBJDIR MAKEOBJDIRPREFIX MAKEVERBOSE \
+               MKBFD MKBINUTILS MKCATPAGES \
+               MKCRYPTO MKCRYPTO_RC5 MKCVS \
+               MKDEBUG MKDEBUGLIB MKDOC MKDTRACE MKDYNAMICROOT \
+               MKGCC MKGCCCMDS MKGDB \
+               MKHESIOD MKHTML MKIEEEFP MKINET6 MKINFO MKIPFILTER \
+               MKKERBEROS MKLDAP MKLINKLIB MKLINT \
+               MKMAN MKMANZ MKMDNS MKNLS MKNPF MKOBJ MKOBJDIRS \
+               MKPAM MKPF MKPIC MKPICINSTALL MKPICLIB MKPOSTFIX MKPROFILE \
+               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 X11FLAVOUR
+
+PRINT_PARAMS= (cd ${.CURDIR}; ${MAKE} _params) | ${_PARAMS_POSTPROCESS}
+
+_params: .PHONY
+.for var in ${RELEASEVARS}
+.if defined(${var})
+       @printf "%20s = '%-s'\n" ${var} ${${var}:C/'/'\\\\''/gW:Q}
+.else
+       @printf "%20s = (undefined)\n" ${var}
+.endif
+.endfor
+
+# _PARAMS_POSTPROCESS:
+#
+# 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 awk program in ${PARAMS_POSTPROCESS} removes the unwanted noise,
+# taking care with variables whose values contain embedded newlines
+# (assuming that embedded newlines appear only inside single quotes).
+#
+_PARAMS_POSTPROCESS= ${TOOL_AWK} '\
+       BEGIN { single_quote = "'\''"; \
+               NORMAL = 0; \
+               SKIP_HEADING = 1; \
+               SKIP_MULTILINE = 2; \
+               PRINT_MULTILINE = 3; \
+               state = SKIP_HEADING; \
+       } \
+       function quotes_balanced_p(line) { \
+               return (line ~ /^([^\\"'\'']|\\.|'\''[^'\'']*'\''|"(\\.|[^\\"])*")*$$/); \
+       } \
+       state == SKIP_MULTILINE { \
+               if (quotes_balanced_p(single_quote $$0)) { \
+                       state = NORMAL; \
+               } \
+               next; \
+       } \
+       state == PRINT_MULTILINE { \
+               if (quotes_balanced_p(single_quote $$0)) { \
+                       state = NORMAL; \
+               } \
+               print; next; \
+       } \
+       state == SKIP_HEADING && $$0 ~ /^--- .* ---$$/ { next; } \
+       state == SKIP_HEADING && $$0 ~ / ===> / { next; } \
+       /^(\+ )?(echo ["'\''])?printf.* = / { \
+               if (quotes_balanced_p($$0)) { \
+                       state = NORMAL; \
+               } else { \
+                       state = SKIP_MULTILINE; \
+               } \
+               next; \
+       } \
+       // { \
+               if (quotes_balanced_p($$0)) { \
+                       state = NORMAL; \
+               } else { \
+                       state = PRINT_MULTILINE; \
+               } \
+               print; next; \
+       } \
+       '



Home | Main Index | Thread Index | Old Index