mirror of
https://git.savannah.gnu.org/git/make.git
synced 2025-01-29 02:20:01 +00:00
* build.template: Rewrite to allow gnulib support.
This commit is contained in:
parent
9be3c0e2b2
commit
da81e0815f
1 changed files with 70 additions and 45 deletions
115
build.template
115
build.template
|
@ -23,67 +23,92 @@
|
|||
LIBOBJDIR=lib/
|
||||
U=
|
||||
|
||||
top_srcdir="@top_srcdir@"
|
||||
CC="@CC@"
|
||||
CFLAGS="@CFLAGS@ @GUILE_CFLAGS@"
|
||||
CPPFLAGS="@CPPFLAGS@"
|
||||
LDFLAGS="@AM_LDFLAGS@ @LDFLAGS@"
|
||||
ALLOCA="@ALLOCA@"
|
||||
LOADLIBES="@LIBS@ @GUILE_LIBS@ @LIBINTL@"
|
||||
LIBOBJS="@LIBOBJS@"
|
||||
REMOTE="@REMOTE@"
|
||||
OBJEXT="@OBJEXT@"
|
||||
EXEEXT="@EXEEXT@"
|
||||
|
||||
# Use our old-style glob implementation
|
||||
test x"@USE_SYSTEM_GLOB@" = xno && LIBOBJS="${LIBOBJS} ${LIBOBJDIR}fnmatch.$OBJEXT ${LIBOBJDIR}glob.$OBJEXT"
|
||||
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@"
|
||||
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
|
||||
libdir=$exec_prefix/lib
|
||||
# Directory to search by default for included makefiles.
|
||||
includedir=${prefix}/include
|
||||
includedir=$prefix/include
|
||||
|
||||
localedir=${prefix}/share/locale
|
||||
localedir=$prefix/share/locale
|
||||
|
||||
defines="-DLOCALEDIR=\"${localedir}\" -DLIBDIR=\"${libdir}\" -DINCLUDEDIR=\"${includedir}\" @DEFS@"
|
||||
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
|
||||
|
||||
# These are all the objects we need to link together.
|
||||
objs="%objs% src/remote-${REMOTE}.${OBJEXT} ${LIBOBJS}"
|
||||
rm -rf _bldobj
|
||||
mkdir _bldobj
|
||||
|
||||
case $LIBOBJS in
|
||||
(*alloca*) cp "$top_srcdir"/lib/alloca.in.h lib/alloca.h ;;
|
||||
esac
|
||||
case $LIBOBJS in
|
||||
(*fnmatch*) cp "$top_srcdir"/lib/fnmatch.in.h lib/fnmatch.h ;;
|
||||
esac
|
||||
case $LIBOBJS in
|
||||
(*glob*) cp "$top_srcdir"/lib/glob.in.h lib/glob.h ;;
|
||||
esac
|
||||
# Build the gnulib library
|
||||
compile $LIBOBJS
|
||||
|
||||
echo creating libgnu.a...
|
||||
$AR $ARFLAGS _bldobj/lib/libgnu.a $objs
|
||||
|
||||
# Compile the source files into those objects.
|
||||
for file in `echo ${objs} | sed 's/\.'${OBJEXT}'/.c/g'`; do
|
||||
echo compiling ${file}...
|
||||
$CC $defines $CPPFLAGS $CFLAGS \
|
||||
-c -Isrc -I"$top_srcdir"/src -Ilib -I"$top_srcdir"/lib "$top_srcdir"/$file
|
||||
done
|
||||
|
||||
# The object files were actually all put in the current directory.
|
||||
# Remove the source directory names from the list.
|
||||
srcobjs="$objs"
|
||||
objs=
|
||||
for obj in $srcobjs; do
|
||||
objs="$objs `basename $obj`"
|
||||
done
|
||||
compile %objs% src/remote-$REMOTE.$OBJEXT
|
||||
|
||||
# Link all the objects together.
|
||||
echo linking make...
|
||||
$CC $CFLAGS $LDFLAGS $objs $LOADLIBES -o makenew${EXEEXT}
|
||||
$CC $CFLAGS $LDFLAGS -L_bldobj/lib $objs -lgnu $LOADLIBES -o makenew$EXEEXT
|
||||
echo done
|
||||
mv -f makenew${EXEEXT} make${EXEEXT}
|
||||
mv -f makenew$EXEEXT make$EXEEXT
|
||||
|
|
Loading…
Reference in a new issue