Simon J. Gerraty 49caa483b3 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

70 lines
2.0 KiB
Makefile

# $Id: whats.mk,v 1.9 2020/05/09 19:48:53 sjg Exp $
#
# @(#) Copyright (c) 2014-2020, Simon J. Gerraty
#
# This file is provided in the hope that it will
# be of use. There is absolutely NO WARRANTY.
# Permission to copy, redistribute or otherwise
# use this file is hereby granted provided that
# the above copyright notice and this notice are
# left intact.
#
# Please send copies of changes and bug-fixes to:
# sjg@crufty.net
#
.if ${MK_WHATSTRING:Uno} == "yes"
# it can be useful to embed a what(1) string in binaries
# so that the build location can be seen from a core file.
.if defined(KMOD)
what_thing ?= ${KMOD}
.elif defined(LIB)
what_thing ?= lib${LIB}
.elif defined(PROG)
what_thing ?= ${PROG}
SRCS ?= ${PROG}.c
.elif defined(SHLIB)
what_thing ?= lib${SHLIB}
.endif
.if !empty(what_thing)
# a unique name that won't conflict with anything
what_uuid = what_${what_thing}_${.CURDIR:T:hash}
what_var = what_${.CURDIR:T:hash}
SRCS += ${what_uuid}.c
CLEANFILES += ${what_uuid}.c
# we do not need to capture this
SUPPRESS_DEPEND += *${what_uuid}.c
SB ?= ${SRCTOP:H}
SB_LOCATION ?= ${HOST}:${SB}
# make customization easy
WHAT_LOCATION ?= ${.OBJDIR:S,${SB},${SB_LOCATION},}
WHAT_1 ?= ${what_thing:tu} built ${%Y%m%d:L:localtime} by ${USER}
WHAT_2 ?= ${what_location}
WHAT_LINE_IDS ?= 1 2
WHAT_NOCMP_LINE_IDS ?= 1
# you can add other WHAT_* just be sure to set WHAT_LINE_IDS
# and WHAT_NOCMP_LINE_IDS accordingly
# this works with clang and gcc
what_t = const char __attribute__ ((section(".data")))
what_location := ${WHAT_LOCATION}
# this script is done in multiple lines so we can
# use the token ${.OODATE:MNO_META_CMP}
# to prevent the variable parts making this constantly out-of-date
${what_uuid}.c:
echo 'extern const char ${WHAT_LINE_IDS:@i@${what_var}_$i[]@:ts,};' > $@
.for i in ${WHAT_LINE_IDS}
.if ${WHAT_NOCMP_LINE_IDS:M$i} != ""
echo '${what_t} ${what_var}_$i[] = "@(#)${WHAT_$i}";' >> $@ ${.OODATE:MNO_META_CMP}
.else
echo '${what_t} ${what_var}_$i[] = "@(#)${WHAT_$i}";' >> $@
.endif
.endfor
.endif
.endif