mirror of
https://git.savannah.gnu.org/git/make.git
synced 2025-02-12 00:16:30 +00:00
* build.sh: Allow a "keep-going" mode during builds
This commit is contained in:
parent
4e18732a1d
commit
92789aa2e7
2 changed files with 35 additions and 10 deletions
43
build.sh
43
build.sh
|
@ -20,6 +20,11 @@
|
||||||
# Get configure-generated values
|
# Get configure-generated values
|
||||||
. ./build.cfg
|
. ./build.cfg
|
||||||
|
|
||||||
|
die () { echo "$*" 1>&2; exit 1; }
|
||||||
|
usage () { echo "$0 [-k]"; exit $1; }
|
||||||
|
|
||||||
|
keep_going=false
|
||||||
|
|
||||||
: ${OUTDIR:=.}
|
: ${OUTDIR:=.}
|
||||||
OUTLIB="$OUTDIR/lib"
|
OUTLIB="$OUTDIR/lib"
|
||||||
|
|
||||||
|
@ -55,6 +60,7 @@ get_mk_var ()
|
||||||
# Compile source files. Object files are put into $objs.
|
# Compile source files. Object files are put into $objs.
|
||||||
compile ()
|
compile ()
|
||||||
{
|
{
|
||||||
|
success=true
|
||||||
objs=
|
objs=
|
||||||
for ofile in "$@"; do
|
for ofile in "$@"; do
|
||||||
# We should try to use a Makefile variable like libgnu_a_SOURCES or
|
# We should try to use a Makefile variable like libgnu_a_SOURCES or
|
||||||
|
@ -65,10 +71,18 @@ compile ()
|
||||||
esac
|
esac
|
||||||
echo "compiling $file..."
|
echo "compiling $file..."
|
||||||
of="$OUTDIR/$ofile"
|
of="$OUTDIR/$ofile"
|
||||||
mkdir -p "${of%/*}"
|
mkdir -p "${of%/*}" || exit 1
|
||||||
$CC $cflags $CPPFLAGS $CFLAGS -c -o "$of" "$top_srcdir/$file"
|
if $CC $cflags $CPPFLAGS $CFLAGS -c -o "$of" "$top_srcdir/$file"; then
|
||||||
|
: worked
|
||||||
|
else
|
||||||
|
$keep_going || die "Compilation failed."
|
||||||
|
success=false
|
||||||
|
fi
|
||||||
|
|
||||||
objs="${objs:+$objs }$of"
|
objs="${objs:+$objs }$of"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
$success
|
||||||
}
|
}
|
||||||
|
|
||||||
# Use config.status to convert a .in file. Output file is put into $out.
|
# Use config.status to convert a .in file. Output file is put into $out.
|
||||||
|
@ -130,28 +144,39 @@ done
|
||||||
# Get object files from the Makefile
|
# Get object files from the Makefile
|
||||||
OBJS=$(get_mk_var Makefile make_OBJECTS | sed "s=\$[\(\{]OBJEXT[\)\}]=$OBJEXT=g")
|
OBJS=$(get_mk_var Makefile make_OBJECTS | sed "s=\$[\(\{]OBJEXT[\)\}]=$OBJEXT=g")
|
||||||
|
|
||||||
# Exit as soon as any command fails.
|
while test -n "$1"; do
|
||||||
set -e
|
case $1 in
|
||||||
|
(-k) keep_going=true; shift ;;
|
||||||
|
(--) shift; break ;;
|
||||||
|
(-[h?]) usage 0 ;;
|
||||||
|
(-*) echo "Unknown option: $1"; usage 1 ;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
test -z "$1" || die "Unknown argument: $*"
|
||||||
|
|
||||||
# Generate gnulib header files that would normally be created by make
|
# Generate gnulib header files that would normally be created by make
|
||||||
|
set -e
|
||||||
for b in $(get_mk_var lib/Makefile BUILT_SOURCES); do
|
for b in $(get_mk_var lib/Makefile BUILT_SOURCES); do
|
||||||
convert $b
|
convert $b
|
||||||
done
|
done
|
||||||
|
set +e
|
||||||
|
|
||||||
# Build the gnulib library
|
# Build the gnulib library
|
||||||
cflags="$DEFS -I$OUTLIB -Ilib -I$top_srcdir/lib -I$OUTDIR/src -Isrc -I$top_srcdir/src"
|
cflags="$DEFS -I$OUTLIB -Ilib -I$top_srcdir/lib -I$OUTDIR/src -Isrc -I$top_srcdir/src"
|
||||||
compile $LIBOBJS
|
compile $LIBOBJS || die "Compilation failed."
|
||||||
|
|
||||||
echo "creating libgnu.a..."
|
echo "creating libgnu.a..."
|
||||||
$AR $ARFLAGS "$OUTLIB"/libgnu.a $objs
|
$AR $ARFLAGS "$OUTLIB"/libgnu.a $objs || die "Archive of libgnu failed."
|
||||||
|
|
||||||
# Compile the source files into those objects.
|
# 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"
|
cflags="$DEFS $defines -I$OUTDIR/src -Isrc -I$top_srcdir/src -I$OUTLIB -Ilib -I$top_srcdir/lib"
|
||||||
compile $OBJS
|
compile $OBJS || die "Compilation failed."
|
||||||
|
|
||||||
# Link all the objects together.
|
# Link all the objects together.
|
||||||
echo "linking make..."
|
echo "linking make..."
|
||||||
$CC $CFLAGS $LDFLAGS -L"$OUTLIB" $objs -lgnu $LOADLIBES -o "$OUTDIR/makenew$EXEEXT"
|
$CC $CFLAGS $LDFLAGS -L"$OUTLIB" -o "$OUTDIR/makenew$EXEEXT" $objs -lgnu $LOADLIBES || die "Link failed."
|
||||||
mv -f "$OUTDIR/makenew$EXEEXT" "$OUTDIR/make$EXEEXT"
|
|
||||||
|
mv -f "$OUTDIR/makenew$EXEEXT" "$OUTDIR/make$EXEEXT" || exit 1
|
||||||
|
|
||||||
echo done.
|
echo done.
|
||||||
|
|
|
@ -295,7 +295,7 @@ NR_MAKE = $(MAKE)
|
||||||
# Check builds both with build.sh and with make
|
# Check builds both with build.sh and with make
|
||||||
build.sh_SCRIPT = exec >>'checkcfg.$*.log' 2>&1; set -x; \
|
build.sh_SCRIPT = exec >>'checkcfg.$*.log' 2>&1; set -x; \
|
||||||
cd $(distdir)/_build \
|
cd $(distdir)/_build \
|
||||||
&& OUTDIR=_bld ../build.sh $(CFGCHECK_BUILD_FLAGS) \
|
&& OUTDIR=_bld ../build.sh -k $(CFGCHECK_BUILD_FLAGS) \
|
||||||
&& _bld/make GMK_OUTDIR=../_bld $(AM_MAKEFLAGS) check-local \
|
&& _bld/make GMK_OUTDIR=../_bld $(AM_MAKEFLAGS) check-local \
|
||||||
&& _bld/make GMK_OUTDIR=../_bld $(AM_MAKEFLAGS) clean
|
&& _bld/make GMK_OUTDIR=../_bld $(AM_MAKEFLAGS) clean
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue