freebsd-nq/contrib/bmake/make-bootstrap.sh.in
Simon J. Gerraty e2eeea75eb Merge bmake-20201117
o allow env var MAKE_OBJDIR_CHECK_WRITABLE=no to skip writable
  checks in InitObjdir.  Explicit .OBJDIR target always allows
  read-only directory.

o More code cleanup and refactoring.

o More unit tests

MFC after:	1 week
2020-11-20 06:02:31 +00:00

96 lines
2.0 KiB
Bash
Executable File

#!/bin/sh
set -e
srcdir=@srcdir@
DEFAULT_SYS_PATH="@default_sys_path@"
case "@use_meta@" in
yes) XDEFS="-DUSE_META ${XDEFS}";;
esac
CC="@CC@"
CFLAGS="@CFLAGS@ -I. -I${srcdir} @DEFS@ @CPPFLAGS@ -DMAKE_NATIVE ${XDEFS} -DBMAKE_PATH_MAX=@bmake_path_max@"
MAKE_VERSION=@_MAKE_VERSION@
MDEFS="-DMAKE_VERSION=\"$MAKE_VERSION\" \
-D@force_machine@MACHINE=\"@machine@\" \
-D@force_machine_arch@MACHINE_ARCH=\"@machine_arch@\" \
-D_PATH_DEFSYSPATH=\"${DEFAULT_SYS_PATH}\""
LDFLAGS="@LDFLAGS@"
LIBS="@LIBS@"
toUpper() {
${TR:-tr} abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ
}
do_compile2() {
obj="$1"; shift
src="$1"; shift
echo ${CC} -c ${CFLAGS} "$@" -o "$obj" "$src"
${CC} -c ${CFLAGS} "$@" -o "$obj" "$src"
}
do_compile() {
obj="$1"; shift
case "$1" in
*.c) src=$1; shift;;
*) src=`basename "$obj" .o`.c;;
esac
for d in "$srcdir" "$srcdir/lst.lib"
do
test -s "$d/$src" || continue
do_compile2 "$obj" "$d/$src" "$@" || exit 1
return
done
echo "Unknown object file '$obj'" >&2
exit 1
}
do_link() {
output="$1"; shift
echo ${CC} ${LDSTATIC} ${LDFLAGS} -o "$output" "$@" ${LIBS}
${CC} ${LDSTATIC} ${LDFLAGS} -o "$output" "$@" ${LIBS}
}
BASE_OBJECTS="arch.o buf.o compat.o cond.o dir.o enum.o for.o getopt hash.o \
lst.o make.o make_malloc.o metachar.o parse.o sigcompat.o str.o \
suff.o targ.o trace.o var.o util.o"
LIB_OBJECTS="@LIBOBJS@"
do_compile main.o ${MDEFS}
for o in ${BASE_OBJECTS} ${LIB_OBJECTS}
do
do_compile "$o"
done
case "@use_meta@" in
yes)
case "@use_filemon@" in
no) MDEFS=;;
*)
MDEFS="-DUSE_FILEMON -DUSE_FILEMON_`echo @use_filemon@ | toUpper`"
case "@use_filemon@,@filemon_h@" in
dev,*/filemon.h) FDEFS="-DHAVE_FILEMON_H -I`dirname @filemon_h@`";;
*) FDEFS=;;
esac
do_compile filemon_@use_filemon@.o filemon/filemon_@use_filemon@.c ${FDEFS}
BASE_OBJECTS="filemon_@use_filemon@.o $BASE_OBJECTS"
;;
esac
do_compile meta.o ${MDEFS}
BASE_OBJECTS="meta.o ${BASE_OBJECTS}"
;;
esac
do_compile job.o ${MDEFS}
do_link bmake main.o job.o ${BASE_OBJECTS} ${LST_OBJECTS} ${LIB_OBJECTS}