mirror of
https://github.com/mirror/make.git
synced 2025-02-04 08:40:27 +08:00
* build.template: Rewrite to allow gnulib support.
This commit is contained in:
parent
9be3c0e2b2
commit
da81e0815f
115
build.template
115
build.template
@ -23,67 +23,92 @@
|
|||||||
LIBOBJDIR=lib/
|
LIBOBJDIR=lib/
|
||||||
U=
|
U=
|
||||||
|
|
||||||
top_srcdir="@top_srcdir@"
|
top_srcdir='@top_srcdir@'
|
||||||
CC="@CC@"
|
CC='@CC@'
|
||||||
CFLAGS="@CFLAGS@ @GUILE_CFLAGS@"
|
AR='@AR@'
|
||||||
CPPFLAGS="@CPPFLAGS@"
|
CFLAGS='@CFLAGS@ @GUILE_CFLAGS@'
|
||||||
LDFLAGS="@AM_LDFLAGS@ @LDFLAGS@"
|
CPPFLAGS='@CPPFLAGS@'
|
||||||
ALLOCA="@ALLOCA@"
|
DEFS='@DEFS@'
|
||||||
LOADLIBES="@LIBS@ @GUILE_LIBS@ @LIBINTL@"
|
ARFLAGS='@ARFLAGS@'
|
||||||
LIBOBJS="@LIBOBJS@"
|
LDFLAGS='@AM_LDFLAGS@ @LDFLAGS@'
|
||||||
REMOTE="@REMOTE@"
|
ALLOCA='@ALLOCA@'
|
||||||
OBJEXT="@OBJEXT@"
|
LOADLIBES='@LIBS@ @GUILE_LIBS@ @LIBINTL@'
|
||||||
EXEEXT="@EXEEXT@"
|
REMOTE='@REMOTE@'
|
||||||
|
OBJEXT='@OBJEXT@'
|
||||||
# Use our old-style glob implementation
|
EXEEXT='@EXEEXT@'
|
||||||
test x"@USE_SYSTEM_GLOB@" = xno && LIBOBJS="${LIBOBJS} ${LIBOBJDIR}fnmatch.$OBJEXT ${LIBOBJDIR}glob.$OBJEXT"
|
|
||||||
|
|
||||||
# Common prefix for machine-independent installed files.
|
# Common prefix for machine-independent installed files.
|
||||||
prefix="@prefix@"
|
prefix='@prefix@'
|
||||||
# Common prefix for machine-dependent installed files.
|
# Common prefix for machine-dependent installed files.
|
||||||
exec_prefix=`eval echo @exec_prefix@`
|
exec_prefix=`eval echo @exec_prefix@`
|
||||||
# Directory to find libraries in for '-lXXX'.
|
# Directory to find libraries in for '-lXXX'.
|
||||||
libdir=${exec_prefix}/lib
|
libdir=$exec_prefix/lib
|
||||||
# Directory to search by default for included makefiles.
|
# 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.
|
# Exit as soon as any command fails.
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
# These are all the objects we need to link together.
|
rm -rf _bldobj
|
||||||
objs="%objs% src/remote-${REMOTE}.${OBJEXT} ${LIBOBJS}"
|
mkdir _bldobj
|
||||||
|
|
||||||
case $LIBOBJS in
|
# Build the gnulib library
|
||||||
(*alloca*) cp "$top_srcdir"/lib/alloca.in.h lib/alloca.h ;;
|
compile $LIBOBJS
|
||||||
esac
|
|
||||||
case $LIBOBJS in
|
echo creating libgnu.a...
|
||||||
(*fnmatch*) cp "$top_srcdir"/lib/fnmatch.in.h lib/fnmatch.h ;;
|
$AR $ARFLAGS _bldobj/lib/libgnu.a $objs
|
||||||
esac
|
|
||||||
case $LIBOBJS in
|
|
||||||
(*glob*) cp "$top_srcdir"/lib/glob.in.h lib/glob.h ;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
# Compile the source files into those objects.
|
# Compile the source files into those objects.
|
||||||
for file in `echo ${objs} | sed 's/\.'${OBJEXT}'/.c/g'`; do
|
compile %objs% src/remote-$REMOTE.$OBJEXT
|
||||||
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
|
|
||||||
|
|
||||||
# Link all the objects together.
|
# Link all the objects together.
|
||||||
echo linking make...
|
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
|
echo done
|
||||||
mv -f makenew${EXEEXT} make${EXEEXT}
|
mv -f makenew$EXEEXT make$EXEEXT
|
||||||
|
Loading…
Reference in New Issue
Block a user