freebsd-skq/contrib/bmake/make-bootstrap.sh.in
sjg 897ced70e6 Merge bmake-20200517
Changes since 20181221 are mostly portability related
hence the large gap in versions imported.

There are however some bug fixes, and a rework of filemon handling.
In NetBSD make/filemon/filemon_ktrace.c allows use of fktrace
and elimination of filemon(4) which has not had the TLC it needs.

FreeBSD filemon(4) is in much better shape, so bmake/filemon/filemon_dev.c
allows use of that, with a bit less overhead than the ktrace model.

Summary of changes from ChangeLog

	o str.c: empty string does not match % pattern
	  plus unit-test changes
	o var.c: import handling of old sysV style modifier using '%'
	o str.c: refactor brk_string
	o meta.c: meta_oodate, CHECK_VALID_META is too aggressive for CMD
	  a blank command is perfectly valid.
	o meta.c: meta_oodate, check for corrupted meta file
	  earlier and more often.
	* meta.c: meta_compat_parent check for USE_FILEMON
	  patch from Soeren Tempel
	o meta.c: fix compat mode, need to call meta_job_output()
	o job.c: extra fds for meta mode not needed if using filemon_dev
	o meta.c: avoid passing NULL to filemon_*() when meta_needed()
	  returns FALSE.
	o filemon/filemon_{dev,ktrace}.c: allow selection of
	  filemon implementation.  filemon_dev.c uses the kernel module
	  while filemon_ktrace.c leverages the fktrace api available in
	  NetBSD.  filemon_ktrace.c can hopefully form the basis for
	  adding support for other tracing mechanisms such as strace on
	  Linux.
	o meta.c: when target is out-of-date per normal make rules
	  record value of .OODATE in meta file.
	o parse.c: don't pass NULL to realpath(3)
	  some versions cannot handle it.
	o parse.c: ParseDoDependency: free paths rather than assert

plus more unit-tests
2020-05-20 22:25:46 +00:00

102 lines
2.3 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@\" -DMACHINE_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 for.o getopt hash.o \
make.o make_malloc.o metachar.o parse.o sigcompat.o str.o strlist.o \
suff.o targ.o trace.o var.o util.o"
LST_OBJECTS="lstAppend.o lstDupl.o lstInit.o lstOpen.o \
lstAtEnd.o lstEnQueue.o lstInsert.o lstAtFront.o lstIsAtEnd.o \
lstClose.o lstFind.o lstIsEmpty.o lstRemove.o lstConcat.o \
lstFindFrom.o lstLast.o lstReplace.o lstFirst.o lstDatum.o \
lstForEach.o lstMember.o lstSucc.o lstDeQueue.o lstForEachFrom.o \
lstDestroy.o lstNext.o lstPrev.o"
LIB_OBJECTS="@LIBOBJS@"
do_compile main.o ${MDEFS}
for o in ${BASE_OBJECTS} ${LST_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}