| #!/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 |