Source-Changes-HG archive

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

[src/trunk]: src build.sh: use mk.conf (if present) as MAKECONF



details:   https://anonhg.NetBSD.org/src/rev/2e7529ba6868
branches:  trunk
changeset: 378078:2e7529ba6868
user:      lukem <lukem%NetBSD.org@localhost>
date:      Tue Jul 18 16:59:57 2023 +0000

description:
build.sh: use mk.conf (if present) as MAKECONF

Set MAKECONF to mk.conf in the same directory as build.sh
(i.e., the top of the source tree) if mk.conf is present.
This means unprivileged users can benefit from mk.conf(5)
semantics without write privileges to /etc/mk.conf, and
also simplifies per-source-directory configuration.

Fail early if $MAKECONF is empty, since build.sh will fail
anyway after rebuilding nbmake.

Ensure that the computed MAKECONF isn't empty, and then
always set MAKECONF in the makewrapper (nbmake-$MACHINE).

Improve some formatting consistency in BUILDING.mdoc,
(even if BUILDING is generated without markup).

diffstat:

 BUILDING          |  22 ++++++++++++++----
 UPDATING          |   6 ++++-
 build.sh          |  30 ++++++++++++++++++++-----
 doc/BUILDING.mdoc |  64 ++++++++++++++++++++++++++++++++++++++++--------------
 4 files changed, 93 insertions(+), 29 deletions(-)

diffs (truncated from 311 to 300 lines):

diff -r 43fffa2ceb03 -r 2e7529ba6868 BUILDING
--- a/BUILDING  Tue Jul 18 13:35:57 2023 +0000
+++ b/BUILDING  Tue Jul 18 16:59:57 2023 +0000
@@ -9,12 +9,16 @@ REQUIREMENTS
      same NetBSD architecture) or cross compiling (on another architecture or
      OS).
 
+     This source tree contains the build.sh shell script which supports both
+     native and cross builds of NetBSD.
+
      This source tree contains a special subtree, "tools", which uses the host
      system to create a build toolchain for the target architecture.  The host
      system must have at least C and C++ compilers in order to create the
-     toolchain (make is not required); all other tools are created as part of
-     the NetBSD build process.  (See the Environment variables section below
-     if you need to override or manually select your compilers.)
+     toolchain (make(1) is not required); all other tools (including make(1)
+     as nbmake) are created as part of the NetBSD build process.  (See the
+     Environment variables section below if you need to override or manually
+     select your compilers.)
 
      Note: Within this document, cross-references to manual pages are to the
      NetBSD manual pages, not the host system manual pages.  The mdoc(7)
@@ -71,6 +75,12 @@ FILES
                     "Reachover" build structure for modular Xorg; the source
                     is in X11SRCDIR.
 
+     mk.conf        Optional source tree specific mk.conf(5), used (if
+                    present) instead of /etc/mk.conf unless MAKECONF is
+                    defined.
+
+                    Note: Not part of the NetBSD source repository.
+
      regress/, tests/
                     Regression test harness.  Can be cross-compiled, but only
                     run natively.  tests/ uses the atf(7) test framework;
@@ -164,7 +174,9 @@ CONFIGURATION
 
                      Note: Only settable in the process environment.
 
-                     Default: "/etc/mk.conf".
+                     Default: "/etc/mk.conf", although build.sh will set the
+                     default to the full path to mk.conf if the latter is
+                     present in the same directory as build.sh.
 
      MAKEFLAGS       Flags to invoke make(1) with.
 
@@ -819,4 +831,4 @@ CAVEATS
      in object directories.  Instead, one may have to manually remove the
      files.  Consult the UPDATING file for notices concerning this.
 
-NetBSD                           July 5, 2023                           NetBSD
+NetBSD                           July 18, 2023                          NetBSD
diff -r 43fffa2ceb03 -r 2e7529ba6868 UPDATING
--- a/UPDATING  Tue Jul 18 13:35:57 2023 +0000
+++ b/UPDATING  Tue Jul 18 16:59:57 2023 +0000
@@ -1,4 +1,4 @@
-$NetBSD: UPDATING,v 1.340 2023/07/11 15:05:17 martin Exp $
+$NetBSD: UPDATING,v 1.341 2023/07/18 16:59:57 lukem Exp $
 
 This file (UPDATING) is intended to be a brief reference to recent
 changes that might cause problems in the build process, and a guide for
@@ -19,6 +19,10 @@ See also: BUILDING, build.sh, Makefile.
 Recent changes:
 ^^^^^^^^^^^^^^^
 
+20230718:
+       build.sh will use mk.conf in the same directory as build.sh instead
+       of /etc/mk.conf, unless MAKECONF is already defined in the environment.
+
 20230604:
        Building native kernels with the installed make(1) instead of
        the $TOOLDIR/bin/nbmake-${arch} wrapper will fail if userland
diff -r 43fffa2ceb03 -r 2e7529ba6868 build.sh
--- a/build.sh  Tue Jul 18 13:35:57 2023 +0000
+++ b/build.sh  Tue Jul 18 16:59:57 2023 +0000
@@ -1,5 +1,5 @@
 #! /usr/bin/env sh
-#      $NetBSD: build.sh,v 1.372 2023/06/13 16:56:00 christos Exp $
+#      $NetBSD: build.sh,v 1.373 2023/07/18 16:59:57 lukem Exp $
 #
 # Copyright (c) 2001-2023 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -1768,11 +1768,25 @@ rebuildmake()
 #
 validatemakeparams()
 {
-       # MAKECONF (which defaults to /etc/mk.conf in share/mk/bsd.own.mk)
-       # can affect many things, so mention it in an early status message.
+       # Determine MAKECONF first, and set in the makewrapper.
+       # If set in the environment, then use that.
+       # else if ./mk.conf exists, then set MAKECONF to that,
+       # else use the default from share/mk/bsd.own.mk (/etc/mk.conf).
        #
-       MAKECONF=$(getmakevar MAKECONF)
-       if [ -e "${MAKECONF}" ]; then
+       if [ -n "${MAKECONF+1}" ]; then
+               setmakeenv MAKECONF "${MAKECONF}"
+               statusmsg2 "getenv MAKECONF:" "${MAKECONF}"
+       elif [ -f "${TOP}/mk.conf" ]; then
+               setmakeenv MAKECONF "${TOP}/mk.conf"
+               statusmsg2 "mk.conf MAKECONF:" "${MAKECONF}"
+       else
+               MAKECONF=$(getmakevar MAKECONF)
+               setmakeenv MAKECONF "${MAKECONF}"
+               statusmsg2 "share/mk MAKECONF:" "${MAKECONF}"
+       fi
+       if [ -z "${MAKECONF}" ]; then
+               bomb "MAKECONF must not be empty"
+       elif [ -e "${MAKECONF}" ]; then
                statusmsg2 "MAKECONF file:" "${MAKECONF}"
        else
                statusmsg2 "MAKECONF file:" "${MAKECONF} (File not found)"
@@ -2016,7 +2030,7 @@ createmakewrapper()
        eval cat <<EOF ${makewrapout}
 #! ${HOST_SH}
 # Set proper variables to allow easy "make" building of a NetBSD subtree.
-# Generated from:  \$NetBSD: build.sh,v 1.372 2023/06/13 16:56:00 christos Exp $
+# Generated from:  \$NetBSD: build.sh,v 1.373 2023/07/18 16:59:57 lukem Exp $
 # with these arguments: ${_args}
 #
 
@@ -2453,6 +2467,10 @@ main()
                done
        fi
 
+       if [ -n "${MAKECONF+1}" ] && [ -z "${MAKECONF}" ]; then
+               bomb "MAKECONF must not be empty"
+       fi
+
        rebuildmake
        validatemakeparams
        createmakewrapper
diff -r 43fffa2ceb03 -r 2e7529ba6868 doc/BUILDING.mdoc
--- a/doc/BUILDING.mdoc Tue Jul 18 13:35:57 2023 +0000
+++ b/doc/BUILDING.mdoc Tue Jul 18 16:59:57 2023 +0000
@@ -1,4 +1,4 @@
-.\"    $NetBSD: BUILDING.mdoc,v 1.145 2023/07/05 16:41:12 lukem Exp $
+.\"    $NetBSD: BUILDING.mdoc,v 1.146 2023/07/18 16:59:57 lukem Exp $
 .\"
 .\" Copyright (c) 2001-2023 The NetBSD Foundation, Inc.
 .\" All rights reserved.
@@ -33,7 +33,7 @@
 .\" Toolchain prefix for commands
 .ds toolprefix nb
 .
-.Dd July 5, 2023
+.Dd July 18, 2023
 .Dt BUILDING 8
 .Os NetBSD
 .\" turn off hyphenation
@@ -68,14 +68,24 @@ architecture) or
 .Em cross compiling
 (on another architecture or OS).
 .Pp
+This source tree contains the
+.Sy build.sh
+shell script which supports both native and cross builds of
+.Nx .
+.Pp
 This source tree contains a special subtree,
 .Dq tools ,
 which uses the host system to create a build toolchain for the target
 architecture.
 The host system must have at least C and C++
 compilers in order to create the toolchain
-.Nm ( make
-is not required); all other tools are created as part of the
+.Xr ( make 1
+is not required); all other tools
+(including
+.Xr make 1
+as
+.Sy \*[toolprefix]make )
+are created as part of the
 .Nx
 build process.
 (See the
@@ -123,7 +133,7 @@ version of
 .Xr make 1 .
 Intended for expert use with knowledge of its shortcomings,
 it has been superseded by the
-.Nm build.sh
+.Sy build.sh
 shell script as the recommended means for building
 .Nx .
 .
@@ -148,9 +158,9 @@ as building with an outdated version of
 Sources imported verbatim from third parties, without mangling the
 existing build structure.
 Other source trees in
-.Sy bin
+.Pa bin
 through
-.Sy usr.sbin
+.Pa usr.sbin
 use the
 .Nx
 .Xr make 1
@@ -185,6 +195,20 @@ directories.
 build structure for modular Xorg; the source is in
 .Sy X11SRCDIR .
 .
+.It Pa mk.conf
+Optional source tree specific
+.Xr mk.conf 5 ,
+used (if present) instead of
+.Pa /etc/mk.conf
+unless
+.Sy MAKECONF
+is defined.
+.Pp
+.Em Note :
+Not part of the
+.Nx
+source repository.
+.
 .It Pa regress/ , tests/
 Regression test harness.
 Can be cross-compiled, but only run natively.
@@ -338,7 +362,7 @@ or
 Most parts of the build require
 .Sy HOST_SH
 to be an absolute path; however,
-.Nm build.sh
+.Sy build.sh
 allows it to be a simple command name, which will be converted
 to an absolute path by searching the
 .Ev PATH .
@@ -380,7 +404,13 @@ and
 .Em Note :
 Only settable in the process environment.
 .DFLT
-.Dq Pa /etc/mk.conf .
+.Dq Pa /etc/mk.conf ,
+although
+.Sy build.sh
+will set the default to the full path to
+.Pa mk.conf
+if the latter is present in the same directory as
+.Sy build.sh .
 .
 .It Sy MAKEFLAGS
 Flags to invoke
@@ -426,7 +456,7 @@ is not defined.
 can be provided only in the environment or via the
 .Fl O
 flag of
-.Nm build.sh ;
+.Sy build.sh ;
 it cannot usefully be set inside a Makefile, including in
 .Xr mk.conf 5
 or
@@ -461,7 +491,7 @@ The current directory may be read only.
 can be provided only in the environment or via the
 .Fl M
 flag of
-.Nm build.sh ;
+.Sy build.sh ;
 it cannot usefully be set inside a Makefile, including in
 .Xr mk.conf 5
 or
@@ -480,7 +510,7 @@ Must support execution of binaries.
 I.e., without
 .Xr mount 8 Ns 's
 .Fl o
-.Sy noexec
+.Cm noexec
 option.
 .DFLT
 .Dq Pa /tmp .
@@ -593,7 +623,7 @@ and any other files known to be created 
 .
 .It Sy depend
 Create dependency files
-.Sy ( .depend )
+.Pa ( .depend )
 containing more detailed information about the dependencies of source
 code on header files.
 Allows programs to be recompiled automatically when a dependency changes.
@@ -948,7 +978,7 @@ a suitable shell using a command like
 .Ed
 .Pp
 The above command will usually enable
-.Nm build.sh
+.Sy build.sh
 to automatically set
 .Sy HOST_SH Ns Cm = Ns Pa /path/to/suitable/shell ,
 but if that fails, then the following set of commands may be used instead:
@@ -965,10 +995,10 @@ to exec a suitable shell instead, or sho
 If
 .Sy HOST_SH
 is not set explicitly, then
-.Nm build.sh
+.Sy build.sh
 sets a default using heuristics dependent on the host platform,
 or from the shell under which
-.Nm build.sh
+.Sy build.sh
 is executed (if that can be determined),



Home | Main Index | Thread Index | Old Index