freebsd-src/Makefile
Simon J. Gerraty 507951f550 Import bmake-20240430
Intersting/relevant changes since bmake-20240309

ChangeLog since bmake-20240309

2024-04-30  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20240430
	Merge with NetBSD make, pick up
	o main.c: ensure '.include <makefile>' respects MAKESYSPATH.
	Dir_FindFile will search .CURDIR first unless ".DOTLAST" is seen.

2024-04-28  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20240428
	Merge with NetBSD make, pick up
	o simplify freeing of lists
	o arch.c: trim pointless comments
	o var.c: delay variable assignments until actually needed
	don't reallocate memory after evaluating an expression, result is
	almost always short-lived.

2024-04-26  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20240426
	Merge with NetBSD make, pick up
	o job.c: in debug output, print the directory in which a job
	failed at same time as failed target so it is more easily found in
	build log.

2024-04-24  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20240424
	Merge with NetBSD make, pick up
	o clean up comments, code and tests

2024-04-23  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20240422
	Merge with NetBSD make, pick up
	o var.c: avoid LazyBuf for :*time modifiers.
	LazyBuf's are not nul terminated so not suitable for passing to
	functions that expect that. These modifiers are used sparingly so
	an extra allocation is not a problem.

2024-04-20  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20240420
	Merge with NetBSD make, pick up
	o provide more context information for parse/evaluate errors

2024-04-14  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20240414
	Merge with NetBSD make, pick up
	o parse.c: print -dp debug info earlier so we see which
	.if or .for line is being parsed.

2024-04-04  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20240404
	Merge with NetBSD make, pick up
	o fix some unit tests for Cygwin
	o parse.c: exit immediately after reading a null byte from a makefile

	* fix generation of bmake.cat1

2024-03-19  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20240314
	Add/Improve support for Cygwin
	o uname -s output isn't useful so allow configure to
	set FORCE_MAKE_OS - to force the value of .MAKE.OS
	and use Cygwin which matches uname -o
	o fix some unit-tests for Cygwin

	* configure.in: use_makefile=no for Cygwin et al.
	NOTE: bmake does not support Cygwin and likely never will,

mk/ChangeLog since bmake-20240309

2024-04-24  Simon J Gerraty  <sjg@beast.crufty.net>

	* meta.autodep.mk: do not override start_utc

2024-04-18  Simon J Gerraty  <sjg@beast.crufty.net>

	* sys.dirdeps.mk: set defaults for DEP_* at level 0 too.
	These help when first include of Makefile.depend happens in a leaf
	dir.

	* install-mk (MK_VERSION): 20240414

2024-04-09  Simon J Gerraty  <sjg@beast.crufty.net>

	* install-mk (MK_VERSION): 20240408

	* init.mk: allow for _ as well as . to join V
	and Q from QUALIFIED_VAR_LIST and VAR_QUALIFIER_LIST.

	* progs.mk: avoid overlap between PROG_VARS and
	init.mk's QUALIFIED_VAR_LIST since PROG would also
	match its VAR_QUALIFIER_LIST,
	libs.mk does not have the same issue.

	* subdir.mk: _SUBDIRUSE for realinstall should run install
	remove include of ${.CURDIR}/Makefile.inc that can be done via
	local.subdir.mk where needed

	* own.mk: do not conflict with man.mk

2024-03-19  Simon J Gerraty  <sjg@beast.crufty.net>

	* install-mk (MK_VERSION): 20240314

	* add sys/Cygwin.mk from Christian Franke
2024-05-03 15:43:12 -07:00

238 lines
5.2 KiB
Makefile

# $Id: Makefile,v 1.127 2024/03/19 16:03:23 sjg Exp $
PROG= bmake
SRCS= \
arch.c \
buf.c \
compat.c \
cond.c \
dir.c \
for.c \
hash.c \
job.c \
lst.c \
main.c \
make.c \
make_malloc.c \
meta.c \
metachar.c \
parse.c \
str.c \
suff.c \
targ.c \
trace.c \
util.c \
var.c
.-include "VERSION"
.-include "Makefile.inc"
# this file gets generated by configure
.-include "Makefile.config"
.if !empty(LIBOBJS)
SRCS+= ${LIBOBJS:T:.o=.c}
.endif
# just in case
prefix?= /usr
srcdir?= ${.CURDIR}
DEFAULT_SYS_PATH?= ${prefix}/share/mk
CPPFLAGS+= -DUSE_META
CFLAGS+= ${CPPFLAGS}
CFLAGS+= -D_PATH_DEFSYSPATH=\"${DEFAULT_SYS_PATH}\"
CFLAGS+= -I. -I${srcdir} ${XDEFS} -DMAKE_NATIVE
CFLAGS+= ${COPTS.${.ALLSRC:M*.c:T:u}}
COPTS.main.c+= "-DMAKE_VERSION=\"${_MAKE_VERSION}\""
.for x in FORCE_MAKE_OS FORCE_MACHINE FORCE_MACHINE_ARCH
.ifdef $x
COPTS.main.c+= "-D$x=\"${$x}\""
.endif
.endfor
# meta mode can be useful even without filemon
# should be set by now
USE_FILEMON ?= no
.if ${USE_FILEMON:tl} != "no"
.PATH: ${srcdir}/filemon
SRCS+= filemon_${USE_FILEMON}.c
COPTS.meta.c+= -DUSE_FILEMON -DUSE_FILEMON_${USE_FILEMON:tu}
COPTS.job.c+= ${COPTS.meta.c}
.if ${USE_FILEMON} == "dev"
FILEMON_H ?= /usr/include/dev/filemon/filemon.h
.if exists(${FILEMON_H}) && ${FILEMON_H:T} == "filemon.h"
COPTS.filemon_dev.c += -DHAVE_FILEMON_H -I${FILEMON_H:H}
.endif
.elif ${USE_FILEMON} == "ktrace"
COPTS.filemon_ktrace.c += -Wno-error=unused-parameter
.endif
.endif # USE_FILEMON
.PATH: ${srcdir}
.if make(obj) || make(clean)
SUBDIR+= unit-tests
.endif
# start-delete1 for bsd.after-import.mk
# we skip a lot of this when building as part of FreeBSD etc.
# list of OS's which are derrived from BSD4.4
BSD44_LIST= NetBSD FreeBSD OpenBSD DragonFly MirBSD Bitrig
# we are...
OS := ${.MAKE.OS:U${uname -s:L:sh}}
# are we 4.4BSD ?
isBSD44:=${BSD44_LIST:M${OS}}
.if ${isBSD44} == "" && ${OS:NCygwin:NDarwin:NLinux} != ""
MANTARGET?= cat
.if ${MACHINE} == "sun386"
# even I don't have one of these anymore :-)
CFLAGS+= -DPORTAR
.elif ${OS} != "SunOS"
# assume the worst
SRCS+= sigcompat.c
CFLAGS+= -DSIGNAL_FLAGS=SA_RESTART
.endif
.else
MANTARGET?= man
.endif
# turn this on by default - ignored if we are root
WITH_INSTALL_AS_USER=
# suppress with -DWITHOUT_*
OPTIONS_DEFAULT_YES+= \
AUTOCONF_MK \
INSTALL_MK \
PROG_LINK
OPTIONS_DEFAULT_NO+= \
PROG_VERSION
# process options now
.include <own.mk>
.if ${MK_PROG_VERSION} == "yes"
PROG_NAME= ${PROG}-${_MAKE_VERSION}
.if ${MK_PROG_LINK} == "yes"
SYMLINKS+= ${PROG_NAME} ${BINDIR}/${PROG}
.endif
.endif
EXTRACT_MAN=no
# end-delete1
MAN= ${PROG}.1
MAN1= ${MAN}
.if ${PROG} != "make"
CLEANFILES+= my.history
.if make(${MAN}) || !exists(${srcdir}/${MAN})
my.history:
@(echo ".Nm"; \
echo "is derived from NetBSD"; \
echo ".Xr make 1 ."; \
echo "It uses autoconf to facilitate portability to other platforms."; \
echo ".Pp") > $@
.NOPATH: ${MAN}
${MAN}: make.1 my.history
@echo making $@
@sed \
-e '/^.Dt/s/MAKE/${PROG:tu}/' \
-e 's/^.Nx/NetBSD/' \
-e '/^.Nm/s/make/${PROG}/' \
-e '/^.Sh HISTORY/rmy.history' \
-e '/^.Sh HISTORY/,$$s,^.Nm,make,' ${srcdir}/make.1 > $@
all beforeinstall: ${MAN}
_mfromdir=.
.endif
.endif
MANTARGET?= cat
MANDEST?= ${MANDIR}/${MANTARGET}1
.if ${MANTARGET} == "cat"
_mfromdir=${srcdir}
.endif
.include <prog.mk>
CPPFLAGS+= -DMAKE_NATIVE -DHAVE_CONFIG_H
COPTS.var.c += -Wno-cast-qual
COPTS.job.c += -Wno-format-nonliteral
COPTS.parse.c += -Wno-format-nonliteral
COPTS.var.c += -Wno-format-nonliteral
# Force these
SHAREDIR= ${SHAREDIR.bmake:U${prefix}/share}
BINDIR= ${BINDIR.bmake:U${prefix}/bin}
MANDIR= ${MANDIR.bmake:U${SHAREDIR}/man}
${OBJS}: config.h
# start-delete2 for bsd.after-import.mk
# make sure that MAKE_VERSION gets updated.
main.o: ${srcdir}/VERSION
.if ${MK_AUTOCONF_MK} == "yes"
CONFIGURE_DEPS += ${.CURDIR}/VERSION
# we do not need or want the generated makefile
CONFIGURE_ARGS += --without-makefile
AUTOCONF_GENERATED_MAKEFILE = Makefile.config
.include <autoconf.mk>
.endif
SHARE_MK ?= ${SHAREDIR}/mk
MKSRC = ${srcdir}/mk
INSTALL ?= ${srcdir}/install-sh
.if ${MK_INSTALL_MK} == "yes"
install: install-mk
.endif
beforeinstall:
test -d ${DESTDIR}${BINDIR} || ${INSTALL} -m ${DIRMODE} -d ${DESTDIR}${BINDIR}
test -d ${DESTDIR}${MANDEST} || ${INSTALL} -m ${DIRMODE} -d ${DESTDIR}${MANDEST}
install-mk:
.if exists(${MKSRC}/install-mk)
test -d ${DESTDIR}${SHARE_MK} || ${INSTALL} -m ${DIRMODE} -d ${DESTDIR}${SHARE_MK}
sh ${MKSRC}/install-mk -v -m ${NONBINMODE} ${DESTDIR}${SHARE_MK}
.else
@echo need to unpack mk.tar.gz under ${srcdir} or set MKSRC; false
.endif
# end-delete2
# A simple unit-test driver to help catch regressions
TEST_MAKE ?= ${.OBJDIR}/${PROG:T}
accept test: .NOMETA
cd ${.CURDIR}/unit-tests && \
MAKEFLAGS= ${TEST_MAKE} -r -m / ${.TARGET} ${TESTS:DTESTS=${TESTS:Q}}
.if make(test) && ${MK_AUTO_OBJ} == "yes"
# The test target above visits unit-tests with -r -m /
# which prevents MK_AUTO_OBJ doing its job
# so do it here
.if defined(MAKEOBJDIRPREFIX) || ${MAKEOBJDIR:U:M*/*} != ""
_utobj = ${.OBJDIR}/unit-tests
.else
_utobj = ${.CURDIR}/unit-tests/${MAKEOBJDIR:Uobj}
.endif
utobj: .NOMETA
@test -d ${_utobj} && exit 0; \
echo "[Creating ${_utobj}...]"; \
umask ${OBJDIR_UMASK:U002}; \
mkdir -p ${_utobj}
test: utobj
.endif