summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Smith <psmith@gnu.org>2019-09-08 15:41:20 -0400
committerPaul Smith <psmith@gnu.org>2019-09-09 18:38:31 -0400
commitbde990bfeaa8797723e11cad216a9b074fa804fa (patch)
treef311ba982969eb3ee6ea4370b7e7791d5e10f076
parent60e54608bdfa29c57ac4d934f413a8cf100c38d2 (diff)
downloadmake-git-bde990bfeaa8797723e11cad216a9b074fa804fa.tar.gz
Rework the creation of build.sh so it's not a template.
* build.sh: Rename from build.template. Get the list of objects from the Makefile. Move configure-replaced variables ... * build.cfg.in: to this new .in file. * configure.ac: Remove special handling of build.sh.in and add build.cfg as a generated file. * Makefile.am (EXTRA_DIST): Remove build.sh.in and add build.sh and build.cfg.in for build.sh.in. * maintMakefile: Remove handling for build.template. Treat build.sh as a source file, not a generated file. * .gitignore: Ignore generated build.cfg file.
-rw-r--r--.gitignore3
-rw-r--r--Makefile.am7
-rw-r--r--build.cfg.in38
-rwxr-xr-xbuild.sh149
-rw-r--r--build.template114
-rw-r--r--configure.ac9
-rw-r--r--maintMakefile18
7 files changed, 194 insertions, 144 deletions
diff --git a/.gitignore b/.gitignore
index 2f5023e7..df60c2ce 100644
--- a/.gitignore
+++ b/.gitignore
@@ -60,8 +60,7 @@ README
README.DOS
README.OS2
README.W32
-build.sh
-build.sh.in
+build.cfg
config.ami
config.h-vms
config.h.W32
diff --git a/Makefile.am b/Makefile.am
index 310ce938..10e04c84 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -97,7 +97,7 @@ test_FILES = tests/run_make_tests tests/run_make_tests.bat \
tests/mkshadow tests/jhelp.pl tests/guile.supp tests/README
# test/scripts are added via dist-hook below.
-EXTRA_DIST = ChangeLog README build.sh.in $(man_MANS) \
+EXTRA_DIST = ChangeLog README build.sh build.cfg.in $(man_MANS) \
README.customs README.OS2 \
README.Amiga SCOPTIONS src/config.ami \
README.DOS builddos.bat src/configh.dos \
@@ -107,11 +107,6 @@ EXTRA_DIST = ChangeLog README build.sh.in $(man_MANS) \
src/gmk-default.scm src/gmk-default.h \
$(mk_FILES) $(m4_FILES) $(test_FILES)
-
-# This is built during configure, but behind configure's back
-
-DISTCLEANFILES = build.sh
-
# --------------- Generate the Guile default module content
src/guile.$(OBJEXT): src/gmk-default.h
diff --git a/build.cfg.in b/build.cfg.in
new file mode 100644
index 00000000..3daa65a6
--- /dev/null
+++ b/build.cfg.in
@@ -0,0 +1,38 @@
+# Configuration for building GNU Make in the absence of any 'make' program.
+# @configure_input@
+
+# Copyright (C) 1993-2019 Free Software Foundation, Inc.
+# This file is part of GNU Make.
+#
+# GNU Make is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 3 of the License, or (at your option) any later
+# version.
+#
+# GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program. If not, see <http://www.gnu.org/licenses/>.
+
+# See Makefile.in for comments describing these variables.
+
+top_srcdir='@top_srcdir@'
+
+prefix='@prefix@'
+exec_prefix=`eval echo @exec_prefix@`
+
+CC='@CC@'
+AR='@AR@'
+CFLAGS='@CFLAGS@ @GUILE_CFLAGS@'
+CPPFLAGS='@CPPFLAGS@'
+DEFS='@DEFS@'
+ARFLAGS='@ARFLAGS@'
+LDFLAGS='@AM_LDFLAGS@ @LDFLAGS@'
+ALLOCA='@ALLOCA@'
+LOADLIBES='@LIBS@ @GUILE_LIBS@ @LIBINTL@'
+REMOTE='@REMOTE@'
+OBJEXT='@OBJEXT@'
+EXEEXT='@EXEEXT@'
diff --git a/build.sh b/build.sh
new file mode 100755
index 00000000..7d288914
--- /dev/null
+++ b/build.sh
@@ -0,0 +1,149 @@
+#!/bin/sh
+# Shell script to build GNU Make in the absence of any 'make' program.
+
+# Copyright (C) 1993-2019 Free Software Foundation, Inc.
+# This file is part of GNU Make.
+#
+# GNU Make is free software; you can redistribute it and/or modify it under
+# the terms of the GNU General Public License as published by the Free Software
+# Foundation; either version 3 of the License, or (at your option) any later
+# version.
+#
+# GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
+# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+# details.
+#
+# You should have received a copy of the GNU General Public License along with
+# this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Get configure-generated values
+. ./build.cfg
+
+: ${OUTDIR:=.}
+OUTLIB="$OUTDIR/lib"
+
+# Directory to find libraries in for '-lXXX'.
+libdir=$exec_prefix/lib
+# Directory to search by default for included makefiles.
+includedir=$prefix/include
+
+localedir=$prefix/share/locale
+
+defines="-DLOCALEDIR=\"$localedir\" -DLIBDIR=\"$libdir\" -DINCLUDEDIR=\"$includedir\""
+
+# Look up a make variable value.
+# It can handle simple recursion where variables are separate words.
+# Print the value to stdout.
+get_mk_var ()
+{
+ file=$1
+ var=$2
+
+ val=
+ v=$(sed -e :a -e '/\\$/N; s/\\\n//; ta' "$file" | sed -n "s=^ *$var *\= *==p")
+ for w in $v; do
+ case $w in
+ (\$[\(\{]*[\)\}]) w=${w#\$[\(\{]}; w=$(get_mk_var "$file" "${w%[\)\}]}") ;;
+ esac
+ val="${val:+$val }$w"
+ done
+
+ printf '%s\n' "$val"
+}
+
+# Compile source files. Object files are put into $objs.
+compile ()
+{
+ objs=
+ for ofile in "$@"; do
+ file="${ofile%.$OBJEXT}.c"
+ echo "compiling $file..."
+ of="$OUTDIR/$ofile"
+ mkdir -p "${of%/*}"
+ $CC $cflags $CPPFLAGS $CFLAGS -c -o "$of" "$top_srcdir/$file"
+ objs="${objs:+$objs }$of"
+ done
+}
+
+# Use config.status to convert a .in file. Output file is put into $out.
+# $out will be empty if no conversion was needed.
+convert ()
+{
+ out=
+ base=$1
+ var="GENERATE_$(echo $base | tr 'a-z./+' A-Z__X)"
+
+ # Is this file disabled?
+ grep "${var}_FALSE\"]=\"\"" config.status >/dev/null && return
+
+ # Not disabled, so create it
+ in="$top_srcdir/lib/$(echo ${base%.*}.in.${base##*.} | tr / _)"
+ out="$OUTLIB/$base"
+ mkdir -p "${out%/*}"
+
+ # First perform the normal replacements, using config.status
+ sed -e 's|@GUARD_PREFIX@|GL|g' \
+ -e 's/@GNULIB_UNISTD_H_GETOPT@/0/g' \
+ "$in" > "${out}_"
+ ./config.status --file "${out}__:${out}_"
+ int="${out}__"
+
+ # Then see if there any files we need to include. Unfortunately there's no
+ # algorithmic conversion so we just have to hard-code it.
+ incls=$(sed -n 's/.*definitions* of \(_[^ $]*\).*/\1/p' "$in")
+
+ for inc in $incls; do
+ case $inc in
+ (_GL_FUNCDECL_RPL) fn=$(get_mk_var lib/Makefile CXXDEFS_H) ;;
+ (_GL_ARG_NONNULL) fn=$(get_mk_var lib/Makefile ARG_NONNULL_H) ;;
+ (_GL_WARN_ON_USE) fn=$(get_mk_var lib/Makefile WARN_ON_USE_H) ;;
+ (_Noreturn) fn=$(get_mk_var lib/Makefile _NORETURN_H) ;;
+ (*) echo "Unknown file replacement: $inc"; exit 1 ;;
+ esac
+
+ fn="$top_srcdir/lib/${fn##*/}"
+ [ -f "$fn" ] || { echo "Missing file: $fn"; exit 1; }
+
+ sed "/definitions* of $inc/r $fn" "$int" > "${int}_"
+ int=${int}_
+ done
+
+ # Done!
+ mv "$int" "$out"
+}
+
+# Get source files provided from gnulib and convert to object files
+LIBOBJS=
+for lo in $( (get_mk_var lib/Makefile libgnu_a_OBJECTS; get_mk_var lib/Makefile libgnu_a_LIBADD) | sed "s=\$[\(\{]OBJEXT[\)\}]=$OBJEXT=g"); do
+ LIBOBJS="${LIBOBJS:+$LIBOBJS }lib/$lo"
+done
+
+# Get object files from the Makefile
+OBJS=$(get_mk_var Makefile make_OBJECTS | sed "s=\$[\(\{]OBJEXT[\)\}]=$OBJEXT=g")
+
+# Exit as soon as any command fails.
+set -e
+
+# Generate gnulib header files that would normally be created by make
+for b in $(get_mk_var lib/Makefile BUILT_SOURCES); do
+ convert $b
+done
+
+# Build the gnulib library
+cflags="$DEFS -I$OUTLIB -Ilib -I$top_srcdir/lib -I$OUTDIR/src -Isrc -I$top_srcdir/src"
+compile $LIBOBJS
+
+echo "creating libgnu.a..."
+$AR $ARFLAGS "$OUTLIB"/libgnu.a $objs
+
+# Compile the source files into those objects.
+cflags="$DEFS $defines -I$OUTDIR/src -Isrc -I$top_srcdir/src -I$OUTLIB -Ilib -I$top_srcdir/lib"
+compile $OBJS
+
+# Link all the objects together.
+echo "linking make..."
+$CC $CFLAGS $LDFLAGS -L"$OUTLIB" $objs -lgnu $LOADLIBES -o "$OUTDIR/makenew$EXEEXT"
+mv -f "$OUTDIR/makenew$EXEEXT" "$OUTDIR/make$EXEEXT"
+
+echo done.
diff --git a/build.template b/build.template
deleted file mode 100644
index 2eb2b630..00000000
--- a/build.template
+++ /dev/null
@@ -1,114 +0,0 @@
-#!/bin/sh
-# Shell script to build GNU Make in the absence of any 'make' program.
-# @configure_input@
-
-# Copyright (C) 1993-2019 Free Software Foundation, Inc.
-# This file is part of GNU Make.
-#
-# GNU Make is free software; you can redistribute it and/or modify it under
-# the terms of the GNU General Public License as published by the Free Software
-# Foundation; either version 3 of the License, or (at your option) any later
-# version.
-#
-# GNU Make is distributed in the hope that it will be useful, but WITHOUT ANY
-# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
-# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
-# details.
-#
-# You should have received a copy of the GNU General Public License along with
-# this program. If not, see <http://www.gnu.org/licenses/>.
-
-# See Makefile.in for comments describing these variables.
-
-LIBOBJDIR=lib/
-U=
-
-top_srcdir='@top_srcdir@'
-CC='@CC@'
-AR='@AR@'
-CFLAGS='@CFLAGS@ @GUILE_CFLAGS@'
-CPPFLAGS='@CPPFLAGS@'
-DEFS='@DEFS@'
-ARFLAGS='@ARFLAGS@'
-LDFLAGS='@AM_LDFLAGS@ @LDFLAGS@'
-ALLOCA='@ALLOCA@'
-LOADLIBES='@LIBS@ @GUILE_LIBS@ @LIBINTL@'
-REMOTE='@REMOTE@'
-OBJEXT='@OBJEXT@'
-EXEEXT='@EXEEXT@'
-
-# Common prefix for machine-independent installed files.
-prefix='@prefix@'
-# Common prefix for machine-dependent installed files.
-exec_prefix=`eval echo @exec_prefix@`
-# Directory to find libraries in for '-lXXX'.
-libdir=$exec_prefix/lib
-# Directory to search by default for included makefiles.
-includedir=$prefix/include
-
-localedir=$prefix/share/locale
-
-defines="-DLOCALEDIR=\"$localedir\" -DLIBDIR=\"$libdir\" -DINCLUDEDIR=\"$includedir\""
-
-# Look up a make variable value
-# It can handle very simple recursion, where variables are separate words
-get_mk_var ()
-{
- file=$1
- var=$2
-
- val=
- v=$(sed -e :a -e '/\\$/N; s/\\\n//; ta' "$file" | sed -n "s=^ *$var *\= *==p")
- for w in $v; do
- case $w in
- (\$[\(\{]*[\)\}]) w=${w#\$[\(\{]}; w=$(get_mk_var "$file" "${w%[\)\}]}") ;;
- esac
- val="${val:+$val }$w"
- done
-
- printf %s "$val"
-}
-
-# Get source files provided from gnulib
-LIBOBJS=
-for lc in $(get_mk_var lib/Makefile libgnu_a_SOURCES); do
- case $lc in
- (*.c) LIBOBJS="${LIBOBJS:+$LIBOBJS }$LIBOBJDIR${lc%.c}.$OBJEXT" ;;
- (*) echo ignore $lc ;;
- esac
-done
-
-compile ()
-{
- objs=
- for ofile in "$@"; do
- file=${ofile%.$OBJEXT}.c
- echo "compiling $file..."
- mkdir -p _bldobj/${file%/*}
- of=_bldobj/$ofile
- $CC $defines $DEFS $CPPFLAGS $CFLAGS -c -o "$of" \
- -Isrc -I"$top_srcdir"/src -Ilib -I"$top_srcdir"/lib "$top_srcdir/$file"
- objs="${objs:+$objs }$of"
- done
-}
-
-# Exit as soon as any command fails.
-set -e
-
-rm -rf _bldobj
-mkdir _bldobj
-
-# Build the gnulib library
-compile $LIBOBJS
-
-echo creating libgnu.a...
-$AR $ARFLAGS _bldobj/lib/libgnu.a $objs
-
-# Compile the source files into those objects.
-compile %objs% src/remote-$REMOTE.$OBJEXT
-
-# Link all the objects together.
-echo linking make...
-$CC $CFLAGS $LDFLAGS -L_bldobj/lib $objs -lgnu $LOADLIBES -o makenew$EXEEXT
-echo done
-mv -f makenew$EXEEXT make$EXEEXT
diff --git a/configure.ac b/configure.ac
index 36422154..f843fdd4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -492,7 +492,7 @@ AS_IF([test "x$make_cv_posix_spawn" = xno && test "x$user_posix_spawn" = xyes],
])
# Specify what files are to be created.
-AC_CONFIG_FILES([Makefile lib/Makefile po/Makefile.in doc/Makefile \
+AC_CONFIG_FILES([Makefile build.cfg lib/Makefile po/Makefile.in doc/Makefile \
tests/config-flags.pm])
# We don't need this: the standard automake output suffices for POSIX systems.
#mk/Posix.mk
@@ -501,13 +501,6 @@ AC_CONFIG_FILES([Makefile lib/Makefile po/Makefile.in doc/Makefile \
AC_OUTPUT
-# We only generate the build.sh if we have a build.sh.in; we won't have
-# one before we've created a distribution.
-AS_IF([test -f "$srcdir/build.sh.in"],
-[ ./config.status --file build.sh
- chmod +x build.sh
-])
-
dnl Local Variables:
dnl comment-start: "dnl "
dnl comment-end: ""
diff --git a/maintMakefile b/maintMakefile
index b47e7145..0a44a623 100644
--- a/maintMakefile
+++ b/maintMakefile
@@ -85,16 +85,6 @@ Basic.mk: Basic.mk.template .dep_segment Makefile
$(word 2,$^) >>$@
chmod a-w $@
-# Construct build.sh.in
-#
-build.sh.in: build.template Makefile
- rm -f $@
- sed -e 's@%objs%@$(patsubst %.o,%.$${OBJEXT},$(filter-out src/remote-%,$(make_OBJECTS)))@g' \
- $< > $@
- chmod a-w+x $@
-
-all: build.sh.in
-
# Use automake to build a dependency list file, for Makebase.mk.
#
@@ -266,9 +256,9 @@ $(CONFIG_CHECKS): checkcfg.%: distdir
$(AM_DISTCHECK_CONFIGURE_FLAGS) $(DISTCHECK_CONFIGURE_FLAGS)
exec >>'checkcfg.$*.log' 2>&1; set -x; \
cd $(distdir)/_build \
- && ./build.sh \
- && ./make $(AM_MAKEFLAGS) check-local \
- && ./make $(AM_MAKEFLAGS) clean
+ && OUTDIR=_bld ../build.sh \
+ && _bld/make $(AM_MAKEFLAGS) check-local \
+ && _bld/make $(AM_MAKEFLAGS) clean
exec >>'checkcfg.$*.log' 2>&1; set -x; \
cd $(distdir)/_build \
&& $(NR_MAKE) $(AM_MAKEFLAGS) CFLAGS='$(AM_CFLAGS)' \
@@ -405,7 +395,7 @@ $(COV_BUILD_FILE): $(filter %.c %.h,$(DISTFILES))
CFLAGS='$(AM_CFLAGS)'
PATH="$${COVERITY_PATH:+$$COVERITY_PATH/bin:}$$PATH"; \
cd '$(distdir)'/_build \
- && cov-build --dir cov-int ./build.sh
+ && cov-build --dir cov-int ../build.sh
rm -f '$@'
(cd '$(distdir)'/_build && tar czf - cov-int) > '$@'