diff options
author | nia <nia@pkgsrc.org> | 2020-05-24 05:35:51 +0000 |
---|---|---|
committer | nia <nia@pkgsrc.org> | 2020-05-24 05:35:51 +0000 |
commit | 8c218dc01b376e7a560d2b7fcbacca532b75fe4b (patch) | |
tree | 934e95ccea73f17c420a7617a820bc6a2596e583 | |
parent | 41f4d684ea949e703f7e4cdb02fffeb278231228 (diff) | |
download | pkgsrc-8c218dc01b376e7a560d2b7fcbacca532b75fe4b.tar.gz |
Import bmake-BMAKE
156 files changed, 20367 insertions, 2434 deletions
diff --git a/devel/bmake/files/ChangeLog b/devel/bmake/files/ChangeLog index f46e95de9a0..ce56229b00f 100644 --- a/devel/bmake/files/ChangeLog +++ b/devel/bmake/files/ChangeLog @@ -1,3 +1,633 @@ +2020-05-17 Simon J Gerraty <sjg@beast.crufty.net> + + * VERSION (_MAKE_VERSION): 20200517 + Merge with NetBSD make, pick up + o modified dollar tests to avoid shell dependencies + o new tests for .INCLUDEFROM + +2020-05-16 Simon J Gerraty <sjg@beast.crufty.net> + + * unit-tests/dollar.mk: tweak '1 dollar literal' test + to not depend so much on shell behavior + +2020-05-10 Simon J Gerraty <sjg@beast.crufty.net> + + * VERSION (_MAKE_VERSION): 20200510 + Merge with NetBSD make, pick up + o unit test for dollar handling + +2020-05-06 Simon J Gerraty <sjg@beast.crufty.net> + + * VERSION (_MAKE_VERSION): 20200506 + Merge with NetBSD make, pick up + o str.c: empty string does not match % pattern + plus unit-test changes + +2020-05-04 Simon J Gerraty <sjg@beast.crufty.net> + + * VERSION (_MAKE_VERSION): 20200504 + May the 4th be with you + Merge with NetBSD make, pick up + o var.c: import handling of old sysV style modifier using '%' + o str.c: refactor brk_string + o unit-tests: add test case for lazy conditions + +2020-04-18 Simon J Gerraty <sjg@beast.crufty.net> + + * VERSION (_MAKE_VERSION): 20200418 + + * configure.in: use_makefile=no for cygwin et al. + case insensitive filesystems just don't work if both + makefile and Makefile exist. + NOTE: bmake does not support cygwin and likely never will, + but if brave souls want to try it - help them out. + +2020-04-02 Simon J Gerraty <sjg@beast.crufty.net> + + * VERSION (_MAKE_VERSION): 20200402 + Merge with NetBSD make, pick up + o meta.c: meta_oodate, CHECK_VALID_META is too aggressive for CMD + a blank command is perfectly valid. + +2020-03-30 Simon J Gerraty <sjg@beast.crufty.net> + + * VERSION (_MAKE_VERSION): 20200330 + Merge with NetBSD make, pick up + o make.h: extern debug_file + +2020-03-18 Simon J Gerraty <sjg@beast.crufty.net> + + * VERSION (_MAKE_VERSION): 20200318 + Merge with NetBSD make, pick up + o meta.c: meta_oodate, check for corrupted meta file + earlier and more often. + +2020-02-20 Simon J Gerraty <sjg@beast.crufty.net> + + * VERSION (_MAKE_VERSION): 20200220 + +2020-02-19 Simon J Gerraty <sjg@beast.crufty.net> + + * boot-strap: unset MAKEFLAGS + +2020-02-12 Simon J Gerraty <sjg@beast.crufty.net> + + * VERSION (_MAKE_VERSION): 20200212 + * meta.c: meta_compat_parent check for USE_FILEMON + patch from Soeren Tempel + +2020-02-05 Simon J Gerraty <sjg@beast.crufty.net> + + * VERSION: 20200205 + Merge with NetBSD make, pick up + 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 + +2020-01-22 Simon J Gerraty <sjg@beast.crufty.net> + + * VERSION: 20200122 + Merge with NetBSD make, pick up + o meta.c: avoid passing NULL to filemon_*() when meta_needed() + returns FALSE. + +2020-01-21 Simon J Gerraty <sjg@beast.crufty.net> + + * VERSION: 20200121 + Merge with NetBSD make, pick up + 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. + +2019-09-26 Simon J Gerraty <sjg@beast.crufty.net> + + * VERSION: 20190926 + Merge with NetBSD make, pick up + o parse.c: don't pass NULL to realpath(3) + some versions cannot handle it. + +2019-04-09 Simon J Gerraty <sjg@beast.crufty.net> + + * VERSION: 20190409 + Merge with NetBSD make, pick up + o parse.c: ParseDoDependency: free paths rather than assert + +2018-12-22 Simon J Gerraty <sjg@beast.crufty.net> + + * VERSION: 20181222 + + * configure.in: add --without-makefile to avoid generating + makefile and make-bootstrap.sh + + * include Makefile.inc if it exists + + * Use Makefile and Makefile.config.in in unit-tests + so we can use just: make obj && make && make test + when bmake is already available. + We add --without-makefile to CONFIGURE_ARGS in this case. + + * tweak bsd.after-import.mk (captures Makefile.config etc + after import to FreeBSD for example) to cope with all the above. + +2018-12-21 Simon J Gerraty <sjg@beast.crufty.net> + + * VERSION: 20181221 + Merge with NetBSD make, pick up + o parse.c: ParseVErrorInternal use .PARSEDIR + and apply if relative, and then use .PARSEFILE + for consistent result. + +2018-12-20 Simon J Gerraty <sjg@beast.crufty.net> + + * VERSION: 20181220 + Merge with NetBSD make, pick up + o parse.c: ParseVErrorInternal use .CURDIR if .PARSEDIR + is relative + o var.c: avoid SEGFAULT in .unexport-env + when MAKELEVEL is not set + +2018-12-16 Simon J Gerraty <sjg@beast.crufty.net> + + * VERSION: 20181216 + Merge with NetBSD make, pick up + o fix for unit-tests/varquote.mk on Debian + +2018-09-21 Simon J. Gerraty <sjg@bad.crufty.net> + + * VERSION: 20180919 + Merge with NetBSD make, pick up + o var.c: add :q + o dir.c: cleanup caching of stats + +2018-09-21 Simon J Gerraty <sjg@beast.crufty.net> + + * Makefile.config.in: use += where it makes sense. + +2018-05-12 Simon J. Gerraty <sjg@bad.crufty.net> + + * VERSION: 20180512 + Merge with NetBSD make, pick up + o job.c: skip polling job token pipe + +2018-04-05 Simon J. Gerraty <sjg@bad.crufty.net> + + * VERSION: 20180405 + Merge with NetBSD make, pick up + o parse.c: be more cautious about detecting depenency line + rather than sysV style include. + +2018-02-22 Simon J. Gerraty <sjg@bad.crufty.net> + + * VERSION: 20180222 + Merge with NetBSD make, pick up + o parse.c: avoid calling sysconf for every call to loadfile + +2018-02-18 Simon J. Gerraty <sjg@bad.crufty.net> + + * VERSION: 20180218 + Merge with NetBSD make, pick up + o var.c: Var_Set handle NULL value anytime. + +2018-02-12 Simon J. Gerraty <sjg@bad.crufty.net> + + * VERSION: 20180212 + Merge with NetBSD make, pick up + o parse.c: do not treat .info as warning with -W + +2017-12-07 Simon J. Gerraty <sjg@bad.crufty.net> + + * VERSION: 20171207 + Merge with NetBSD make, pick up + o var.c: Var_Append use Var_Set if var not previously set + so that VAR_CMD is handled correctly. + Add a suitable unit-test. + +2017-11-26 Simon J. Gerraty <sjg@bad.crufty.net> + + * VERSION (_MAKE_VERSION): 20171126 + + * aclocal.m4: use AC_LINK_IFELSE for AC_C___ATTRIBUTE__ + since AC_TRY_COMPILE puts input inside main() + which upsets modern compilers. + +2017-11-18 Simon J. Gerraty <sjg@bad.crufty.net> + + * VERSION: 20171118 + Merge with NetBSD make, pick up + o var.c: do not append to variable set on command line + add unit-test to catch this. + +2017-10-28 Simon J. Gerraty <sjg@bad.crufty.net> + + * VERSION: 20171028 + Merge with NetBSD make, pick up + o main.c: ignore empty MAKEOBJDIR + + * Makefile.config.in: + make @prefix@ @machine*@ and @default_sys_path@ defaults. + +2017-10-05 Simon J. Gerraty <sjg@bad.crufty.net> + + * VERSION: 20171005 + + * unit-tests/dotwait.mk: redirect stderr through pipe for more + consistent result on some platforms. + +2017-08-13 Simon J. Gerraty <sjg@bad.crufty.net> + + * machine.sh: entry for AIX + +2017-08-12 Simon J. Gerraty <sjg@bad.crufty.net> + + * VERSION (_MAKE_VERSION): Move the setting of _MAKE_VERSION + to a file that can be included by configure as well as make. + This allows configure to set set _MAKE_VERSION in make-bootstrap.sh + +2017-08-10 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20170810 + Merge with NetBSD make, pick up + o meta.c: if target is in subdir we only need subdir name in + meta_name. + +2017-07-20 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20170720 + Merge with NetBSD make, pick up + o compat.c: pass SIGINT etc onto child and wait for it to exit + before we self-terminate. + +2017-07-11 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20170711 + forgot to update after merge on 20170708 ;-) + o main.c: refactor to reduce size of main function. + add -v option to always fully expand values. + o meta.c: ensure command output in meta file has ending newline + even when filemon not being used. + When matching ${.MAKE.META.IGNORE_PATTERNS} do not use + pathname via ':L' since any ':' in pathname breaks that. + Instead set a '${.p.}' to pathname in the target context and + use that. + +2017-05-10 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20170510 + Merge with NetBSD make, pick up + o main.c: Main_SetObjdir: ensure buf2 is in scope + +2017-05-08 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20170505 + see mk/ChangeLog + +2017-05-05 Simon J. Gerraty <sjg@bad.crufty.net> + + * parse.c: not everyone has stdint.h + +2017-05-01 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20170501 + see mk/ChangeLog + +2017-04-21 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20170421 + Merge with NetBSD make, pick up + o str.c: Str_Match: fix closure tests for [^] and add unit-test. + +2017-04-20 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20170420 + Merge with NetBSD make, pick up + o main.c: only use -C arg "as is" if it contains no + relative component. + +2017-04-18 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20170418 + Merge with NetBSD make, pick up + o main.c: fix Main_SetObjdir() for relative paths (eg obj). + +2017-04-17 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20170417 + Merge with NetBSD make, pick up + o fixes a number of coverity complaints + - check return value of fseek, fcntl + - plug memory leak in Dir_FindFile, Var_LoopExpand, + JobPrintCommand, ParseTraditionalInclude + - use bmake_malloc() where NULL is not tollerated + - use MAKE_ATTR_UNUSED rather that kludges like + return(unused ? 0 : 0) + - use purge_cached_realpaths() rather than abuse cached_realpath() + +2017-04-13 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20170413 + Merge with NetBSD make, pick up + o main.c: when setting .OBJDIR ignore '$' in paths. + + * job.c: use MALLOC_OPTIONS to set malloc_options. + +2017-04-11 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20170411 + Merge with NetBSD make, pick up + o str.c: Str_Match: allow [^a-z] to behave as expected. + +2017-03-26 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20170326 + Merge with NetBSD make, pick up + o main.c: purge relative paths from realpath cache when .OBJDIR + is changed. + +2017-03-11 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20170311 + Merge with NetBSD make, pick up + o main.c: only use -C arg "as is" if it starts with '/'. + +2017-03-01 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20170301 + Merge with NetBSD make, pick up + o main.c: use -C arg "as is" rather than getcwd() + if they identify the same directory. + o parse.c: ensure loadfile buffer is \n terminated in non-mmap case + +2017-02-01 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20170201 + Merge with NetBSD make, pick up + o var.c: allow :_=var and avoid use of special context. + +2017-01-30 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20170130 + Merge with NetBSD make, pick up + o var.c: add :range and :_ + o main.c: partially initialize Dir_* before MainParseArgs() + can be called. + If -V, skip Main_ExportMAKEFLAGS() + +2017-01-14 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20170114 + Merge with NetBSD make, pick up + o var.c: allow specifying the utc value used by :{gm,local}time + +2016-12-12 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20161212 + Merge with NetBSD make, pick up + o main.c: look for obj.${MACHINE}-${MACHINE_ARCH} too. + +2016-12-09 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20161209 + Merge with NetBSD make, pick up + o main.c: cleanup setting of .OBJDIR + o parse.c: avoid coredump from (var)=val + +2016-11-26 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20161126 + Merge with NetBSD make, pick up + o make.c: Make_OODate: report src node name if path not set + +2016-09-26 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20160926 + Merge with NetBSD make, pick up + o support for .DELETE_ON_ERROR: (remove targets that fail) + +2016-09-26 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile MAN: tweak .Dt to match ${PROG} + +2016-08-18 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20160818 + its a neater number; pick up whitespace fixes to man page. + +2016-08-17 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20160817 + Merge with NetBSD make, pick up + o meta.c: move handling of .MAKE.META.IGNORE_* to meta_ignore() + so we can call it before adding entries to missingFiles. + Thus we do not track files we have been told to ignore. + +2016-08-15 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20160815 + Merge with NetBSD make, pick up + o meta_oodate: apply .MAKE.META.IGNORE_FILTER (if defined) to + pathnames, and skip if the expansion is empty. + Useful for dirdeps.mk when checking DIRDEPS_CACHE. + +2016-08-12 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20160812 + Merge with NetBSD make, pick up + o meta.c: remove all missingFiles entries that match a deleted + dir. + o main.c: set .ERROR_CMD if possible. + +2016-06-06 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20160606 + Merge with NetBSD make, pick up + o dir.c: extend mtimes cache to others via cached_stat() + +2016-06-04 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20160604 + Merge with NetBSD make, pick up + o meta.c: missing filemon data is only relevant if we read a + meta file. + Also do not return oodate for a missing metafile if gn->path + points to .CURDIR + +2016-06-02 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20160602 + Merge with NetBSD make, pick up + o cached_realpath(): avoid hitting filesystem more than necessary. + o meta.c: refactor need_meta decision, add knobs for + missing meta file and filemon data wrt out-of-datedness. + +2016-05-28 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20160528 + + * boot-strap, make-bootstrap.sh.in: Makefile now uses _MAKE_VERSION + +2016-05-12 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20160512 + Merge with NetBSD make, pick up + o meta.c: ignore paths that match .MAKE.META.IGNORE_PATTERNS + this is useful for gcov builds. + o propagate errors from filemon(4). + +2016-05-09 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20160509 + Merge with NetBSD make, pick up + o remove use of non-standard types u_int etc. + o meta.c: apply realpath() before matching against metaIgnorePaths + +2016-04-04 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20160404 + Merge with NetBSD make, pick up + o allow makefile to set .MAKE.JOBS + + * Makefile (PROG_NAME): use ${_MAKE_VERSION} + +2016-03-15 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): 20160315 + Merge with NetBSD make, pick up + o fix handling of archive members + +2016-03-13 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (_MAKE_VERSION): rename variable to avoid interference + with checks for ${MAKE_VERSION} + +2016-03-10 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (MAKE_VERSION): 20160310 + Merge with NetBSD make, pick up + o meta.c: treat missing Read file same as Write, incase we Delete it. + +2016-03-07 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (MAKE_VERSION): 20160307 + Merge with NetBSD make, pick up + o var.c: fix :ts\nnn to be octal by default. + o meta.c: meta_finish() to cleanup memory. + +2016-02-26 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (MAKE_VERSION): 20160226 + Merge with NetBSD make, pick up + o meta.c: allow meta file for makeDepend if makefiles want it. + +2016-02-19 Simon J. Gerraty <sjg@bad.crufty.net> + + * var.c: default .MAKE.SAVE_DOLLARS to FALSE + for backwards compatability. + + * Makefile (MAKE_VERSION): 20160220 + Merge with NetBSD make, pick up + o var.c: add knob to control handling of '$$' in := + +2016-02-18 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (MAKE_VERSION): 20160218 + Merge with NetBSD make, pick up + o var.c: add .export-literal allows us to fix sys.clean-env.mk + post the changes to Var_Subst. + Var_Subst now takes flags, and does not consume '$$' in := + +2016-02-17 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (MAKE_VERSION): 20160217 + Merge with NetBSD make, pick up + o var.c: preserve '$$' in := + o parse.c: add .dinclude for handling included + makefile like .depend + +2015-12-20 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (MAKE_VERSION): 20151220 + Merge with NetBSD make, pick up + o suff.c: re-initialize suffNull when clearing suffixes. + +2015-12-01 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (MAKE_VERSION): 20151201 + Merge with NetBSD make, pick up + o cond.c: CondCvtArg: avoid access beyond end of empty buffer. + o meta.c: meta_oodate: use lstat(2) for checking link target + in case it is a symlink. + o var.c: avoid calling brk_string and Var_Export1 with empty + strings. + +2015-11-26 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (MAKE_VERSION): 20151126 + Merge with NetBSD make, pick up + o parse.c: ParseTrackInput don't access beyond + end of old value. + +2015-10-22 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (MAKE_VERSION): 20151022 + + * Add support for BSD/OS which lacks inttypes.h + and really needs sys/param.h for sys/sysctl.h + also 'type' is not a shell builtin. + + * var.c: eliminate uint32_t and need for inttypes.h + + * main.c: PrintOnError flush stdout before run .ERROR + + * parse.c: cope with _SC_PAGESIZE not being defined. + + +2015-10-20 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (MAKE_VERSION): 20151020 + Merge with NetBSD make, pick up + o var.c: fix uninitialized var + +2015-10-12 Simon J. Gerraty <sjg@bad.crufty.net> + + * var.c: the conditional expressions used with ':?' can be + expensive, if already discarding do not evaluate or expand + anything. + +2015-10-10 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (MAKE_VERSION): 20151010 + Merge with NetBSD make, pick up + o Add Boolean wantit flag to Var_Subst and Var_Parse + when FALSE we know we are discarding the result and can + skip operations like Cmd_Exec. + +2015-10-09 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (MAKE_VERSION): 20151009 + Merge with NetBSD make, pick up + o var.c: don't check for NULL before free() + o meta.c: meta_oodate, do not hard code ignore of makeDependfile + +2015-09-10 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (MAKE_VERSION): 20150910 + Merge with NetBSD make, pick up + o main.c: with -w print Enter/Leaving messages for objdir too + if necessary. + o centralize shell metachar handling + + * FILES: add metachar.[ch] + +2015-06-06 Simon J. Gerraty <sjg@bad.crufty.net> + + * Makefile (MAKE_VERSION): 20150606 + Merge with NetBSD make, pick up + o make.1: document .OBJDIR target + 2015-05-05 Simon J. Gerraty <sjg@bad.crufty.net> * Makefile (MAKE_VERSION): 20150505 diff --git a/devel/bmake/files/FILES b/devel/bmake/files/FILES index c46e74bd7a4..5dd4eae97b1 100644 --- a/devel/bmake/files/FILES +++ b/devel/bmake/files/FILES @@ -5,6 +5,7 @@ Makefile.config.in PSD.doc/Makefile PSD.doc/tutorial.ms README +VERSION aclocal.m4 arch.c bmake.1 @@ -21,6 +22,9 @@ configure.in dir.c dir.h dirname.c +filemon/filemon.h +filemon/filemon_dev.c +filemon/filemon_ktrace.c find_lib.sh for.c getopt.c @@ -71,6 +75,8 @@ make_malloc.h makefile.in meta.c meta.h +metachar.c +metachar.h missing/sys/cdefs.h mkdeps.sh nonints.h @@ -91,13 +97,18 @@ suff.c targ.c trace.c trace.h -unit-tests/Makefile.in +unit-tests/Makefile +unit-tests/Makefile.config.in unit-tests/comment.exp unit-tests/comment.mk unit-tests/cond1.exp unit-tests/cond1.mk unit-tests/cond2.exp unit-tests/cond2.mk +unit-tests/cond-late.mk +unit-tests/cond-late.exp +unit-tests/dollar.exp +unit-tests/dollar.mk unit-tests/doterror.exp unit-tests/doterror.mk unit-tests/dotwait.exp @@ -120,6 +131,10 @@ unit-tests/hash.exp unit-tests/hash.mk unit-tests/impsrc.exp unit-tests/impsrc.mk +unit-tests/include-main.exp +unit-tests/include-main.mk +unit-tests/include-sub.mk +unit-tests/include-subsub.mk unit-tests/misc.exp unit-tests/misc.mk unit-tests/moderrs.exp @@ -160,6 +175,10 @@ unit-tests/varcmd.exp unit-tests/varcmd.mk unit-tests/varmisc.exp unit-tests/varmisc.mk +unit-tests/varmod-edge.exp +unit-tests/varmod-edge.mk +unit-tests/varquote.exp +unit-tests/varquote.mk unit-tests/varshell.exp unit-tests/varshell.mk util.c diff --git a/devel/bmake/files/Makefile b/devel/bmake/files/Makefile index d0312fd064d..893dfa19c73 100644 --- a/devel/bmake/files/Makefile +++ b/devel/bmake/files/Makefile @@ -1,7 +1,4 @@ -# $Id: Makefile,v 1.1.1.1 2015/05/19 21:36:43 joerg Exp $ - -# Base version on src date -MAKE_VERSION= 20150505 +# $Id: Makefile,v 1.1.1.2 2020/05/24 05:35:51 nia Exp $ PROG= bmake @@ -18,6 +15,7 @@ SRCS= \ make.c \ make_malloc.c \ meta.c \ + metachar.c \ parse.c \ str.c \ strlist.c \ @@ -57,6 +55,9 @@ SRCS+= \ lstReplace.c \ lstSucc.c +.-include "VERSION" +.-include "Makefile.inc" + # this file gets generated by configure .-include "Makefile.config" @@ -75,13 +76,25 @@ 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}\"" - -# meta mode can be useful even without filemon +COPTS.main.c+= "-DMAKE_VERSION=\"${_MAKE_VERSION}\"" + +# meta mode can be useful even without filemon +# should be set by now +USE_FILEMON ?= no +.if ${USE_FILEMON:tl} != "no" +.PATH: ${.CURDIR}/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.meta.c += -DHAVE_FILEMON_H -I${FILEMON_H:H} +COPTS.filemon_dev.c += -DHAVE_FILEMON_H -I${FILEMON_H:H} .endif +.endif # USE_FILEMON == dev + +.endif # USE_FILEMON .PATH: ${srcdir} .PATH: ${srcdir}/lst.lib @@ -130,9 +143,9 @@ OPTIONS_DEFAULT_NO+= \ .include <own.mk> .if ${MK_PROG_VERSION} == "yes" -PROG_NAME= ${PROG}-${MAKE_VERSION} +PROG_NAME= ${PROG}-${_MAKE_VERSION} .if ${MK_PROG_LINK} == "yes" -SYMLINKS+= ${PROG}-${MAKE_VERSION} ${BINDIR}/${PROG} +SYMLINKS+= ${PROG_NAME} ${BINDIR}/${PROG} .endif .endif @@ -155,7 +168,10 @@ my.history: ${MAKEFILE} .NOPATH: ${MAN} ${MAN}: make.1 my.history @echo making $@ - @sed -e 's/^.Nx/NetBSD/' -e '/^.Nm/s/make/${PROG}/' \ + @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 > $@ @@ -188,11 +204,15 @@ MANDIR= ${MANDIR.bmake:U${SHAREDIR}/man} ${OBJS}: config.h .endif +# start-delete2 for bsd.after-import.mk + # make sure that MAKE_VERSION gets updated. -main.o: ${SRCS} ${MAKEFILE} +main.o: ${SRCS} ${.CURDIR}/VERSION -# start-delete2 for bsd.after-import.mk .if ${MK_AUTOCONF_MK} == "yes" +CONFIGURE_DEPS += ${.CURDIR}/VERSION +# we do not need or want the generated makefile +CONFIGURE_ARGS += --without-makefile .include <autoconf.mk> .endif SHARE_MK?=${SHAREDIR}/mk diff --git a/devel/bmake/files/Makefile.config.in b/devel/bmake/files/Makefile.config.in index 1f9aefe1dfa..38de8f5dd3c 100644 --- a/devel/bmake/files/Makefile.config.in +++ b/devel/bmake/files/Makefile.config.in @@ -1,20 +1,22 @@ # things set by configure -prefix= @prefix@ +_MAKE_VERSION?=@_MAKE_VERSION@ + +prefix?= @prefix@ srcdir= @srcdir@ CC?= @CC@ -MACHINE= @machine@ -MACHINE_ARCH= @machine_arch@ -DEFAULT_SYS_PATH= @default_sys_path@ +MACHINE?= @machine@ +MACHINE_ARCH?= @machine_arch@ +DEFAULT_SYS_PATH?= @default_sys_path@ CPPFLAGS+= @CPPFLAGS@ CFLAGS+= ${CPPFLAGS} @DEFS@ -LDFLAGS= @LDFLAGS@ -LIBOBJS= @LIBOBJS@ -LDADD= @LIBS@ -USE_META= @use_meta@ -FILEMON_H= @filemon_h@ +LDFLAGS+= @LDFLAGS@ +LIBOBJS+= @LIBOBJS@ +LDADD+= @LIBS@ +USE_META?= @use_meta@ +USE_FILEMON?= @use_filemon@ +FILEMON_H?= @filemon_h@ BMAKE_PATH_MAX?= @bmake_path_max@ # used if MAXPATHLEN not defined CPPFLAGS+= -DBMAKE_PATH_MAX=${BMAKE_PATH_MAX} - diff --git a/devel/bmake/files/PSD.doc/tutorial.ms b/devel/bmake/files/PSD.doc/tutorial.ms index ca6c7ff7826..5ab0e61721e 100644 --- a/devel/bmake/files/PSD.doc/tutorial.ms +++ b/devel/bmake/files/PSD.doc/tutorial.ms @@ -1,4 +1,4 @@ -.\" $NetBSD: tutorial.ms,v 1.1.1.4 2015/05/19 21:36:45 joerg Exp $ +.\" $NetBSD: tutorial.ms,v 1.1.1.5 2020/05/24 05:35:53 nia Exp $ .\" Copyright (c) 1988, 1989, 1993 .\" The Regents of the University of California. All rights reserved. .\" @@ -117,6 +117,15 @@ .de No .br .ne 0.5i +.ie n \{\ +.nr g3 \w'NOTE ' +.po -\\n(g3u +.br +NOTE +.br +.po +\\n(g3u +.\} +.el \{\ .po -0.5i .br .mk @@ -148,12 +157,14 @@ .rt .ft \\n(g3 .ps \\n(g4 +.\} .. .de Bp .ie !\\n(.$ .IP \(bu 2 .el .IP "\&" 2 .. -.po +.3i +.ie n .po +\w'NOTE 'u +.el .po +.3i .TL PMake \*- A Tutorial .AU diff --git a/devel/bmake/files/README b/devel/bmake/files/README index d09e977e48b..a782f6dfc5b 100644 --- a/devel/bmake/files/README +++ b/devel/bmake/files/README @@ -1,47 +1,52 @@ bmake + ***** -This directory contains a port of the BSD make tool (from NetBSD) -I have run it on SunOS,Solaris,HP-UX,AIX,IRIX,FreeBSD and Linux. +This directory contains a port of the BSD make tool (from NetBSD). +Since 1993 I have run it on AIX, BSDi, Darwin, FreeBSD, HP-UX, IRIX, +Linux, Minix, OSF, Solaris, SunOS and even UTS. +Others have run it on many more systems. -Version 3 was re-worked from scratch to better facilitate -importing newer make(1) versions from NetBSD. The original code base -was NetBSD-1.0, so version 3 was built by doing a fresh import of the -NetBSD-1.0 usr.bin/make, adding the autoconf and other portability -patches to sync it with bmake v2, and then NetBSD's make -of Feb 20, 2000 was imported and conflicts dealt with. -NetBSD's make was again imported on June 6 and December 15, 2000. +Currently each release is tested on NetBSD, FreeBSD, Solaris and Linux. -In 2003 bmake switched to a date based version (first was 20030714) +Since 2003 bmake switched to a date based version (first was 20030714) which generally represents the date it was last merged with NetBSD's make. Since then, NetBSD's make is imported within a week of any interesting changes, so that bmake tracks it very closely. -Building: +Building +======== -The preferred way to bootstrap bmake is: +The preferred way to bootstrap bmake is:: -./bmake/boot-strap + ./bmake/boot-strap there are a number of args - most of which get passed to configure, eg. +:: -./bmake/boot-strap --prefix=/opt + ./bmake/boot-strap --prefix=/opt see the boot-strap script for details. +For folk that hate to read anything, since 20121212 you can also use +the GNU standard process of:: + + ./configure; make; make install + To make much use of bmake you will need the bsd.*.mk macros or my -portable *.mk macros. See +portable *.mk macros which are included with bmake since 20121212 +and separately available from http://www.crufty.net/ftp/pub/sjg/mk.tar.gz which will be links to the latest versions. -On a non-BSD system, you would want to unpack mk[-YYYYmmdd].tar.gz in -the same directory as bmake (so ./mk and ./bmake exist), and -./bmake/boot-strap will do the rest. +Porting +======= + +If you encounter a system that bmake does not build or work on *out of +the box*, I welcome patches. +If you can provide access to a suitable machine - even better. -If you want to do it all by hand then read boot-strap first to get the -idea. +More info can be found at http://www.crufty.net/help/sjg/bmake.htm -Even if you have an earlier version of bmake installed, use boot-strap -to ensure that all goes well. +--sjg <sjg@crufty.net> ---sjg diff --git a/devel/bmake/files/VERSION b/devel/bmake/files/VERSION new file mode 100644 index 00000000000..e8a5a49202a --- /dev/null +++ b/devel/bmake/files/VERSION @@ -0,0 +1,2 @@ +# keep this compatible with sh and make +_MAKE_VERSION=20200517 diff --git a/devel/bmake/files/aclocal.m4 b/devel/bmake/files/aclocal.m4 index ca977067415..6e75218a24d 100644 --- a/devel/bmake/files/aclocal.m4 +++ b/devel/bmake/files/aclocal.m4 @@ -1,5 +1,5 @@ dnl RCSid: -dnl $Id: aclocal.m4,v 1.1.1.3 2009/09/18 20:55:24 joerg Exp $ +dnl $Id: aclocal.m4,v 1.1.1.4 2020/05/24 05:35:51 nia Exp $ dnl dnl @@ -55,10 +55,9 @@ dnl AC_DEFUN(AC_C___ATTRIBUTE__, [ AC_MSG_CHECKING(for __attribute__) AC_CACHE_VAL(ac_cv___attribute__, [ -AC_TRY_COMPILE([ +AC_LINK_IFELSE([ #include <stdlib.h> -], -[ + static void foo(void) __attribute__ ((noreturn)); static void @@ -66,6 +65,12 @@ foo(void) { exit(1); } + +int +main(int argc, char **argv) +{ + foo(); +} ], ac_cv___attribute__=yes, ac_cv___attribute__=no)]) diff --git a/devel/bmake/files/arch.c b/devel/bmake/files/arch.c index e5321e78f65..6ec99f729c6 100644 --- a/devel/bmake/files/arch.c +++ b/devel/bmake/files/arch.c @@ -1,4 +1,4 @@ -/* $NetBSD: arch.c,v 1.1.1.8 2015/05/19 21:36:43 joerg Exp $ */ +/* $NetBSD: arch.c,v 1.1.1.9 2020/05/24 05:35:51 nia Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: arch.c,v 1.1.1.8 2015/05/19 21:36:43 joerg Exp $"; +static char rcsid[] = "$NetBSD: arch.c,v 1.1.1.9 2020/05/24 05:35:51 nia Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)arch.c 8.2 (Berkeley) 1/2/94"; #else -__RCSID("$NetBSD: arch.c,v 1.1.1.8 2015/05/19 21:36:43 joerg Exp $"); +__RCSID("$NetBSD: arch.c,v 1.1.1.9 2020/05/24 05:35:51 nia Exp $"); #endif #endif /* not lint */ #endif @@ -136,7 +136,6 @@ __RCSID("$NetBSD: arch.c,v 1.1.1.8 2015/05/19 21:36:43 joerg Exp $"); #include <sys/stat.h> #include <sys/time.h> #include <sys/param.h> -#include <ctype.h> #ifdef HAVE_AR_H #include <ar.h> #else @@ -156,7 +155,6 @@ struct ar_hdr { #if defined(HAVE_RANLIB_H) && !(defined(__ELF__) || defined(NO_RANLIB)) #include <ranlib.h> #endif -#include <fcntl.h> #include <stdio.h> #include <stdlib.h> #ifdef HAVE_UTIME_H @@ -254,8 +252,7 @@ ArchFree(void *ap) free(Hash_GetValue(entry)); free(a->name); - if (a->fnametab) - free(a->fnametab); + free(a->fnametab); Hash_DeleteTable(&a->members); free(a); } @@ -310,9 +307,10 @@ Arch_ParseArchive(char **linePtr, Lst nodeLst, GNode *ctxt) void *freeIt; char *result; - result = Var_Parse(cp, ctxt, TRUE, &length, &freeIt); - if (freeIt) - free(freeIt); + result = Var_Parse(cp, ctxt, VARF_UNDEFERR|VARF_WANTRES, + &length, &freeIt); + free(freeIt); + if (result == var_Error) { return(FAILURE); } else { @@ -325,7 +323,7 @@ Arch_ParseArchive(char **linePtr, Lst nodeLst, GNode *ctxt) *cp++ = '\0'; if (subLibName) { - libName = Var_Subst(NULL, libName, ctxt, TRUE); + libName = Var_Subst(NULL, libName, ctxt, VARF_UNDEFERR|VARF_WANTRES); } @@ -351,9 +349,10 @@ Arch_ParseArchive(char **linePtr, Lst nodeLst, GNode *ctxt) void *freeIt; char *result; - result = Var_Parse(cp, ctxt, TRUE, &length, &freeIt); - if (freeIt) - free(freeIt); + result = Var_Parse(cp, ctxt, VARF_UNDEFERR|VARF_WANTRES, + &length, &freeIt); + free(freeIt); + if (result == var_Error) { return(FAILURE); } else { @@ -404,7 +403,8 @@ Arch_ParseArchive(char **linePtr, Lst nodeLst, GNode *ctxt) char *oldMemName = memName; size_t sz; - memName = Var_Subst(NULL, memName, ctxt, TRUE); + memName = Var_Subst(NULL, memName, ctxt, + VARF_UNDEFERR|VARF_WANTRES); /* * Now form an archive spec and recurse to deal with nested @@ -682,7 +682,7 @@ ArchStatMember(char *archive, char *member, Boolean hash) arh.AR_SIZE[sizeof(arh.AR_SIZE)-1] = '\0'; size = (int)strtol(arh.AR_SIZE, NULL, 10); - (void)strncpy(memName, arh.AR_NAME, sizeof(arh.AR_NAME)); + memcpy(memName, arh.AR_NAME, sizeof(arh.AR_NAME)); for (cp = &memName[AR_MAX_NAME_LEN]; *cp == ' '; cp--) { continue; } @@ -726,7 +726,8 @@ ArchStatMember(char *archive, char *member, Boolean hash) if (fread(memName, elen, 1, arch) != 1) goto badarch; memName[elen] = '\0'; - fseek(arch, -elen, SEEK_CUR); + if (fseek(arch, -elen, SEEK_CUR) != 0) + goto badarch; if (DEBUG(ARCH) || DEBUG(MAKE)) { fprintf(debug_file, "ArchStat: Extended format entry for %s\n", memName); } @@ -737,7 +738,8 @@ ArchStatMember(char *archive, char *member, Boolean hash) Hash_SetValue(he, bmake_malloc(sizeof(struct ar_hdr))); memcpy(Hash_GetValue(he), &arh, sizeof(struct ar_hdr)); } - fseek(arch, (size + 1) & ~1, SEEK_CUR); + if (fseek(arch, (size + 1) & ~1, SEEK_CUR) != 0) + goto badarch; } fclose(arch); @@ -759,8 +761,7 @@ ArchStatMember(char *archive, char *member, Boolean hash) badarch: fclose(arch); Hash_DeleteTable(&ar->members); - if (ar->fnametab) - free(ar->fnametab); + free(ar->fnametab); free(ar); return NULL; } @@ -833,7 +834,7 @@ ArchSVR4Entry(Arch *ar, char *name, size_t size, FILE *arch) } if (DEBUG(ARCH)) { fprintf(debug_file, "Found svr4 archive name table with %lu entries\n", - (u_long)entry); + (unsigned long)entry); } return 0; } @@ -851,7 +852,7 @@ ArchSVR4Entry(Arch *ar, char *name, size_t size, FILE *arch) if (entry >= ar->fnamesize) { if (DEBUG(ARCH)) { fprintf(debug_file, "SVR4 entry offset %s is greater than %lu\n", - name, (u_long)ar->fnamesize); + name, (unsigned long)ar->fnamesize); } return 2; } @@ -957,7 +958,10 @@ ArchFindMember(char *archive, char *member, struct ar_hdr *arhPtr, * the file at the actual member, rather than its header, but * not here... */ - fseek(arch, -sizeof(struct ar_hdr), SEEK_CUR); + if (fseek(arch, -sizeof(struct ar_hdr), SEEK_CUR) != 0) { + fclose(arch); + return NULL; + } return (arch); } } else @@ -987,10 +991,17 @@ ArchFindMember(char *archive, char *member, struct ar_hdr *arhPtr, } if (strncmp(ename, member, len) == 0) { /* Found as extended name */ - fseek(arch, -sizeof(struct ar_hdr) - elen, SEEK_CUR); + if (fseek(arch, -sizeof(struct ar_hdr) - elen, + SEEK_CUR) != 0) { + fclose(arch); + return NULL; + } return (arch); } - fseek(arch, -elen, SEEK_CUR); + if (fseek(arch, -elen, SEEK_CUR) != 0) { + fclose(arch); + return NULL; + } goto skip; } else #endif @@ -1003,9 +1014,12 @@ skip: * extract the size of the file from the 'size' field of the * header and round it up during the seek. */ - arhPtr->ar_size[sizeof(arhPtr->AR_SIZE)-1] = '\0'; + arhPtr->AR_SIZE[sizeof(arhPtr->AR_SIZE)-1] = '\0'; size = (int)strtol(arhPtr->AR_SIZE, NULL, 10); - fseek(arch, (size + 1) & ~1, SEEK_CUR); + if (fseek(arch, (size + 1) & ~1, SEEK_CUR) != 0) { + fclose(arch); + return NULL; + } } } @@ -1045,10 +1059,10 @@ Arch_Touch(GNode *gn) arch = ArchFindMember(Var_Value(ARCHIVE, gn, &p1), Var_Value(MEMBER, gn, &p2), &arh, "r+"); - if (p1) - free(p1); - if (p2) - free(p2); + + free(p1); + free(p2); + snprintf(arh.AR_DATE, sizeof(arh.AR_DATE), "%-12ld", (long) now); if (arch != NULL) { @@ -1127,10 +1141,9 @@ Arch_MTime(GNode *gn) arhPtr = ArchStatMember(Var_Value(ARCHIVE, gn, &p1), Var_Value(MEMBER, gn, &p2), TRUE); - if (p1) - free(p1); - if (p2) - free(p2); + + free(p1); + free(p2); if (arhPtr != NULL) { modTime = (time_t)strtol(arhPtr->AR_DATE, NULL, 10); diff --git a/devel/bmake/files/bmake.1 b/devel/bmake/files/bmake.1 index 85e8493fb77..9f3ac27c5c1 100644 --- a/devel/bmake/files/bmake.1 +++ b/devel/bmake/files/bmake.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: bmake.1,v 1.1.1.5 2015/05/19 21:36:43 joerg Exp $ +.\" $NetBSD: bmake.1,v 1.1.1.6 2020/05/24 05:35:51 nia Exp $ .\" .\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,8 +29,8 @@ .\" .\" from: @(#)make.1 8.4 (Berkeley) 3/19/94 .\" -.Dd April 9, 2015 -.Dt MAKE 1 +.Dd May 26, 2018 +.Dt BMAKE 1 .Os .Sh NAME .Nm bmake @@ -48,6 +48,7 @@ .Op Fl m Ar directory .Op Fl T Ar file .Op Fl V Ar variable +.Op Fl v Ar variable .Op Ar variable=value .Op Ar target ... .Sh DESCRIPTION @@ -206,7 +207,9 @@ Print debugging information about target list maintenance. .It Ar V Force the .Fl V -option to print raw values of variables. +option to print raw values of variables, overriding the default behavior +set via +.Va .MAKE.EXPAND_VARIABLES . .It Ar v Print debugging information about variable assignment. .It Ar x @@ -293,7 +296,7 @@ then will search for the specified file or directory named in the remaining part of the argument string. The search starts with the current directory of -the Makefile and then works upward towards the root of the filesystem. +the Makefile and then works upward towards the root of the file system. If the search is successful, then the resulting directory replaces the .Qq \&.../ specification in the @@ -334,20 +337,39 @@ for each job started and completed. Rather than re-building a target as specified in the makefile, create it or update its modification time to make it appear up-to-date. .It Fl V Ar variable -Print -.Nm Ns 's -idea of the value of -.Ar variable , -in the global context. +Print the value of +.Ar variable . Do not build any targets. Multiple instances of this option may be specified; the variables will be printed one per line, with a blank line for each null or undefined variable. +The value printed is extracted from the global context after all +makefiles have been read. +By default, the raw variable contents (which may +include additional unexpanded variable references) are shown. If .Ar variable contains a .Ql \&$ -then the value will be expanded before printing. +then the value will be recursively expanded to its complete resultant +text before printing. +The expanded value will also be printed if +.Va .MAKE.EXPAND_VARIABLES +is set to true and +the +.Fl dV +option has not been used to override it. +Note that loop-local and target-local variables, as well as values +taken temporarily by global variables during makefile processing, are +not accessible via this option. +The +.Fl dv +debug mode can be used to see these at the cost of generating +substantial extraneous output. +.It Fl v Ar variable +Like +.Fl V +but the variable is always expanded to its complete value. .It Fl W Treat any warnings during makefile parsing as errors. .It Fl w @@ -657,7 +679,7 @@ The seven local variables are as follows: .Bl -tag -width ".ARCHIVE" -offset indent .It Va .ALLSRC The list of all sources for this target; also known as -.Ql Va \&\*[Gt] . +.Ql Va \&> . .It Va .ARCHIVE The name of the archive file; also known as .Ql Va \&! . @@ -666,7 +688,7 @@ In suffix-transformation rules, the name/path of the source from which the target is to be transformed (the .Dq implied source); also known as -.Ql Va \&\*[Lt] . +.Ql Va \&< . It is not defined in explicit rules. .It Va .MEMBER The name of the archive member; also known as @@ -685,12 +707,15 @@ or it will not be recognized. .It Va .TARGET The name of the target; also known as .Ql Va @ . +For compatibility with other makes this is an alias for +.Ic .ARCHIVE +in archive member rules. .El .Pp The shorter forms -.Ql ( Va \*[Gt] , +.Ql ( Va > , .Ql Va \&! , -.Ql Va \*[Lt] , +.Ql Va < , .Ql Va % , .Ql Va \&? , .Ql Va * , @@ -773,6 +798,10 @@ from which generated dependencies are read. A boolean that controls the default behavior of the .Fl V option. +If true, variable values printed with +.Fl V +are fully expanded; if false, the raw variable contents (which may +include additional unexpanded variable references) are shown. .It Va .MAKE.EXPORTED The list of variables exported by .Nm . @@ -843,7 +872,7 @@ Can affect the mode that .Nm runs in. It can contain a number of keywords: -.Bl -hang -width ignore-cmd +.Bl -hang -width missing-filemon=bf. .It Pa compat Like .Fl B , @@ -867,8 +896,19 @@ will not create .meta files in This can be overridden by setting .Va bf to a value which represents True. +.It Pa missing-meta= Ar bf +If +.Va bf +is True, then a missing .meta file makes the target out-of-date. +.It Pa missing-filemon= Ar bf +If +.Va bf +is True, then missing filemon data makes the target out-of-date. +.It Pa nofilemon +Do not use +.Xr filemon 4 . .It Pa env -For debugging, it can be useful to inlcude the environment +For debugging, it can be useful to include the environment in the .meta file. .It Pa verbose If in "meta" mode, print a clue about the target being built. @@ -910,6 +950,12 @@ Provides a list of path prefixes that should be ignored; because the contents are expected to change over time. The default list includes: .Ql Pa /dev /etc /proc /tmp /var/run /var/tmp +.It Va .MAKE.META.IGNORE_PATTERNS +Provides a list of patterns to match against pathnames. +Ignore any that match. +.It Va .MAKE.META.IGNORE_FILTER +Provides a list of variable modifiers to apply to each pathname. +Ignore if the expansion is an empty string. .It Va .MAKE.META.PREFIX Defines the message printed for each meta file updated in "meta verbose" mode. The default value is: @@ -918,7 +964,7 @@ The default value is: This variable is used to record the names of variables assigned to on the command line, so that they may be exported as part of .Ql Ev MAKEFLAGS . -This behaviour can be disabled by assigning an empty value to +This behavior can be disabled by assigning an empty value to .Ql Va .MAKEOVERRIDES within a makefile. Extra variables can be exported from a makefile @@ -941,10 +987,35 @@ The process-id of .It Va .MAKE.PPID The parent process-id of .Nm . +.It Va .MAKE.SAVE_DOLLARS +value should be a boolean that controls whether +.Ql $$ +are preserved when doing +.Ql := +assignments. +The default is false, for backwards compatibility. +Set to true for compatability with other makes. +If set to false, +.Ql $$ +becomes +.Ql $ +per normal evaluation rules. .It Va MAKE_PRINT_VAR_ON_ERROR When .Nm -stops due to an error, it prints its name and the value of +stops due to an error, it sets +.Ql Va .ERROR_TARGET +to the name of the target that failed, +.Ql Va .ERROR_CMD +to the commands of the failed target, +and in "meta" mode, it also sets +.Ql Va .ERROR_CWD +to the +.Xr getcwd 3 , +and +.Ql Va .ERROR_META_FILE +to the path of the meta file (if any) describing the failed target. +It then prints its name and the value of .Ql Va .CURDIR as well as the value of any variables named in .Ql Va MAKE_PRINT_VAR_ON_ERROR . @@ -993,14 +1064,15 @@ This is especially useful with .Ql Ev MAKEOBJDIR . .Pp .Ql Va .OBJDIR -may be modified in the makefile as a global variable. +may be modified in the makefile via the special target +.Ql Ic .OBJDIR . In all cases, .Nm will .Xr chdir 2 -to +to the specified directory if it exists, and set .Ql Va .OBJDIR -and set +and .Ql Ev PWD to that directory before executing any targets. . @@ -1043,7 +1115,7 @@ sets to the value of .Ql Ev PWD instead. -This behaviour is disabled if +This behavior is disabled if .Ql Ev MAKEOBJDIRPREFIX is set or .Ql Ev MAKEOBJDIR @@ -1113,7 +1185,7 @@ The wildcard characters may be escaped with a backslash As a consequence of the way values are split into words, matched, and then joined, a construct like .Dl ${VAR:M*} -will normalise the inter-word spacing, removing all leading and +will normalize the inter-word spacing, removing all leading and trailing space, and converting multiple consecutive spaces to single spaces. . @@ -1133,7 +1205,7 @@ Randomize words in variable. The results will be different each time you are referring to the modified variable; use the assignment with expansion .Pq Ql Cm \&:= -to prevent such behaviour. +to prevent such behavior. For example, .Bd -literal -offset indent LIST= uno due tre quattro @@ -1155,22 +1227,39 @@ due uno quattro tre .Ed .It Cm \&:Q Quotes every shell meta-character in the variable, so that it can be passed +safely to the shell. +.It Cm \&:q +Quotes every shell meta-character in the variable, and also doubles +.Sq $ +characters so that it can be passed safely through recursive invocations of .Nm . +This is equivalent to: +.Sq \&:S/\e\&$/&&/g:Q . .It Cm \&:R Replaces each word in the variable with everything but its suffix. -.It Cm \&:gmtime +.It Cm \&:range[=count] +The value is an integer sequence representing the words of the original +value, or the supplied +.Va count . +.It Cm \&:gmtime[=utc] The value is a format string for .Xr strftime 3 , -using the current +using .Xr gmtime 3 . +If a +.Va utc +value is not provided or is 0, the current time is used. .It Cm \&:hash -Compute a 32bit hash of the value and encode it as hex digits. -.It Cm \&:localtime +Compute a 32-bit hash of the value and encode it as hex digits. +.It Cm \&:localtime[=utc] The value is a format string for .Xr strftime 3 , -using the current +using .Xr localtime 3 . +If a +.Va utc +value is not provided or is 0, the current time is used. .It Cm \&:tA Attempt to convert variable to an absolute path using .Xr realpath 3 , @@ -1231,7 +1320,7 @@ it is anchored at the end of each word. Inside .Ar new_string , an ampersand -.Pq Ql \*[Am] +.Pq Ql & is replaced by .Ar old_string (without any @@ -1370,6 +1459,27 @@ For example. .Pp However a single character variable is often more readable: .Dl ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@} +.It Cm \&:_[=var] +Save the current variable value in +.Ql $_ +or the named +.Va var +for later reference. +Example usage: +.Bd -literal -offset indent +M_cmpv.units = 1 1000 1000000 +M_cmpv = S,., ,g:_:range:@i@+ $${_:[-$$i]} \&\\ +\\* $${M_cmpv.units:[$$i]}@:S,^,expr 0 ,1:sh + +.Dv .if ${VERSION:${M_cmpv}} < ${3.1.12:L:${M_cmpv}} + +.Ed +Here +.Ql $_ +is used to save the result of the +.Ql :S +modifier which is later referenced using the index values from +.Ql :range . .It Cm \&:U Ns Ar newval If the variable is undefined .Ar newval @@ -1443,7 +1553,7 @@ value is divided into words. .Pp Ordinarily, a value is treated as a sequence of words delimited by white space. -Some modifiers suppress this behaviour, +Some modifiers suppress this behavior, causing a value to be treated as a single word (possibly containing embedded white space). An empty value, or a value that consists entirely of white-space, @@ -1529,12 +1639,20 @@ For compatibility with other versions of .Nm .Ql include file ... is also accepted. +.Pp If the include statement is written as .Cm .-include or as .Cm .sinclude then errors locating and/or opening include files are ignored. .Pp +If the include statement is written as +.Cm .dinclude +not only are errors locating and/or opening include files ignored, +but stale dependencies within the included file will be ignored +just like +.Va .MAKE.DEPENDFILE . +.Pp Conditional expressions are also preceded by a single dot as the first character of a line. The possible conditionals are as follows: @@ -1570,6 +1688,10 @@ This allows exporting a value to the environment which is different from that used by .Nm internally. +.It Ic .export-literal Ar variable ... +The same as +.Ql .export-env , +except that variables in the value are not expanded. .It Ic .info Ar message The message is printed along with the name of the makefile and line number. .It Ic .undef Ar variable @@ -1662,7 +1784,7 @@ may be any one of the following: .Bl -tag -width "Cm XX" .It Cm \&|\&| Logical OR. -.It Cm \&\*[Am]\*[Am] +.It Cm \&&& Logical .Tn AND ; of higher precedence than @@ -1679,7 +1801,7 @@ The boolean operator may be used to logically negate an entire conditional. It is of higher precedence than -.Ql Ic \&\*[Am]\*[Am] . +.Ql Ic \&&& . .Pp The value of .Ar expression @@ -1750,7 +1872,8 @@ expression is applied. Similarly, if the form is .Ql Ic .ifmake or -.Ql Ic .ifnmake , the +.Ql Ic .ifnmake , +the .Dq make expression is applied. .Pp @@ -1953,6 +2076,14 @@ variable of a target that inherits .Ic .DEFAULT Ns 's commands is set to the target's own name. +.It Ic .DELETE_ON_ERROR +If this target is present in the makefile, it globally causes make to +delete targets whose commands fail. +(By default, only targets whose commands are interrupted during +execution are deleted. +This is the historical behavior.) +This setting can be used to help prevent half-finished or malformed +targets from being left around and corrupting future rebuilds. .It Ic .END Any command lines attached to this target are executed after everything else is done. @@ -2001,6 +2132,15 @@ Disable parallel mode. Synonym for .Ic .NOTPARALLEL , for compatibility with other pmake variants. +.It Ic .OBJDIR +The source is a new value for +.Ql Va .OBJDIR . +If it exists, +.Nm +will +.Xr chdir 2 +to it and update the value of +.Ql Va .OBJDIR . .It Ic .ORDER The named targets are made in sequence. This ordering does not add targets to the list of targets to be made. @@ -2058,7 +2198,7 @@ The sources are a set of pairs. .Bl -tag -width hasErrCtls .It Ar name -This is the minimal specification, used to select one of the builtin +This is the minimal specification, used to select one of the built-in shell specs; .Ar sh , .Ar ksh , diff --git a/devel/bmake/files/bmake.cat1 b/devel/bmake/files/bmake.cat1 index 5c62c1ba8e4..4f1893db18c 100644 --- a/devel/bmake/files/bmake.cat1 +++ b/devel/bmake/files/bmake.cat1 @@ -1,73 +1,73 @@ -MAKE(1) NetBSD General Commands Manual MAKE(1) +BMAKE(1) FreeBSD General Commands Manual BMAKE(1) -NNAAMMEE - bbmmaakkee -- maintain program dependencies +[1mNAME[0m + [1mbmake [22m-- maintain program dependencies -SSYYNNOOPPSSIISS - bbmmaakkee [--BBeeiikkNNnnqqrrssttWWwwXX] [--CC _d_i_r_e_c_t_o_r_y] [--DD _v_a_r_i_a_b_l_e] [--dd _f_l_a_g_s] - [--ff _m_a_k_e_f_i_l_e] [--II _d_i_r_e_c_t_o_r_y] [--JJ _p_r_i_v_a_t_e] [--jj _m_a_x___j_o_b_s] - [--mm _d_i_r_e_c_t_o_r_y] [--TT _f_i_l_e] [--VV _v_a_r_i_a_b_l_e] [_v_a_r_i_a_b_l_e_=_v_a_l_u_e] - [_t_a_r_g_e_t _._._.] +[1mSYNOPSIS[0m + [1mbmake [22m[[1m-BeikNnqrstWwX[22m] [[1m-C [4m[22mdirectory[24m] [[1m-D [4m[22mvariable[24m] [[1m-d [4m[22mflags[24m] + [[1m-f [4m[22mmakefile[24m] [[1m-I [4m[22mdirectory[24m] [[1m-J [4m[22mprivate[24m] [[1m-j [4m[22mmax_jobs[24m] + [[1m-m [4m[22mdirectory[24m] [[1m-T [4m[22mfile[24m] [[1m-V [4m[22mvariable[24m] [[1m-v [4m[22mvariable[24m] + [[4mvariable=value[24m] [[4mtarget[24m [4m...[24m] -DDEESSCCRRIIPPTTIIOONN - bbmmaakkee is a program designed to simplify the maintenance of other pro- +[1mDESCRIPTION[0m + [1mbmake [22mis a program designed to simplify the maintenance of other pro- grams. Its input is a list of specifications as to the files upon which - programs and other files depend. If no --ff _m_a_k_e_f_i_l_e makefile option is - given, bbmmaakkee will try to open `_m_a_k_e_f_i_l_e' then `_M_a_k_e_f_i_l_e' in order to find - the specifications. If the file `_._d_e_p_e_n_d' exists, it is read (see + programs and other files depend. If no [1m-f [4m[22mmakefile[24m makefile option is + given, [1mbmake [22mwill try to open `[4mmakefile[24m' then `[4mMakefile[24m' in order to find + the specifications. If the file `[4m.depend[24m' exists, it is read (see mkdep(1)). This manual page is intended as a reference document only. For a more - thorough description of bbmmaakkee and makefiles, please refer to _P_M_a_k_e _- _A - _T_u_t_o_r_i_a_l. + thorough description of [1mbmake [22mand makefiles, please refer to [4mPMake[24m [4m-[24m [4mA[0m + [4mTutorial[24m. - bbmmaakkee will prepend the contents of the _M_A_K_E_F_L_A_G_S environment variable to + [1mbmake [22mwill prepend the contents of the [4mMAKEFLAGS[24m environment variable to the command line arguments before parsing them. The options are as follows: - --BB Try to be backwards compatible by executing a single shell per + [1m-B [22mTry to be backwards compatible by executing a single shell per command and by executing the commands to make the sources of a dependency line in sequence. - --CC _d_i_r_e_c_t_o_r_y - Change to _d_i_r_e_c_t_o_r_y before reading the makefiles or doing any- - thing else. If multiple --CC options are specified, each is inter- - preted relative to the previous one: --CC _/ --CC _e_t_c is equivalent to - --CC _/_e_t_c. + [1m-C [4m[22mdirectory[0m + Change to [4mdirectory[24m before reading the makefiles or doing any- + thing else. If multiple [1m-C [22moptions are specified, each is inter- + preted relative to the previous one: [1m-C [4m[22m/[24m [1m-C [4m[22metc[24m is equivalent to + [1m-C [4m[22m/etc[24m. - --DD _v_a_r_i_a_b_l_e - Define _v_a_r_i_a_b_l_e to be 1, in the global context. + [1m-D [4m[22mvariable[0m + Define [4mvariable[24m to be 1, in the global context. - --dd _[_-_]_f_l_a_g_s - Turn on debugging, and specify which portions of bbmmaakkee are to + [1m-d [4m[22m[-]flags[0m + Turn on debugging, and specify which portions of [1mbmake [22mare to print debugging information. Unless the flags are preceded by - `-' they are added to the _M_A_K_E_F_L_A_G_S environment variable and will + `-' they are added to the [4mMAKEFLAGS[24m environment variable and will be processed by any child make processes. By default, debugging information is printed to standard error, but this can be changed - using the _F debugging flag. The debugging output is always + using the [4mF[24m debugging flag. The debugging output is always unbuffered; in addition, if debugging is enabled but debugging output is not directed to standard output, then the standard out- - put is line buffered. _F_l_a_g_s is one or more of the following: + put is line buffered. [4mFlags[24m is one or more of the following: - _A Print all possible debugging information; equivalent to + [4mA[24m Print all possible debugging information; equivalent to specifying all of the debugging flags. - _a Print debugging information about archive searching and + [4ma[24m Print debugging information about archive searching and caching. - _C Print debugging information about current working direc- + [4mC[24m Print debugging information about current working direc- tory. - _c Print debugging information about conditional evaluation. + [4mc[24m Print debugging information about conditional evaluation. - _d Print debugging information about directory searching and + [4md[24m Print debugging information about directory searching and caching. - _e Print debugging information about failed commands and + [4me[24m Print debugging information about failed commands and targets. - _F[++]_f_i_l_e_n_a_m_e + [4mF[24m[[1m+[22m][4mfilename[0m Specify where debugging output is written. This must be the last flag, because it consumes the remainder of the argument. If the character immediately after the `F' @@ -80,78 +80,80 @@ DDEESSCCRRIIPPTTIIOONN named file. If the file name ends `.%d' then the `%d' is replaced by the pid. - _f Print debugging information about loop evaluation. + [4mf[24m Print debugging information about loop evaluation. - _g_1 Print the input graph before making anything. + [4mg1[24m Print the input graph before making anything. - _g_2 Print the input graph after making everything, or before + [4mg2[24m Print the input graph after making everything, or before exiting on error. - _g_3 Print the input graph before exiting on error. + [4mg3[24m Print the input graph before exiting on error. - _j Print debugging information about running multiple + [4mj[24m Print debugging information about running multiple shells. - _l Print commands in Makefiles regardless of whether or not + [4ml[24m Print commands in Makefiles regardless of whether or not they are prefixed by `@' or other "quiet" flags. Also known as "loud" behavior. - _M Print debugging information about "meta" mode decisions + [4mM[24m Print debugging information about "meta" mode decisions about targets. - _m Print debugging information about making targets, includ- + [4mm[24m Print debugging information about making targets, includ- ing modification dates. - _n Don't delete the temporary command scripts created when + [4mn[24m Don't delete the temporary command scripts created when running commands. These temporary scripts are created in the directory referred to by the TMPDIR environment vari- - able, or in _/_t_m_p if TMPDIR is unset or set to the empty + able, or in [4m/tmp[24m if TMPDIR is unset or set to the empty string. The temporary scripts are created by mkstemp(3), - and have names of the form _m_a_k_e_X_X_X_X_X_X. _N_O_T_E: This can - create many files in TMPDIR or _/_t_m_p, so use with care. + and have names of the form [4mmakeXXXXXX[24m. [4mNOTE[24m: This can + create many files in TMPDIR or [4m/tmp[24m, so use with care. - _p Print debugging information about makefile parsing. + [4mp[24m Print debugging information about makefile parsing. - _s Print debugging information about suffix-transformation + [4ms[24m Print debugging information about suffix-transformation rules. - _t Print debugging information about target list mainte- + [4mt[24m Print debugging information about target list mainte- nance. - _V Force the --VV option to print raw values of variables. + [4mV[24m Force the [1m-V [22moption to print raw values of variables, + overriding the default behavior set via + [4m.MAKE.EXPAND_VARIABLES[24m. - _v Print debugging information about variable assignment. + [4mv[24m Print debugging information about variable assignment. - _x Run shell commands with --xx so the actual commands are + [4mx[24m Run shell commands with [1m-x [22mso the actual commands are printed as they are executed. - --ee Specify that environment variables override macro assignments + [1m-e [22mSpecify that environment variables override macro assignments within makefiles. - --ff _m_a_k_e_f_i_l_e - Specify a makefile to read instead of the default `_m_a_k_e_f_i_l_e'. If - _m_a_k_e_f_i_l_e is `--', standard input is read. Multiple makefiles may + [1m-f [4m[22mmakefile[0m + Specify a makefile to read instead of the default `[4mmakefile[24m'. If + [4mmakefile[24m is `[1m-[22m', standard input is read. Multiple makefiles may be specified, and are read in the order specified. - --II _d_i_r_e_c_t_o_r_y + [1m-I [4m[22mdirectory[0m Specify a directory in which to search for makefiles and included makefiles. The system makefile directory (or directories, see - the --mm option) is automatically included as part of this list. + the [1m-m [22moption) is automatically included as part of this list. - --ii Ignore non-zero exit of shell commands in the makefile. Equiva- - lent to specifying `--' before each command line in the makefile. + [1m-i [22mIgnore non-zero exit of shell commands in the makefile. Equiva- + lent to specifying `[1m-[22m' before each command line in the makefile. - --JJ _p_r_i_v_a_t_e - This option should _n_o_t be specified by the user. + [1m-J [4m[22mprivate[0m + This option should [4mnot[24m be specified by the user. - When the _j option is in use in a recursive build, this option is + When the [4mj[24m option is in use in a recursive build, this option is passed by a make to child makes to allow all the make processes in the build to cooperate to avoid overloading the system. - --jj _m_a_x___j_o_b_s - Specify the maximum number of jobs that bbmmaakkee may have running at - any one time. The value is saved in _._M_A_K_E_._J_O_B_S. Turns compati- - bility mode off, unless the _B flag is also specified. When com- + [1m-j [4m[22mmax_jobs[0m + Specify the maximum number of jobs that [1mbmake [22mmay have running at + any one time. The value is saved in [4m.MAKE.JOBS[24m. Turns compati- + bility mode off, unless the [4mB[24m flag is also specified. When com- patibility mode is off, all commands associated with a target are executed in a single shell invocation as opposed to the tradi- tional one shell invocation per line. This can break traditional @@ -160,77 +162,90 @@ DDEESSCCRRIIPPTTIIOONN It is more efficient to correct the scripts rather than turn backwards compatibility on. - --kk Continue processing after errors are encountered, but only on + [1m-k [22mContinue processing after errors are encountered, but only on those targets that do not depend on the target whose creation caused the error. - --mm _d_i_r_e_c_t_o_r_y + [1m-m [4m[22mdirectory[0m Specify a directory in which to search for sys.mk and makefiles - included via the <_f_i_l_e>-style include statement. The --mm option + included via the <[4mfile[24m>-style include statement. The [1m-m [22moption can be used multiple times to form a search path. This path will override the default system include path: /usr/share/mk. Fur- thermore the system include path will be appended to the search - path used for "_f_i_l_e"-style include statements (see the --II + path used for "[4mfile[24m"-style include statements (see the [1m-I[0m option). - If a file or directory name in the --mm argument (or the + If a file or directory name in the [1m-m [22margument (or the MAKESYSPATH environment variable) starts with the string ".../" - then bbmmaakkee will search for the specified file or directory named + then [1mbmake [22mwill search for the specified file or directory named in the remaining part of the argument string. The search starts with the current directory of the Makefile and then works upward - towards the root of the filesystem. If the search is successful, - then the resulting directory replaces the ".../" specification in - the --mm argument. If used, this feature allows bbmmaakkee to easily - search in the current source tree for customized sys.mk files - (e.g., by using ".../mk/sys.mk" as an argument). + towards the root of the file system. If the search is success- + ful, then the resulting directory replaces the ".../" specifica- + tion in the [1m-m [22margument. If used, this feature allows [1mbmake [22mto + easily search in the current source tree for customized sys.mk + files (e.g., by using ".../mk/sys.mk" as an argument). - --nn Display the commands that would have been executed, but do not + [1m-n [22mDisplay the commands that would have been executed, but do not actually execute them unless the target depends on the .MAKE spe- cial source (see below). - --NN Display the commands which would have been executed, but do not + [1m-N [22mDisplay the commands which would have been executed, but do not actually execute any of them; useful for debugging top-level makefiles without descending into subdirectories. - --qq Do not execute any commands, but exit 0 if the specified targets + [1m-q [22mDo not execute any commands, but exit 0 if the specified targets are up-to-date and 1, otherwise. - --rr Do not use the built-in rules specified in the system makefile. + [1m-r [22mDo not use the built-in rules specified in the system makefile. - --ss Do not echo any commands as they are executed. Equivalent to - specifying `@@' before each command line in the makefile. + [1m-s [22mDo not echo any commands as they are executed. Equivalent to + specifying `[1m@[22m' before each command line in the makefile. - --TT _t_r_a_c_e_f_i_l_e - When used with the --jj flag, append a trace record to _t_r_a_c_e_f_i_l_e + [1m-T [4m[22mtracefile[0m + When used with the [1m-j [22mflag, append a trace record to [4mtracefile[0m for each job started and completed. - --tt Rather than re-building a target as specified in the makefile, + [1m-t [22mRather than re-building a target as specified in the makefile, create it or update its modification time to make it appear up- to-date. - --VV _v_a_r_i_a_b_l_e - Print bbmmaakkee's idea of the value of _v_a_r_i_a_b_l_e, in the global con- - text. Do not build any targets. Multiple instances of this - option may be specified; the variables will be printed one per - line, with a blank line for each null or undefined variable. If - _v_a_r_i_a_b_l_e contains a `$' then the value will be expanded before - printing. - - --WW Treat any warnings during makefile parsing as errors. - - --ww Print entering and leaving directory messages, pre and post pro- + [1m-V [4m[22mvariable[0m + Print the value of [4mvariable[24m. Do not build any targets. Multiple + instances of this option may be specified; the variables will be + printed one per line, with a blank line for each null or unde- + fined variable. The value printed is extracted from the global + context after all makefiles have been read. By default, the raw + variable contents (which may include additional unexpanded vari- + able references) are shown. If [4mvariable[24m contains a `$' then the + value will be recursively expanded to its complete resultant text + before printing. The expanded value will also be printed if + [4m.MAKE.EXPAND_VARIABLES[24m is set to true and the [1m-dV [22moption has not + been used to override it. Note that loop-local and target-local + variables, as well as values taken temporarily by global vari- + ables during makefile processing, are not accessible via this + option. The [1m-dv [22mdebug mode can be used to see these at the cost + of generating substantial extraneous output. + + [1m-v [4m[22mvariable[0m + Like [1m-V [22mbut the variable is always expanded to its complete + value. + + [1m-W [22mTreat any warnings during makefile parsing as errors. + + [1m-w [22mPrint entering and leaving directory messages, pre and post pro- cessing. - --XX Don't export variables passed on the command line to the environ- + [1m-X [22mDon't export variables passed on the command line to the environ- ment individually. Variables passed on the command line are - still exported via the _M_A_K_E_F_L_A_G_S environment variable. This + still exported via the [4mMAKEFLAGS[24m environment variable. This option may be useful on systems which have a small limit on the size of command arguments. - _v_a_r_i_a_b_l_e_=_v_a_l_u_e - Set the value of the variable _v_a_r_i_a_b_l_e to _v_a_l_u_e. Normally, all + [4mvariable=value[0m + Set the value of the variable [4mvariable[24m to [4mvalue[24m. Normally, all values passed on the command line are also exported to sub-makes - in the environment. The --XX flag disables this behavior. Vari- + in the environment. The [1m-X [22mflag disables this behavior. Vari- able assignments should follow options for POSIX compatibility but no ordering is enforced. @@ -242,28 +257,28 @@ DDEESSCCRRIIPPTTIIOONN them with a backslash (`\'). The trailing newline character and initial whitespace on the following line are compressed into a single space. -FFIILLEE DDEEPPEENNDDEENNCCYY SSPPEECCIIFFIICCAATTIIOONNSS +[1mFILE DEPENDENCY SPECIFICATIONS[0m Dependency lines consist of one or more targets, an operator, and zero or more sources. This creates a relationship where the targets ``depend'' on the sources and are usually created from them. The exact relationship between the target and the source is determined by the operator that sep- arates them. The three operators are as follows: - :: A target is considered out-of-date if its modification time is less + [1m: [22mA target is considered out-of-date if its modification time is less than those of any of its sources. Sources for a target accumulate over dependency lines when this operator is used. The target is - removed if bbmmaakkee is interrupted. + removed if [1mbmake [22mis interrupted. - !! Targets are always re-created, but not until all sources have been + [1m! [22mTargets are always re-created, but not until all sources have been examined and re-created as necessary. Sources for a target accumu- late over dependency lines when this operator is used. The target - is removed if bbmmaakkee is interrupted. + is removed if [1mbmake [22mis interrupted. - :::: If no sources are specified, the target is always re-created. Oth- + [1m:: [22mIf no sources are specified, the target is always re-created. Oth- erwise, a target is considered out-of-date if any of its sources has been modified more recently than the target. Sources for a target do not accumulate over dependency lines when this operator - is used. The target will not be removed if bbmmaakkee is interrupted. + is used. The target will not be removed if [1mbmake [22mis interrupted. Targets and sources may contain the shell wildcard values `?', `*', `[]', and `{}'. The values `?', `*', and `[]' may only be used as part of the @@ -272,37 +287,37 @@ FFIILLEE DDEEPPEENNDDEENNCCYY SSPPEECCIIFFIICCAATTIIOO existing files. Expansion is in directory order, not alphabetically as done in the shell. -SSHHEELLLL CCOOMMMMAANNDDSS +[1mSHELL COMMANDS[0m Each target may have associated with it one or more lines of shell com- mands, normally used to create the target. Each of the lines in this - script _m_u_s_t be preceded by a tab. (For historical reasons, spaces are + script [4mmust[24m be preceded by a tab. (For historical reasons, spaces are not accepted.) While targets can appear in many dependency lines if desired, by default only one of these rules may be followed by a creation - script. If the `::::' operator is used, however, all rules may include + script. If the `[1m::[22m' operator is used, however, all rules may include scripts and the scripts are executed in the order found. Each line is treated as a separate shell command, unless the end of line is escaped with a backslash (`\') in which case that line and the next are combined. If the first characters of the command are any combination - of `@@', `++', or `--', the command is treated specially. A `@@' causes the - command not to be echoed before it is executed. A `++' causes the command - to be executed even when --nn is given. This is similar to the effect of + of `[1m@[22m', `[1m+[22m', or `[1m-[22m', the command is treated specially. A `[1m@[22m' causes the + command not to be echoed before it is executed. A `[1m+[22m' causes the command + to be executed even when [1m-n [22mis given. This is similar to the effect of the .MAKE special source, except that the effect can be limited to a sin- - gle line of a script. A `--' in compatibility mode causes any non-zero + gle line of a script. A `[1m-[22m' in compatibility mode causes any non-zero exit status of the command line to be ignored. - When bbmmaakkee is run in jobs mode with --jj _m_a_x___j_o_b_s, the entire script for + When [1mbmake [22mis run in jobs mode with [1m-j [4m[22mmax_jobs[24m, the entire script for the target is fed to a single instance of the shell. In compatibility (non-jobs) mode, each command is run in a separate process. If the com- mand contains any shell meta characters (`#=|^(){};&<>*?[]:$`\\n') it - will be passed to the shell; otherwise bbmmaakkee will attempt direct execu- - tion. If a line starts with `--' and the shell has ErrCtl enabled then + will be passed to the shell; otherwise [1mbmake [22mwill attempt direct execu- + tion. If a line starts with `[1m-[22m' and the shell has ErrCtl enabled then failure of the command line will be ignored as in compatibility mode. - Otherwise `--' affects the entire job; the script will stop at the first + Otherwise `[1m-[22m' affects the entire job; the script will stop at the first command line that fails, but the target will not be deemed to have failed. - Makefiles should be written so that the mode of bbmmaakkee operation does not + Makefiles should be written so that the mode of [1mbmake [22moperation does not change their behavior. For example, any command which needs to use ``cd'' or ``chdir'' without potentially changing the directory for subse- quent commands should be put in parentheses so it executes in a subshell. @@ -319,35 +334,35 @@ SSHHEELLLL CCOOMMMMAANNDDSS (cd ${.CURDIR} && ${MAKE} $@); \ echo Back in `pwd` - Since bbmmaakkee will chdir(2) to `_._O_B_J_D_I_R' before executing any targets, each + Since [1mbmake [22mwill chdir(2) to `[4m.OBJDIR[24m' before executing any targets, each child process starts with that as its current working directory. -VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS +[1mVARIABLE ASSIGNMENTS[0m Variables in make are much like variables in the shell, and, by tradi- tion, consist of all upper-case letters. - VVaarriiaabbllee aassssiiggnnmmeenntt mmooddiiffiieerrss + [1mVariable assignment modifiers[0m The five operators that can be used to assign values to variables are as follows: - == Assign the value to the variable. Any previous value is overrid- + [1m= [22mAssign the value to the variable. Any previous value is overrid- den. - ++== Append the value to the current value of the variable. + [1m+= [22mAppend the value to the current value of the variable. - ??== Assign the value to the variable if it is not already defined. + [1m?= [22mAssign the value to the variable if it is not already defined. - ::== Assign with expansion, i.e. expand the value before assigning it + [1m:= [22mAssign with expansion, i.e. expand the value before assigning it to the variable. Normally, expansion is not done until the vari- - able is referenced. _N_O_T_E: References to undefined variables are - _n_o_t expanded. This can cause problems when variable modifiers + able is referenced. [4mNOTE[24m: References to undefined variables are + [4mnot[24m expanded. This can cause problems when variable modifiers are used. - !!== Expand the value and pass it to the shell for execution and + [1m!= [22mExpand the value and pass it to the shell for execution and assign the result to the variable. Any newlines in the result are replaced with spaces. - Any white-space before the assigned _v_a_l_u_e is removed; if the value is + Any white-space before the assigned [4mvalue[24m is removed; if the value is being appended, a single space is inserted between the previous contents of the variable and the appended value. @@ -397,12 +412,12 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS ${b} contains ``${j} ${j} ${j}'' which expands to ``3 3 3'' since after the loop completes ${j} contains ``3''. - VVaarriiaabbllee ccllaasssseess + [1mVariable classes[0m The four different classes of variables (in order of increasing prece- dence) are: Environment variables - Variables defined as part of bbmmaakkee's environment. + Variables defined as part of [1mbmake[22m's environment. Global variables Variables defined in the makefile or in included makefiles. @@ -417,86 +432,91 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS target to target. It is not currently possible to define new local vari- ables. The seven local variables are as follows: - _._A_L_L_S_R_C The list of all sources for this target; also known as - `_>'. + [4m.ALLSRC[24m The list of all sources for this target; also known as + `[4m>[24m'. - _._A_R_C_H_I_V_E The name of the archive file; also known as `_!'. + [4m.ARCHIVE[24m The name of the archive file; also known as `[4m![24m'. - _._I_M_P_S_R_C In suffix-transformation rules, the name/path of the + [4m.IMPSRC[24m In suffix-transformation rules, the name/path of the source from which the target is to be transformed (the - ``implied'' source); also known as `_<'. It is not + ``implied'' source); also known as `[4m<[24m'. It is not defined in explicit rules. - _._M_E_M_B_E_R The name of the archive member; also known as `_%'. + [4m.MEMBER[24m The name of the archive member; also known as `[4m%[24m'. - _._O_O_D_A_T_E The list of sources for this target that were deemed out- - of-date; also known as `_?'. + [4m.OODATE[24m The list of sources for this target that were deemed out- + of-date; also known as `[4m?[24m'. - _._P_R_E_F_I_X The file prefix of the target, containing only the file + [4m.PREFIX[24m The file prefix of the target, containing only the file portion, no suffix or preceding directory components; - also known as `_*'. The suffix must be one of the known - suffixes declared with ..SSUUFFFFIIXXEESS or it will not be recog- + also known as `[4m*[24m'. The suffix must be one of the known + suffixes declared with [1m.SUFFIXES [22mor it will not be recog- nized. - _._T_A_R_G_E_T The name of the target; also known as `_@'. + [4m.TARGET[24m The name of the target; also known as `[4m@[24m'. For compati- + bility with other makes this is an alias for [1m.ARCHIVE [22min + archive member rules. - The shorter forms (`_>', `_!', `_<', `_%', `_?', `_*', and `_@') are permitted + The shorter forms (`[4m>[24m', `[4m![24m', `[4m<[24m', `[4m%[24m', `[4m?[24m', `[4m*[24m', and `[4m@[24m') are permitted for backward compatibility with historical makefiles and legacy POSIX make and are not recommended. Variants of these variables with the punctuation followed immediately by - `D' or `F', e.g. `_$_(_@_D_)', are legacy forms equivalent to using the `:H' + `D' or `F', e.g. `[4m$(@D)[24m', are legacy forms equivalent to using the `:H' and `:T' modifiers. These forms are accepted for compatibility with AT&T System V UNIX makefiles and POSIX but are not recommended. Four of the local variables may be used in sources on dependency lines because they expand to the proper value for each target on the line. - These variables are `_._T_A_R_G_E_T', `_._P_R_E_F_I_X', `_._A_R_C_H_I_V_E', and `_._M_E_M_B_E_R'. + These variables are `[4m.TARGET[24m', `[4m.PREFIX[24m', `[4m.ARCHIVE[24m', and `[4m.MEMBER[24m'. - AAddddiittiioonnaall bbuuiilltt--iinn vvaarriiaabblleess - In addition, bbmmaakkee sets or knows about the following variables: + [1mAdditional built-in variables[0m + In addition, [1mbmake [22msets or knows about the following variables: - _$ A single dollar sign `$', i.e. `$$' expands to a single + [4m$[24m A single dollar sign `$', i.e. `$$' expands to a single dollar sign. - _._A_L_L_T_A_R_G_E_T_S The list of all targets encountered in the Makefile. If + [4m.ALLTARGETS[24m The list of all targets encountered in the Makefile. If evaluated during Makefile parsing, lists only those tar- gets encountered thus far. - _._C_U_R_D_I_R A path to the directory where bbmmaakkee was executed. Refer + [4m.CURDIR[24m A path to the directory where [1mbmake [22mwas executed. Refer to the description of `PWD' for more details. - _._I_N_C_L_U_D_E_D_F_R_O_M_D_I_R + [4m.INCLUDEDFROMDIR[0m The directory of the file this Makefile was included from. - _._I_N_C_L_U_D_E_D_F_R_O_M_F_I_L_E + [4m.INCLUDEDFROMFILE[0m The filename of the file this Makefile was included from. - MAKE The name that bbmmaakkee was executed with (_a_r_g_v_[_0_]). For - compatibility bbmmaakkee also sets _._M_A_K_E with the same value. + MAKE The name that [1mbmake [22mwas executed with ([4margv[0][24m). For + compatibility [1mbmake [22malso sets [4m.MAKE[24m with the same value. The preferred variable to use is the environment variable MAKE because it is more compatible with other versions of - bbmmaakkee and cannot be confused with the special target with + [1mbmake [22mand cannot be confused with the special target with the same name. - _._M_A_K_E_._D_E_P_E_N_D_F_I_L_E - Names the makefile (default `_._d_e_p_e_n_d') from which gener- + [4m.MAKE.DEPENDFILE[0m + Names the makefile (default `[4m.depend[24m') from which gener- ated dependencies are read. - _._M_A_K_E_._E_X_P_A_N_D___V_A_R_I_A_B_L_E_S - A boolean that controls the default behavior of the --VV - option. + [4m.MAKE.EXPAND_VARIABLES[0m + A boolean that controls the default behavior of the [1m-V[0m + option. If true, variable values printed with [1m-V [22mare + fully expanded; if false, the raw variable contents + (which may include additional unexpanded variable refer- + ences) are shown. - _._M_A_K_E_._E_X_P_O_R_T_E_D The list of variables exported by bbmmaakkee. + [4m.MAKE.EXPORTED[24m The list of variables exported by [1mbmake[22m. - _._M_A_K_E_._J_O_B_S The argument to the --jj option. + [4m.MAKE.JOBS[24m The argument to the [1m-j [22moption. - _._M_A_K_E_._J_O_B_._P_R_E_F_I_X - If bbmmaakkee is run with _j then output for each target is + [4m.MAKE.JOB.PREFIX[0m + If [1mbmake [22mis run with [4mj[24m then output for each target is prefixed with a token `--- target ---' the first part of - which can be controlled via _._M_A_K_E_._J_O_B_._P_R_E_F_I_X. If - _._M_A_K_E_._J_O_B_._P_R_E_F_I_X is empty, no token is printed. + which can be controlled via [4m.MAKE.JOB.PREFIX[24m. If + [4m.MAKE.JOB.PREFIX[24m is empty, no token is printed. For example: .MAKE.JOB.PREFIX=${.newline}---${.MAKE:T}[${.MAKE.PID}] would produce tokens like `---make[1234] target ---' mak- @@ -504,122 +524,156 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS achieved. MAKEFLAGS The environment variable `MAKEFLAGS' may contain anything - that may be specified on bbmmaakkee's command line. Anything - specified on bbmmaakkee's command line is appended to the + that may be specified on [1mbmake[22m's command line. Anything + specified on [1mbmake[22m's command line is appended to the `MAKEFLAGS' variable which is then entered into the envi- - ronment for all programs which bbmmaakkee executes. + ronment for all programs which [1mbmake [22mexecutes. - _._M_A_K_E_._L_E_V_E_L The recursion depth of bbmmaakkee. The initial instance of - bbmmaakkee will be 0, and an incremented value is put into the + [4m.MAKE.LEVEL[24m The recursion depth of [1mbmake[22m. The initial instance of + [1mbmake [22mwill be 0, and an incremented value is put into the environment to be seen by the next generation. This allows tests like: .if ${.MAKE.LEVEL} == 0 to protect things which should only be evaluated in the initial - instance of bbmmaakkee. + instance of [1mbmake[22m. - _._M_A_K_E_._M_A_K_E_F_I_L_E___P_R_E_F_E_R_E_N_C_E - The ordered list of makefile names (default `_m_a_k_e_f_i_l_e', - `_M_a_k_e_f_i_l_e') that bbmmaakkee will look for. + [4m.MAKE.MAKEFILE_PREFERENCE[0m + The ordered list of makefile names (default `[4mmakefile[24m', + `[4mMakefile[24m') that [1mbmake [22mwill look for. - _._M_A_K_E_._M_A_K_E_F_I_L_E_S - The list of makefiles read by bbmmaakkee, which is useful for + [4m.MAKE.MAKEFILES[0m + The list of makefiles read by [1mbmake[22m, which is useful for tracking dependencies. Each makefile is recorded only once, regardless of the number of times read. - _._M_A_K_E_._M_O_D_E Processed after reading all makefiles. Can affect the - mode that bbmmaakkee runs in. It can contain a number of key- + [4m.MAKE.MODE[24m Processed after reading all makefiles. Can affect the + mode that [1mbmake [22mruns in. It can contain a number of key- words: - _c_o_m_p_a_t Like --BB, puts bbmmaakkee into "compat" mode. - - _m_e_t_a Puts bbmmaakkee into "meta" mode, where meta files - are created for each target to capture the - command run, the output generated and if - filemon(4) is available, the system calls - which are of interest to bbmmaakkee. The captured - output can be very useful when diagnosing - errors. - - _c_u_r_d_i_r_O_k_= _b_f Normally bbmmaakkee will not create .meta files - in `_._C_U_R_D_I_R'. This can be overridden by set- - ting _b_f to a value which represents True. - - _e_n_v For debugging, it can be useful to inlcude - the environment in the .meta file. - - _v_e_r_b_o_s_e If in "meta" mode, print a clue about the - target being built. This is useful if the - build is otherwise running silently. The - message printed the value of: - _._M_A_K_E_._M_E_T_A_._P_R_E_F_I_X. - - _i_g_n_o_r_e_-_c_m_d Some makefiles have commands which are simply - not stable. This keyword causes them to be - ignored for determining whether a target is - out of date in "meta" mode. See also - ..NNOOMMEETTAA__CCMMPP. - - _s_i_l_e_n_t_= _b_f If _b_f is True, when a .meta file is created, - mark the target ..SSIILLEENNTT. - - _._M_A_K_E_._M_E_T_A_._B_A_I_L_I_W_I_C_K + [4mcompat[24m Like [1m-B[22m, puts [1mbmake [22minto "compat" + mode. + + [4mmeta[24m Puts [1mbmake [22minto "meta" mode, where + meta files are created for each tar- + get to capture the command run, the + output generated and if filemon(4) + is available, the system calls which + are of interest to [1mbmake[22m. The cap- + tured output can be very useful when + diagnosing errors. + + [4mcurdirOk=[24m [4mbf[24m Normally [1mbmake [22mwill not create .meta + files in `[4m.CURDIR[24m'. This can be + overridden by setting [4mbf[24m to a value + which represents True. + + [4mmissing-meta=[24m [4mbf[24m If [4mbf[24m is True, then a missing .meta + file makes the target out-of-date. + + [4mmissing-filemon=[24m [4mbf[24m If [4mbf[24m is True, then missing filemon + data makes the target out-of-date. + + [4mnofilemon[24m Do not use filemon(4). + + [4menv[24m For debugging, it can be useful to + include the environment in the .meta + file. + + [4mverbose[24m If in "meta" mode, print a clue + about the target being built. This + is useful if the build is otherwise + running silently. The message + printed the value of: + [4m.MAKE.META.PREFIX[24m. + + [4mignore-cmd[24m Some makefiles have commands which + are simply not stable. This keyword + causes them to be ignored for deter- + mining whether a target is out of + date in "meta" mode. See also + [1m.NOMETA_CMP[22m. + + [4msilent=[24m [4mbf[24m If [4mbf[24m is True, when a .meta file is + created, mark the target [1m.SILENT[22m. + + [4m.MAKE.META.BAILIWICK[0m In "meta" mode, provides a list of prefixes which match - the directories controlled by bbmmaakkee. If a file that was - generated outside of _._O_B_J_D_I_R but within said bailiwick is + the directories controlled by [1mbmake[22m. If a file that was + generated outside of [4m.OBJDIR[24m but within said bailiwick is missing, the current target is considered out-of-date. - _._M_A_K_E_._M_E_T_A_._C_R_E_A_T_E_D + [4m.MAKE.META.CREATED[0m In "meta" mode, this variable contains a list of all the meta files updated. If not empty, it can be used to - trigger processing of _._M_A_K_E_._M_E_T_A_._F_I_L_E_S. + trigger processing of [4m.MAKE.META.FILES[24m. - _._M_A_K_E_._M_E_T_A_._F_I_L_E_S + [4m.MAKE.META.FILES[0m In "meta" mode, this variable contains a list of all the meta files used (updated or not). This list can be used to process the meta files to extract dependency informa- tion. - _._M_A_K_E_._M_E_T_A_._I_G_N_O_R_E___P_A_T_H_S + [4m.MAKE.META.IGNORE_PATHS[0m Provides a list of path prefixes that should be ignored; because the contents are expected to change over time. - The default list includes: `_/_d_e_v _/_e_t_c _/_p_r_o_c _/_t_m_p _/_v_a_r_/_r_u_n - _/_v_a_r_/_t_m_p' + The default list includes: `[4m/dev[24m [4m/etc[24m [4m/proc[24m [4m/tmp[24m [4m/var/run[0m + [4m/var/tmp[24m' - _._M_A_K_E_._M_E_T_A_._P_R_E_F_I_X + [4m.MAKE.META.IGNORE_PATTERNS[0m + Provides a list of patterns to match against pathnames. + Ignore any that match. + + [4m.MAKE.META.IGNORE_FILTER[0m + Provides a list of variable modifiers to apply to each + pathname. Ignore if the expansion is an empty string. + + [4m.MAKE.META.PREFIX[0m Defines the message printed for each meta file updated in "meta verbose" mode. The default value is: Building ${.TARGET:H:tA}/${.TARGET:T} - _._M_A_K_E_O_V_E_R_R_I_D_E_S This variable is used to record the names of variables + [4m.MAKEOVERRIDES[24m This variable is used to record the names of variables assigned to on the command line, so that they may be - exported as part of `MAKEFLAGS'. This behaviour can be - disabled by assigning an empty value to `_._M_A_K_E_O_V_E_R_R_I_D_E_S' + exported as part of `MAKEFLAGS'. This behavior can be + disabled by assigning an empty value to `[4m.MAKEOVERRIDES[24m' within a makefile. Extra variables can be exported from - a makefile by appending their names to `_._M_A_K_E_O_V_E_R_R_I_D_E_S'. - `MAKEFLAGS' is re-exported whenever `_._M_A_K_E_O_V_E_R_R_I_D_E_S' is + a makefile by appending their names to `[4m.MAKEOVERRIDES[24m'. + `MAKEFLAGS' is re-exported whenever `[4m.MAKEOVERRIDES[24m' is modified. - _._M_A_K_E_._P_A_T_H___F_I_L_E_M_O_N - If bbmmaakkee was built with filemon(4) support, this is set + [4m.MAKE.PATH_FILEMON[0m + If [1mbmake [22mwas built with filemon(4) support, this is set to the path of the device node. This allows makefiles to test for this support. - _._M_A_K_E_._P_I_D The process-id of bbmmaakkee. - - _._M_A_K_E_._P_P_I_D The parent process-id of bbmmaakkee. - - _M_A_K_E___P_R_I_N_T___V_A_R___O_N___E_R_R_O_R - When bbmmaakkee stops due to an error, it prints its name and - the value of `_._C_U_R_D_I_R' as well as the value of any vari- - ables named in `_M_A_K_E___P_R_I_N_T___V_A_R___O_N___E_R_R_O_R'. - - _._n_e_w_l_i_n_e This variable is simply assigned a newline character as - its value. This allows expansions using the ::@@ modifier + [4m.MAKE.PID[24m The process-id of [1mbmake[22m. + + [4m.MAKE.PPID[24m The parent process-id of [1mbmake[22m. + + [4m.MAKE.SAVE_DOLLARS[0m + value should be a boolean that controls whether `$$' are + preserved when doing `:=' assignments. The default is + false, for backwards compatibility. Set to true for com- + patability with other makes. If set to false, `$$' + becomes `$' per normal evaluation rules. + + [4mMAKE_PRINT_VAR_ON_ERROR[0m + When [1mbmake [22mstops due to an error, it sets `[4m.ERROR_TARGET[24m' + to the name of the target that failed, `[4m.ERROR_CMD[24m' to + the commands of the failed target, and in "meta" mode, it + also sets `[4m.ERROR_CWD[24m' to the getcwd(3), and + `[4m.ERROR_META_FILE[24m' to the path of the meta file (if any) + describing the failed target. It then prints its name + and the value of `[4m.CURDIR[24m' as well as the value of any + variables named in `[4mMAKE_PRINT_VAR_ON_ERROR[24m'. + + [4m.newline[24m This variable is simply assigned a newline character as + its value. This allows expansions using the [1m:@ [22mmodifier to put a newline between iterations of the loop rather than a space. For example, the printing of - `_M_A_K_E___P_R_I_N_T___V_A_R___O_N___E_R_R_O_R' could be done as + `[4mMAKE_PRINT_VAR_ON_ERROR[24m' could be done as ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@}. - _._O_B_J_D_I_R A path to the directory where the targets are built. Its + [4m.OBJDIR[24m A path to the directory where the targets are built. Its value is determined by trying to chdir(2) to the follow- ing directories in order and using the first match: @@ -633,11 +687,11 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS (Only if `MAKEOBJDIR' is set in the environment or on the command line.) - 3. ${.CURDIR}_/_o_b_j_.${MACHINE} + 3. ${.CURDIR}[4m/obj.[24m${MACHINE} - 4. ${.CURDIR}_/_o_b_j + 4. ${.CURDIR}[4m/obj[0m - 5. _/_u_s_r_/_o_b_j_/${.CURDIR} + 5. [4m/usr/obj/[24m${.CURDIR} 6. ${.CURDIR} @@ -647,43 +701,43 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS may be used. This is especially useful with `MAKEOBJDIR'. - `_._O_B_J_D_I_R' may be modified in the makefile as a global - variable. In all cases, bbmmaakkee will chdir(2) to `_._O_B_J_D_I_R' - and set `PWD' to that directory before executing any tar- - gets. + `[4m.OBJDIR[24m' may be modified in the makefile via the special + target `[1m.OBJDIR[22m'. In all cases, [1mbmake [22mwill chdir(2) to + the specified directory if it exists, and set `[4m.OBJDIR[24m' + and `PWD' to that directory before executing any targets. - _._P_A_R_S_E_D_I_R A path to the directory of the current `_M_a_k_e_f_i_l_e' being + [4m.PARSEDIR[24m A path to the directory of the current `[4mMakefile[24m' being parsed. - _._P_A_R_S_E_F_I_L_E The basename of the current `_M_a_k_e_f_i_l_e' being parsed. - This variable and `_._P_A_R_S_E_D_I_R' are both set only while the - `_M_a_k_e_f_i_l_e_s' are being parsed. If you want to retain + [4m.PARSEFILE[24m The basename of the current `[4mMakefile[24m' being parsed. + This variable and `[4m.PARSEDIR[24m' are both set only while the + `[4mMakefiles[24m' are being parsed. If you want to retain their current values, assign them to a variable using - assignment with expansion: (`::=='). + assignment with expansion: (`[1m:=[22m'). - _._P_A_T_H A variable that represents the list of directories that - bbmmaakkee will search for files. The search list should be - updated using the target `_._P_A_T_H' rather than the vari- + [4m.PATH[24m A variable that represents the list of directories that + [1mbmake [22mwill search for files. The search list should be + updated using the target `[4m.PATH[24m' rather than the vari- able. - PWD Alternate path to the current directory. bbmmaakkee normally - sets `_._C_U_R_D_I_R' to the canonical path given by getcwd(3). + PWD Alternate path to the current directory. [1mbmake [22mnormally + sets `[4m.CURDIR[24m' to the canonical path given by getcwd(3). However, if the environment variable `PWD' is set and - gives a path to the current directory, then bbmmaakkee sets - `_._C_U_R_D_I_R' to the value of `PWD' instead. This behaviour + gives a path to the current directory, then [1mbmake [22msets + `[4m.CURDIR[24m' to the value of `PWD' instead. This behavior is disabled if `MAKEOBJDIRPREFIX' is set or `MAKEOBJDIR' contains a variable transform. `PWD' is set to the value - of `_._O_B_J_D_I_R' for all programs which bbmmaakkee executes. + of `[4m.OBJDIR[24m' for all programs which [1mbmake [22mexecutes. .TARGETS The list of targets explicitly specified on the command line, if any. - VPATH Colon-separated (``:'') lists of directories that bbmmaakkee + VPATH Colon-separated (``:'') lists of directories that [1mbmake[0m will search for files. The variable is supported for - compatibility with old make programs only, use `_._P_A_T_H' + compatibility with old make programs only, use `[4m.PATH[24m' instead. - VVaarriiaabbllee mmooddiiffiieerrss + [1mVariable modifiers[0m Variable expansion may be modified to select or modify each word of the variable (where a ``word'' is white-space delimited sequence of charac- ters). The general format of a variable expansion is as follows: @@ -705,32 +759,32 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS The supported modifiers are: - ::EE Replaces each word in the variable with its suffix. + [1m:E [22mReplaces each word in the variable with its suffix. - ::HH Replaces each word in the variable with everything but the last com- + [1m:H [22mReplaces each word in the variable with everything but the last com- ponent. - ::MM_p_a_t_t_e_r_n - Select only those words that match _p_a_t_t_e_r_n. The standard shell + [1m:M[4m[22mpattern[0m + Select only those words that match [4mpattern[24m. The standard shell wildcard characters (`*', `?', and `[]') may be used. The wildcard characters may be escaped with a backslash (`\'). As a consequence of the way values are split into words, matched, and then joined, a construct like ${VAR:M*} - will normalise the inter-word spacing, removing all leading and + will normalize the inter-word spacing, removing all leading and trailing space, and converting multiple consecutive spaces to single spaces. - ::NN_p_a_t_t_e_r_n - This is identical to `::MM', but selects all words which do not match - _p_a_t_t_e_r_n. + [1m:N[4m[22mpattern[0m + This is identical to `[1m:M[22m', but selects all words which do not match + [4mpattern[24m. - ::OO Order every word in variable alphabetically. To sort words in - reverse order use the `::OO::[[--11....11]]' combination of modifiers. + [1m:O [22mOrder every word in variable alphabetically. To sort words in + reverse order use the `[1m:O:[-1..1][22m' combination of modifiers. - ::OOxx Randomize words in variable. The results will be different each + [1m:Ox [22mRandomize words in variable. The results will be different each time you are referring to the modified variable; use the assignment - with expansion (`::==') to prevent such behaviour. For example, + with expansion (`[1m:=[22m') to prevent such behavior. For example, LIST= uno due tre quattro RANDOM_LIST= ${LIST:Ox} @@ -748,88 +802,92 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS due uno quattro tre due uno quattro tre - ::QQ Quotes every shell meta-character in the variable, so that it can be - passed safely through recursive invocations of bbmmaakkee. + [1m:Q [22mQuotes every shell meta-character in the variable, so that it can be + passed safely through recursive invocations of [1mbmake[22m. + + [1m:R [22mReplaces each word in the variable with everything but its suffix. - ::RR Replaces each word in the variable with everything but its suffix. + [1m:range[=count][0m + The value is an integer sequence representing the words of the orig- + inal value, or the supplied [4mcount[24m. - ::ggmmttiimmee - The value is a format string for strftime(3), using the current - gmtime(3). + [1m:gmtime[=utc][0m + The value is a format string for strftime(3), using gmtime(3). If a + [4mutc[24m value is not provided or is 0, the current time is used. - ::hhaasshh - Compute a 32bit hash of the value and encode it as hex digits. + [1m:hash[0m + Compute a 32-bit hash of the value and encode it as hex digits. - ::llooccaallttiimmee - The value is a format string for strftime(3), using the current - localtime(3). + [1m:localtime[=utc][0m + The value is a format string for strftime(3), using localtime(3). + If a [4mutc[24m value is not provided or is 0, the current time is used. - ::ttAA Attempt to convert variable to an absolute path using realpath(3), + [1m:tA [22mAttempt to convert variable to an absolute path using realpath(3), if that fails, the value is unchanged. - ::ttll Converts variable to lower-case letters. + [1m:tl [22mConverts variable to lower-case letters. - ::ttss_c + [1m:ts[4m[22mc[0m Words in the variable are normally separated by a space on expan- - sion. This modifier sets the separator to the character _c. If _c is + sion. This modifier sets the separator to the character [4mc[24m. If [4mc[24m is omitted, then no separator is used. The common escapes (including octal numeric codes), work as expected. - ::ttuu Converts variable to upper-case letters. + [1m:tu [22mConverts variable to upper-case letters. - ::ttWW Causes the value to be treated as a single word (possibly containing - embedded white space). See also `::[[**]]'. + [1m:tW [22mCauses the value to be treated as a single word (possibly containing + embedded white space). See also `[1m:[*][22m'. - ::ttww Causes the value to be treated as a sequence of words delimited by - white space. See also `::[[@@]]'. + [1m:tw [22mCauses the value to be treated as a sequence of words delimited by + white space. See also `[1m:[@][22m'. - ::SS/_o_l_d___s_t_r_i_n_g/_n_e_w___s_t_r_i_n_g/[11ggWW] - Modify the first occurrence of _o_l_d___s_t_r_i_n_g in the variable's value, - replacing it with _n_e_w___s_t_r_i_n_g. If a `g' is appended to the last + [1m:S[22m/[4mold_string[24m/[4mnew_string[24m/[[1m1gW[22m] + Modify the first occurrence of [4mold_string[24m in the variable's value, + replacing it with [4mnew_string[24m. If a `g' is appended to the last slash of the pattern, all occurrences in each word are replaced. If a `1' is appended to the last slash of the pattern, only the first word is affected. If a `W' is appended to the last slash of the pattern, then the value is treated as a single word (possibly con- - taining embedded white space). If _o_l_d___s_t_r_i_n_g begins with a caret - (`^'), _o_l_d___s_t_r_i_n_g is anchored at the beginning of each word. If - _o_l_d___s_t_r_i_n_g ends with a dollar sign (`$'), it is anchored at the end - of each word. Inside _n_e_w___s_t_r_i_n_g, an ampersand (`&') is replaced by - _o_l_d___s_t_r_i_n_g (without any `^' or `$'). Any character may be used as a + taining embedded white space). If [4mold_string[24m begins with a caret + (`^'), [4mold_string[24m is anchored at the beginning of each word. If + [4mold_string[24m ends with a dollar sign (`$'), it is anchored at the end + of each word. Inside [4mnew_string[24m, an ampersand (`&') is replaced by + [4mold_string[24m (without any `^' or `$'). Any character may be used as a delimiter for the parts of the modifier string. The anchoring, ampersand and delimiter characters may be escaped with a backslash (`\'). Variable expansion occurs in the normal fashion inside both - _o_l_d___s_t_r_i_n_g and _n_e_w___s_t_r_i_n_g with the single exception that a backslash + [4mold_string[24m and [4mnew_string[24m with the single exception that a backslash is used to prevent the expansion of a dollar sign (`$'), not a pre- ceding dollar sign as is usual. - ::CC/_p_a_t_t_e_r_n/_r_e_p_l_a_c_e_m_e_n_t/[11ggWW] - The ::CC modifier is just like the ::SS modifier except that the old and + [1m:C[22m/[4mpattern[24m/[4mreplacement[24m/[[1m1gW[22m] + The [1m:C [22mmodifier is just like the [1m:S [22mmodifier except that the old and new strings, instead of being simple strings, are an extended regu- - lar expression (see regex(3)) string _p_a_t_t_e_r_n and an ed(1)-style - string _r_e_p_l_a_c_e_m_e_n_t. Normally, the first occurrence of the pattern - _p_a_t_t_e_r_n in each word of the value is substituted with _r_e_p_l_a_c_e_m_e_n_t. + lar expression (see regex(3)) string [4mpattern[24m and an ed(1)-style + string [4mreplacement[24m. Normally, the first occurrence of the pattern + [4mpattern[24m in each word of the value is substituted with [4mreplacement[24m. The `1' modifier causes the substitution to apply to at most one word; the `g' modifier causes the substitution to apply to as many - instances of the search pattern _p_a_t_t_e_r_n as occur in the word or + instances of the search pattern [4mpattern[24m as occur in the word or words it is found in; the `W' modifier causes the value to be treated as a single word (possibly containing embedded white space). Note that `1' and `g' are orthogonal; the former specifies whether multiple words are potentially affected, the latter whether multiple substitutions can potentially occur within each affected word. - As for the ::SS modifier, the _p_a_t_t_e_r_n and _r_e_p_l_a_c_e_m_e_n_t are subjected to + As for the [1m:S [22mmodifier, the [4mpattern[24m and [4mreplacement[24m are subjected to variable expansion before being parsed as regular expressions. - ::TT Replaces each word in the variable with its last component. + [1m:T [22mReplaces each word in the variable with its last component. - ::uu Remove adjacent duplicate words (like uniq(1)). + [1m:u [22mRemove adjacent duplicate words (like uniq(1)). - ::??_t_r_u_e___s_t_r_i_n_g::_f_a_l_s_e___s_t_r_i_n_g + [1m:?[4m[22mtrue_string[24m[1m:[4m[22mfalse_string[0m If the variable name (not its value), when parsed as a .if condi- tional expression, evaluates to true, return as its value the - _t_r_u_e___s_t_r_i_n_g, otherwise return the _f_a_l_s_e___s_t_r_i_n_g. Since the variable + [4mtrue_string[24m, otherwise return the [4mfalse_string[24m. Since the variable name is used as the expression, :? must be the first modifier after the variable name itself - which will, of course, usually contain variable expansions. A common error is trying to use expressions @@ -839,32 +897,45 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS match "42" you need to use something like: ${"${NUMBERS:M42}" != "":?match:no}. - _:_o_l_d___s_t_r_i_n_g_=_n_e_w___s_t_r_i_n_g + [4m:old_string=new_string[0m This is the AT&T System V UNIX style variable substitution. It must - be the last modifier specified. If _o_l_d___s_t_r_i_n_g or _n_e_w___s_t_r_i_n_g do not - contain the pattern matching character _% then it is assumed that + be the last modifier specified. If [4mold_string[24m or [4mnew_string[24m do not + contain the pattern matching character [4m%[24m then it is assumed that they are anchored at the end of each word, so only suffixes or - entire words may be replaced. Otherwise _% is the substring of - _o_l_d___s_t_r_i_n_g to be replaced in _n_e_w___s_t_r_i_n_g. + entire words may be replaced. Otherwise [4m%[24m is the substring of + [4mold_string[24m to be replaced in [4mnew_string[24m. Variable expansion occurs in the normal fashion inside both - _o_l_d___s_t_r_i_n_g and _n_e_w___s_t_r_i_n_g with the single exception that a backslash + [4mold_string[24m and [4mnew_string[24m with the single exception that a backslash is used to prevent the expansion of a dollar sign (`$'), not a pre- ceding dollar sign as is usual. - ::@@_t_e_m_p@@_s_t_r_i_n_g@@ + [1m:@[4m[22mtemp[24m[1m@[4m[22mstring[24m[1m@[0m This is the loop expansion mechanism from the OSF Development Envi- - ronment (ODE) make. Unlike ..ffoorr loops expansion occurs at the time - of reference. Assign _t_e_m_p to each word in the variable and evaluate - _s_t_r_i_n_g. The ODE convention is that _t_e_m_p should start and end with a + ronment (ODE) make. Unlike [1m.for [22mloops expansion occurs at the time + of reference. Assign [4mtemp[24m to each word in the variable and evaluate + [4mstring[24m. The ODE convention is that [4mtemp[24m should start and end with a period. For example. ${LINKS:@.LINK.@${LN} ${TARGET} ${.LINK.}@} However a single character variable is often more readable: ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@} - ::UU_n_e_w_v_a_l - If the variable is undefined _n_e_w_v_a_l is the value. If the variable + [1m:_[=var][0m + Save the current variable value in `$_' or the named [4mvar[24m for later + reference. Example usage: + + M_cmpv.units = 1 1000 1000000 + M_cmpv = S,., ,g:_:range:@i@+ $${_:[-$$i]} \ + \* $${M_cmpv.units:[$$i]}@:S,^,expr 0 ,1:sh + + .if ${VERSION:${M_cmpv}} < ${3.1.12:L:${M_cmpv}} + + Here `$_' is used to save the result of the `:S' modifier which is + later referenced using the index values from `:range'. + + [1m:U[4m[22mnewval[0m + If the variable is undefined [4mnewval[24m is the value. If the variable is defined, the existing value is returned. This is another ODE make feature. It is handy for setting per-target CFLAGS for instance: @@ -872,134 +943,144 @@ VVAARRIIAABBLLEE AASSSSIIGGNNMMEENNTTSS If a value is only required if the variable is undefined, use: ${VAR:D:Unewval} - ::DD_n_e_w_v_a_l - If the variable is defined _n_e_w_v_a_l is the value. + [1m:D[4m[22mnewval[0m + If the variable is defined [4mnewval[24m is the value. - ::LL The name of the variable is the value. + [1m:L [22mThe name of the variable is the value. - ::PP The path of the node which has the same name as the variable is the + [1m:P [22mThe path of the node which has the same name as the variable is the value. If no such node exists or its path is null, then the name of the variable is used. In order for this modifier to work, the name (node) must at least have appeared on the rhs of a dependency. - ::!!_c_m_d!! - The output of running _c_m_d is the value. + [1m:![4m[22mcmd[24m[1m![0m + The output of running [4mcmd[24m is the value. - ::sshh If the variable is non-empty it is run as a command and the output + [1m:sh [22mIf the variable is non-empty it is run as a command and the output becomes the new value. - ::::==_s_t_r - The variable is assigned the value _s_t_r after substitution. This + [1m::=[4m[22mstr[0m + The variable is assigned the value [4mstr[24m after substitution. This modifier and its variations are useful in obscure situations such as wanting to set a variable when shell commands are being parsed. These assignment modifiers always expand to nothing, so if appearing in a rule line by themselves should be preceded with something to - keep bbmmaakkee happy. + keep [1mbmake [22mhappy. - The `::::' helps avoid false matches with the AT&T System V UNIX style - ::== modifier and since substitution always occurs the ::::== form is + The `[1m::[22m' helps avoid false matches with the AT&T System V UNIX style + [1m:= [22mmodifier and since substitution always occurs the [1m::= [22mform is vaguely appropriate. - ::::??==_s_t_r - As for ::::== but only if the variable does not already have a value. + [1m::?=[4m[22mstr[0m + As for [1m::= [22mbut only if the variable does not already have a value. - ::::++==_s_t_r - Append _s_t_r to the variable. + [1m::+=[4m[22mstr[0m + Append [4mstr[24m to the variable. - ::::!!==_c_m_d - Assign the output of _c_m_d to the variable. + [1m::!=[4m[22mcmd[0m + Assign the output of [4mcmd[24m to the variable. - ::[[_r_a_n_g_e]] + [1m:[[4m[22mrange[24m[1m][0m Selects one or more words from the value, or performs other opera- tions related to the way in which the value is divided into words. Ordinarily, a value is treated as a sequence of words delimited by - white space. Some modifiers suppress this behaviour, causing a - value to be treated as a single word (possibly containing embedded - white space). An empty value, or a value that consists entirely of - white-space, is treated as a single word. For the purposes of the - `::[[]]' modifier, the words are indexed both forwards using positive - integers (where index 1 represents the first word), and backwards - using negative integers (where index -1 represents the last word). - - The _r_a_n_g_e is subjected to variable expansion, and the expanded + white space. Some modifiers suppress this behavior, causing a value + to be treated as a single word (possibly containing embedded white + space). An empty value, or a value that consists entirely of white- + space, is treated as a single word. For the purposes of the `[1m:[][22m' + modifier, the words are indexed both forwards using positive inte- + gers (where index 1 represents the first word), and backwards using + negative integers (where index -1 represents the last word). + + The [4mrange[24m is subjected to variable expansion, and the expanded result is then interpreted as follows: - _i_n_d_e_x Selects a single word from the value. + [4mindex[24m Selects a single word from the value. - _s_t_a_r_t...._e_n_d - Selects all words from _s_t_a_r_t to _e_n_d, inclusive. For example, - `::[[22....--11]]' selects all words from the second word to the last - word. If _s_t_a_r_t is greater than _e_n_d, then the words are out- - put in reverse order. For example, `::[[--11....11]]' selects all + [4mstart[24m[1m..[4m[22mend[0m + Selects all words from [4mstart[24m to [4mend[24m, inclusive. For example, + `[1m:[2..-1][22m' selects all words from the second word to the last + word. If [4mstart[24m is greater than [4mend[24m, then the words are out- + put in reverse order. For example, `[1m:[-1..1][22m' selects all the words from last to first. - ** Causes subsequent modifiers to treat the value as a single + [1m* [22mCauses subsequent modifiers to treat the value as a single word (possibly containing embedded white space). Analogous to the effect of "$*" in Bourne shell. - 0 Means the same as `::[[**]]'. + 0 Means the same as `[1m:[*][22m'. - @@ Causes subsequent modifiers to treat the value as a sequence + [1m@ [22mCauses subsequent modifiers to treat the value as a sequence of words delimited by white space. Analogous to the effect of "$@" in Bourne shell. - ## Returns the number of words in the value. + [1m# [22mReturns the number of words in the value. -IINNCCLLUUDDEE SSTTAATTEEMMEENNTTSS,, CCOONNDDIITTIIOONNAALLSS AANNDD FFOORR LLOOOOPPSS +[1mINCLUDE STATEMENTS, CONDITIONALS AND FOR LOOPS[0m Makefile inclusion, conditional structures and for loops reminiscent of - the C programming language are provided in bbmmaakkee. All such structures + the C programming language are provided in [1mbmake[22m. All such structures are identified by a line beginning with a single dot (`.') character. - Files are included with either ..iinncclluuddee <_f_i_l_e> or ..iinncclluuddee "_f_i_l_e". Vari- + Files are included with either [1m.include [22m<[4mfile[24m> or [1m.include [22m"[4mfile[24m". Vari- ables between the angle brackets or double quotes are expanded to form the file name. If angle brackets are used, the included makefile is expected to be in the system makefile directory. If double quotes are used, the including makefile's directory and any directories specified - using the --II option are searched before the system makefile directory. - For compatibility with other versions of bbmmaakkee `include file ...' is also - accepted. If the include statement is written as ..--iinncclluuddee or as - ..ssiinncclluuddee then errors locating and/or opening include files are ignored. + using the [1m-I [22moption are searched before the system makefile directory. + For compatibility with other versions of [1mbmake [22m`include file ...' is also + accepted. + + If the include statement is written as [1m.-include [22mor as [1m.sinclude [22mthen + errors locating and/or opening include files are ignored. + + If the include statement is written as [1m.dinclude [22mnot only are errors + locating and/or opening include files ignored, but stale dependencies + within the included file will be ignored just like [4m.MAKE.DEPENDFILE[24m. Conditional expressions are also preceded by a single dot as the first character of a line. The possible conditionals are as follows: - ..eerrrroorr _m_e_s_s_a_g_e + [1m.error [4m[22mmessage[0m The message is printed along with the name of the makefile and - line number, then bbmmaakkee will exit. + line number, then [1mbmake [22mwill exit. - ..eexxppoorrtt _v_a_r_i_a_b_l_e _._._. + [1m.export [4m[22mvariable[24m [4m...[0m Export the specified global variable. If no variable list is provided, all globals are exported except for internal variables - (those that start with `.'). This is not affected by the --XX + (those that start with `.'). This is not affected by the [1m-X[0m flag, so should be used with caution. For compatibility with - other bbmmaakkee programs `export variable=value' is also accepted. + other [1mbmake [22mprograms `export variable=value' is also accepted. - Appending a variable name to _._M_A_K_E_._E_X_P_O_R_T_E_D is equivalent to + Appending a variable name to [4m.MAKE.EXPORTED[24m is equivalent to exporting a variable. - ..eexxppoorrtt--eennvv _v_a_r_i_a_b_l_e _._._. + [1m.export-env [4m[22mvariable[24m [4m...[0m The same as `.export', except that the variable is not appended - to _._M_A_K_E_._E_X_P_O_R_T_E_D. This allows exporting a value to the environ- - ment which is different from that used by bbmmaakkee internally. + to [4m.MAKE.EXPORTED[24m. This allows exporting a value to the environ- + ment which is different from that used by [1mbmake [22minternally. - ..iinnffoo _m_e_s_s_a_g_e + [1m.export-literal [4m[22mvariable[24m [4m...[0m + The same as `.export-env', except that variables in the value are + not expanded. + + [1m.info [4m[22mmessage[0m The message is printed along with the name of the makefile and line number. - ..uunnddeeff _v_a_r_i_a_b_l_e + [1m.undef [4m[22mvariable[0m Un-define the specified global variable. Only global variables may be un-defined. - ..uunneexxppoorrtt _v_a_r_i_a_b_l_e _._._. - The opposite of `.export'. The specified global _v_a_r_i_a_b_l_e will be - removed from _._M_A_K_E_._E_X_P_O_R_T_E_D. If no variable list is provided, - all globals are unexported, and _._M_A_K_E_._E_X_P_O_R_T_E_D deleted. + [1m.unexport [4m[22mvariable[24m [4m...[0m + The opposite of `.export'. The specified global [4mvariable[24m will be + removed from [4m.MAKE.EXPORTED[24m. If no variable list is provided, + all globals are unexported, and [4m.MAKE.EXPORTED[24m deleted. - ..uunneexxppoorrtt--eennvv + [1m.unexport-env[0m Unexport all globals previously exported and clear the environ- ment inherited from the parent. This operation will cause a mem- ory leak of the original environment, so should be used spar- - ingly. Testing for _._M_A_K_E_._L_E_V_E_L being 0, would make sense. Also + ingly. Testing for [4m.MAKE.LEVEL[24m being 0, would make sense. Also note that any variables which originated in the parent environ- ment should be explicitly preserved if desired. For example: @@ -1013,148 +1094,148 @@ IINNCCLLUUDDEE SSTTAATTEEMMEENNTTSS,, CCOONNDDIITTIIOO the minimal useful environment. Actually `.MAKE.LEVEL' will also be pushed into the new environment. - ..wwaarrnniinngg _m_e_s_s_a_g_e - The message prefixed by `_w_a_r_n_i_n_g_:' is printed along with the name + [1m.warning [4m[22mmessage[0m + The message prefixed by `[4mwarning:[24m' is printed along with the name of the makefile and line number. - ..iiff [!]_e_x_p_r_e_s_s_i_o_n [_o_p_e_r_a_t_o_r _e_x_p_r_e_s_s_i_o_n _._._.] + [1m.if [22m[!][4mexpression[24m [[4moperator[24m [4mexpression[24m [4m...[24m] Test the value of an expression. - ..iiffddeeff [!]_v_a_r_i_a_b_l_e [_o_p_e_r_a_t_o_r _v_a_r_i_a_b_l_e _._._.] + [1m.ifdef [22m[!][4mvariable[24m [[4moperator[24m [4mvariable[24m [4m...[24m] Test the value of a variable. - ..iiffnnddeeff [!]_v_a_r_i_a_b_l_e [_o_p_e_r_a_t_o_r _v_a_r_i_a_b_l_e _._._.] + [1m.ifndef [22m[!][4mvariable[24m [[4moperator[24m [4mvariable[24m [4m...[24m] Test the value of a variable. - ..iiffmmaakkee [!]_t_a_r_g_e_t [_o_p_e_r_a_t_o_r _t_a_r_g_e_t _._._.] + [1m.ifmake [22m[!][4mtarget[24m [[4moperator[24m [4mtarget[24m [4m...[24m] Test the target being built. - ..iiffnnmmaakkee [!] _t_a_r_g_e_t [_o_p_e_r_a_t_o_r _t_a_r_g_e_t _._._.] + [1m.ifnmake [22m[!] [4mtarget[24m [[4moperator[24m [4mtarget[24m [4m...[24m] Test the target being built. - ..eellssee Reverse the sense of the last conditional. + [1m.else [22mReverse the sense of the last conditional. - ..eelliiff [!] _e_x_p_r_e_s_s_i_o_n [_o_p_e_r_a_t_o_r _e_x_p_r_e_s_s_i_o_n _._._.] - A combination of `..eellssee' followed by `..iiff'. + [1m.elif [22m[!] [4mexpression[24m [[4moperator[24m [4mexpression[24m [4m...[24m] + A combination of `[1m.else[22m' followed by `[1m.if[22m'. - ..eelliiffddeeff [!]_v_a_r_i_a_b_l_e [_o_p_e_r_a_t_o_r _v_a_r_i_a_b_l_e _._._.] - A combination of `..eellssee' followed by `..iiffddeeff'. + [1m.elifdef [22m[!][4mvariable[24m [[4moperator[24m [4mvariable[24m [4m...[24m] + A combination of `[1m.else[22m' followed by `[1m.ifdef[22m'. - ..eelliiffnnddeeff [!]_v_a_r_i_a_b_l_e [_o_p_e_r_a_t_o_r _v_a_r_i_a_b_l_e _._._.] - A combination of `..eellssee' followed by `..iiffnnddeeff'. + [1m.elifndef [22m[!][4mvariable[24m [[4moperator[24m [4mvariable[24m [4m...[24m] + A combination of `[1m.else[22m' followed by `[1m.ifndef[22m'. - ..eelliiffmmaakkee [!]_t_a_r_g_e_t [_o_p_e_r_a_t_o_r _t_a_r_g_e_t _._._.] - A combination of `..eellssee' followed by `..iiffmmaakkee'. + [1m.elifmake [22m[!][4mtarget[24m [[4moperator[24m [4mtarget[24m [4m...[24m] + A combination of `[1m.else[22m' followed by `[1m.ifmake[22m'. - ..eelliiffnnmmaakkee [!]_t_a_r_g_e_t [_o_p_e_r_a_t_o_r _t_a_r_g_e_t _._._.] - A combination of `..eellssee' followed by `..iiffnnmmaakkee'. + [1m.elifnmake [22m[!][4mtarget[24m [[4moperator[24m [4mtarget[24m [4m...[24m] + A combination of `[1m.else[22m' followed by `[1m.ifnmake[22m'. - ..eennddiiff End the body of the conditional. + [1m.endif [22mEnd the body of the conditional. - The _o_p_e_r_a_t_o_r may be any one of the following: + The [4moperator[24m may be any one of the following: - |||| Logical OR. + [1m|| [22mLogical OR. - &&&& Logical AND; of higher precedence than ``||''. + [1m&& [22mLogical AND; of higher precedence than ``||''. - As in C, bbmmaakkee will only evaluate a conditional as far as is necessary to + As in C, [1mbmake [22mwill only evaluate a conditional as far as is necessary to determine its value. Parentheses may be used to change the order of - evaluation. The boolean operator `!!' may be used to logically negate an - entire conditional. It is of higher precedence than `&&&&'. + evaluation. The boolean operator `[1m![22m' may be used to logically negate an + entire conditional. It is of higher precedence than `[1m&&[22m'. - The value of _e_x_p_r_e_s_s_i_o_n may be any of the following: + The value of [4mexpression[24m may be any of the following: - ddeeffiinneedd Takes a variable name as an argument and evaluates to true if + [1mdefined [22mTakes a variable name as an argument and evaluates to true if the variable has been defined. - mmaakkee Takes a target name as an argument and evaluates to true if the - target was specified as part of bbmmaakkee's command line or was + [1mmake [22mTakes a target name as an argument and evaluates to true if the + target was specified as part of [1mbmake[22m's command line or was declared the default target (either implicitly or explicitly, - see _._M_A_I_N) before the line containing the conditional. + see [4m.MAIN[24m) before the line containing the conditional. - eemmppttyy Takes a variable, with possible modifiers, and evaluates to true + [1mempty [22mTakes a variable, with possible modifiers, and evaluates to true if the expansion of the variable would result in an empty string. - eexxiissttss Takes a file name as an argument and evaluates to true if the + [1mexists [22mTakes a file name as an argument and evaluates to true if the file exists. The file is searched for on the system search path - (see _._P_A_T_H). + (see [4m.PATH[24m). - ttaarrggeett Takes a target name as an argument and evaluates to true if the + [1mtarget [22mTakes a target name as an argument and evaluates to true if the target has been defined. - ccoommmmaannddss + [1mcommands[0m Takes a target name as an argument and evaluates to true if the target has been defined and has commands associated with it. - _E_x_p_r_e_s_s_i_o_n may also be an arithmetic or string comparison. Variable + [4mExpression[24m may also be an arithmetic or string comparison. Variable expansion is performed on both sides of the comparison, after which the integral values are compared. A value is interpreted as hexadecimal if it is preceded by 0x, otherwise it is decimal; octal numbers are not sup- ported. The standard C relational operators are all supported. If after - variable expansion, either the left or right hand side of a `====' or `!!==' + variable expansion, either the left or right hand side of a `[1m==[22m' or `[1m!=[22m' operator is not an integral value, then string comparison is performed between the expanded variables. If no relational operator is given, it is assumed that the expanded variable is being compared against 0 or an empty string in the case of a string comparison. - When bbmmaakkee is evaluating one of these conditional expressions, and it + When [1mbmake [22mis evaluating one of these conditional expressions, and it encounters a (white-space separated) word it doesn't recognize, either the ``make'' or ``defined'' expression is applied to it, depending on the - form of the conditional. If the form is `..iiffddeeff', `..iiffnnddeeff', or `..iiff' + form of the conditional. If the form is `[1m.ifdef[22m', `[1m.ifndef[22m', or `[1m.if[22m' the ``defined'' expression is applied. Similarly, if the form is - `..iiffmmaakkee' or `..iiffnnmmaakkee, tthhee' ``make'' expression is applied. + `[1m.ifmake[22m' or `[1m.ifnmake[22m, [1mthe[22m' ``make'' expression is applied. If the conditional evaluates to true the parsing of the makefile contin- ues as before. If it evaluates to false, the following lines are - skipped. In both cases this continues until a `..eellssee' or `..eennddiiff' is + skipped. In both cases this continues until a `[1m.else[22m' or `[1m.endif[22m' is found. For loops are typically used to apply a set of rules to a list of files. The syntax of a for loop is: - ..ffoorr _v_a_r_i_a_b_l_e [_v_a_r_i_a_b_l_e _._._.] iinn _e_x_p_r_e_s_s_i_o_n + [1m.for [4m[22mvariable[24m [[4mvariable[24m [4m...[24m] [1min [4m[22mexpression[0m <make-rules> - ..eennddffoorr + [1m.endfor[0m - After the for eexxpprreessssiioonn is evaluated, it is split into words. On each - iteration of the loop, one word is taken and assigned to each vvaarriiaabbllee, - in order, and these vvaarriiaabblleess are substituted into the mmaakkee--rruulleess inside + After the for [1mexpression [22mis evaluated, it is split into words. On each + iteration of the loop, one word is taken and assigned to each [1mvariable[22m, + in order, and these [1mvariables [22mare substituted into the [1mmake-rules [22minside the body of the for loop. The number of words must come out even; that is, if there are three iteration variables, the number of words provided must be a multiple of three. -CCOOMMMMEENNTTSS +[1mCOMMENTS[0m Comments begin with a hash (`#') character, anywhere but in a shell com- mand line, and continue to the end of an unescaped new line. -SSPPEECCIIAALL SSOOUURRCCEESS ((AATTTTRRIIBBUUTTEESS)) - ..EEXXEECC Target is never out of date, but always execute commands any- +[1mSPECIAL SOURCES (ATTRIBUTES)[0m + [1m.EXEC [22mTarget is never out of date, but always execute commands any- way. - ..IIGGNNOORREE Ignore any errors from the commands associated with this tar- + [1m.IGNORE [22mIgnore any errors from the commands associated with this tar- get, exactly as if they all were preceded by a dash (`-'). - ..MMAADDEE Mark all sources of this target as being up-to-date. + [1m.MADE [22mMark all sources of this target as being up-to-date. - ..MMAAKKEE Execute the commands associated with this target even if the --nn - or --tt options were specified. Normally used to mark recursive - bbmmaakkees. + [1m.MAKE [22mExecute the commands associated with this target even if the [1m-n[0m + or [1m-t [22moptions were specified. Normally used to mark recursive + [1mbmake[22ms. - ..MMEETTAA Create a meta file for the target, even if it is flagged as - ..PPHHOONNYY, ..MMAAKKEE, or ..SSPPEECCIIAALL. Usage in conjunction with ..MMAAKKEE is + [1m.META [22mCreate a meta file for the target, even if it is flagged as + [1m.PHONY[22m, [1m.MAKE[22m, or [1m.SPECIAL[22m. Usage in conjunction with [1m.MAKE [22mis the most likely case. In "meta" mode, the target is out-of- date if the meta file is missing. - ..NNOOMMEETTAA Do not create a meta file for the target. Meta files are also - not created for ..PPHHOONNYY, ..MMAAKKEE, or ..SSPPEECCIIAALL targets. + [1m.NOMETA [22mDo not create a meta file for the target. Meta files are also + not created for [1m.PHONY[22m, [1m.MAKE[22m, or [1m.SPECIAL [22mtargets. - ..NNOOMMEETTAA__CCMMPP + [1m.NOMETA_CMP[0m Ignore differences in commands when deciding if target is out of date. This is useful if the command contains a value which always changes. If the number of commands change, though, the target will still be out of date. The same effect applies to - any command line that uses the variable _._O_O_D_A_T_E, which can be + any command line that uses the variable [4m.OODATE[24m, which can be used for that purpose even when not otherwise needed or desired: @@ -1164,48 +1245,48 @@ SSPPEECCIIAALL SSOOUURRCCEESS ((AATTTTRRIIBBUUTTEESS)) @echo this will not ${.OODATE:M.NOMETA_CMP} @echo this will also be compared - The ::MM pattern suppresses any expansion of the unwanted vari- + The [1m:M [22mpattern suppresses any expansion of the unwanted vari- able. - ..NNOOPPAATTHH Do not search for the target in the directories specified by - ..PPAATTHH. + [1m.NOPATH [22mDo not search for the target in the directories specified by + [1m.PATH[22m. - ..NNOOTTMMAAIINN Normally bbmmaakkee selects the first target it encounters as the + [1m.NOTMAIN [22mNormally [1mbmake [22mselects the first target it encounters as the default target to be built if no target was specified. This source prevents this target from being selected. - ..OOPPTTIIOONNAALL - If a target is marked with this attribute and bbmmaakkee can't fig- + [1m.OPTIONAL[0m + If a target is marked with this attribute and [1mbmake [22mcan't fig- ure out how to create it, it will ignore this fact and assume the file isn't needed or already exists. - ..PPHHOONNYY The target does not correspond to an actual file; it is always + [1m.PHONY [22mThe target does not correspond to an actual file; it is always considered to be out of date, and will not be created with the - --tt option. Suffix-transformation rules are not applied to - ..PPHHOONNYY targets. + [1m-t [22moption. Suffix-transformation rules are not applied to + [1m.PHONY [22mtargets. - ..PPRREECCIIOOUUSS - When bbmmaakkee is interrupted, it normally removes any partially + [1m.PRECIOUS[0m + When [1mbmake [22mis interrupted, it normally removes any partially made targets. This source prevents the target from being removed. - ..RREECCUURRSSIIVVEE - Synonym for ..MMAAKKEE. + [1m.RECURSIVE[0m + Synonym for [1m.MAKE[22m. - ..SSIILLEENNTT Do not echo any of the commands associated with this target, + [1m.SILENT [22mDo not echo any of the commands associated with this target, exactly as if they all were preceded by an at sign (`@'). - ..UUSSEE Turn the target into bbmmaakkee's version of a macro. When the tar- + [1m.USE [22mTurn the target into [1mbmake[22m's version of a macro. When the tar- get is used as a source for another target, the other target acquires the commands, sources, and attributes (except for - ..UUSSEE) of the source. If the target already has commands, the - ..UUSSEE target's commands are appended to them. + [1m.USE[22m) of the source. If the target already has commands, the + [1m.USE [22mtarget's commands are appended to them. - ..UUSSEEBBEEFFOORREE - Exactly like ..UUSSEE, but prepend the ..UUSSEEBBEEFFOORREE target commands + [1m.USEBEFORE[0m + Exactly like [1m.USE[22m, but prepend the [1m.USEBEFORE [22mtarget commands to the target. - ..WWAAIITT If ..WWAAIITT appears in a dependency line, the sources that precede + [1m.WAIT [22mIf [1m.WAIT [22mappears in a dependency line, the sources that precede it are made before the sources that succeed it in the line. Since the dependents of files are not made until the file itself could be made, this also stops the dependents being @@ -1222,56 +1303,67 @@ SSPPEECCIIAALL SSOOUURRCCEESS ((AATTTTRRIIBBUUTTEESS)) echo b1 the output is always `a', `b1', `b', `x'. - The ordering imposed by ..WWAAIITT is only relevant for parallel + The ordering imposed by [1m.WAIT [22mis only relevant for parallel makes. -SSPPEECCIIAALL TTAARRGGEETTSS +[1mSPECIAL TARGETS[0m Special targets may not be included with other targets, i.e. they must be the only target specified. - ..BBEEGGIINN Any command lines attached to this target are executed before + [1m.BEGIN [22mAny command lines attached to this target are executed before anything else is done. - ..DDEEFFAAUULLTT - This is sort of a ..UUSSEE rule for any target (that was used only - as a source) that bbmmaakkee can't figure out any other way to cre- - ate. Only the shell script is used. The ..IIMMPPSSRRCC variable of a - target that inherits ..DDEEFFAAUULLTT's commands is set to the target's + [1m.DEFAULT[0m + This is sort of a [1m.USE [22mrule for any target (that was used only + as a source) that [1mbmake [22mcan't figure out any other way to cre- + ate. Only the shell script is used. The [1m.IMPSRC [22mvariable of a + target that inherits [1m.DEFAULT[22m's commands is set to the target's own name. - ..EENNDD Any command lines attached to this target are executed after + [1m.DELETE_ON_ERROR[0m + If this target is present in the makefile, it globally causes + make to delete targets whose commands fail. (By default, only + targets whose commands are interrupted during execution are + deleted. This is the historical behavior.) This setting can be + used to help prevent half-finished or malformed targets from + being left around and corrupting future rebuilds. + + [1m.END [22mAny command lines attached to this target are executed after everything else is done. - ..EERRRROORR Any command lines attached to this target are executed when - another target fails. The ..EERRRROORR__TTAARRGGEETT variable is set to the - target that failed. See also MMAAKKEE__PPRRIINNTT__VVAARR__OONN__EERRRROORR. + [1m.ERROR [22mAny command lines attached to this target are executed when + another target fails. The [1m.ERROR_TARGET [22mvariable is set to the + target that failed. See also [1mMAKE_PRINT_VAR_ON_ERROR[22m. - ..IIGGNNOORREE Mark each of the sources with the ..IIGGNNOORREE attribute. If no + [1m.IGNORE [22mMark each of the sources with the [1m.IGNORE [22mattribute. If no sources are specified, this is the equivalent of specifying the - --ii option. + [1m-i [22moption. - ..IINNTTEERRRRUUPPTT - If bbmmaakkee is interrupted, the commands for this target will be + [1m.INTERRUPT[0m + If [1mbmake [22mis interrupted, the commands for this target will be executed. - ..MMAAIINN If no target is specified when bbmmaakkee is invoked, this target + [1m.MAIN [22mIf no target is specified when [1mbmake [22mis invoked, this target will be built. - ..MMAAKKEEFFLLAAGGSS - This target provides a way to specify flags for bbmmaakkee when the + [1m.MAKEFLAGS[0m + This target provides a way to specify flags for [1mbmake [22mwhen the makefile is used. The flags are as if typed to the shell, - though the --ff option will have no effect. + though the [1m-f [22moption will have no effect. - ..NNOOPPAATTHH Apply the ..NNOOPPAATTHH attribute to any specified sources. + [1m.NOPATH [22mApply the [1m.NOPATH [22mattribute to any specified sources. - ..NNOOTTPPAARRAALLLLEELL + [1m.NOTPARALLEL[0m Disable parallel mode. - ..NNOO__PPAARRAALLLLEELL - Synonym for ..NNOOTTPPAARRAALLLLEELL, for compatibility with other pmake + [1m.NO_PARALLEL[0m + Synonym for [1m.NOTPARALLEL[22m, for compatibility with other pmake variants. - ..OORRDDEERR The named targets are made in sequence. This ordering does not + [1m.OBJDIR [22mThe source is a new value for `[4m.OBJDIR[24m'. If it exists, [1mbmake[0m + will chdir(2) to it and update the value of `[4m.OBJDIR[24m'. + + [1m.ORDER [22mThe named targets are made in sequence. This ordering does not add targets to the list of targets to be made. Since the depen- dents of a target do not get built until the target itself could be built, unless `a' is built by another part of the dependency @@ -1280,54 +1372,54 @@ SSPPEECCIIAALL TTAARRGGEETTSS .ORDER: b a b: a - The ordering imposed by ..OORRDDEERR is only relevant for parallel + The ordering imposed by [1m.ORDER [22mis only relevant for parallel makes. - ..PPAATTHH The sources are directories which are to be searched for files + [1m.PATH [22mThe sources are directories which are to be searched for files not found in the current directory. If no sources are speci- fied, any previously specified directories are deleted. If the - source is the special ..DDOOTTLLAASSTT target, then the current working + source is the special [1m.DOTLAST [22mtarget, then the current working directory is searched last. - ..PPAATTHH.._s_u_f_f_i_x - Like ..PPAATTHH but applies only to files with a particular suffix. - The suffix must have been previously declared with ..SSUUFFFFIIXXEESS. + [1m.PATH.[4m[22msuffix[0m + Like [1m.PATH [22mbut applies only to files with a particular suffix. + The suffix must have been previously declared with [1m.SUFFIXES[22m. - ..PPHHOONNYY Apply the ..PPHHOONNYY attribute to any specified sources. + [1m.PHONY [22mApply the [1m.PHONY [22mattribute to any specified sources. - ..PPRREECCIIOOUUSS - Apply the ..PPRREECCIIOOUUSS attribute to any specified sources. If no - sources are specified, the ..PPRREECCIIOOUUSS attribute is applied to + [1m.PRECIOUS[0m + Apply the [1m.PRECIOUS [22mattribute to any specified sources. If no + sources are specified, the [1m.PRECIOUS [22mattribute is applied to every target in the file. - ..SSHHEELLLL Sets the shell that bbmmaakkee will use to execute commands. The - sources are a set of _f_i_e_l_d_=_v_a_l_u_e pairs. + [1m.SHELL [22mSets the shell that [1mbmake [22mwill use to execute commands. The + sources are a set of [4mfield=value[24m pairs. - _n_a_m_e This is the minimal specification, used to select - one of the builtin shell specs; _s_h, _k_s_h, and _c_s_h. + [4mname[24m This is the minimal specification, used to select + one of the built-in shell specs; [4msh[24m, [4mksh[24m, and [4mcsh[24m. - _p_a_t_h Specifies the path to the shell. + [4mpath[24m Specifies the path to the shell. - _h_a_s_E_r_r_C_t_l Indicates whether the shell supports exit on error. + [4mhasErrCtl[24m Indicates whether the shell supports exit on error. - _c_h_e_c_k The command to turn on error checking. + [4mcheck[24m The command to turn on error checking. - _i_g_n_o_r_e The command to disable error checking. + [4mignore[24m The command to disable error checking. - _e_c_h_o The command to turn on echoing of commands executed. + [4mecho[24m The command to turn on echoing of commands executed. - _q_u_i_e_t The command to turn off echoing of commands exe- + [4mquiet[24m The command to turn off echoing of commands exe- cuted. - _f_i_l_t_e_r The output to filter after issuing the _q_u_i_e_t com- - mand. It is typically identical to _q_u_i_e_t. + [4mfilter[24m The output to filter after issuing the [4mquiet[24m com- + mand. It is typically identical to [4mquiet[24m. - _e_r_r_F_l_a_g The flag to pass the shell to enable error checking. + [4merrFlag[24m The flag to pass the shell to enable error checking. - _e_c_h_o_F_l_a_g The flag to pass the shell to enable command echo- + [4mechoFlag[24m The flag to pass the shell to enable command echo- ing. - _n_e_w_l_i_n_e The string literal to pass the shell that results in + [4mnewline[24m The string literal to pass the shell that results in a single newline character when used outside of any quoting characters. Example: @@ -1337,15 +1429,15 @@ SSPPEECCIIAALL TTAARRGGEETTSS echo="set -v" quiet="set +v" filter="set +v" \ echoFlag=v errFlag=e newline="'\n'" - ..SSIILLEENNTT Apply the ..SSIILLEENNTT attribute to any specified sources. If no - sources are specified, the ..SSIILLEENNTT attribute is applied to every + [1m.SILENT [22mApply the [1m.SILENT [22mattribute to any specified sources. If no + sources are specified, the [1m.SILENT [22mattribute is applied to every command in the file. - ..SSTTAALLEE This target gets run when a dependency file contains stale - entries, having _._A_L_L_S_R_C set to the name of that dependency file. + [1m.STALE [22mThis target gets run when a dependency file contains stale + entries, having [4m.ALLSRC[24m set to the name of that dependency file. - ..SSUUFFFFIIXXEESS - Each source specifies a suffix to bbmmaakkee. If no sources are + [1m.SUFFIXES[0m + Each source specifies a suffix to [1mbmake[22m. If no sources are specified, any previously specified suffixes are deleted. It allows the creation of suffix-transformation rules. @@ -1355,29 +1447,29 @@ SSPPEECCIIAALL TTAARRGGEETTSS .c.o: cc -o ${.TARGET} -c ${.IMPSRC} -EENNVVIIRROONNMMEENNTT - bbmmaakkee uses the following environment variables, if they exist: MACHINE, +[1mENVIRONMENT[0m + [1mbmake [22muses the following environment variables, if they exist: MACHINE, MACHINE_ARCH, MAKE, MAKEFLAGS, MAKEOBJDIR, MAKEOBJDIRPREFIX, MAKESYSPATH, PWD, and TMPDIR. MAKEOBJDIRPREFIX and MAKEOBJDIR may only be set in the environment or on - the command line to bbmmaakkee and not as makefile variables; see the descrip- - tion of `_._O_B_J_D_I_R' for more details. + the command line to [1mbmake [22mand not as makefile variables; see the descrip- + tion of `[4m.OBJDIR[24m' for more details. -FFIILLEESS +[1mFILES[0m .depend list of dependencies Makefile list of dependencies makefile list of dependencies sys.mk system makefile /usr/share/mk system makefile directory -CCOOMMPPAATTIIBBIILLIITTYY +[1mCOMPATIBILITY[0m The basic make syntax is compatible between different versions of make; however the special variables, variable modifiers and conditionals are not. - OOllddeerr vveerrssiioonnss - An incomplete list of changes in older versions of bbmmaakkee: + [1mOlder versions[0m + An incomplete list of changes in older versions of [1mbmake[22m: The way that .for loop variables are substituted changed after NetBSD 5.0 so that they still appear to be variable expansions. In particular this @@ -1388,47 +1480,47 @@ CCOOMMPPAATTIIBBIILLIITTYY .ORDER and .WAIT apply recursively to the dependent nodes. The algo- rithms used may change again in the future. - OOtthheerr mmaakkee ddiiaalleeccttss + [1mOther make dialects[0m Other make dialects (GNU make, SVR4 make, POSIX make, etc.) do not sup- - port most of the features of bbmmaakkee as described in this manual. Most + port most of the features of [1mbmake [22mas described in this manual. Most notably: - ++oo The ..WWAAIITT and ..OORRDDEERR declarations and most functionality per- + [1m+o [22mThe [1m.WAIT [22mand [1m.ORDER [22mdeclarations and most functionality per- taining to parallelization. (GNU make supports parallelization but lacks these features needed to control it effectively.) - ++oo Directives, including for loops and conditionals and most of + [1m+o [22mDirectives, including for loops and conditionals and most of the forms of include files. (GNU make has its own incompatible and less powerful syntax for conditionals.) - ++oo All built-in variables that begin with a dot. + [1m+o [22mAll built-in variables that begin with a dot. - ++oo Most of the special sources and targets that begin with a dot, - with the notable exception of ..PPHHOONNYY, ..PPRREECCIIOOUUSS, and ..SSUUFFFFIIXXEESS. + [1m+o [22mMost of the special sources and targets that begin with a dot, + with the notable exception of [1m.PHONY[22m, [1m.PRECIOUS[22m, and [1m.SUFFIXES[22m. - ++oo Variable modifiers, except for the + [1m+o [22mVariable modifiers, except for the :old=new string substitution, which does not portably support globbing with `%' and historically only works on declared suffixes. - ++oo The $$>> variable even in its short form; most makes support this + [1m+o [22mThe [1m$> [22mvariable even in its short form; most makes support this functionality but its name varies. - Some features are somewhat more portable, such as assignment with ++==, ??==, - and !!==. The ..PPAATTHH functionality is based on an older feature VVPPAATTHH found + Some features are somewhat more portable, such as assignment with [1m+=[22m, [1m?=[22m, + and [1m!=[22m. The [1m.PATH [22mfunctionality is based on an older feature [1mVPATH [22mfound in GNU make and many versions of SVR4 make; however, historically its behavior is too ill-defined (and too buggy) to rely upon. - The $$@@ and $$<< variables are more or less universally portable, as is the - $$((MMAAKKEE)) variable. Basic use of suffix rules (for files only in the cur- + The [1m$@ [22mand [1m$< [22mvariables are more or less universally portable, as is the + [1m$(MAKE) [22mvariable. Basic use of suffix rules (for files only in the cur- rent directory, not trying to chain transformations together, etc.) is also reasonably portable. -SSEEEE AALLSSOO +[1mSEE ALSO[0m mkdep(1) -HHIISSTTOORRYY - bbmmaakkee is derived from NetBSD make(1). It uses autoconf to facilitate +[1mHISTORY[0m + [1mbmake [22mis derived from NetBSD make(1). It uses autoconf to facilitate portability to other platforms. A make command appeared in Version 7 AT&T UNIX. This make implementation @@ -1440,7 +1532,7 @@ HHIISSTTOORRYY rebuilding (since the target/dependency does not exist... unless someone creates an ``FRC'' file). -BBUUGGSS +[1mBUGS[0m The make syntax is difficult to parse without actually acting of the data. For instance finding the end of a variable use should involve scanning each the modifiers using the correct terminator for each field. @@ -1449,4 +1541,4 @@ BBUUGGSS There is no way of escaping a space character in a filename. -NetBSD 5.1 April 9, 2015 NetBSD 5.1 +FreeBSD 11.1 June 22, 2017 FreeBSD 11.1 diff --git a/devel/bmake/files/boot-strap b/devel/bmake/files/boot-strap index 8bfce51e746..2aa8f7f339e 100755 --- a/devel/bmake/files/boot-strap +++ b/devel/bmake/files/boot-strap @@ -89,6 +89,10 @@ # disable use of filemon(9) which is currently only # available for NetBSD and FreeBSD. # +# --with-filemon=ktrace +# on NetBSD or others with fktrace(2), use ktrace +# version of filemon. +# # --with-filemon="path/to/filemon.h" # enables use of filemon(9) by meta mode. # @@ -111,7 +115,7 @@ # Simon J. Gerraty <sjg@crufty.net> # RCSid: -# $Id: boot-strap,v 1.1.1.11 2015/05/19 21:36:43 joerg Exp $ +# $Id: boot-strap,v 1.1.1.12 2020/05/24 05:35:51 nia Exp $ # # @(#) Copyright (c) 2001 Simon J. Gerraty # @@ -161,6 +165,8 @@ cmd_args="$@" # clear some things from the environment that we care about unset MAKEOBJDIR MAKEOBJDIRPREFIX +# or that might be incompatible +unset MAKE MAKEFLAGS # --install[-host-target] will set this INSTALL_PREFIX= @@ -395,8 +401,15 @@ Bmake() { ) } +# there is actually a shell where type is not a builtin +# if type is missing, which(1) had better exists! +if (type cat) > /dev/null 2>&1; then +which() { + type "$@" | sed 's,[()],,g;s,^[^/][^/]*,,;q' +} +fi # make sure test below uses the same diff that configure did -TOOL_DIFF=`type diff | sed 's,[()],,g;s,^[^/][^/]*,,;q'` +TOOL_DIFF=`which diff` export TOOL_DIFF op_configure() { @@ -444,7 +457,7 @@ op_all() { op_install else op_test - MAKE_VERSION=`sed -n '/^MAKE_VERSION/ { s,.*= *,,;p; }' $srcdir/Makefile` + MAKE_VERSION=`sed -n '/^_MAKE_VERSION/ { s,.*= *,,;p; }' $srcdir/Makefile` echo You can install by running: echo echo $0 $cmd_args op=install diff --git a/devel/bmake/files/bsd.after-import.mk b/devel/bmake/files/bsd.after-import.mk index c92c5a1ee7f..95e07f9586f 100644 --- a/devel/bmake/files/bsd.after-import.mk +++ b/devel/bmake/files/bsd.after-import.mk @@ -1,4 +1,4 @@ -# $Id: bsd.after-import.mk,v 1.1.1.1 2015/05/19 21:36:43 joerg Exp $ +# $Id: bsd.after-import.mk,v 1.1.1.2 2020/05/24 05:35:51 nia Exp $ # This makefile is for use when integrating bmake into a BSD build # system. Use this makefile after importing bmake. @@ -56,13 +56,14 @@ bootstrap: ${BMAKE_SRC}/boot-strap ${MAKEFILE} # Makefiles need a little more tweaking than say config.h MAKEFILE_SED = sed -e '/^MACHINE/d' \ + -e '/include.*VERSION/d' \ -e '/^PROG/ { s,=,?=,;s,bmake,$${.CURDIR:T},; }' \ -e 's,^.-include,.sinclude,' \ -e '/^\..*include *</ { s,<,<bsd.,;/autoconf/d; }' \ -e 's,${SRCTOP},$${SRCTOP},g' # These are the simple files we want to capture -configured_files= config.h Makefile.config unit-tests/Makefile +configured_files= config.h Makefile.config unit-tests/Makefile.config after-import: bootstrap ${MAKEFILE} .for f in ${configured_files:M*.[ch]} @@ -86,7 +87,6 @@ _makefile: bootstrap ${MAKEFILE} @(echo '# This is a generated file, do NOT edit!'; \ echo '# See ${_this:S,${SRCTOP}/,,}'; \ echo '#'; echo '# $$${HOST_OS}$$'; \ - echo; echo '.sinclude "Makefile.inc"'; \ echo; echo 'SRCTOP?= $${.CURDIR:${.CURDIR:S,${SRCTOP}/,,:C,[^/]+,H,g:S,/,:,g}}'; \ echo; echo '# look here first for config.h'; \ echo 'CFLAGS+= -I$${.CURDIR}'; echo; \ diff --git a/devel/bmake/files/buf.h b/devel/bmake/files/buf.h index 03c4be4fbc6..d4b94c0fc0e 100644 --- a/devel/bmake/files/buf.h +++ b/devel/bmake/files/buf.h @@ -1,4 +1,4 @@ -/* $NetBSD: buf.h,v 1.1.1.5 2015/05/19 21:36:43 joerg Exp $ */ +/* $NetBSD: buf.h,v 1.1.1.6 2020/05/24 05:35:51 nia Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -77,8 +77,8 @@ * Header for users of the buf library. */ -#ifndef _BUF_H -#define _BUF_H +#ifndef MAKE_BUF_H +#define MAKE_BUF_H typedef char Byte; @@ -116,4 +116,4 @@ void Buf_Init(Buffer *, int); Byte *Buf_Destroy(Buffer *, Boolean); Byte *Buf_DestroyCompact(Buffer *); -#endif /* _BUF_H */ +#endif /* MAKE_BUF_H */ diff --git a/devel/bmake/files/compat.c b/devel/bmake/files/compat.c index 3486cd33706..cc5a31df349 100644 --- a/devel/bmake/files/compat.c +++ b/devel/bmake/files/compat.c @@ -1,4 +1,4 @@ -/* $NetBSD: compat.c,v 1.1.1.9 2015/05/19 21:36:43 joerg Exp $ */ +/* $NetBSD: compat.c,v 1.1.1.10 2020/05/24 05:35:51 nia Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -70,14 +70,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: compat.c,v 1.1.1.9 2015/05/19 21:36:43 joerg Exp $"; +static char rcsid[] = "$NetBSD: compat.c,v 1.1.1.10 2020/05/24 05:35:51 nia Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)compat.c 8.2 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: compat.c,v 1.1.1.9 2015/05/19 21:36:43 joerg Exp $"); +__RCSID("$NetBSD: compat.c,v 1.1.1.10 2020/05/24 05:35:51 nia Exp $"); #endif #endif /* not lint */ #endif @@ -111,35 +111,33 @@ __RCSID("$NetBSD: compat.c,v 1.1.1.9 2015/05/19 21:36:43 joerg Exp $"); #include "hash.h" #include "dir.h" #include "job.h" +#include "metachar.h" #include "pathnames.h" -/* - * The following array is used to make a fast determination of which - * characters are interpreted specially by the shell. If a command - * contains any of these characters, it is executed by the shell, not - * directly by us. - */ - -static char meta[256]; static GNode *curTarg = NULL; static GNode *ENDNode; static void CompatInterrupt(int); +static pid_t compatChild; +static int compatSigno; +/* + * CompatDeleteTarget -- delete a failed, interrupted, or otherwise + * duffed target if not inhibited by .PRECIOUS. + */ static void -Compat_Init(void) +CompatDeleteTarget(GNode *gn) { - const char *cp; + if ((gn != NULL) && !Targ_Precious (gn)) { + char *p1; + char *file = Var_Value(TARGET, gn, &p1); - Shell_Init(); /* setup default shell */ - - for (cp = "~#=|^(){};&<>*?[]:$`\\\n"; *cp != '\0'; cp++) { - meta[(unsigned char) *cp] = 1; + if (!noExecute && eunlink(file) != -1) { + Error("*** %s removed", file); + } + + free(p1); } - /* - * The null character serves as a sentinel in the string. - */ - meta[0] = 1; } /*- @@ -155,6 +153,9 @@ Compat_Init(void) * The target is removed and the process exits. If .INTERRUPT exists, * its commands are run first WITH INTERRUPTS IGNORED.. * + * XXX: is .PRECIOUS supposed to inhibit .INTERRUPT? I doubt it, but I've + * left the logic alone for now. - dholland 20160826 + * *----------------------------------------------------------------------- */ static void @@ -162,16 +163,9 @@ CompatInterrupt(int signo) { GNode *gn; - if ((curTarg != NULL) && !Targ_Precious (curTarg)) { - char *p1; - char *file = Var_Value(TARGET, curTarg, &p1); - - if (!noExecute && eunlink(file) != -1) { - Error("*** %s removed", file); - } - if (p1) - free(p1); + CompatDeleteTarget(curTarg); + if ((curTarg != NULL) && !Targ_Precious (curTarg)) { /* * Run .INTERRUPT only if hit with interrupt signal */ @@ -181,12 +175,20 @@ CompatInterrupt(int signo) Compat_Make(gn, gn); } } - } if (signo == SIGQUIT) _exit(signo); - bmake_signal(signo, SIG_DFL); - kill(myPid, signo); + /* + * If there is a child running, pass the signal on + * we will exist after it has exited. + */ + compatSigno = signo; + if (compatChild > 0) { + KILLPG(compatChild, signo); + } else { + bmake_signal(signo, SIG_DFL); + kill(myPid, signo); + } } /*- @@ -236,7 +238,7 @@ CompatRunCommand(void *cmdp, void *gnp) doIt = FALSE; cmdNode = Lst_Member(gn->commands, cmd); - cmdStart = Var_Subst(NULL, cmd, gn, FALSE); + cmdStart = Var_Subst(NULL, cmd, gn, VARF_WANTRES); /* * brk_string will return an argv with a NULL in av[0], thus causing @@ -271,8 +273,8 @@ CompatRunCommand(void *cmdp, void *gnp) break; case '+': doIt = TRUE; - if (!meta[0]) /* we came here from jobs */ - Compat_Init(); + if (!shellName) /* we came here from jobs */ + Shell_Init(); break; } cmd++; @@ -300,11 +302,13 @@ CompatRunCommand(void *cmdp, void *gnp) * Search for meta characters in the command. If there are no meta * characters, there's no need to execute a shell to execute the * command. + * + * Additionally variable assignments and empty commands + * go to the shell. Therefore treat '=' and ':' like shell + * meta characters as documented in make(1). */ - for (cp = cmd; !meta[(unsigned char)*cp]; cp++) { - continue; - } - useShell = (*cp != '\0'); + + useShell = needshell(cmd, FALSE); #endif /* @@ -377,7 +381,7 @@ again: /* * Fork and execute the single command. If the fork fails, we abort. */ - cpid = vFork(); + compatChild = cpid = vFork(); if (cpid < 0) { Fatal("Could not fork"); } @@ -395,15 +399,15 @@ again: execError("exec", av[0]); _exit(1); } - if (mav) - free(mav); - if (bp) - free(bp); + + free(mav); + free(bp); + Lst_Replace(cmdNode, NULL); #ifdef USE_META if (useMeta) { - meta_compat_parent(); + meta_compat_parent(cpid); } #endif @@ -468,6 +472,11 @@ again: * continue. */ printf(" (continuing)\n"); + } else { + printf("\n"); + } + if (deleteOnError) { + CompatDeleteTarget(gn); } } else { /* @@ -485,7 +494,12 @@ again: } } free(cmdStart); - + compatChild = 0; + if (compatSigno) { + bmake_signal(compatSigno, SIG_DFL); + kill(myPid, compatSigno); + } + return (status); } @@ -512,8 +526,8 @@ Compat_Make(void *gnp, void *pgnp) GNode *gn = (GNode *)gnp; GNode *pgn = (GNode *)pgnp; - if (!meta[0]) /* we came here from jobs */ - Compat_Init(); + if (!shellName) /* we came here from jobs */ + Shell_Init(); if (gn->made == UNMADE && (gn == pgn || (pgn->type & OP_MADE) == 0)) { /* * First mark ourselves to be made, then apply whatever transformations @@ -537,8 +551,7 @@ Compat_Make(void *gnp, void *pgnp) if (Lst_Member(gn->iParents, pgn) != NULL) { char *p1; Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), pgn, 0); - if (p1) - free(p1); + free(p1); } /* @@ -608,7 +621,8 @@ Compat_Make(void *gnp, void *pgnp) } #ifdef USE_META if (useMeta && !NoExecute(gn)) { - meta_job_finish(NULL); + if (meta_job_finish(NULL) != 0) + gn->made = ERROR; } #endif @@ -628,7 +642,7 @@ Compat_Make(void *gnp, void *pgnp) } else if (keepgoing) { pgn->flags &= ~REMAKE; } else { - PrintOnError(gn, "\n\nStop."); + PrintOnError(gn, "\nStop."); exit(1); } } else if (gn->made == ERROR) { @@ -641,8 +655,7 @@ Compat_Make(void *gnp, void *pgnp) if (Lst_Member(gn->iParents, pgn) != NULL) { char *p1; Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), pgn, 0); - if (p1) - free(p1); + free(p1); } switch(gn->made) { case BEINGMADE: @@ -693,7 +706,8 @@ Compat_Run(Lst targs) GNode *gn = NULL;/* Current root target */ int errors; /* Number of targets not remade due to errors */ - Compat_Init(); + if (!shellName) + Shell_Init(); if (bmake_signal(SIGINT, SIG_IGN) != SIG_IGN) { bmake_signal(SIGINT, CompatInterrupt); @@ -719,7 +733,7 @@ Compat_Run(Lst targs) if (gn != NULL) { Compat_Make(gn, gn); if (gn->made == ERROR) { - PrintOnError(gn, "\n\nStop."); + PrintOnError(gn, "\nStop."); exit(1); } } @@ -760,7 +774,7 @@ Compat_Run(Lst targs) if (errors == 0) { Compat_Make(ENDNode, ENDNode); if (gn->made == ERROR) { - PrintOnError(gn, "\n\nStop."); + PrintOnError(gn, "\nStop."); exit(1); } } diff --git a/devel/bmake/files/cond.c b/devel/bmake/files/cond.c index 5633ea375db..ec455c8b4a5 100644 --- a/devel/bmake/files/cond.c +++ b/devel/bmake/files/cond.c @@ -1,4 +1,4 @@ -/* $NetBSD: cond.c,v 1.1.1.8 2015/05/19 21:36:43 joerg Exp $ */ +/* $NetBSD: cond.c,v 1.1.1.9 2020/05/24 05:35:51 nia Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -70,14 +70,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: cond.c,v 1.1.1.8 2015/05/19 21:36:43 joerg Exp $"; +static char rcsid[] = "$NetBSD: cond.c,v 1.1.1.9 2020/05/24 05:35:51 nia Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)cond.c 8.2 (Berkeley) 1/2/94"; #else -__RCSID("$NetBSD: cond.c,v 1.1.1.8 2015/05/19 21:36:43 joerg Exp $"); +__RCSID("$NetBSD: cond.c,v 1.1.1.9 2020/05/24 05:35:51 nia Exp $"); #endif #endif /* not lint */ #endif @@ -91,6 +91,7 @@ __RCSID("$NetBSD: cond.c,v 1.1.1.8 2015/05/19 21:36:43 joerg Exp $"); * */ +#include <assert.h> #include <ctype.h> #include <errno.h> /* For strtoul() error checking */ @@ -289,10 +290,10 @@ CondGetArg(char **linePtr, char **argPtr, const char *func) int len; void *freeIt; - cp2 = Var_Parse(cp, VAR_CMD, TRUE, &len, &freeIt); + cp2 = Var_Parse(cp, VAR_CMD, VARF_UNDEFERR|VARF_WANTRES, + &len, &freeIt); Buf_AddBytes(&buf, strlen(cp2), cp2); - if (freeIt) - free(freeIt); + free(freeIt); cp += len; continue; } @@ -346,8 +347,8 @@ CondDoDefined(int argLen MAKE_ATTR_UNUSED, const char *arg) } else { result = FALSE; } - if (p1) - free(p1); + + free(p1); return (result); } @@ -490,6 +491,10 @@ CondCvtArg(char *str, double *value) double d_val; errno = 0; + if (!*str) { + *value = (double)0; + return TRUE; + } l_val = strtoul(str, &eptr, str[1] == 'x' ? 16 : 10); ech = *eptr; if (ech == 0 && errno != ERANGE) { @@ -570,8 +575,9 @@ CondGetString(Boolean doEval, Boolean *quoted, void **freeIt, Boolean strictLHS) break; case '$': /* if we are in quotes, then an undefined variable is ok */ - str = Var_Parse(condExpr, VAR_CMD, (qt ? 0 : doEval), - &len, freeIt); + str = Var_Parse(condExpr, VAR_CMD, + ((!qt && doEval) ? VARF_UNDEFERR : 0) | + VARF_WANTRES, &len, freeIt); if (str == var_Error) { if (*freeIt) { free(*freeIt); @@ -801,10 +807,8 @@ do_string_compare: } done: - if (lhsFree) - free(lhsFree); - if (rhsFree) - free(rhsFree); + free(lhsFree); + free(rhsFree); return t; } @@ -823,7 +827,7 @@ get_mpt_arg(char **linePtr, char **argPtr, const char *func MAKE_ATTR_UNUSED) /* We do all the work here and return the result as the length */ *argPtr = NULL; - val = Var_Parse(cp - 1, VAR_CMD, FALSE, &length, &freeIt); + val = Var_Parse(cp - 1, VAR_CMD, VARF_WANTRES, &length, &freeIt); /* * Advance *linePtr to beyond the closing ). Note that * we subtract one because 'length' is calculated from 'cp - 1'. @@ -844,8 +848,7 @@ get_mpt_arg(char **linePtr, char **argPtr, const char *func MAKE_ATTR_UNUSED) * true/false here. */ length = *val ? 2 : 1; - if (freeIt) - free(freeIt); + free(freeIt); return length; } @@ -896,8 +899,7 @@ compare_function(Boolean doEval) } /* Evaluate the argument using the required function. */ t = !doEval || fn_def->fn_proc(arglen, arg); - if (arg) - free(arg); + free(arg); condExpr = cp; return t; } @@ -929,8 +931,7 @@ compare_function(Boolean doEval) * be empty - even if it contained a variable expansion. */ t = !doEval || if_info->defProc(arglen, arg) != if_info->doNot; - if (arg) - free(arg); + free(arg); return t; } @@ -1174,8 +1175,9 @@ Cond_EvalExpression(const struct If *info, char *line, Boolean *value, int eprin break; dflt_info = info; } + assert(info != NULL); - if_info = info != NULL ? info : ifs + 4; + if_info = info; condExpr = line; condPushBack = TOK_NONE; diff --git a/devel/bmake/files/config.h.in b/devel/bmake/files/config.h.in index ce30da1e36c..6ceb16bc141 100644 --- a/devel/bmake/files/config.h.in +++ b/devel/bmake/files/config.h.in @@ -59,6 +59,12 @@ /* Define to 1 if you have the `killpg' function. */ #undef HAVE_KILLPG +/* Define to 1 if you have the <libgen.h> header file. */ +#undef HAVE_LIBGEN_H + +/* Define to 1 if you have the <limits.h> header file. */ +#undef HAVE_LIMITS_H + /* Define to 1 if you have the <memory.h> header file. */ #undef HAVE_MEMORY_H @@ -137,7 +143,7 @@ /* Define to 1 if you have the `strtol' function. */ #undef HAVE_STRTOL -/* Define to 1 if `struct stat' is a member of `st_rdev'. */ +/* Define to 1 if `st_rdev' is a member of `struct stat'. */ #undef HAVE_STRUCT_STAT_ST_RDEV /* Define to 1 if your `struct stat' has `st_rdev'. Deprecated, use @@ -158,6 +164,9 @@ */ #undef HAVE_SYS_NDIR_H +/* Define to 1 if you have the <sys/param.h> header file. */ +#undef HAVE_SYS_PARAM_H + /* Define to 1 if you have the <sys/select.h> header file. */ #undef HAVE_SYS_SELECT_H @@ -304,12 +313,20 @@ /* Define to 1 if you need to in order for `stat' and other things to work. */ #undef _POSIX_SOURCE +/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>, + <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the + #define below would cause a syntax error. */ +#undef _UINT32_T + /* C99 function name */ #undef __func__ /* Define to empty if `const' does not conform to ANSI C. */ #undef const +/* Define to `int' if <sys/types.h> does not define. */ +#undef mode_t + /* Define to `long int' if <sys/types.h> does not define. */ #undef off_t @@ -319,5 +336,9 @@ /* Define to `unsigned int' if <sys/types.h> does not define. */ #undef size_t +/* Define to the type of an unsigned integer type of width exactly 32 bits if + such a type exists and the standard includes do not define it. */ +#undef uint32_t + /* Define as `fork' if `vfork' does not work. */ #undef vfork diff --git a/devel/bmake/files/configure b/devel/bmake/files/configure index 08b21b324ab..74c7e10053f 100755 --- a/devel/bmake/files/configure +++ b/devel/bmake/files/configure @@ -1,12 +1,12 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.64 for bmake 20140214. +# Generated by GNU Autoconf 2.69 for bmake 20200418. # # Report bugs to <sjg@NetBSD.org>. # -# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001, -# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software -# Foundation, Inc. +# +# Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. +# # # This configure script is free software; the Free Software Foundation # gives unlimited permission to copy, distribute and modify it. @@ -89,6 +89,7 @@ fi IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. +as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -133,6 +134,31 @@ export LANGUAGE # CDPATH. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH +# Use a proper internal environment variable to ensure we don't fall + # into an infinite loop, continuously re-executing ourselves. + if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then + _as_can_reexec=no; export _as_can_reexec; + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +as_fn_exit 255 + fi + # We don't want this to propagate to other subprocesses. + { _as_can_reexec=; unset _as_can_reexec;} if test "x$CONFIG_SHELL" = x; then as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then : emulate sh @@ -166,7 +192,8 @@ if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then : else exitcode=1; echo positional parameters were not saved. fi -test x\$exitcode = x0 || exit 1" +test x\$exitcode = x0 || exit 1 +test -x / || exit 1" as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" && @@ -211,14 +238,25 @@ IFS=$as_save_IFS if test "x$CONFIG_SHELL" != x; then : - # We cannot yet assume a decent shell, so we have to provide a - # neutralization value for shells without unset; and this also - # works around shells that cannot unset nonexistent variables. - BASH_ENV=/dev/null - ENV=/dev/null - (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV - export CONFIG_SHELL - exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"} + export CONFIG_SHELL + # We cannot yet assume a decent shell, so we have to provide a +# neutralization value for shells without unset; and this also +# works around shells that cannot unset nonexistent variables. +# Preserve -v and -x to the replacement shell. +BASH_ENV=/dev/null +ENV=/dev/null +(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV +case $- in # (((( + *v*x* | *x*v* ) as_opts=-vx ;; + *v* ) as_opts=-v ;; + *x* ) as_opts=-x ;; + * ) as_opts= ;; +esac +exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"} +# Admittedly, this is quite paranoid, since all the known shells bail +# out after a failed `exec'. +$as_echo "$0: could not re-execute with $CONFIG_SHELL" >&2 +exit 255 fi if test x$as_have_required = xno; then : @@ -317,10 +355,18 @@ $as_echo X"$as_dir" | test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p # as_fn_append VAR VALUE # ---------------------- # Append the text in VALUE to the end of the definition contained in VAR. Take @@ -357,19 +403,19 @@ else fi # as_fn_arith -# as_fn_error ERROR [LINENO LOG_FD] -# --------------------------------- +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with status $?, using 1 if that was 0. +# script with STATUS, using 1 if that was 0. as_fn_error () { - as_status=$?; test $as_status -eq 0 && as_status=1 - if test "$3"; then - as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi - $as_echo "$as_me: error: $1" >&2 + $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error @@ -442,6 +488,10 @@ as_cr_alnum=$as_cr_Letters$as_cr_digits chmod +x "$as_me.lineno" || { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; } + # If we had to re-execute with $CONFIG_SHELL, we're ensured to have + # already done that, so ensure we don't try to do so again and fall + # in an infinite loop. This has already happened in practice. + _as_can_reexec=no; export _as_can_reexec # Don't try to exec as it changes $[0], causing all sort of problems # (the dirname of $[0] is not the place where we might find the # original and so on. Autoconf is especially sensitive to this). @@ -476,16 +526,16 @@ if (echo >conf$$.file) 2>/dev/null; then # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. + # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' + as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null @@ -497,28 +547,8 @@ else as_mkdir_p=false fi -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in #( - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x +as_test_x='test -x' +as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -527,10 +557,11 @@ as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'" -exec 7<&0 </dev/null 6>&1 +test -n "$DJDIR" || exec 7<&0 </dev/null +exec 6>&1 # Name of the host. -# hostname on some systems (SVR3.2, Linux) returns a bogus exit status, +# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status, # so uname gets run too. ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q` @@ -549,8 +580,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='bmake' PACKAGE_TARNAME='bmake' -PACKAGE_VERSION='20140214' -PACKAGE_STRING='bmake 20140214' +PACKAGE_VERSION='20200418' +PACKAGE_STRING='bmake 20200418' PACKAGE_BUGREPORT='sjg@NetBSD.org' PACKAGE_URL='' @@ -591,7 +622,9 @@ ac_includes_default="\ #endif" ac_subst_vars='LTLIBOBJS +_MAKE_VERSION filemon_h +use_filemon use_meta diff_u GCC @@ -659,6 +692,7 @@ ac_subst_files='' ac_user_opts=' enable_option_checking with_defshell +with_makefile with_meta with_filemon with_machine @@ -742,8 +776,9 @@ do fi case $ac_option in - *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; - *) ac_optarg=yes ;; + *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;; + *=) ac_optarg= ;; + *) ac_optarg=yes ;; esac # Accept the important Cygnus configure options, so we can diagnose typos. @@ -788,7 +823,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid feature name: $ac_useropt" + as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -814,7 +849,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid feature name: $ac_useropt" + as_fn_error $? "invalid feature name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1018,7 +1053,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid package name: $ac_useropt" + as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1034,7 +1069,7 @@ do ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'` # Reject names that are not valid shell variable names. expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null && - as_fn_error "invalid package name: $ac_useropt" + as_fn_error $? "invalid package name: $ac_useropt" ac_useropt_orig=$ac_useropt ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'` case $ac_user_opts in @@ -1064,8 +1099,8 @@ do | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) x_libraries=$ac_optarg ;; - -*) as_fn_error "unrecognized option: \`$ac_option' -Try \`$0 --help' for more information." + -*) as_fn_error $? "unrecognized option: \`$ac_option' +Try \`$0 --help' for more information" ;; *=*) @@ -1073,7 +1108,7 @@ Try \`$0 --help' for more information." # Reject names that are not valid shell variable names. case $ac_envvar in #( '' | [0-9]* | *[!_$as_cr_alnum]* ) - as_fn_error "invalid variable name: \`$ac_envvar'" ;; + as_fn_error $? "invalid variable name: \`$ac_envvar'" ;; esac eval $ac_envvar=\$ac_optarg export $ac_envvar ;; @@ -1083,7 +1118,7 @@ Try \`$0 --help' for more information." $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2 expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null && $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2 - : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option} + : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}" ;; esac @@ -1091,13 +1126,13 @@ done if test -n "$ac_prev"; then ac_option=--`echo $ac_prev | sed 's/_/-/g'` - as_fn_error "missing argument to $ac_option" + as_fn_error $? "missing argument to $ac_option" fi if test -n "$ac_unrecognized_opts"; then case $enable_option_checking in no) ;; - fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;; + fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;; *) $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;; esac fi @@ -1120,7 +1155,7 @@ do [\\/$]* | ?:[\\/]* ) continue;; NONE | '' ) case $ac_var in *prefix ) continue;; esac;; esac - as_fn_error "expected an absolute directory name for --$ac_var: $ac_val" + as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val" done # There might be people who depend on the old broken behavior: `$host' @@ -1134,8 +1169,6 @@ target=$target_alias if test "x$host_alias" != x; then if test "x$build_alias" = x; then cross_compiling=maybe - $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host. - If a cross compiler is detected then cross compile mode will be used." >&2 elif test "x$build_alias" != "x$host_alias"; then cross_compiling=yes fi @@ -1150,9 +1183,9 @@ test "$silent" = yes && exec 6>/dev/null ac_pwd=`pwd` && test -n "$ac_pwd" && ac_ls_di=`ls -di .` && ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` || - as_fn_error "working directory cannot be determined" + as_fn_error $? "working directory cannot be determined" test "X$ac_ls_di" = "X$ac_pwd_ls_di" || - as_fn_error "pwd does not report name of working directory" + as_fn_error $? "pwd does not report name of working directory" # Find the source files, if location was not specified. @@ -1191,11 +1224,11 @@ else fi if test ! -r "$srcdir/$ac_unique_file"; then test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .." - as_fn_error "cannot find sources ($ac_unique_file) in $srcdir" + as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir" fi ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work" ac_abs_confdir=`( - cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg" + cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg" pwd)` # When building in place, set srcdir=. if test "$ac_abs_confdir" = "$ac_pwd"; then @@ -1221,7 +1254,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures bmake 20140214 to adapt to many kinds of systems. +\`configure' configures bmake 20200418 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1235,7 +1268,7 @@ Configuration: --help=short display options specific to this package --help=recursive display the short help of all the included packages -V, --version display version information and exit - -q, --quiet, --silent do not print \`checking...' messages + -q, --quiet, --silent do not print \`checking ...' messages --cache-file=FILE cache test results in FILE [disabled] -C, --config-cache alias for \`--cache-file=config.cache' -n, --no-create do not create output files @@ -1282,7 +1315,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of bmake 20140214:";; + short | recursive ) echo "Configuration of bmake 20200418:";; esac cat <<\_ACEOF @@ -1298,8 +1331,9 @@ Optional Packages: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) --with-defshell=SHELL use SHELL by default - must be sh compatible, use sh or ksh to pick the internal definitions + --without-makefile dissable use of generated makefile --without-meta dissable use of meta-mode - --with-filemon=path/filemon.h indicate path to filemon.h for meta-mode + --with-filemon={no,dev,ktrace,path/filemon.h} indicate filemon method for meta-mode. Path to filemon.h implies dev --with-machine=MACHINE explicitly set MACHINE --with-force-machine=MACHINE set FORCE_MACHINE --with-force-machine-arch=MACHINE set FORCE_MACHINE_ARCH @@ -1317,7 +1351,7 @@ Some influential environment variables: LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a nonstandard directory <lib dir> LIBS libraries to pass to the linker, e.g. -l<library> - CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I<include dir> if + CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if you have headers in a nonstandard directory <include dir> CPP C preprocessor @@ -1387,10 +1421,10 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -bmake configure 20140214 -generated by GNU Autoconf 2.64 +bmake configure 20200418 +generated by GNU Autoconf 2.69 -Copyright (C) 2009 Free Software Foundation, Inc. +Copyright (C) 2012 Free Software Foundation, Inc. This configure script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it. _ACEOF @@ -1434,8 +1468,8 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - return $ac_retval + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval } # ac_fn_c_try_compile @@ -1460,7 +1494,7 @@ $as_echo "$ac_try_echo"; } >&5 mv -f conftest.er1 conftest.err fi $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; } >/dev/null && { + test $ac_status = 0; } > conftest.i && { test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" || test ! -s conftest.err }; then : @@ -1471,8 +1505,8 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=1 fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - return $ac_retval + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval } # ac_fn_c_try_cpp @@ -1484,10 +1518,10 @@ fi ac_fn_c_check_header_mongrel () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + if eval \${$3+:} false; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 fi eval ac_res=\$$3 @@ -1523,7 +1557,7 @@ if ac_fn_c_try_cpp "$LINENO"; then : else ac_header_preproc=no fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5 $as_echo "$ac_header_preproc" >&6; } @@ -1546,17 +1580,15 @@ $as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;} $as_echo "$as_me: WARNING: $2: section \"Present But Cannot Be Compiled\"" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5 $as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;} -( cat <<\_ASBOX -## ----------------------------- ## +( $as_echo "## ----------------------------- ## ## Report this to sjg@NetBSD.org ## -## ----------------------------- ## -_ASBOX +## ----------------------------- ##" ) | sed "s/^/$as_me: WARNING: /" >&2 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=\$ac_header_compiler" @@ -1565,7 +1597,7 @@ eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } fi - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_mongrel @@ -1606,8 +1638,8 @@ sed 's/^/| /' conftest.$ac_ext >&5 ac_retval=$ac_status fi rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - return $ac_retval + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval } # ac_fn_c_try_run @@ -1620,7 +1652,7 @@ ac_fn_c_check_header_compile () as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -1638,7 +1670,7 @@ fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_header_compile @@ -1669,7 +1701,7 @@ $as_echo "$ac_try_echo"; } >&5 test ! -s conftest.err } && test -s conftest$ac_exeext && { test "$cross_compiling" = yes || - $as_test_x conftest$ac_exeext + test -x conftest$ac_exeext }; then : ac_retval=0 else @@ -1683,8 +1715,8 @@ fi # interfere with the next link command; also delete a directory that is # left behind by Apple's compiler. We do this before executing the actions. rm -rf conftest.dSYM conftest_ipa8_conftest.oo - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} - return $ac_retval + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + as_fn_set_status $ac_retval } # ac_fn_c_try_link @@ -1697,7 +1729,7 @@ ac_fn_c_check_type () as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else eval "$3=no" @@ -1738,19 +1770,76 @@ fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_type -# ac_fn_c_check_decl LINENO SYMBOL VAR +# ac_fn_c_find_uintX_t LINENO BITS VAR # ------------------------------------ -# Tests whether SYMBOL is declared, setting cache variable VAR accordingly. +# Finds an unsigned integer type with width BITS, setting cache variable VAR +# accordingly. +ac_fn_c_find_uintX_t () +{ + as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for uint$2_t" >&5 +$as_echo_n "checking for uint$2_t... " >&6; } +if eval \${$3+:} false; then : + $as_echo_n "(cached) " >&6 +else + eval "$3=no" + # Order is important - never check a type that is potentially smaller + # than half of the expected target width. + for ac_type in uint$2_t 'unsigned int' 'unsigned long int' \ + 'unsigned long long int' 'unsigned short int' 'unsigned char'; do + cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +$ac_includes_default +int +main () +{ +static int test_array [1 - 2 * !((($ac_type) -1 >> ($2 / 2 - 1)) >> ($2 / 2 - 1) == 3)]; +test_array [0] = 0; +return test_array [0]; + + ; + return 0; +} +_ACEOF +if ac_fn_c_try_compile "$LINENO"; then : + case $ac_type in #( + uint$2_t) : + eval "$3=yes" ;; #( + *) : + eval "$3=\$ac_type" ;; +esac +fi +rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + if eval test \"x\$"$3"\" = x"no"; then : + +else + break +fi + done +fi +eval ac_res=\$$3 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 +$as_echo "$ac_res" >&6; } + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno + +} # ac_fn_c_find_uintX_t + +# ac_fn_c_check_decl LINENO SYMBOL VAR INCLUDES +# --------------------------------------------- +# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR +# accordingly. ac_fn_c_check_decl () { as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $2 is declared" >&5 -$as_echo_n "checking whether $2 is declared... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : + as_decl_name=`echo $2|sed 's/ *(.*//'` + as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'` + { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5 +$as_echo_n "checking whether $as_decl_name is declared... " >&6; } +if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -1759,8 +1848,12 @@ $4 int main () { -#ifndef $2 - (void) $2; +#ifndef $as_decl_name +#ifdef __cplusplus + (void) $as_decl_use; +#else + (void) $as_decl_name; +#endif #endif ; @@ -1777,7 +1870,7 @@ fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_decl @@ -1789,7 +1882,7 @@ ac_fn_c_check_func () as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5 $as_echo_n "checking for $2... " >&6; } -if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval \${$3+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -1844,7 +1937,7 @@ fi eval ac_res=\$$3 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_func @@ -1857,7 +1950,7 @@ ac_fn_c_check_member () as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5 $as_echo_n "checking for $2.$3... " >&6; } -if { as_var=$4; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval \${$4+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -1901,15 +1994,15 @@ fi eval ac_res=\$$4 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } - eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;} + eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno } # ac_fn_c_check_member cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by bmake $as_me 20140214, which was -generated by GNU Autoconf 2.64. Invocation command line was +It was created by bmake $as_me 20200418, which was +generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -2019,11 +2112,9 @@ trap 'exit_status=$? { echo - cat <<\_ASBOX -## ---------------- ## + $as_echo "## ---------------- ## ## Cache variables. ## -## ---------------- ## -_ASBOX +## ---------------- ##" echo # The following way of writing the cache mishandles newlines in values, ( @@ -2057,11 +2148,9 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; ) echo - cat <<\_ASBOX -## ----------------- ## + $as_echo "## ----------------- ## ## Output variables. ## -## ----------------- ## -_ASBOX +## ----------------- ##" echo for ac_var in $ac_subst_vars do @@ -2074,11 +2163,9 @@ _ASBOX echo if test -n "$ac_subst_files"; then - cat <<\_ASBOX -## ------------------- ## + $as_echo "## ------------------- ## ## File substitutions. ## -## ------------------- ## -_ASBOX +## ------------------- ##" echo for ac_var in $ac_subst_files do @@ -2092,11 +2179,9 @@ _ASBOX fi if test -s confdefs.h; then - cat <<\_ASBOX -## ----------- ## + $as_echo "## ----------- ## ## confdefs.h. ## -## ----------- ## -_ASBOX +## ----------- ##" echo cat confdefs.h echo @@ -2151,7 +2236,12 @@ _ACEOF ac_site_file1=NONE ac_site_file2=NONE if test -n "$CONFIG_SITE"; then - ac_site_file1=$CONFIG_SITE + # We do not want a PATH search for config.site. + case $CONFIG_SITE in #(( + -*) ac_site_file1=./$CONFIG_SITE;; + */*) ac_site_file1=$CONFIG_SITE;; + *) ac_site_file1=./$CONFIG_SITE;; + esac elif test "x$prefix" != xNONE; then ac_site_file1=$prefix/share/config.site ac_site_file2=$prefix/etc/config.site @@ -2162,18 +2252,22 @@ fi for ac_site_file in "$ac_site_file1" "$ac_site_file2" do test "x$ac_site_file" = xNONE && continue - if test -r "$ac_site_file"; then + if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5 $as_echo "$as_me: loading site script $ac_site_file" >&6;} sed 's/^/| /' "$ac_site_file" >&5 - . "$ac_site_file" + . "$ac_site_file" \ + || { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "failed to load site script $ac_site_file +See \`config.log' for more details" "$LINENO" 5; } fi done if test -r "$cache_file"; then - # Some versions of bash will fail to source /dev/null (special - # files actually), so we avoid doing that. - if test -f "$cache_file"; then + # Some versions of bash will fail to source /dev/null (special files + # actually), so we avoid doing that. DJGPP emulates it as a regular file. + if test /dev/null != "$cache_file" && test -f "$cache_file"; then { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5 $as_echo "$as_me: loading cache $cache_file" >&6;} case $cache_file in @@ -2242,7 +2336,7 @@ if $ac_cache_corrupted; then $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5 $as_echo "$as_me: error: changes in the environment can compromise the build" >&2;} - as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 + as_fn_error $? "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5 fi ## -------------------- ## ## Main body of script. ## @@ -2263,11 +2357,14 @@ case "$srcdir" in *) srcdir=`cd $srcdir && pwd`;; esac +. $srcdir/VERSION +OS=`uname -s` + # Check whether --with-defshell was given. if test "${with_defshell+set}" = set; then : withval=$with_defshell; case "${withval}" in -yes) as_fn_error "bad value ${withval} given for bmake DEFSHELL" "$LINENO" 5 ;; +yes) as_fn_error $? "bad value ${withval} given for bmake DEFSHELL" "$LINENO" 5 ;; no) ;; *) case "$with_defshell" in sh) DEFSHELL_INDEX=DEFSHELL_INDEX_SH;; # it's the default anyway @@ -2279,13 +2376,26 @@ no) ;; esac fi +case "$OS" in +CYGWIN*|MINGW*) use_makefile=no;; +*) use_makefile=yes;; +esac + +# Check whether --with-makefile was given. +if test "${with_makefile+set}" = set; then : + withval=$with_makefile; case "${withval}" in +yes|no) use_makefile=${withval};; +*) as_fn_error $? "bad value ${withval} given for makefile" "$LINENO" 5 ;; +esac +fi + use_meta=yes # Check whether --with-meta was given. if test "${with_meta+set}" = set; then : withval=$with_meta; case "${withval}" in yes|no) use_meta=${withval};; -*) as_fn_error "bad value ${withval} given for meta" "$LINENO" 5 ;; +*) as_fn_error $? "bad value ${withval} given for meta" "$LINENO" 5 ;; esac fi @@ -2293,30 +2403,41 @@ fi # Check whether --with-filemon was given. if test "${with_filemon+set}" = set; then : withval=$with_filemon; case "/${withval}" in -/no|*/filemon.h) filemon_h="${withval}";; +/no) use_filemon=no;; +/*trace) filemon_h=no use_filemon="${withval}";; +*/filemon.h) filemon_h="${withval}";; */filemon*) filemon_h="${withval}/filemon.h";; -*) as_fn_error "bad value ${withval} given for filemon" "$LINENO" 5 ;; +*) as_fn_error $? "bad value ${withval} given for filemon" "$LINENO" 5 ;; esac else -OS=`uname -s` -for d in "/usr/include/dev/filemon" "$prefix/include/dev/filemon" "$srcdir/filemon" "$srcdir/../filemon" "$srcdir/../../sys/dev/filemon" -do - for x in "/$OS" "" - do - filemon_h="$d$x/filemon.h" - test -s "$filemon_h" && break - done - test -s "$filemon_h" && break -done -test -s "${filemon_h:-/dev/null}" || filemon_h=no +case "$OS" in +NetBSD) filemon_h=no use_filemon=ktrace;; +*) + for d in "/usr/include/dev/filemon" "$prefix/include/dev/filemon" "$srcdir/../../sys/dev/filemon" + do + for x in "/$OS" "" + do + filemon_h="$d$x/filemon.h" + test -s "$filemon_h" && break + done + test -s "$filemon_h" && { use_filemon=dev; break; } + done + ;; +esac +use_filemon=${use_filemon:-no} +case "$use_filemon" in +dev) ;; +*) filemon_h=no;; +esac fi case "$use_meta" in yes) - case "$filemon_h" in - *.h) echo "Using: filemon=$filemon_h" >&6;; + case "$use_filemon" in + no) ;; + *) echo "Using: filemon_${use_filemon}.c" >&6;; esac ;; esac @@ -2330,7 +2451,7 @@ if test -n "$ac_tool_prefix"; then set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -2342,7 +2463,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2370,7 +2491,7 @@ if test -z "$ac_cv_prog_CC"; then set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : +if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -2382,7 +2503,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2423,7 +2544,7 @@ if test -z "$CC"; then set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -2435,7 +2556,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2463,7 +2584,7 @@ if test -z "$CC"; then set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -2476,7 +2597,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue @@ -2522,7 +2643,7 @@ if test -z "$CC"; then set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -2534,7 +2655,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2566,7 +2687,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : +if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -2578,7 +2699,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -2620,8 +2741,8 @@ fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "no acceptable C compiler found in \$PATH -See \`config.log' for more details." "$LINENO" 5; } +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 @@ -2642,32 +2763,30 @@ $as_echo "$ac_try_echo"; } >&5 ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 - rm -f conftest.er1 conftest.err fi + rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -#include <stdio.h> + int main () { -FILE *f = fopen ("conftest.out", "w"); - return ferror (f) || fclose (f) != 0; ; return 0; } _ACEOF ac_clean_files_save=$ac_clean_files -ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out conftest.out" +ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out" # Try to create an executable without -o first, disregard a.out. # It will help us diagnose broken compilers, and finding out an intuition # of exeext. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 -$as_echo_n "checking for C compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 +$as_echo_n "checking whether the C compiler works... " >&6; } ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'` # The possible output files: @@ -2729,62 +2848,28 @@ test "$ac_cv_exeext" = no && ac_cv_exeext= else ac_file='' fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 -$as_echo "$ac_file" >&6; } if test -z "$ac_file"; then : - $as_echo "$as_me: failed program was:" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +$as_echo "$as_me: failed program was:" >&5 sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -{ as_fn_set_status 77 -as_fn_error "C compiler cannot create executables -See \`config.log' for more details." "$LINENO" 5; }; } +as_fn_error 77 "C compiler cannot create executables +See \`config.log' for more details" "$LINENO" 5; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 +$as_echo "yes" >&6; } fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5 +$as_echo_n "checking for C compiler default output file name... " >&6; } +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5 +$as_echo "$ac_file" >&6; } ac_exeext=$ac_cv_exeext -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5 -$as_echo_n "checking whether the C compiler works... " >&6; } -# If not cross compiling, check that we can run a simple program. -if test "$cross_compiling" != yes; then - if { ac_try='./$ac_file' - { { case "(($ac_try" in - *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; - *) ac_try_echo=$ac_try;; -esac -eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" -$as_echo "$ac_try_echo"; } >&5 - (eval "$ac_try") 2>&5 - ac_status=$? - $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 - test $ac_status = 0; }; }; then - cross_compiling=no - else - if test "$cross_compiling" = maybe; then - cross_compiling=yes - else - { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 -$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "cannot run C compiled programs. -If you meant to cross compile, use \`--host'. -See \`config.log' for more details." "$LINENO" 5; } - fi - fi -fi -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - -rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out conftest.out +rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out ac_clean_files=$ac_clean_files_save -# Check that the compiler produces executables we can run. If not, either -# the compiler is broken, or we cross compile. -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 -$as_echo_n "checking whether we are cross compiling... " >&6; } -{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 -$as_echo "$cross_compiling" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5 $as_echo_n "checking for suffix of executables... " >&6; } if { { ac_try="$ac_link" @@ -2814,19 +2899,78 @@ done else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "cannot compute suffix of executables: cannot compile and link -See \`config.log' for more details." "$LINENO" 5; } +as_fn_error $? "cannot compute suffix of executables: cannot compile and link +See \`config.log' for more details" "$LINENO" 5; } fi -rm -f conftest$ac_cv_exeext +rm -f conftest conftest$ac_cv_exeext { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5 $as_echo "$ac_cv_exeext" >&6; } rm -f conftest.$ac_ext EXEEXT=$ac_cv_exeext ac_exeext=$EXEEXT +cat confdefs.h - <<_ACEOF >conftest.$ac_ext +/* end confdefs.h. */ +#include <stdio.h> +int +main () +{ +FILE *f = fopen ("conftest.out", "w"); + return ferror (f) || fclose (f) != 0; + + ; + return 0; +} +_ACEOF +ac_clean_files="$ac_clean_files conftest.out" +# Check that the compiler produces executables we can run. If not, either +# the compiler is broken, or we cross compile. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5 +$as_echo_n "checking whether we are cross compiling... " >&6; } +if test "$cross_compiling" != yes; then + { { ac_try="$ac_link" +case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_link") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; } + if { ac_try='./conftest$ac_cv_exeext' + { { case "(($ac_try" in + *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;; + *) ac_try_echo=$ac_try;; +esac +eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\"" +$as_echo "$ac_try_echo"; } >&5 + (eval "$ac_try") 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; }; then + cross_compiling=no + else + if test "$cross_compiling" = maybe; then + cross_compiling=yes + else + { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 +$as_echo "$as_me: error: in \`$ac_pwd':" >&2;} +as_fn_error $? "cannot run C compiled programs. +If you meant to cross compile, use \`--host'. +See \`config.log' for more details" "$LINENO" 5; } + fi + fi +fi +{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5 +$as_echo "$cross_compiling" >&6; } + +rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out +ac_clean_files=$ac_clean_files_save { $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5 $as_echo_n "checking for suffix of object files... " >&6; } -if test "${ac_cv_objext+set}" = set; then : +if ${ac_cv_objext+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -2866,8 +3010,8 @@ sed 's/^/| /' conftest.$ac_ext >&5 { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "cannot compute suffix of object files: cannot compile -See \`config.log' for more details." "$LINENO" 5; } +as_fn_error $? "cannot compute suffix of object files: cannot compile +See \`config.log' for more details" "$LINENO" 5; } fi rm -f conftest.$ac_cv_objext conftest.$ac_ext fi @@ -2877,7 +3021,7 @@ OBJEXT=$ac_cv_objext ac_objext=$OBJEXT { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if test "${ac_cv_c_compiler_gnu+set}" = set; then : +if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -2914,7 +3058,7 @@ ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } -if test "${ac_cv_prog_cc_g+set}" = set; then : +if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag @@ -2992,7 +3136,7 @@ else fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if test "${ac_cv_prog_cc_c89+set}" = set; then : +if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no @@ -3001,8 +3145,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <stdarg.h> #include <stdio.h> -#include <sys/types.h> -#include <sys/stat.h> +struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); @@ -3100,7 +3243,7 @@ if test -n "$CPP" && test -d "$CPP"; then CPP= fi if test -z "$CPP"; then - if test "${ac_cv_prog_CPP+set}" = set; then : + if ${ac_cv_prog_CPP+:} false; then : $as_echo_n "(cached) " >&6 else # Double quotes because CPP needs to be expanded @@ -3130,7 +3273,7 @@ else # Broken: fails on valid input. continue fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. @@ -3146,11 +3289,11 @@ else ac_preproc_ok=: break fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext +rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : break fi @@ -3189,7 +3332,7 @@ else # Broken: fails on valid input. continue fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext # OK, works on sane cases. Now check whether nonexistent headers # can be detected and how. @@ -3205,18 +3348,18 @@ else ac_preproc_ok=: break fi -rm -f conftest.err conftest.$ac_ext +rm -f conftest.err conftest.i conftest.$ac_ext done # Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped. -rm -f conftest.err conftest.$ac_ext +rm -f conftest.i conftest.err conftest.$ac_ext if $ac_preproc_ok; then : else { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "C preprocessor \"$CPP\" fails sanity check -See \`config.log' for more details." "$LINENO" 5; } +as_fn_error $? "C preprocessor \"$CPP\" fails sanity check +See \`config.log' for more details" "$LINENO" 5; } fi ac_ext=c @@ -3228,7 +3371,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu { $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5 $as_echo_n "checking for grep that handles long lines and -e... " >&6; } -if test "${ac_cv_path_GREP+set}" = set; then : +if ${ac_cv_path_GREP+:} false; then : $as_echo_n "(cached) " >&6 else if test -z "$GREP"; then @@ -3242,7 +3385,7 @@ do for ac_prog in grep ggrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue + as_fn_executable_p "$ac_path_GREP" || continue # Check for GNU ac_path_GREP and select it if it is found. # Check for GNU $ac_path_GREP case `"$ac_path_GREP" --version 2>&1` in @@ -3277,7 +3420,7 @@ esac done IFS=$as_save_IFS if test -z "$ac_cv_path_GREP"; then - as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_GREP=$GREP @@ -3291,7 +3434,7 @@ $as_echo "$ac_cv_path_GREP" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5 $as_echo_n "checking for egrep... " >&6; } -if test "${ac_cv_path_EGREP+set}" = set; then : +if ${ac_cv_path_EGREP+:} false; then : $as_echo_n "(cached) " >&6 else if echo a | $GREP -E '(a|b)' >/dev/null 2>&1 @@ -3308,7 +3451,7 @@ do for ac_prog in egrep; do for ac_exec_ext in '' $ac_executable_extensions; do ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext" - { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue + as_fn_executable_p "$ac_path_EGREP" || continue # Check for GNU ac_path_EGREP and select it if it is found. # Check for GNU $ac_path_EGREP case `"$ac_path_EGREP" --version 2>&1` in @@ -3343,7 +3486,7 @@ esac done IFS=$as_save_IFS if test -z "$ac_cv_path_EGREP"; then - as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 + as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5 fi else ac_cv_path_EGREP=$EGREP @@ -3358,7 +3501,7 @@ $as_echo "$ac_cv_path_EGREP" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } -if test "${ac_cv_header_stdc+set}" = set; then : +if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -3475,8 +3618,7 @@ do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default " -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -3488,7 +3630,7 @@ done ac_fn_c_check_header_mongrel "$LINENO" "minix/config.h" "ac_cv_header_minix_config_h" "$ac_includes_default" -if test "x$ac_cv_header_minix_config_h" = x""yes; then : +if test "x$ac_cv_header_minix_config_h" = xyes; then : MINIX=yes else MINIX= @@ -3510,14 +3652,14 @@ $as_echo "#define _MINIX 1" >>confdefs.h { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5 $as_echo_n "checking whether it is safe to define __EXTENSIONS__... " >&6; } -if test "${ac_cv_safe_to_define___extensions__+set}" = set; then : +if ${ac_cv_safe_to_define___extensions__+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ -# define __EXTENSIONS__ 1 - $ac_includes_default +# define __EXTENSIONS__ 1 + $ac_includes_default int main () { @@ -3557,7 +3699,7 @@ if test -n "$ac_tool_prefix"; then set dummy ${ac_tool_prefix}gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -3569,7 +3711,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3597,7 +3739,7 @@ if test -z "$ac_cv_prog_CC"; then set dummy gcc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : +if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -3609,7 +3751,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="gcc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3650,7 +3792,7 @@ if test -z "$CC"; then set dummy ${ac_tool_prefix}cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -3662,7 +3804,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="${ac_tool_prefix}cc" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3690,7 +3832,7 @@ if test -z "$CC"; then set dummy cc; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -3703,7 +3845,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then ac_prog_rejected=yes continue @@ -3749,7 +3891,7 @@ if test -z "$CC"; then set dummy $ac_tool_prefix$ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_CC+set}" = set; then : +if ${ac_cv_prog_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$CC"; then @@ -3761,7 +3903,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_CC="$ac_tool_prefix$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3793,7 +3935,7 @@ do set dummy $ac_prog; ac_word=$2 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 $as_echo_n "checking for $ac_word... " >&6; } -if test "${ac_cv_prog_ac_ct_CC+set}" = set; then : +if ${ac_cv_prog_ac_ct_CC+:} false; then : $as_echo_n "(cached) " >&6 else if test -n "$ac_ct_CC"; then @@ -3805,7 +3947,7 @@ do IFS=$as_save_IFS test -z "$as_dir" && as_dir=. for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then ac_cv_prog_ac_ct_CC="$ac_prog" $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 break 2 @@ -3847,8 +3989,8 @@ fi test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5 $as_echo "$as_me: error: in \`$ac_pwd':" >&2;} -as_fn_error "no acceptable C compiler found in \$PATH -See \`config.log' for more details." "$LINENO" 5; } +as_fn_error $? "no acceptable C compiler found in \$PATH +See \`config.log' for more details" "$LINENO" 5; } # Provide some information about the compiler. $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5 @@ -3869,15 +4011,15 @@ $as_echo "$ac_try_echo"; } >&5 ... rest of stderr output deleted ... 10q' conftest.err >conftest.er1 cat conftest.er1 >&5 - rm -f conftest.er1 conftest.err fi + rm -f conftest.er1 conftest.err $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 test $ac_status = 0; } done { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5 $as_echo_n "checking whether we are using the GNU C compiler... " >&6; } -if test "${ac_cv_c_compiler_gnu+set}" = set; then : +if ${ac_cv_c_compiler_gnu+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -3914,7 +4056,7 @@ ac_test_CFLAGS=${CFLAGS+set} ac_save_CFLAGS=$CFLAGS { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5 $as_echo_n "checking whether $CC accepts -g... " >&6; } -if test "${ac_cv_prog_cc_g+set}" = set; then : +if ${ac_cv_prog_cc_g+:} false; then : $as_echo_n "(cached) " >&6 else ac_save_c_werror_flag=$ac_c_werror_flag @@ -3992,7 +4134,7 @@ else fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5 $as_echo_n "checking for $CC option to accept ISO C89... " >&6; } -if test "${ac_cv_prog_cc_c89+set}" = set; then : +if ${ac_cv_prog_cc_c89+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_prog_cc_c89=no @@ -4001,8 +4143,7 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ #include <stdarg.h> #include <stdio.h> -#include <sys/types.h> -#include <sys/stat.h> +struct stat; /* Most of the following tests are stolen from RCS 5.7's src/conf.sh. */ struct buf { int x; }; FILE * (*rcsopen) (struct buf *, struct stat *, int); @@ -4090,7 +4231,7 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu if test $ac_cv_c_compiler_gnu = yes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC needs -traditional" >&5 $as_echo_n "checking whether $CC needs -traditional... " >&6; } -if test "${ac_cv_prog_gcc_traditional+set}" = set; then : +if ${ac_cv_prog_gcc_traditional+:} false; then : $as_echo_n "(cached) " >&6 else ac_pattern="Autoconf.*'x'" @@ -4131,16 +4272,22 @@ fi ac_aux_dir= for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do - for ac_t in install-sh install.sh shtool; do - if test -f "$ac_dir/$ac_t"; then - ac_aux_dir=$ac_dir - ac_install_sh="$ac_aux_dir/$ac_t -c" - break 2 - fi - done + if test -f "$ac_dir/install-sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f "$ac_dir/install.sh"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + elif test -f "$ac_dir/shtool"; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/shtool install -c" + break + fi done if test -z "$ac_aux_dir"; then - as_fn_error "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 + as_fn_error $? "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5 fi # These three variables are undocumented and unsupported, @@ -4169,7 +4316,7 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. { $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5 $as_echo_n "checking for a BSD-compatible install... " >&6; } if test -z "$INSTALL"; then -if test "${ac_cv_path_install+set}" = set; then : +if ${ac_cv_path_install+:} false; then : $as_echo_n "(cached) " >&6 else as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -4189,7 +4336,7 @@ case $as_dir/ in #(( # by default. for ac_prog in ginstall scoinst install; do for ac_exec_ext in '' $ac_executable_extensions; do - if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then + if as_fn_executable_p "$as_dir/$ac_prog$ac_exec_ext"; then if test $ac_prog = install && grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then # AIX install. It has an incompatible calling convention. @@ -4259,7 +4406,7 @@ echo "Using: BMAKE_PATH_MAX=$bmake_path_max" >&6 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5 $as_echo_n "checking for ANSI C header files... " >&6; } -if test "${ac_cv_header_stdc+set}" = set; then : +if ${ac_cv_header_stdc+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -4371,7 +4518,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sys/wait.h that is POSIX.1 compatible" >&5 $as_echo_n "checking for sys/wait.h that is POSIX.1 compatible... " >&6; } -if test "${ac_cv_header_sys_wait_h+set}" = set; then : +if ${ac_cv_header_sys_wait_h+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -4415,7 +4562,7 @@ for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do as_ac_Header=`$as_echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh` { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_hdr that defines DIR" >&5 $as_echo_n "checking for $ac_hdr that defines DIR... " >&6; } -if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then : +if eval \${$as_ac_Header+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -4442,8 +4589,7 @@ fi eval ac_res=\$$as_ac_Header { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5 $as_echo "$ac_res" >&6; } -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_hdr" | $as_tr_cpp` 1 _ACEOF @@ -4456,7 +4602,7 @@ done if test $ac_header_dirent = dirent.h; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5 $as_echo_n "checking for library containing opendir... " >&6; } -if test "${ac_cv_search_opendir+set}" = set; then : +if ${ac_cv_search_opendir+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS @@ -4490,11 +4636,11 @@ for ac_lib in '' dir; do fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext - if test "${ac_cv_search_opendir+set}" = set; then : + if ${ac_cv_search_opendir+:} false; then : break fi done -if test "${ac_cv_search_opendir+set}" = set; then : +if ${ac_cv_search_opendir+:} false; then : else ac_cv_search_opendir=no @@ -4513,7 +4659,7 @@ fi else { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5 $as_echo_n "checking for library containing opendir... " >&6; } -if test "${ac_cv_search_opendir+set}" = set; then : +if ${ac_cv_search_opendir+:} false; then : $as_echo_n "(cached) " >&6 else ac_func_search_save_LIBS=$LIBS @@ -4547,11 +4693,11 @@ for ac_lib in '' x; do fi rm -f core conftest.err conftest.$ac_objext \ conftest$ac_exeext - if test "${ac_cv_search_opendir+set}" = set; then : + if ${ac_cv_search_opendir+:} false; then : break fi done -if test "${ac_cv_search_opendir+set}" = set; then : +if ${ac_cv_search_opendir+:} false; then : else ac_cv_search_opendir=no @@ -4569,10 +4715,41 @@ fi fi +for ac_header in sys/param.h +do : + ac_fn_c_check_header_mongrel "$LINENO" "sys/param.h" "ac_cv_header_sys_param_h" "$ac_includes_default" +if test "x$ac_cv_header_sys_param_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SYS_PARAM_H 1 +_ACEOF + +fi + +done + +for ac_header in sys/sysctl.h +do : + ac_fn_c_check_header_compile "$LINENO" "sys/sysctl.h" "ac_cv_header_sys_sysctl_h" "#ifdef HAVE_SYS_PARAM_H +# include <sys/param.h> +# endif + +" +if test "x$ac_cv_header_sys_sysctl_h" = xyes; then : + cat >>confdefs.h <<_ACEOF +#define HAVE_SYS_SYSCTL_H 1 +_ACEOF + +fi + +done + + for ac_header in \ ar.h \ err.h \ fcntl.h \ + libgen.h \ + limits.h \ paths.h \ poll.h \ ranlib.h \ @@ -4580,7 +4757,6 @@ for ac_header in \ sys/mman.h \ sys/select.h \ sys/socket.h \ - sys/sysctl.h \ sys/time.h \ sys/uio.h \ unistd.h \ @@ -4589,8 +4765,7 @@ for ac_header in \ do : as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default" -eval as_val=\$$as_ac_Header - if test "x$as_val" = x""yes; then : +if eval test \"x\$"$as_ac_Header"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1 _ACEOF @@ -4601,7 +4776,7 @@ done ac_fn_c_check_header_mongrel "$LINENO" "sys/cdefs.h" "ac_cv_header_sys_cdefs_h" "$ac_includes_default" -if test "x$ac_cv_header_sys_cdefs_h" = x""yes; then : +if test "x$ac_cv_header_sys_cdefs_h" = xyes; then : echo $ECHO_N "checking whether sys/cdefs.h is compatible... $ECHO_C" >&6 cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ @@ -4628,7 +4803,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking for __attribute__" >&5 $as_echo_n "checking for __attribute__... " >&6; } -if test "${ac_cv___attribute__+set}" = set; then : +if ${ac_cv___attribute__+:} false; then : $as_echo_n "(cached) " >&6 else @@ -4637,10 +4812,6 @@ cat confdefs.h - <<_ACEOF >conftest.$ac_ext #include <stdlib.h> -int -main () -{ - static void foo(void) __attribute__ ((noreturn)); static void @@ -4649,16 +4820,20 @@ foo(void) exit(1); } - ; - return 0; +int +main(int argc, char **argv) +{ + foo(); } + _ACEOF -if ac_fn_c_try_compile "$LINENO"; then : +if ac_fn_c_try_link "$LINENO"; then : ac_cv___attribute__=yes else ac_cv___attribute__=no fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext +rm -f core conftest.err conftest.$ac_objext \ + conftest$ac_exeext conftest.$ac_ext fi if test "$ac_cv___attribute__" = "yes"; then @@ -4671,7 +4846,7 @@ $as_echo "$ac_cv___attribute__" >&6; } { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5 $as_echo_n "checking whether byte ordering is bigendian... " >&6; } -if test "${ac_cv_c_bigendian+set}" = set; then : +if ${ac_cv_c_bigendian+:} false; then : $as_echo_n "(cached) " >&6 else ac_cv_c_bigendian=unknown @@ -4889,13 +5064,13 @@ $as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h ;; #( *) - as_fn_error "unknown endianness + as_fn_error $? "unknown endianness presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;; esac { $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5 $as_echo_n "checking for an ANSI C-conforming const... " >&6; } -if test "${ac_cv_c_const+set}" = set; then : +if ${ac_cv_c_const+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -4904,11 +5079,11 @@ else int main () { -/* FIXME: Include the comments suggested by Paul. */ + #ifndef __cplusplus - /* Ultrix mips cc rejects this. */ + /* Ultrix mips cc rejects this sort of thing. */ typedef int charset[2]; - const charset cs; + const charset cs = { 0, 0 }; /* SunOS 4.1.1 cc rejects this. */ char const *const *pcpcc; char **ppc; @@ -4925,8 +5100,9 @@ main () ++pcpcc; ppc = (char**) pcpcc; pcpcc = (char const *const *) ppc; - { /* SCO 3.2v4 cc rejects this. */ - char *t; + { /* SCO 3.2v4 cc rejects this sort of thing. */ + char tx; + char *t = &tx; char const *s = 0 ? (char *) 0 : (char const *) 0; *t++ = 0; @@ -4942,10 +5118,10 @@ main () iptr p = 0; ++p; } - { /* AIX XL C 1.02.0.0 rejects this saying + { /* AIX XL C 1.02.0.0 rejects this sort of thing, saying "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ - struct s { int j; const int *ap[3]; }; - struct s *b; b->j = 5; + struct s { int j; const int *ap[3]; } bx; + struct s *b = &bx; b->j = 5; } { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ const int foo = 10; @@ -4973,8 +5149,19 @@ $as_echo "#define const /**/" >>confdefs.h fi +ac_fn_c_check_type "$LINENO" "mode_t" "ac_cv_type_mode_t" "$ac_includes_default" +if test "x$ac_cv_type_mode_t" = xyes; then : + +else + +cat >>confdefs.h <<_ACEOF +#define mode_t int +_ACEOF + +fi + ac_fn_c_check_type "$LINENO" "off_t" "ac_cv_type_off_t" "$ac_includes_default" -if test "x$ac_cv_type_off_t" = x""yes; then : +if test "x$ac_cv_type_off_t" = xyes; then : else @@ -4985,7 +5172,7 @@ _ACEOF fi ac_fn_c_check_type "$LINENO" "pid_t" "ac_cv_type_pid_t" "$ac_includes_default" -if test "x$ac_cv_type_pid_t" = x""yes; then : +if test "x$ac_cv_type_pid_t" = xyes; then : else @@ -4996,7 +5183,7 @@ _ACEOF fi ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default" -if test "x$ac_cv_type_size_t" = x""yes; then : +if test "x$ac_cv_type_size_t" = xyes; then : else @@ -5006,6 +5193,20 @@ _ACEOF fi +ac_fn_c_find_uintX_t "$LINENO" "32" "ac_cv_c_uint32_t" +case $ac_cv_c_uint32_t in #( + no|yes) ;; #( + *) + +$as_echo "#define _UINT32_T 1" >>confdefs.h + + +cat >>confdefs.h <<_ACEOF +#define uint32_t $ac_cv_c_uint32_t +_ACEOF +;; + esac + ac_fn_c_check_decl "$LINENO" "sys_siglist" "ac_cv_have_decl_sys_siglist" "#include <signal.h> /* NetBSD declares sys_siglist in unistd.h. */ #ifdef HAVE_UNISTD_H @@ -5013,7 +5214,7 @@ ac_fn_c_check_decl "$LINENO" "sys_siglist" "ac_cv_have_decl_sys_siglist" "#inclu #endif " -if test "x$ac_cv_have_decl_sys_siglist" = x""yes; then : +if test "x$ac_cv_have_decl_sys_siglist" = xyes; then : ac_have_decl=1 else ac_have_decl=0 @@ -5026,7 +5227,7 @@ _ACEOF { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5 $as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; } -if test "${ac_cv_header_time+set}" = set; then : +if ${ac_cv_header_time+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -5061,7 +5262,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether struct tm is in sys/time.h or time.h" >&5 $as_echo_n "checking whether struct tm is in sys/time.h or time.h... " >&6; } -if test "${ac_cv_struct_tm+set}" = set; then : +if ${ac_cv_struct_tm+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -5097,7 +5298,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5 $as_echo_n "checking return type of signal handlers... " >&6; } -if test "${ac_cv_type_signal+set}" = set; then : +if ${ac_cv_type_signal+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -5131,7 +5332,7 @@ _ACEOF for ac_header in vfork.h do : ac_fn_c_check_header_mongrel "$LINENO" "vfork.h" "ac_cv_header_vfork_h" "$ac_includes_default" -if test "x$ac_cv_header_vfork_h" = x""yes; then : +if test "x$ac_cv_header_vfork_h" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_VFORK_H 1 _ACEOF @@ -5144,8 +5345,7 @@ for ac_func in fork vfork do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -eval as_val=\$$as_ac_var - if test "x$as_val" = x""yes; then : +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF @@ -5156,7 +5356,7 @@ done if test "x$ac_cv_func_fork" = xyes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working fork" >&5 $as_echo_n "checking for working fork... " >&6; } -if test "${ac_cv_func_fork_works+set}" = set; then : +if ${ac_cv_func_fork_works+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : @@ -5209,7 +5409,7 @@ ac_cv_func_vfork_works=$ac_cv_func_vfork if test "x$ac_cv_func_vfork" = xyes; then { $as_echo "$as_me:${as_lineno-$LINENO}: checking for working vfork" >&5 $as_echo_n "checking for working vfork... " >&6; } -if test "${ac_cv_func_vfork_works+set}" = set; then : +if ${ac_cv_func_vfork_works+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : @@ -5345,13 +5545,13 @@ fi for ac_func in vprintf do : ac_fn_c_check_func "$LINENO" "vprintf" "ac_cv_func_vprintf" -if test "x$ac_cv_func_vprintf" = x""yes; then : +if test "x$ac_cv_func_vprintf" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_VPRINTF 1 _ACEOF ac_fn_c_check_func "$LINENO" "_doprnt" "ac_cv_func__doprnt" -if test "x$ac_cv_func__doprnt" = x""yes; then : +if test "x$ac_cv_func__doprnt" = xyes; then : $as_echo "#define HAVE_DOPRNT 1" >>confdefs.h @@ -5363,7 +5563,7 @@ done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for wait3 that fills in rusage" >&5 $as_echo_n "checking for wait3 that fills in rusage... " >&6; } -if test "${ac_cv_func_wait3_rusage+set}" = set; then : +if ${ac_cv_func_wait3_rusage+:} false; then : $as_echo_n "(cached) " >&6 else if test "$cross_compiling" = yes; then : @@ -5459,8 +5659,7 @@ for ac_func in \ do : as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -eval as_val=\$$as_ac_var - if test "x$as_val" = x""yes; then : +if eval test \"x\$"$as_ac_var"\" = x"yes"; then : cat >>confdefs.h <<_ACEOF #define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 _ACEOF @@ -5469,36 +5668,63 @@ fi done -for ac_func in \ - realpath \ - dirname \ - stresep \ - strlcpy \ +ac_fn_c_check_func "$LINENO" "realpath" "ac_cv_func_realpath" +if test "x$ac_cv_func_realpath" = xyes; then : + $as_echo "#define HAVE_REALPATH 1" >>confdefs.h -do : - as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh` -ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var" -eval as_val=\$$as_ac_var - if test "x$as_val" = x""yes; then : - cat >>confdefs.h <<_ACEOF -#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1 -_ACEOF +else + case " $LIBOBJS " in + *" realpath.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS realpath.$ac_objext" + ;; +esac + +fi + +ac_fn_c_check_func "$LINENO" "dirname" "ac_cv_func_dirname" +if test "x$ac_cv_func_dirname" = xyes; then : + $as_echo "#define HAVE_DIRNAME 1" >>confdefs.h else case " $LIBOBJS " in - *" $ac_func.$ac_objext "* ) ;; - *) LIBOBJS="$LIBOBJS $ac_func.$ac_objext" + *" dirname.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS dirname.$ac_objext" + ;; +esac + +fi + +ac_fn_c_check_func "$LINENO" "stresep" "ac_cv_func_stresep" +if test "x$ac_cv_func_stresep" = xyes; then : + $as_echo "#define HAVE_STRESEP 1" >>confdefs.h + +else + case " $LIBOBJS " in + *" stresep.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS stresep.$ac_objext" + ;; +esac + +fi + +ac_fn_c_check_func "$LINENO" "strlcpy" "ac_cv_func_strlcpy" +if test "x$ac_cv_func_strlcpy" = xyes; then : + $as_echo "#define HAVE_STRLCPY 1" >>confdefs.h + +else + case " $LIBOBJS " in + *" strlcpy.$ac_objext "* ) ;; + *) LIBOBJS="$LIBOBJS strlcpy.$ac_objext" ;; esac fi -done { $as_echo "$as_me:${as_lineno-$LINENO}: checking for emalloc in -lutil" >&5 $as_echo_n "checking for emalloc in -lutil... " >&6; } -if test "${ac_cv_lib_util_emalloc+set}" = set; then : +if ${ac_cv_lib_util_emalloc+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -5532,10 +5758,10 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_util_emalloc" >&5 $as_echo "$ac_cv_lib_util_emalloc" >&6; } -if test "x$ac_cv_lib_util_emalloc" = x""yes; then : +if test "x$ac_cv_lib_util_emalloc" = xyes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for erealloc in -lutil" >&5 $as_echo_n "checking for erealloc in -lutil... " >&6; } -if test "${ac_cv_lib_util_erealloc+set}" = set; then : +if ${ac_cv_lib_util_erealloc+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -5569,10 +5795,10 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_util_erealloc" >&5 $as_echo "$ac_cv_lib_util_erealloc" >&6; } -if test "x$ac_cv_lib_util_erealloc" = x""yes; then : +if test "x$ac_cv_lib_util_erealloc" = xyes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for estrdup in -lutil" >&5 $as_echo_n "checking for estrdup in -lutil... " >&6; } -if test "${ac_cv_lib_util_estrdup+set}" = set; then : +if ${ac_cv_lib_util_estrdup+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -5606,10 +5832,10 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_util_estrdup" >&5 $as_echo "$ac_cv_lib_util_estrdup" >&6; } -if test "x$ac_cv_lib_util_estrdup" = x""yes; then : +if test "x$ac_cv_lib_util_estrdup" = xyes; then : { $as_echo "$as_me:${as_lineno-$LINENO}: checking for estrndup in -lutil" >&5 $as_echo_n "checking for estrndup in -lutil... " >&6; } -if test "${ac_cv_lib_util_estrndup+set}" = set; then : +if ${ac_cv_lib_util_estrndup+:} false; then : $as_echo_n "(cached) " >&6 else ac_check_lib_save_LIBS=$LIBS @@ -5643,7 +5869,7 @@ LIBS=$ac_check_lib_save_LIBS fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_util_estrndup" >&5 $as_echo "$ac_cv_lib_util_estrndup" >&6; } -if test "x$ac_cv_lib_util_estrndup" = x""yes; then : +if test "x$ac_cv_lib_util_estrndup" = xyes; then : LIBS="$LIBS -lutil" CPPFLAGS="$CPPFLAGS -DUSE_EMALLOC" fi @@ -5657,7 +5883,7 @@ fi { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stat file-mode macros are broken" >&5 $as_echo_n "checking whether stat file-mode macros are broken... " >&6; } -if test "${ac_cv_header_stat_broken+set}" = set; then : +if ${ac_cv_header_stat_broken+:} false; then : $as_echo_n "(cached) " >&6 else cat confdefs.h - <<_ACEOF >conftest.$ac_ext @@ -5698,7 +5924,7 @@ $as_echo "#define STAT_MACROS_BROKEN 1" >>confdefs.h fi ac_fn_c_check_member "$LINENO" "struct stat" "st_rdev" "ac_cv_member_struct_stat_st_rdev" "$ac_includes_default" -if test "x$ac_cv_member_struct_stat_st_rdev" = x""yes; then : +if test "x$ac_cv_member_struct_stat_st_rdev" = xyes; then : cat >>confdefs.h <<_ACEOF #define HAVE_STRUCT_STAT_ST_RDEV 1 @@ -5769,7 +5995,7 @@ echo "defaults: MACHINE=$machine, MACHINE_ARCH=$machine_arch" 1>&6 # Check whether --with-machine was given. if test "${with_machine+set}" = set; then : withval=$with_machine; case "${withval}" in -yes) as_fn_error "bad value ${withval} given for bmake MACHINE" "$LINENO" 5 ;; +yes) as_fn_error $? "bad value ${withval} given for bmake MACHINE" "$LINENO" 5 ;; no) ;; generic) machine=`$srcdir/machine.sh`;; *) machine=$with_machine;; @@ -5802,7 +6028,7 @@ fi # Check whether --with-machine_arch was given. if test "${with_machine_arch+set}" = set; then : withval=$with_machine_arch; case "${withval}" in -yes) as_fn_error "bad value ${withval} given for bmake MACHINE_ARCH" "$LINENO" 5 ;; +yes) as_fn_error $? "bad value ${withval} given for bmake MACHINE_ARCH" "$LINENO" 5 ;; no) ;; *) machine_arch=$with_machine_arch;; esac @@ -5814,7 +6040,7 @@ default_sys_path=\${prefix}/share/mk # Check whether --with-default-sys-path was given. if test "${with_default_sys_path+set}" = set; then : withval=$with_default_sys_path; case "${withval}" in -yes) as_fn_error "bad value ${withval} given for bmake _PATH_DEFSYSPATH" "$LINENO" 5 ;; +yes) as_fn_error $? "bad value ${withval} given for bmake _PATH_DEFSYSPATH" "$LINENO" 5 ;; no) ;; *) default_sys_path="$with_default_sys_path" ;; @@ -5825,7 +6051,7 @@ fi # Check whether --with-path-objdirprefix was given. if test "${with_path_objdirprefix+set}" = set; then : withval=$with_path_objdirprefix; case "${withval}" in -yes) as_fn_error "bad value ${withval} given for bmake _PATH_OBJDIRPREFIX" "$LINENO" 5 ;; +yes) as_fn_error $? "bad value ${withval} given for bmake _PATH_OBJDIRPREFIX" "$LINENO" 5 ;; no) CPPFLAGS="$CPPFLAGS -DNO_PATH_OBJDIRPREFIX" ;; *) CPPFLAGS="$CPPFLAGS \"-D_PATH_OBJDIRPREFIX=\\\"$with_path-objdir\\\"\"" ;; esac @@ -5836,7 +6062,7 @@ if test "${enable_pwd_override+set}" = set; then : enableval=$enable_pwd_override; case "${enableval}" in yes) ;; no) CPPFLAGS="$CPPFLAGS -DNO_PWD_OVERRIDE" ;; -*) as_fn_error "bad value ${enableval} given for pwd-override option" "$LINENO" 5 ;; +*) as_fn_error $? "bad value ${enableval} given for pwd-override option" "$LINENO" 5 ;; esac fi @@ -5845,7 +6071,7 @@ if test "${enable_check_make_chdir+set}" = set; then : enableval=$enable_check_make_chdir; case "${enableval}" in yes) ;; no) CPPFLAGS="$CPPFLAGS -DNO_CHECK_MAKE_CHDIR" ;; -*) as_fn_error "bad value ${enableval} given for check-make-chdir option" "$LINENO" 5 ;; +*) as_fn_error $? "bad value ${enableval} given for check-make-chdir option" "$LINENO" 5 ;; esac fi @@ -5855,7 +6081,7 @@ if test "${with_mksrc+set}" = set; then : withval=$with_mksrc; case "${withval}" in ""|yes|no) ;; *) test -s $withval/install-mk && mksrc=$withval || -as_fn_error "bad value ${withval} given for mksrc cannot find install-mk" "$LINENO" 5 +as_fn_error $? "bad value ${withval} given for mksrc cannot find install-mk" "$LINENO" 5 ;; esac @@ -5898,7 +6124,13 @@ fi -ac_config_files="$ac_config_files makefile Makefile.config make-bootstrap.sh unit-tests/Makefile" + + +bm_outfiles="Makefile.config unit-tests/Makefile.config make-bootstrap.sh" +if test $use_makefile = yes; then + bm_outfiles="makefile $bm_outfiles" +fi +ac_config_files="$ac_config_files $bm_outfiles" cat >confcache <<\_ACEOF # This file is a shell script that caches the results of configure @@ -5964,10 +6196,21 @@ $as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;; :end' >>confcache if diff "$cache_file" confcache >/dev/null 2>&1; then :; else if test -w "$cache_file"; then - test "x$cache_file" != "x/dev/null" && + if test "x$cache_file" != "x/dev/null"; then { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5 $as_echo "$as_me: updating cache $cache_file" >&6;} - cat confcache >$cache_file + if test ! -f "$cache_file" || test -h "$cache_file"; then + cat confcache >"$cache_file" + else + case $cache_file in #( + */* | ?:*) + mv -f confcache "$cache_file"$$ && + mv -f "$cache_file"$$ "$cache_file" ;; #( + *) + mv -f confcache "$cache_file" ;; + esac + fi + fi else { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5 $as_echo "$as_me: not updating unwritable cache $cache_file" >&6;} @@ -5983,6 +6226,7 @@ DEFS=-DHAVE_CONFIG_H ac_libobjs= ac_ltlibobjs= +U= for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue # 1. Remove the extension, and $U if already installed. ac_script='s/\$U\././;s/\.o$//;s/\.obj$//' @@ -5999,7 +6243,7 @@ LTLIBOBJS=$ac_ltlibobjs -: ${CONFIG_STATUS=./config.status} +: "${CONFIG_STATUS=./config.status}" ac_write_fail=0 ac_clean_files_save=$ac_clean_files ac_clean_files="$ac_clean_files $CONFIG_STATUS" @@ -6100,6 +6344,7 @@ fi IFS=" "" $as_nl" # Find who we are. Look in the path if we contain no directory separator. +as_myself= case $0 in #(( *[\\/]* ) as_myself=$0 ;; *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR @@ -6145,19 +6390,19 @@ export LANGUAGE (unset CDPATH) >/dev/null 2>&1 && unset CDPATH -# as_fn_error ERROR [LINENO LOG_FD] -# --------------------------------- +# as_fn_error STATUS ERROR [LINENO LOG_FD] +# ---------------------------------------- # Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are # provided, also output the error to LOG_FD, referencing LINENO. Then exit the -# script with status $?, using 1 if that was 0. +# script with STATUS, using 1 if that was 0. as_fn_error () { - as_status=$?; test $as_status -eq 0 && as_status=1 - if test "$3"; then - as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack - $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3 + as_status=$1; test $as_status -eq 0 && as_status=1 + if test "$4"; then + as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack + $as_echo "$as_me:${as_lineno-$LINENO}: error: $2" >&$4 fi - $as_echo "$as_me: error: $1" >&2 + $as_echo "$as_me: error: $2" >&2 as_fn_exit $as_status } # as_fn_error @@ -6295,16 +6540,16 @@ if (echo >conf$$.file) 2>/dev/null; then # ... but there are two gotchas: # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail. # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable. - # In both cases, we have to default to `cp -p'. + # In both cases, we have to default to `cp -pR'. ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe || - as_ln_s='cp -p' + as_ln_s='cp -pR' elif ln conf$$.file conf$$ 2>/dev/null; then as_ln_s=ln else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi else - as_ln_s='cp -p' + as_ln_s='cp -pR' fi rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file rmdir conf$$.dir 2>/dev/null @@ -6353,7 +6598,7 @@ $as_echo X"$as_dir" | test -d "$as_dir" && break done test -z "$as_dirs" || eval "mkdir $as_dirs" - } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir" + } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir" } # as_fn_mkdir_p @@ -6364,28 +6609,16 @@ else as_mkdir_p=false fi -if test -x / >/dev/null 2>&1; then - as_test_x='test -x' -else - if ls -dL / >/dev/null 2>&1; then - as_ls_L_option=L - else - as_ls_L_option= - fi - as_test_x=' - eval sh -c '\'' - if test -d "$1"; then - test -d "$1/."; - else - case $1 in #( - -*)set "./$1";; - esac; - case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #(( - ???[sx]*):;;*)false;;esac;fi - '\'' sh - ' -fi -as_executable_p=$as_test_x + +# as_fn_executable_p FILE +# ----------------------- +# Test if FILE is an executable regular file. +as_fn_executable_p () +{ + test -f "$1" && test -x "$1" +} # as_fn_executable_p +as_test_x='test -x' +as_executable_p=as_fn_executable_p # Sed expression to map a string onto a valid CPP name. as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'" @@ -6406,8 +6639,8 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by bmake $as_me 20140214, which was -generated by GNU Autoconf 2.64. Invocation command line was +This file was extended by bmake $as_me 20200418, which was +generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES CONFIG_HEADERS = $CONFIG_HEADERS @@ -6446,6 +6679,7 @@ Usage: $0 [OPTION]... [TAG]... -h, --help print this help, then exit -V, --version print version number and configuration settings, then exit + --config print configuration, then exit -q, --quiet, --silent do not print progress messages -d, --debug don't remove temporary files @@ -6465,12 +6699,13 @@ Report bugs to <sjg@NetBSD.org>." _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 +ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -bmake config.status 20140214 -configured by $0, generated by GNU Autoconf 2.64, - with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\" +bmake config.status 20200418 +configured by $0, generated by GNU Autoconf 2.69, + with options \\"\$ac_cs_config\\" -Copyright (C) 2009 Free Software Foundation, Inc. +Copyright (C) 2012 Free Software Foundation, Inc. This config.status script is free software; the Free Software Foundation gives unlimited permission to copy, distribute and modify it." @@ -6486,11 +6721,16 @@ ac_need_defaults=: while test $# != 0 do case $1 in - --*=*) + --*=?*) ac_option=`expr "X$1" : 'X\([^=]*\)='` ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'` ac_shift=: ;; + --*=) + ac_option=`expr "X$1" : 'X\([^=]*\)='` + ac_optarg= + ac_shift=: + ;; *) ac_option=$1 ac_optarg=$2 @@ -6504,12 +6744,15 @@ do ac_cs_recheck=: ;; --version | --versio | --versi | --vers | --ver | --ve | --v | -V ) $as_echo "$ac_cs_version"; exit ;; + --config | --confi | --conf | --con | --co | --c ) + $as_echo "$ac_cs_config"; exit ;; --debug | --debu | --deb | --de | --d | -d ) debug=: ;; --file | --fil | --fi | --f ) $ac_shift case $ac_optarg in *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;; + '') as_fn_error $? "missing file argument" ;; esac as_fn_append CONFIG_FILES " '$ac_optarg'" ac_need_defaults=false;; @@ -6522,7 +6765,7 @@ do ac_need_defaults=false;; --he | --h) # Conflict between --help and --header - as_fn_error "ambiguous option: \`$1' + as_fn_error $? "ambiguous option: \`$1' Try \`$0 --help' for more information.";; --help | --hel | -h ) $as_echo "$ac_cs_usage"; exit ;; @@ -6531,7 +6774,7 @@ Try \`$0 --help' for more information.";; ac_cs_silent=: ;; # This is an error. - -*) as_fn_error "unrecognized option: \`$1' + -*) as_fn_error $? "unrecognized option: \`$1' Try \`$0 --help' for more information." ;; *) as_fn_append ac_config_targets " $1" @@ -6551,7 +6794,7 @@ fi _ACEOF cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 if \$ac_cs_recheck; then - set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion + set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion shift \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6 CONFIG_SHELL='$SHELL' @@ -6581,12 +6824,9 @@ for ac_config_target in $ac_config_targets do case $ac_config_target in "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; - "makefile") CONFIG_FILES="$CONFIG_FILES makefile" ;; - "Makefile.config") CONFIG_FILES="$CONFIG_FILES Makefile.config" ;; - "make-bootstrap.sh") CONFIG_FILES="$CONFIG_FILES make-bootstrap.sh" ;; - "unit-tests/Makefile") CONFIG_FILES="$CONFIG_FILES unit-tests/Makefile" ;; + "$bm_outfiles") CONFIG_FILES="$CONFIG_FILES $bm_outfiles" ;; - *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;; + *) as_fn_error $? "invalid argument: \`$ac_config_target'" "$LINENO" 5;; esac done @@ -6608,9 +6848,10 @@ fi # after its creation but before its name has been assigned to `$tmp'. $debug || { - tmp= + tmp= ac_tmp= trap 'exit_status=$? - { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status + : "${ac_tmp:=$tmp}" + { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status ' 0 trap 'as_fn_exit 1' 1 2 13 15 } @@ -6618,12 +6859,13 @@ $debug || { tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` && - test -n "$tmp" && test -d "$tmp" + test -d "$tmp" } || { tmp=./conf$$-$RANDOM (umask 077 && mkdir "$tmp") -} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5 +} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5 +ac_tmp=$tmp # Set up the scripts for CONFIG_FILES section. # No need to generate them if there are no CONFIG_FILES. @@ -6640,12 +6882,12 @@ if test "x$ac_cr" = x; then fi ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null` if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then - ac_cs_awk_cr='\r' + ac_cs_awk_cr='\\r' else ac_cs_awk_cr=$ac_cr fi -echo 'BEGIN {' >"$tmp/subs1.awk" && +echo 'BEGIN {' >"$ac_tmp/subs1.awk" && _ACEOF @@ -6654,18 +6896,18 @@ _ACEOF echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' && echo "_ACEOF" } >conf$$subs.sh || - as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 -ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'` + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 +ac_delim_num=`echo "$ac_subst_vars" | grep -c '^'` ac_delim='%!_!# ' for ac_last_try in false false false false false :; do . ./conf$$subs.sh || - as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X` if test $ac_delim_n = $ac_delim_num; then break elif $ac_last_try; then - as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5 + as_fn_error $? "could not make $CONFIG_STATUS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi @@ -6673,7 +6915,7 @@ done rm -f conf$$subs.sh cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 -cat >>"\$tmp/subs1.awk" <<\\_ACAWK && +cat >>"\$ac_tmp/subs1.awk" <<\\_ACAWK && _ACEOF sed -n ' h @@ -6687,7 +6929,7 @@ s/'"$ac_delim"'$// t delim :nl h -s/\(.\{148\}\).*/\1/ +s/\(.\{148\}\)..*/\1/ t more1 s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/ p @@ -6701,7 +6943,7 @@ s/.\{148\}// t nl :delim h -s/\(.\{148\}\).*/\1/ +s/\(.\{148\}\)..*/\1/ t more2 s/["\\]/\\&/g; s/^/"/; s/$/"/ p @@ -6721,7 +6963,7 @@ t delim rm -f conf$$subs.awk cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK -cat >>"\$tmp/subs1.awk" <<_ACAWK && +cat >>"\$ac_tmp/subs1.awk" <<_ACAWK && for (key in S) S_is_set[key] = 1 FS = "" @@ -6753,21 +6995,29 @@ if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g" else cat -fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \ - || as_fn_error "could not setup config files machinery" "$LINENO" 5 +fi < "$ac_tmp/subs1.awk" > "$ac_tmp/subs.awk" \ + || as_fn_error $? "could not setup config files machinery" "$LINENO" 5 _ACEOF -# VPATH may cause trouble with some makes, so we remove $(srcdir), -# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and +# VPATH may cause trouble with some makes, so we remove sole $(srcdir), +# ${srcdir} and @srcdir@ entries from VPATH if srcdir is ".", strip leading and # trailing colons and then remove the whole line if VPATH becomes empty # (actually we leave an empty line to preserve line numbers). if test "x$srcdir" = x.; then - ac_vpsub='/^[ ]*VPATH[ ]*=/{ -s/:*\$(srcdir):*/:/ -s/:*\${srcdir}:*/:/ -s/:*@srcdir@:*/:/ -s/^\([^=]*=[ ]*\):*/\1/ + ac_vpsub='/^[ ]*VPATH[ ]*=[ ]*/{ +h +s/// +s/^/:/ +s/[ ]*$/:/ +s/:\$(srcdir):/:/g +s/:\${srcdir}:/:/g +s/:@srcdir@:/:/g +s/^:*// s/:*$// +x +s/\(=[ ]*\).*/\1/ +G +s/\n// s/^[^=]*=[ ]*$// }' fi @@ -6779,7 +7029,7 @@ fi # test -n "$CONFIG_FILES" # No need to generate them if there are no CONFIG_HEADERS. # This happens for instance with `./config.status Makefile'. if test -n "$CONFIG_HEADERS"; then -cat >"$tmp/defines.awk" <<\_ACAWK || +cat >"$ac_tmp/defines.awk" <<\_ACAWK || BEGIN { _ACEOF @@ -6791,11 +7041,11 @@ _ACEOF # handling of long lines. ac_delim='%!_!# ' for ac_last_try in false false :; do - ac_t=`sed -n "/$ac_delim/p" confdefs.h` - if test -z "$ac_t"; then + ac_tt=`sed -n "/$ac_delim/p" confdefs.h` + if test -z "$ac_tt"; then break elif $ac_last_try; then - as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5 + as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5 else ac_delim="$ac_delim!$ac_delim _$ac_delim!! " fi @@ -6880,7 +7130,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 _ACAWK _ACEOF cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 - as_fn_error "could not setup config headers machinery" "$LINENO" 5 + as_fn_error $? "could not setup config headers machinery" "$LINENO" 5 fi # test -n "$CONFIG_HEADERS" @@ -6893,7 +7143,7 @@ do esac case $ac_mode$ac_tag in :[FHL]*:*);; - :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;; + :L* | :C*:*) as_fn_error $? "invalid tag \`$ac_tag'" "$LINENO" 5;; :[FH]-) ac_tag=-:-;; :[FH]*) ac_tag=$ac_tag:$ac_tag.in;; esac @@ -6912,7 +7162,7 @@ do for ac_f do case $ac_f in - -) ac_f="$tmp/stdin";; + -) ac_f="$ac_tmp/stdin";; *) # Look for the file first in the build tree, then in the source tree # (if the path is not absolute). The absolute path cannot be DOS-style, # because $ac_f cannot contain `:'. @@ -6921,7 +7171,7 @@ do [\\/$]*) false;; *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";; esac || - as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;; + as_fn_error 1 "cannot find input file: \`$ac_f'" "$LINENO" 5;; esac case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac as_fn_append ac_file_inputs " '$ac_f'" @@ -6947,8 +7197,8 @@ $as_echo "$as_me: creating $ac_file" >&6;} esac case $ac_tag in - *:-:* | *:-) cat >"$tmp/stdin" \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 ;; + *:-:* | *:-) cat >"$ac_tmp/stdin" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; esac ;; esac @@ -7078,23 +7328,24 @@ s&@abs_top_builddir@&$ac_abs_top_builddir&;t t s&@INSTALL@&$ac_INSTALL&;t t $ac_datarootdir_hack " -eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 +eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$ac_tmp/subs.awk" \ + >$ac_tmp/out || as_fn_error $? "could not create $ac_file" "$LINENO" 5 test -z "$ac_datarootdir_hack$ac_datarootdir_seen" && - { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } && - { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } && + { ac_out=`sed -n '/\${datarootdir}/p' "$ac_tmp/out"`; test -n "$ac_out"; } && + { ac_out=`sed -n '/^[ ]*datarootdir[ ]*:*=/p' \ + "$ac_tmp/out"`; test -z "$ac_out"; } && { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&5 +which seems to be undefined. Please make sure it is defined" >&5 $as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir' -which seems to be undefined. Please make sure it is defined." >&2;} +which seems to be undefined. Please make sure it is defined" >&2;} - rm -f "$tmp/stdin" + rm -f "$ac_tmp/stdin" case $ac_file in - -) cat "$tmp/out" && rm -f "$tmp/out";; - *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";; + -) cat "$ac_tmp/out" && rm -f "$ac_tmp/out";; + *) rm -f "$ac_file" && mv "$ac_tmp/out" "$ac_file";; esac \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;; :H) # @@ -7103,21 +7354,21 @@ which seems to be undefined. Please make sure it is defined." >&2;} if test x"$ac_file" != x-; then { $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" - } >"$tmp/config.h" \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 - if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" + } >"$ac_tmp/config.h" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 + if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5 $as_echo "$as_me: $ac_file is unchanged" >&6;} else rm -f "$ac_file" - mv "$tmp/config.h" "$ac_file" \ - || as_fn_error "could not create $ac_file" "$LINENO" 5 + mv "$ac_tmp/config.h" "$ac_file" \ + || as_fn_error $? "could not create $ac_file" "$LINENO" 5 fi else $as_echo "/* $configure_input */" \ - && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \ - || as_fn_error "could not create -" "$LINENO" 5 + && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \ + || as_fn_error $? "could not create -" "$LINENO" 5 fi ;; @@ -7132,7 +7383,7 @@ _ACEOF ac_clean_files=$ac_clean_files_save test $ac_write_fail = 0 || - as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5 + as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5 # configure is writing to config.log, and then calls config.status. @@ -7153,14 +7404,13 @@ if test "$no_create" != yes; then exec 5>>config.log # Use ||, not &&, to avoid exiting from the if with $? = 1, which # would make configure fail if this is the last instruction. - $ac_cs_success || as_fn_exit $? + $ac_cs_success || as_fn_exit 1 fi if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5 $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;} fi - cat <<EOF You can now run diff --git a/devel/bmake/files/configure.in b/devel/bmake/files/configure.in index 65197e76db4..8deaaf28c33 100644 --- a/devel/bmake/files/configure.in +++ b/devel/bmake/files/configure.in @@ -1,11 +1,11 @@ dnl dnl RCSid: -dnl $Id: configure.in,v 1.1.1.7 2015/05/19 21:36:43 joerg Exp $ +dnl $Id: configure.in,v 1.1.1.8 2020/05/24 05:35:51 nia Exp $ dnl dnl Process this file with autoconf to produce a configure script dnl AC_PREREQ(2.50) -AC_INIT([bmake], [20140214], [sjg@NetBSD.org]) +AC_INIT([bmake], [20200418], [sjg@NetBSD.org]) AC_CONFIG_HEADERS(config.h) dnl make srcdir absolute @@ -14,6 +14,10 @@ case "$srcdir" in *) srcdir=`cd $srcdir && pwd`;; esac +dnl get _MAKE_VERSION +. $srcdir/VERSION +OS=`uname -s` + dnl AC_ARG_WITH(defshell, [ --with-defshell=SHELL use SHELL by default - must be sh compatible, use sh or ksh to pick the internal definitions], @@ -29,6 +33,17 @@ no) ;; ;; esac]) dnl +case "$OS" in +CYGWIN*|MINGW*) use_makefile=no;; +*) use_makefile=yes;; +esac +AC_ARG_WITH(makefile, +[ --without-makefile dissable use of generated makefile], +[case "${withval}" in +yes|no) use_makefile=${withval};; +*) AC_MSG_ERROR(bad value ${withval} given for makefile) ;; +esac]) +dnl use_meta=yes AC_ARG_WITH(meta, [ --without-meta dissable use of meta-mode], @@ -38,30 +53,41 @@ yes|no) use_meta=${withval};; esac]) dnl AC_ARG_WITH(filemon, -[ --with-filemon=path/filemon.h indicate path to filemon.h for meta-mode], +[ --with-filemon={no,dev,ktrace,path/filemon.h} indicate filemon method for meta-mode. Path to filemon.h implies dev], [ case "/${withval}" in -/no|*/filemon.h) filemon_h="${withval}";; +/no) use_filemon=no;; +/*trace) filemon_h=no use_filemon="${withval}";; +*/filemon.h) filemon_h="${withval}";; */filemon*) filemon_h="${withval}/filemon.h";; *) AC_MSG_ERROR(bad value ${withval} given for filemon) ;; esac], [ -OS=`uname -s` -for d in "/usr/include/dev/filemon" "$prefix/include/dev/filemon" "$srcdir/filemon" "$srcdir/../filemon" "$srcdir/../../sys/dev/filemon" -do - for x in "/$OS" "" - do - filemon_h="$d$x/filemon.h" - test -s "$filemon_h" && break - done - test -s "$filemon_h" && break -done -test -s "${filemon_h:-/dev/null}" || filemon_h=no +case "$OS" in +NetBSD) filemon_h=no use_filemon=ktrace;; +*) + for d in "/usr/include/dev/filemon" "$prefix/include/dev/filemon" "$srcdir/../../sys/dev/filemon" + do + for x in "/$OS" "" + do + filemon_h="$d$x/filemon.h" + test -s "$filemon_h" && break + done + test -s "$filemon_h" && { use_filemon=dev; break; } + done + ;; +esac +use_filemon=${use_filemon:-no} +case "$use_filemon" in +dev) ;; +*) filemon_h=no;; +esac ]) -dnl echo "Note: use_meta=$use_meta filemon_h=$filemon_h" >&6 +dnl echo "Note: use_meta=$use_meta use_filemon=$use_filemon filemon_h=$filemon_h" >&6 case "$use_meta" in yes) - case "$filemon_h" in - *.h) echo "Using: filemon=$filemon_h" >&6;; + case "$use_filemon" in + no) ;; + *) echo "Using: filemon_${use_filemon}.c" >&6;; esac ;; esac @@ -101,10 +127,20 @@ AC_HEADER_STDC AC_HEADER_SYS_WAIT AC_HEADER_DIRENT dnl Keep this list sorted +AC_CHECK_HEADERS(sys/param.h) +dnl On BSDi at least we really need sys/param.h for sys/sysctl.h +AC_CHECK_HEADERS([sys/sysctl.h], [], [], +[#ifdef HAVE_SYS_PARAM_H +# include <sys/param.h> +# endif +]) + AC_CHECK_HEADERS( \ ar.h \ err.h \ fcntl.h \ + libgen.h \ + limits.h \ paths.h \ poll.h \ ranlib.h \ @@ -112,7 +148,6 @@ AC_CHECK_HEADERS( \ sys/mman.h \ sys/select.h \ sys/socket.h \ - sys/sysctl.h \ sys/time.h \ sys/uio.h \ unistd.h \ @@ -139,9 +174,11 @@ dnl Checks for typedefs, structures, and compiler characteristics. AC_C___ATTRIBUTE__ AC_C_BIGENDIAN AC_C_CONST +AC_TYPE_MODE_T AC_TYPE_OFF_T AC_TYPE_PID_T AC_TYPE_SIZE_T +AC_TYPE_UINT32_T AC_DECL_SYS_SIGLIST AC_HEADER_TIME AC_STRUCT_TM @@ -374,9 +411,14 @@ AC_SUBST(INSTALL) AC_SUBST(GCC) AC_SUBST(diff_u) AC_SUBST(use_meta) +AC_SUBST(use_filemon) AC_SUBST(filemon_h) -AC_OUTPUT(makefile Makefile.config make-bootstrap.sh unit-tests/Makefile) - +AC_SUBST(_MAKE_VERSION) +bm_outfiles="Makefile.config unit-tests/Makefile.config make-bootstrap.sh" +if test $use_makefile = yes; then + bm_outfiles="makefile $bm_outfiles" +fi +AC_OUTPUT($bm_outfiles) cat <<EOF You can now run diff --git a/devel/bmake/files/dir.c b/devel/bmake/files/dir.c index db94744340c..17e17ed384e 100644 --- a/devel/bmake/files/dir.c +++ b/devel/bmake/files/dir.c @@ -1,4 +1,4 @@ -/* $NetBSD: dir.c,v 1.1.1.7 2015/05/19 21:36:43 joerg Exp $ */ +/* $NetBSD: dir.c,v 1.1.1.8 2020/05/24 05:35:52 nia Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -70,14 +70,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: dir.c,v 1.1.1.7 2015/05/19 21:36:43 joerg Exp $"; +static char rcsid[] = "$NetBSD: dir.c,v 1.1.1.8 2020/05/24 05:35:52 nia Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94"; #else -__RCSID("$NetBSD: dir.c,v 1.1.1.7 2015/05/19 21:36:43 joerg Exp $"); +__RCSID("$NetBSD: dir.c,v 1.1.1.8 2020/05/24 05:35:52 nia Exp $"); #endif #endif /* not lint */ #endif @@ -244,6 +244,7 @@ static Hash_Table mtimes; /* Results of doing a last-resort stat in * be two rules to update a single file, so this * should be ok, but... */ +static Hash_Table lmtimes; /* same as mtimes but for lstat */ static int DirFindName(const void *, const void *); static int DirMatchFiles(const char *, Path *, Lst); @@ -256,6 +257,79 @@ static char *DirLookupSubdir(Path *, const char *); static char *DirFindDot(Boolean, const char *, const char *); static char *DirLookupAbs(Path *, const char *, const char *); + +/* + * We use stat(2) a lot, cache the results + * mtime and mode are all we care about. + */ +struct cache_st { + time_t mtime; + mode_t mode; +}; + +/* minimize changes below */ +#define CST_LSTAT 1 +#define CST_UPDATE 2 + +static int +cached_stats(Hash_Table *htp, const char *pathname, struct stat *st, int flags) +{ + Hash_Entry *entry; + struct cache_st *cst; + int rc; + + if (!pathname || !pathname[0]) + return -1; + + entry = Hash_FindEntry(htp, pathname); + + if (entry && (flags & CST_UPDATE) == 0) { + cst = entry->clientPtr; + + memset(st, 0, sizeof(*st)); + st->st_mtime = cst->mtime; + st->st_mode = cst->mode; + if (DEBUG(DIR)) { + fprintf(debug_file, "Using cached time %s for %s\n", + Targ_FmtTime(st->st_mtime), pathname); + } + return 0; + } + + rc = (flags & CST_LSTAT) ? lstat(pathname, st) : stat(pathname, st); + if (rc == -1) + return -1; + + if (st->st_mtime == 0) + st->st_mtime = 1; /* avoid confusion with missing file */ + + if (!entry) + entry = Hash_CreateEntry(htp, pathname, NULL); + if (!entry->clientPtr) + entry->clientPtr = bmake_malloc(sizeof(*cst)); + cst = entry->clientPtr; + cst->mtime = st->st_mtime; + cst->mode = st->st_mode; + if (DEBUG(DIR)) { + fprintf(debug_file, " Caching %s for %s\n", + Targ_FmtTime(st->st_mtime), pathname); + } + + return 0; +} + +int +cached_stat(const char *pathname, void *st) +{ + return cached_stats(&mtimes, pathname, st, 0); +} + +int +cached_lstat(const char *pathname, void *st) +{ + return cached_stats(&lmtimes, pathname, st, CST_LSTAT); +} + /*- *----------------------------------------------------------------------- * Dir_Init -- @@ -271,10 +345,13 @@ static char *DirLookupAbs(Path *, const char *, const char *); void Dir_Init(const char *cdname) { - dirSearchPath = Lst_Init(FALSE); - openDirectories = Lst_Init(FALSE); - Hash_InitTable(&mtimes, 0); - + if (!cdname) { + dirSearchPath = Lst_Init(FALSE); + openDirectories = Lst_Init(FALSE); + Hash_InitTable(&mtimes, 0); + Hash_InitTable(&lmtimes, 0); + return; + } Dir_InitCur(cdname); dotLast = bmake_malloc(sizeof(Path)); @@ -725,11 +802,11 @@ DirExpandInt(const char *word, Lst path, Lst expansions) *----------------------------------------------------------------------- */ static int -DirPrintWord(void *word, void *dummy) +DirPrintWord(void *word, void *dummy MAKE_ATTR_UNUSED) { fprintf(debug_file, "%s ", (char *)word); - return(dummy ? 0 : 0); + return 0; } /*- @@ -901,7 +978,6 @@ static char * DirLookupSubdir(Path *p, const char *name) { struct stat stb; /* Buffer for stat, if necessary */ - Hash_Entry *entry; /* Entry for mtimes table */ char *file; /* the current filename to check */ if (p != dot) { @@ -917,19 +993,7 @@ DirLookupSubdir(Path *p, const char *name) fprintf(debug_file, "checking %s ...\n", file); } - if (stat(file, &stb) == 0) { - if (stb.st_mtime == 0) - stb.st_mtime = 1; - /* - * Save the modification time so if it's needed, we don't have - * to fetch it again. - */ - if (DEBUG(DIR)) { - fprintf(debug_file, " Caching %s for %s\n", Targ_FmtTime(stb.st_mtime), - file); - } - entry = Hash_CreateEntry(&mtimes, file, NULL); - Hash_SetTimeValue(entry, stb.st_mtime); + if (cached_stat(file, &stb) == 0) { nearmisses += 1; return (file); } @@ -1061,7 +1125,6 @@ Dir_FindFile(const char *name, Lst path) Boolean hasLastDot = FALSE; /* true we should search dot last */ Boolean hasSlash; /* true if 'name' contains a / */ struct stat stb; /* Buffer for stat, if necessary */ - Hash_Entry *entry; /* Entry for mtimes table */ const char *trailing_dot = "."; /* @@ -1242,8 +1305,14 @@ Dir_FindFile(const char *name, Lst path) fprintf(debug_file, " Trying exact path matches...\n"); } - if (!hasLastDot && cur && (file = DirLookupAbs(cur, name, cp)) != NULL) - return *file?file:NULL; + if (!hasLastDot && cur && ((file = DirLookupAbs(cur, name, cp)) + != NULL)) { + if (file[0] == '\0') { + free(file); + return NULL; + } + return file; + } (void)Lst_Open(path); while ((ln = Lst_Next(path)) != NULL) { @@ -1252,13 +1321,23 @@ Dir_FindFile(const char *name, Lst path) continue; if ((file = DirLookupAbs(p, name, cp)) != NULL) { Lst_Close(path); - return *file?file:NULL; + if (file[0] == '\0') { + free(file); + return NULL; + } + return file; } } Lst_Close(path); - if (hasLastDot && cur && (file = DirLookupAbs(cur, name, cp)) != NULL) - return *file?file:NULL; + if (hasLastDot && cur && ((file = DirLookupAbs(cur, name, cp)) + != NULL)) { + if (file[0] == '\0') { + free(file); + return NULL; + } + return file; + } } /* @@ -1306,28 +1385,14 @@ Dir_FindFile(const char *name, Lst path) } bigmisses += 1; - entry = Hash_FindEntry(&mtimes, name); - if (entry != NULL) { - if (DEBUG(DIR)) { - fprintf(debug_file, " got it (in mtime cache)\n"); - } - return(bmake_strdup(name)); - } else if (stat(name, &stb) == 0) { - if (stb.st_mtime == 0) - stb.st_mtime = 1; - entry = Hash_CreateEntry(&mtimes, name, NULL); - if (DEBUG(DIR)) { - fprintf(debug_file, " Caching %s for %s\n", Targ_FmtTime(stb.st_mtime), - name); - } - Hash_SetTimeValue(entry, stb.st_mtime); + if (cached_stat(name, &stb) == 0) { return (bmake_strdup(name)); - } else { - if (DEBUG(DIR)) { - fprintf(debug_file, " failed. Returning NULL\n"); - } - return NULL; } + + if (DEBUG(DIR)) { + fprintf(debug_file, " failed. Returning NULL\n"); + } + return NULL; #endif /* notdef */ } @@ -1368,7 +1433,7 @@ Dir_FindHereOrAbove(char *here, char *search_path, char *result, int rlen) { /* try and stat(2) it ... */ snprintf(try, sizeof(try), "%s/%s", dirbase, search_path); - if (stat(try, &st) != -1) { + if (cached_stat(try, &st) != -1) { /* * success! if we found a file, chop off * the filename so we return a directory. @@ -1433,7 +1498,6 @@ Dir_MTime(GNode *gn, Boolean recheck) { char *fullName; /* the full pathname of name */ struct stat stb; /* buffer for finding the mod time */ - Hash_Entry *entry; if (gn->type & OP_ARCHV) { return Arch_MTime(gn); @@ -1484,17 +1548,7 @@ Dir_MTime(GNode *gn, Boolean recheck) fullName = bmake_strdup(gn->name); } - if (!recheck) - entry = Hash_FindEntry(&mtimes, fullName); - else - entry = NULL; - if (entry != NULL) { - if (DEBUG(DIR)) { - fprintf(debug_file, "Using cached time %s for %s\n", - Targ_FmtTime(Hash_GetTimeValue(entry)), fullName); - } - stb.st_mtime = Hash_GetTimeValue(entry); - } else if (stat(fullName, &stb) < 0) { + if (cached_stats(&mtimes, fullName, &stb, recheck ? CST_UPDATE : 0) < 0) { if (gn->type & OP_MEMBER) { if (fullName != gn->path) free(fullName); @@ -1502,18 +1556,8 @@ Dir_MTime(GNode *gn, Boolean recheck) } else { stb.st_mtime = 0; } - } else { - if (stb.st_mtime == 0) { - /* - * 0 handled specially by the code, if the time is really 0, - * return something else instead - */ - stb.st_mtime = 1; - } - entry = Hash_CreateEntry(&mtimes, fullName, NULL); - Hash_SetTimeValue(entry, stb.st_mtime); } - + if (fullName && gn->path == NULL) { gn->path = fullName; } @@ -1792,10 +1836,10 @@ Dir_PrintDirectories(void) } static int -DirPrintDir(void *p, void *dummy) +DirPrintDir(void *p, void *dummy MAKE_ATTR_UNUSED) { fprintf(debug_file, "%s ", ((Path *)p)->name); - return (dummy ? 0 : 0); + return 0; } void diff --git a/devel/bmake/files/dir.h b/devel/bmake/files/dir.h index 8c9eb62c02d..75096963297 100644 --- a/devel/bmake/files/dir.h +++ b/devel/bmake/files/dir.h @@ -1,4 +1,4 @@ -/* $NetBSD: dir.h,v 1.1.1.5 2015/05/19 21:36:44 joerg Exp $ */ +/* $NetBSD: dir.h,v 1.1.1.6 2020/05/24 05:35:52 nia Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -75,8 +75,8 @@ /* dir.h -- */ -#ifndef _DIR -#define _DIR +#ifndef MAKE_DIR_H +#define MAKE_DIR_H typedef struct Path { char *name; /* Name of directory */ @@ -105,4 +105,4 @@ void Dir_PrintPath(Lst); void Dir_Destroy(void *); void * Dir_CopyDir(void *); -#endif /* _DIR */ +#endif /* MAKE_DIR_H */ diff --git a/devel/bmake/files/dirname.c b/devel/bmake/files/dirname.c index 2f4ede97a26..8652328c78c 100644 --- a/devel/bmake/files/dirname.c +++ b/devel/bmake/files/dirname.c @@ -1,4 +1,4 @@ -/* $NetBSD: dirname.c,v 1.1.1.1 2011/06/18 22:17:55 bsiegert Exp $ */ +/* $NetBSD: dirname.c,v 1.1.1.2 2020/05/24 05:35:52 nia Exp $ */ /*- * Copyright (c) 1997, 2002 The NetBSD Foundation, Inc. @@ -35,7 +35,15 @@ #ifndef HAVE_DIRNAME #include <sys/cdefs.h> +#if defined(LIBC_SCCS) && !defined(lint) +__RCSID("$NetBSD: dirname.c,v 1.1.1.2 2020/05/24 05:35:52 nia Exp $"); +#endif /* !LIBC_SCCS && !lint */ +#include "namespace.h" +#include <sys/param.h> +#ifdef HAVE_LIBGEN_H +#include <libgen.h> +#endif #ifdef HAVE_LIMITS_H #include <limits.h> #endif @@ -45,51 +53,74 @@ #ifndef PATH_MAX # define PATH_MAX 1024 #endif +#ifndef MIN +# define MIN(a, b) ((a < b) ? a : b) +#endif -char * -dirname(char *path) + +static size_t +xdirname_r(const char *path, char *buf, size_t buflen) { - static char result[PATH_MAX]; - const char *lastp; + const char *endp; size_t len; /* * If `path' is a null pointer or points to an empty string, * return a pointer to the string ".". */ - if ((path == NULL) || (*path == '\0')) - goto singledot; - + if (path == NULL || *path == '\0') { + path = "."; + len = 1; + goto out; + } /* Strip trailing slashes, if any. */ - lastp = path + strlen(path) - 1; - while (lastp != path && *lastp == '/') - lastp--; + endp = path + strlen(path) - 1; + while (endp != path && *endp == '/') + endp--; + + /* Find the start of the dir */ + while (endp > path && *endp != '/') + endp--; - /* Terminate path at the last occurence of '/'. */ - do { - if (*lastp == '/') { - /* Strip trailing slashes, if any. */ - while (lastp != path && *lastp == '/') - lastp--; + if (endp == path) { + path = *endp == '/' ? "/" : "."; + len = 1; + goto out; + } - /* ...and copy the result into the result buffer. */ - len = (lastp - path) + 1 /* last char */; - if (len > (PATH_MAX - 1)) - len = PATH_MAX - 1; + do + endp--; + while (endp > path && *endp == '/'); - memcpy(result, path, len); - result[len] = '\0'; + len = endp - path + 1; +out: + if (buf != NULL && buflen != 0) { + buflen = MIN(len, buflen - 1); + if (buf != path) + memcpy(buf, path, buflen); + buf[buflen] = '\0'; + } + return len; +} - return (result); - } - } while (--lastp >= path); +char * +dirname(char *path) +{ + static char result[PATH_MAX]; + (void)xdirname_r(path, result, sizeof(result)); + return result; +} - /* No /'s found, return a pointer to the string ".". */ -singledot: - result[0] = '.'; - result[1] = '\0'; +#ifdef MAIN +#include <stdlib.h> +#include <stdio.h> - return (result); +int +main(int argc, char *argv[]) +{ + printf("%s\n", dirname(argv[1])); + exit(0); } #endif +#endif diff --git a/devel/bmake/files/filemon/filemon.h b/devel/bmake/files/filemon/filemon.h new file mode 100644 index 00000000000..5b5b25a6ed5 --- /dev/null +++ b/devel/bmake/files/filemon/filemon.h @@ -0,0 +1,53 @@ +/* $NetBSD: filemon.h,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ */ + +/*- + * Copyright (c) 2019 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Taylor R. Campbell. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef FILEMON_H_ +#define FILEMON_H_ + +#include <sys/types.h> + +struct filemon; + +const char * + filemon_path(void); + +struct filemon * + filemon_open(void); +int filemon_close(struct filemon *); + +int filemon_setfd(struct filemon *, int); +void filemon_setpid_parent(struct filemon *, pid_t); +int filemon_setpid_child(const struct filemon *, pid_t); + +int filemon_readfd(const struct filemon *); +int filemon_process(struct filemon *); + +#endif /* FILEMON_H_ */ diff --git a/devel/bmake/files/filemon/filemon_dev.c b/devel/bmake/files/filemon/filemon_dev.c new file mode 100644 index 00000000000..1411afe6821 --- /dev/null +++ b/devel/bmake/files/filemon/filemon_dev.c @@ -0,0 +1,151 @@ +/* $NetBSD: filemon_dev.c,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ */ + +/*- + * Copyright (c) 2020 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Taylor R. Campbell. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#include "filemon.h" + +#include <sys/ioctl.h> + +#include <errno.h> +#include <fcntl.h> +#include <stdlib.h> +#include <unistd.h> + +#ifdef HAVE_FILEMON_H +# include <filemon.h> +#endif + +#ifndef _PATH_FILEMON +#define _PATH_FILEMON "/dev/filemon" +#endif + +struct filemon { + int fd; +}; + +const char * +filemon_path(void) +{ + + return _PATH_FILEMON; +} + +struct filemon * +filemon_open(void) +{ + struct filemon *F; + unsigned i; + int error; + + /* Allocate and zero a struct filemon object. */ + F = calloc(1, sizeof(*F)); + if (F == NULL) + return NULL; + + /* Try opening /dev/filemon, up to six times (cargo cult!). */ + for (i = 0; (F->fd = open(_PATH_FILEMON, O_RDWR)) == -1; i++) { + if (i == 5) { + error = errno; + goto fail0; + } + } + + /* Success! */ + return F; + +fail0: free(F); + errno = error; + return NULL; +} + +int +filemon_setfd(struct filemon *F, int fd) +{ + + /* Point the kernel at this file descriptor. */ + if (ioctl(F->fd, FILEMON_SET_FD, &fd) == -1) + return -1; + + /* No need for it in userland any more; close it. */ + (void)close(fd); + + /* Success! */ + return 0; +} + +void +filemon_setpid_parent(struct filemon *F, pid_t pid) +{ + /* Nothing to do! */ +} + +int +filemon_setpid_child(const struct filemon *F, pid_t pid) +{ + + /* Just pass it on to the kernel. */ + return ioctl(F->fd, FILEMON_SET_PID, &pid); +} + +int +filemon_close(struct filemon *F) +{ + int error = 0; + + /* Close the filemon device fd. */ + if (close(F->fd) == -1 && error == 0) + error = errno; + + /* Free the filemon descriptor. */ + free(F); + + /* Set errno and return -1 if anything went wrong. */ + if (error) { + errno = error; + return -1; + } + + /* Success! */ + return 0; +} + +int +filemon_readfd(const struct filemon *F) +{ + + return -1; +} + +int +filemon_process(struct filemon *F) +{ + + return 0; +} diff --git a/devel/bmake/files/filemon/filemon_ktrace.c b/devel/bmake/files/filemon/filemon_ktrace.c new file mode 100644 index 00000000000..dd11e02f255 --- /dev/null +++ b/devel/bmake/files/filemon/filemon_ktrace.c @@ -0,0 +1,878 @@ +/* $NetBSD: filemon_ktrace.c,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ */ + +/*- + * Copyright (c) 2019 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Taylor R. Campbell. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#define _KERNTYPES /* register_t */ + +#include "filemon.h" + +#include <sys/param.h> +#include <sys/types.h> +#include <sys/rbtree.h> +#include <sys/syscall.h> +#include <sys/time.h> +#include <sys/uio.h> +#include <sys/wait.h> + +#include <sys/ktrace.h> + +#include <assert.h> +#include <err.h> +#include <errno.h> +#include <fcntl.h> +#include <stdbool.h> +#include <stddef.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <unistd.h> + +#ifndef AT_CWD +#define AT_CWD -1 +#endif + +struct filemon; +struct filemon_key; +struct filemon_state; + +typedef struct filemon_state *filemon_syscall_t(struct filemon *, + const struct filemon_key *, const struct ktr_syscall *); + +static filemon_syscall_t filemon_sys_chdir; +static filemon_syscall_t filemon_sys_execve; +static filemon_syscall_t filemon_sys_exit; +static filemon_syscall_t filemon_sys_fork; +static filemon_syscall_t filemon_sys_link; +static filemon_syscall_t filemon_sys_open; +static filemon_syscall_t filemon_sys_openat; +static filemon_syscall_t filemon_sys_symlink; +static filemon_syscall_t filemon_sys_unlink; +static filemon_syscall_t filemon_sys_rename; + +static filemon_syscall_t *const filemon_syscalls[] = { + [SYS_chdir] = &filemon_sys_chdir, + [SYS_execve] = &filemon_sys_execve, + [SYS_exit] = &filemon_sys_exit, + [SYS_fork] = &filemon_sys_fork, + [SYS_link] = &filemon_sys_link, + [SYS_open] = &filemon_sys_open, + [SYS_openat] = &filemon_sys_openat, + [SYS_symlink] = &filemon_sys_symlink, + [SYS_unlink] = &filemon_sys_unlink, + [SYS_rename] = &filemon_sys_rename, +}; + +struct filemon { + int ktrfd; /* kernel writes ktrace events here */ + FILE *in; /* we read ktrace events from here */ + FILE *out; /* we write filemon events to here */ + rb_tree_t active; + pid_t child; + + /* I/O state machine. */ + enum { + FILEMON_START = 0, + FILEMON_HEADER, + FILEMON_PAYLOAD, + FILEMON_ERROR, + } state; + unsigned char *p; + size_t resid; + + /* I/O buffer. */ + struct ktr_header hdr; + union { + struct ktr_syscall syscall; + struct ktr_sysret sysret; + char namei[PATH_MAX]; + unsigned char buf[4096]; + } payload; +}; + +struct filemon_state { + struct filemon_key { + pid_t pid; + lwpid_t lid; + } key; + struct rb_node node; + int syscode; + void (*show)(struct filemon *, const struct filemon_state *, + const struct ktr_sysret *); + unsigned i; + unsigned npath; + char *path[/*npath*/]; +}; + +static int +compare_filemon_states(void *cookie, const void *na, const void *nb) +{ + const struct filemon_state *Sa = na; + const struct filemon_state *Sb = nb; + + if (Sa->key.pid < Sb->key.pid) + return -1; + if (Sa->key.pid > Sb->key.pid) + return +1; + if (Sa->key.lid < Sb->key.lid) + return -1; + if (Sa->key.lid > Sb->key.lid) + return +1; + return 0; +} + +static int +compare_filemon_key(void *cookie, const void *n, const void *k) +{ + const struct filemon_state *S = n; + const struct filemon_key *key = k; + + if (S->key.pid < key->pid) + return -1; + if (S->key.pid > key->pid) + return +1; + if (S->key.lid < key->lid) + return -1; + if (S->key.lid > key->lid) + return +1; + return 0; +} + +static const rb_tree_ops_t filemon_rb_ops = { + .rbto_compare_nodes = &compare_filemon_states, + .rbto_compare_key = &compare_filemon_key, + .rbto_node_offset = offsetof(struct filemon_state, node), + .rbto_context = NULL, +}; + +/* + * filemon_path() + * + * Return a pointer to a constant string denoting the `path' of + * the filemon. + */ +const char * +filemon_path(void) +{ + + return "ktrace"; +} + +/* + * filemon_open() + * + * Allocate a filemon descriptor. Returns NULL and sets errno on + * failure. + */ +struct filemon * +filemon_open(void) +{ + struct filemon *F; + int ktrpipe[2]; + int error; + + /* Allocate and zero a struct filemon object. */ + F = calloc(1, sizeof(*F)); + if (F == NULL) + return NULL; + + /* Create a pipe for ktrace events. */ + if (pipe2(ktrpipe, O_CLOEXEC|O_NONBLOCK) == -1) { + error = errno; + goto fail0; + } + + /* Create a file stream for reading the ktrace events. */ + if ((F->in = fdopen(ktrpipe[0], "r")) == NULL) { + error = errno; + goto fail1; + } + ktrpipe[0] = -1; /* claimed by fdopen */ + + /* + * Set the fd for writing ktrace events and initialize the + * rbtree. The rest can be safely initialized to zero. + */ + F->ktrfd = ktrpipe[1]; + rb_tree_init(&F->active, &filemon_rb_ops); + + /* Success! */ + return F; + +fail2: __unused + (void)fclose(F->in); +fail1: (void)close(ktrpipe[0]); + (void)close(ktrpipe[1]); +fail0: free(F); + errno = error; + return NULL; +} + +/* + * filemon_closefd(F) + * + * Internal subroutine to try to flush and close the output file. + * If F is not open for output, do nothing. Never leaves F open + * for output even on failure. Returns 0 on success; sets errno + * and return -1 on failure. + */ +static int +filemon_closefd(struct filemon *F) +{ + int error = 0; + + /* If we're not open, nothing to do. */ + if (F->out == NULL) + return 0; + + /* + * Flush it, close it, and null it unconditionally, but be + * careful to return the earliest error in errno. + */ + if (fflush(F->out) == EOF && error == 0) + error = errno; + if (fclose(F->out) == EOF && error == 0) + error = errno; + F->out = NULL; + + /* Set errno and return -1 if anything went wrong. */ + if (error) { + errno = error; + return -1; + } + + /* Success! */ + return 0; +} + +/* + * filemon_setfd(F, fd) + * + * Cause filemon activity on F to be sent to fd. Claims ownership + * of fd; caller should not use fd afterward, and any duplicates + * of fd may see their file positions changed. + */ +int +filemon_setfd(struct filemon *F, int fd) +{ + + /* + * Close an existing output file if done. Fail now if there's + * an error closing. + */ + if ((filemon_closefd(F)) == -1) + return -1; + assert(F->out == NULL); + + /* Open a file stream and claim ownership of the fd. */ + if ((F->out = fdopen(fd, "a")) == NULL) + return -1; + + /* + * Print the opening output. Any failure will be deferred + * until closing. For hysterical raisins, we show the parent + * pid, not the child pid. + */ + fprintf(F->out, "# filemon version 4\n"); + fprintf(F->out, "# Target pid %jd\n", (intmax_t)getpid()); + fprintf(F->out, "V 4\n"); + + /* Success! */ + return 0; +} + +/* + * filemon_setpid_parent(F, pid) + * + * Set the traced pid, from the parent. Never fails. + */ +void +filemon_setpid_parent(struct filemon *F, pid_t pid) +{ + + F->child = pid; +} + +/* + * filemon_setpid_child(F, pid) + * + * Set the traced pid, from the child. Returns 0 on success; sets + * errno and returns -1 on failure. + */ +int +filemon_setpid_child(const struct filemon *F, pid_t pid) +{ + int ops, trpoints; + + ops = KTROP_SET|KTRFLAG_DESCEND; + trpoints = KTRFACv2; + trpoints |= KTRFAC_SYSCALL|KTRFAC_NAMEI|KTRFAC_SYSRET; + trpoints |= KTRFAC_INHERIT; + if (fktrace(F->ktrfd, ops, trpoints, pid) == -1) + return -1; + + return 0; +} + +/* + * filemon_close(F) + * + * Close F for output if necessary, and free a filemon descriptor. + * Returns 0 on success; sets errno and returns -1 on failure, but + * frees the filemon descriptor either way; + */ +int +filemon_close(struct filemon *F) +{ + struct filemon_state *S; + int error = 0; + + /* Close for output. */ + if (filemon_closefd(F) == -1 && error == 0) + error = errno; + + /* Close the ktrace pipe. */ + if (fclose(F->in) == EOF && error == 0) + error = errno; + if (close(F->ktrfd) == -1 && error == 0) + error = errno; + + /* Free any active records. */ + while ((S = RB_TREE_MIN(&F->active)) != NULL) { + rb_tree_remove_node(&F->active, S); + free(S); + } + + /* Free the filemon descriptor. */ + free(F); + + /* Set errno and return -1 if anything went wrong. */ + if (error) { + errno = error; + return -1; + } + + /* Success! */ + return 0; +} + +/* + * filemon_readfd(F) + * + * Returns a file descriptor which will select/poll ready for read + * when there are filemon events to be processed by + * filemon_process, or -1 if anything has gone wrong. + */ +int +filemon_readfd(const struct filemon *F) +{ + + if (F->state == FILEMON_ERROR) + return -1; + return fileno(F->in); +} + +/* + * filemon_dispatch(F) + * + * Internal subroutine to dispatch a filemon ktrace event. + * Silently ignore events that we don't recognize. + */ +static void +filemon_dispatch(struct filemon *F) +{ + const struct filemon_key key = { + .pid = F->hdr.ktr_pid, + .lid = F->hdr.ktr_lid, + }; + struct filemon_state *S; + + switch (F->hdr.ktr_type) { + case KTR_SYSCALL: { + struct ktr_syscall *call = &F->payload.syscall; + struct filemon_state *S1; + + /* Validate the syscall code. */ + if (call->ktr_code < 0 || + (size_t)call->ktr_code >= __arraycount(filemon_syscalls) || + filemon_syscalls[call->ktr_code] == NULL) + break; + + /* + * Invoke the syscall-specific logic to create a new + * active state. + */ + S = (*filemon_syscalls[call->ktr_code])(F, &key, call); + if (S == NULL) + break; + + /* + * Insert the active state, or ignore it if there + * already is one. + * + * Collisions shouldn't happen because the states are + * keyed by <pid,lid>, in which syscalls should happen + * sequentially in CALL/RET pairs, but let's be + * defensive. + */ + S1 = rb_tree_insert_node(&F->active, S); + if (S1 != S) { + /* XXX Which one to drop? */ + free(S); + break; + } + break; + } + case KTR_NAMEI: + /* Find an active syscall state, or drop it. */ + S = rb_tree_find_node(&F->active, &key); + if (S == NULL) + break; + /* Find the position of the next path, or drop it. */ + if (S->i >= S->npath) + break; + /* Record the path. */ + S->path[S->i++] = strndup(F->payload.namei, + sizeof F->payload.namei); + break; + case KTR_SYSRET: { + struct ktr_sysret *ret = &F->payload.sysret; + unsigned i; + + /* Find and remove an active syscall state, or drop it. */ + S = rb_tree_find_node(&F->active, &key); + if (S == NULL) + break; + rb_tree_remove_node(&F->active, S); + + /* + * If the active syscall state matches this return, + * invoke the syscall-specific logic to show a filemon + * event. + */ + /* XXX What to do if syscall code doesn't match? */ + if (S->i == S->npath && S->syscode == ret->ktr_code) + (*S->show)(F, S, ret); + + /* Free the state now that it is no longer active. */ + for (i = 0; i < S->i; i++) + free(S->path[i]); + free(S); + break; + } + default: + /* Ignore all other ktrace events. */ + break; + } +} + +/* + * filemon_process(F) + * + * Process all pending events after filemon_readfd(F) has + * selected/polled ready for read. + * + * Returns -1 on failure, 0 on end of events, and anything else if + * there may be more events. + * + * XXX What about fairness to other activities in the event loop? + * If we stop while there's events buffered in F->in, then select + * or poll may not return ready even though there's work queued up + * in the buffer of F->in, but if we don't stop then ktrace events + * may overwhelm all other activity in the event loop. + */ +int +filemon_process(struct filemon *F) +{ + size_t nread; + +top: /* If the child has exited, nothing to do. */ + /* XXX What if one thread calls exit while another is running? */ + if (F->child == 0) + return 0; + + /* If we're waiting for input, read some. */ + if (F->resid) { + nread = fread(F->p, 1, F->resid, F->in); + if (nread == 0) { + if (feof(F->in)) + return 0; + assert(ferror(F->in)); + /* + * If interrupted or would block, there may be + * more events. Otherwise fail. + */ + if (errno == EAGAIN || errno == EINTR) + return 1; + F->state = FILEMON_ERROR; + F->p = NULL; + F->resid = 0; + return -1; + } + assert(nread <= F->resid); + F->p += nread; + F->resid -= nread; + if (F->resid) /* may be more events */ + return 1; + } + + /* Process a state transition now that we've read a buffer. */ + switch (F->state) { + case FILEMON_START: /* just started filemon; read header next */ + F->state = FILEMON_HEADER; + F->p = (void *)&F->hdr; + F->resid = sizeof F->hdr; + goto top; + case FILEMON_HEADER: /* read header */ + /* Sanity-check ktrace header; then read payload. */ + if (F->hdr.ktr_len < 0 || + (size_t)F->hdr.ktr_len > sizeof F->payload) { + F->state = FILEMON_ERROR; + F->p = NULL; + F->resid = 0; + errno = EIO; + return -1; + } + F->state = FILEMON_PAYLOAD; + F->p = (void *)&F->payload; + F->resid = (size_t)F->hdr.ktr_len; + goto top; + case FILEMON_PAYLOAD: /* read header and payload */ + /* Dispatch ktrace event; then read next header. */ + filemon_dispatch(F); + F->state = FILEMON_HEADER; + F->p = (void *)&F->hdr; + F->resid = sizeof F->hdr; + goto top; + default: /* paranoia */ + F->state = FILEMON_ERROR; + /*FALLTHROUGH*/ + case FILEMON_ERROR: /* persistent error indicator */ + F->p = NULL; + F->resid = 0; + errno = EIO; + return -1; + } +} + +static struct filemon_state * +syscall_enter(struct filemon *F, + const struct filemon_key *key, const struct ktr_syscall *call, + unsigned npath, + void (*show)(struct filemon *, const struct filemon_state *, + const struct ktr_sysret *)) +{ + struct filemon_state *S; + unsigned i; + + S = calloc(1, offsetof(struct filemon_state, path[npath])); + if (S == NULL) + return NULL; + S->key = *key; + S->show = show; + S->syscode = call->ktr_code; + S->i = 0; + S->npath = npath; + for (i = 0; i < npath; i++) + S->path[i] = NULL; /* paranoia */ + + return S; +} + +static void +show_paths(struct filemon *F, const struct filemon_state *S, + const struct ktr_sysret *ret, const char *prefix) +{ + unsigned i; + + /* Caller must ensure all paths have been specified. */ + assert(S->i == S->npath); + + /* + * Ignore it if it failed or yielded EJUSTRETURN (-2), or if + * we're not producing output. + */ + if (ret->ktr_error && ret->ktr_error != -2) + return; + if (F->out == NULL) + return; + + /* + * Print the prefix, pid, and paths -- with the paths quoted if + * there's more than one. + */ + fprintf(F->out, "%s %jd", prefix, (intmax_t)S->key.pid); + for (i = 0; i < S->npath; i++) { + const char *q = S->npath > 1 ? "'" : ""; + fprintf(F->out, " %s%s%s", q, S->path[i], q); + } + fprintf(F->out, "\n"); +} + +static void +show_retval(struct filemon *F, const struct filemon_state *S, + const struct ktr_sysret *ret, const char *prefix) +{ + + /* + * Ignore it if it failed or yielded EJUSTRETURN (-2), or if + * we're not producing output. + */ + if (ret->ktr_error && ret->ktr_error != -2) + return; + if (F->out == NULL) + return; + + fprintf(F->out, "%s %jd %jd\n", prefix, (intmax_t)S->key.pid, + (intmax_t)ret->ktr_retval); +} + +static void +show_chdir(struct filemon *F, const struct filemon_state *S, + const struct ktr_sysret *ret) +{ + show_paths(F, S, ret, "C"); +} + +static void +show_execve(struct filemon *F, const struct filemon_state *S, + const struct ktr_sysret *ret) +{ + return show_paths(F, S, ret, "E"); +} + +static void +show_fork(struct filemon *F, const struct filemon_state *S, + const struct ktr_sysret *ret) +{ + show_retval(F, S, ret, "F"); +} + +static void +show_link(struct filemon *F, const struct filemon_state *S, + const struct ktr_sysret *ret) +{ + show_paths(F, S, ret, "L"); /* XXX same as symlink */ +} + +static void +show_open_read(struct filemon *F, const struct filemon_state *S, + const struct ktr_sysret *ret) +{ + show_paths(F, S, ret, "R"); +} + +static void +show_open_write(struct filemon *F, const struct filemon_state *S, + const struct ktr_sysret *ret) +{ + show_paths(F, S, ret, "W"); +} + +static void +show_open_readwrite(struct filemon *F, const struct filemon_state *S, + const struct ktr_sysret *ret) +{ + show_paths(F, S, ret, "R"); + show_paths(F, S, ret, "W"); +} + +static void +show_openat_read(struct filemon *F, const struct filemon_state *S, + const struct ktr_sysret *ret) +{ + if (S->path[0][0] != '/') + show_paths(F, S, ret, "A"); + show_paths(F, S, ret, "R"); +} + +static void +show_openat_write(struct filemon *F, const struct filemon_state *S, + const struct ktr_sysret *ret) +{ + if (S->path[0][0] != '/') + show_paths(F, S, ret, "A"); + show_paths(F, S, ret, "W"); +} + +static void +show_openat_readwrite(struct filemon *F, const struct filemon_state *S, + const struct ktr_sysret *ret) +{ + if (S->path[0][0] != '/') + show_paths(F, S, ret, "A"); + show_paths(F, S, ret, "R"); + show_paths(F, S, ret, "W"); +} + +static void +show_symlink(struct filemon *F, const struct filemon_state *S, + const struct ktr_sysret *ret) +{ + show_paths(F, S, ret, "L"); /* XXX same as link */ +} + +static void +show_unlink(struct filemon *F, const struct filemon_state *S, + const struct ktr_sysret *ret) +{ + show_paths(F, S, ret, "D"); +} + +static void +show_rename(struct filemon *F, const struct filemon_state *S, + const struct ktr_sysret *ret) +{ + show_paths(F, S, ret, "M"); +} + +static struct filemon_state * +filemon_sys_chdir(struct filemon *F, const struct filemon_key *key, + const struct ktr_syscall *call) +{ + return syscall_enter(F, key, call, 1, &show_chdir); +} + +static struct filemon_state * +filemon_sys_execve(struct filemon *F, const struct filemon_key *key, + const struct ktr_syscall *call) +{ + return syscall_enter(F, key, call, 1, &show_execve); +} + +static struct filemon_state * +filemon_sys_exit(struct filemon *F, const struct filemon_key *key, + const struct ktr_syscall *call) +{ + const register_t *args = (const void *)&call[1]; + int status = args[0]; + + if (F->out) { + fprintf(F->out, "X %jd %d\n", (intmax_t)key->pid, status); + if (key->pid == F->child) { + fprintf(F->out, "# Bye bye\n"); + F->child = 0; + } + } + return NULL; +} + +static struct filemon_state * +filemon_sys_fork(struct filemon *F, const struct filemon_key *key, + const struct ktr_syscall *call) +{ + return syscall_enter(F, key, call, 0, &show_fork); +} + +static struct filemon_state * +filemon_sys_link(struct filemon *F, const struct filemon_key *key, + const struct ktr_syscall *call) +{ + return syscall_enter(F, key, call, 2, &show_link); +} + +static struct filemon_state * +filemon_sys_open(struct filemon *F, const struct filemon_key *key, + const struct ktr_syscall *call) +{ + const register_t *args = (const void *)&call[1]; + int flags; + + if (call->ktr_argsize < 2) + return NULL; + flags = args[1]; + + if ((flags & O_RDWR) == O_RDWR) + return syscall_enter(F, key, call, 1, &show_open_readwrite); + else if ((flags & O_WRONLY) == O_WRONLY) + return syscall_enter(F, key, call, 1, &show_open_write); + else if ((flags & O_RDONLY) == O_RDONLY) + return syscall_enter(F, key, call, 1, &show_open_read); + else + return NULL; /* XXX Do we care if no read or write? */ +} + +static struct filemon_state * +filemon_sys_openat(struct filemon *F, const struct filemon_key *key, + const struct ktr_syscall *call) +{ + const register_t *args = (const void *)&call[1]; + int flags, fd; + + if (call->ktr_argsize < 3) + return NULL; + fd = args[0]; + flags = args[2]; + + if (fd == AT_CWD) { + if ((flags & O_RDWR) == O_RDWR) + return syscall_enter(F, key, call, 1, + &show_open_readwrite); + else if ((flags & O_WRONLY) == O_WRONLY) + return syscall_enter(F, key, call, 1, + &show_open_write); + else if ((flags & O_RDONLY) == O_RDONLY) + return syscall_enter(F, key, call, 1, &show_open_read); + else + return NULL; + } else { + if ((flags & O_RDWR) == O_RDWR) + return syscall_enter(F, key, call, 1, + &show_openat_readwrite); + else if ((flags & O_WRONLY) == O_WRONLY) + return syscall_enter(F, key, call, 1, + &show_openat_write); + else if ((flags & O_RDONLY) == O_RDONLY) + return syscall_enter(F, key, call, 1, + &show_openat_read); + else + return NULL; + } +} + +static struct filemon_state * +filemon_sys_symlink(struct filemon *F, const struct filemon_key *key, + const struct ktr_syscall *call) +{ + return syscall_enter(F, key, call, 2, &show_symlink); +} + +static struct filemon_state * +filemon_sys_unlink(struct filemon *F, const struct filemon_key *key, + const struct ktr_syscall *call) +{ + return syscall_enter(F, key, call, 1, &show_unlink); +} + +static struct filemon_state * +filemon_sys_rename(struct filemon *F, const struct filemon_key *key, + const struct ktr_syscall *call) +{ + return syscall_enter(F, key, call, 2, &show_rename); +} diff --git a/devel/bmake/files/for.c b/devel/bmake/files/for.c index 3f33057d434..f20a471cdfa 100644 --- a/devel/bmake/files/for.c +++ b/devel/bmake/files/for.c @@ -1,4 +1,4 @@ -/* $NetBSD: for.c,v 1.1.1.8 2015/05/19 21:36:44 joerg Exp $ */ +/* $NetBSD: for.c,v 1.1.1.9 2020/05/24 05:35:52 nia Exp $ */ /* * Copyright (c) 1992, The Regents of the University of California. @@ -30,14 +30,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: for.c,v 1.1.1.8 2015/05/19 21:36:44 joerg Exp $"; +static char rcsid[] = "$NetBSD: for.c,v 1.1.1.9 2020/05/24 05:35:52 nia Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)for.c 8.1 (Berkeley) 6/6/93"; #else -__RCSID("$NetBSD: for.c,v 1.1.1.8 2015/05/19 21:36:44 joerg Exp $"); +__RCSID("$NetBSD: for.c,v 1.1.1.9 2020/05/24 05:35:52 nia Exp $"); #endif #endif /* not lint */ #endif @@ -216,7 +216,7 @@ For_Eval(char *line) * We can't do the escapes here - because we don't know whether * we are substuting into ${...} or $(...). */ - sub = Var_Subst(NULL, ptr, VAR_GLOBAL, FALSE); + sub = Var_Subst(NULL, ptr, VAR_GLOBAL, VARF_WANTRES); /* * Split into words allowing for quoted strings. @@ -427,7 +427,7 @@ For_Iterate(void *v_arg, size_t *ret_len) for (cp = cmd_cp; (cp = strchr(cp, '$')) != NULL;) { char ech; ch = *++cp; - if ((ch == '(' && (ech = ')')) || (ch == '{' && (ech = '}'))) { + if ((ch == '(' && (ech = ')', 1)) || (ch == '{' && (ech = '}', 1))) { cp++; /* Check variable name against the .for loop variables */ STRLIST_FOREACH(var, &arg->vars, i) { diff --git a/devel/bmake/files/getopt.c b/devel/bmake/files/getopt.c index eb1f0e65fe7..8945275bb8c 100644 --- a/devel/bmake/files/getopt.c +++ b/devel/bmake/files/getopt.c @@ -1,3 +1,5 @@ +/* $NetBSD: getopt.c,v 1.1.1.4 2020/05/24 05:35:52 nia Exp $ */ + /* * Copyright (c) 1987, 1993, 1994 * The Regents of the University of California. All rights reserved. @@ -10,11 +12,7 @@ * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. - * 3. All advertising materials mentioning features or use of this software - * must display the following acknowledgement: - * This product includes software developed by the University of - * California, Berkeley and its contributors. - * 4. Neither the name of the University nor the names of its contributors + * 3. Neither the name of the University nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * @@ -35,11 +33,7 @@ # include "config.h" #endif #if !defined(HAVE_GETOPT) || defined(WANT_GETOPT_LONG) || defined(BROKEN_GETOPT) - -#if defined(LIBC_SCCS) && !defined(lint) -/* static char sccsid[] = "from: @(#)getopt.c 8.2 (Berkeley) 4/2/94"; */ -static char *rcsid = "$Id: getopt.c,v 1.1.1.3 2009/09/18 20:55:25 joerg Exp $"; -#endif /* LIBC_SCCS and not lint */ +#include <sys/cdefs.h> #include <stdio.h> #include <stdlib.h> @@ -61,13 +55,10 @@ char *optarg; /* argument associated with option */ * Parse argc/argv argument vector. */ int -getopt(nargc, nargv, ostr) - int nargc; - char * const *nargv; - const char *ostr; +getopt(int nargc, char * const nargv[], const char *ostr) { extern char *__progname; - static char *place = EMSG; /* option letter processing */ + static const char *place = EMSG; /* option letter processing */ char *oli; /* option letter list index */ #ifndef BSD4_4 @@ -79,43 +70,63 @@ getopt(nargc, nargv, ostr) } #endif - if (optreset || !*place) { /* update scanning pointer */ + if (optreset || *place == 0) { /* update scanning pointer */ optreset = 0; - if (optind >= nargc || *(place = nargv[optind]) != '-') { + place = nargv[optind]; + if (optind >= nargc || *place++ != '-') { + /* Argument is absent or is not an option */ place = EMSG; return (-1); } - if (place[1] && *++place == '-' /* found "--" */ - && !place[1]) { /* and not "--foo" */ + optopt = *place++; + if (optopt == '-' && *place == 0) { + /* "--" => end of options */ ++optind; place = EMSG; return (-1); } - } /* option letter okay? */ - if ((optopt = (int)*place++) == (int)':' || - !(oli = strchr(ostr, optopt))) { - /* - * if the user didn't specify '-' as an option, - * assume it means -1. - */ - if (optopt == (int)'-') - return (-1); - if (!*place) + if (optopt == 0) { + /* Solitary '-', treat as a '-' option + if the program (eg su) is looking for it. */ + place = EMSG; + if (strchr(ostr, '-') == NULL) + return -1; + optopt = '-'; + } + } else + optopt = *place++; + + /* See if option letter is one the caller wanted... */ + if (optopt == ':' || (oli = strchr(ostr, optopt)) == NULL) { + if (*place == 0) ++optind; if (opterr && *ostr != ':') (void)fprintf(stderr, - "%s: illegal option -- %c\n", __progname, optopt); + "%s: unknown option -- %c\n", __progname, optopt); return (BADCH); } - if (*++oli != ':') { /* don't need argument */ + + /* Does this option need an argument? */ + if (oli[1] != ':') { + /* don't need argument */ optarg = NULL; - if (!*place) + if (*place == 0) ++optind; - } - else { /* need an argument */ - if (*place) /* no white space */ - optarg = place; - else if (nargc <= ++optind) { /* no arg */ + } else { + /* Option-argument is either the rest of this argument or the + entire next argument. */ + if (*place) + optarg = __UNCONST(place); + else if (oli[2] == ':') + /* + * GNU Extension, for optional arguments if the rest of + * the argument is empty, we return NULL + */ + optarg = NULL; + else if (nargc > ++optind) + optarg = nargv[optind]; + else { + /* option-argument absent */ place = EMSG; if (*ostr == ':') return (BADARG); @@ -125,12 +136,10 @@ getopt(nargc, nargv, ostr) __progname, optopt); return (BADCH); } - else /* white space */ - optarg = nargv[optind]; place = EMSG; ++optind; } - return (optopt); /* dump back option letter */ + return (optopt); /* return option letter */ } #endif #ifdef MAIN diff --git a/devel/bmake/files/hash.h b/devel/bmake/files/hash.h index 994f9336d94..5e5b9d949bc 100644 --- a/devel/bmake/files/hash.h +++ b/devel/bmake/files/hash.h @@ -1,4 +1,4 @@ -/* $NetBSD: hash.h,v 1.1.1.3 2009/09/18 20:55:26 joerg Exp $ */ +/* $NetBSD: hash.h,v 1.1.1.4 2020/05/24 05:35:52 nia Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -78,8 +78,8 @@ * which maintains hash tables. */ -#ifndef _HASH -#define _HASH +#ifndef _HASH_H +#define _HASH_H /* * The following defines one entry in the hash table. @@ -89,10 +89,7 @@ typedef struct Hash_Entry { struct Hash_Entry *next; /* Used to link together all the * entries associated with the same * bucket. */ - union { - void *clientPtr; /* Arbitrary pointer */ - time_t clientTime; /* Arbitrary Time */ - } clientInfo; + void *clientPtr; /* Arbitrary pointer */ unsigned namehash; /* hash value of key */ char name[1]; /* key string */ } Hash_Entry; @@ -125,8 +122,7 @@ typedef struct Hash_Search { * Hash_Entry *h; */ -#define Hash_GetValue(h) ((h)->clientInfo.clientPtr) -#define Hash_GetTimeValue(h) ((h)->clientInfo.clientTime) +#define Hash_GetValue(h) ((h)->clientPtr) /* * Hash_SetValue(h, val); @@ -134,8 +130,7 @@ typedef struct Hash_Search { * char *val; */ -#define Hash_SetValue(h, val) ((h)->clientInfo.clientPtr = (val)) -#define Hash_SetTimeValue(h, val) ((h)->clientInfo.clientTime = (val)) +#define Hash_SetValue(h, val) ((h)->clientPtr = (val)) /* * Hash_Size(n) returns the number of words in an object of n bytes @@ -151,4 +146,4 @@ void Hash_DeleteEntry(Hash_Table *, Hash_Entry *); Hash_Entry *Hash_EnumFirst(Hash_Table *, Hash_Search *); Hash_Entry *Hash_EnumNext(Hash_Search *); -#endif /* _HASH */ +#endif /* _HASH_H */ diff --git a/devel/bmake/files/job.c b/devel/bmake/files/job.c index e140b945aab..5427c75f958 100644 --- a/devel/bmake/files/job.c +++ b/devel/bmake/files/job.c @@ -1,4 +1,4 @@ -/* $NetBSD: job.c,v 1.1.1.10 2015/05/19 21:36:44 joerg Exp $ */ +/* $NetBSD: job.c,v 1.1.1.11 2020/05/24 05:35:52 nia Exp $ */ /* * Copyright (c) 1988, 1989, 1990 The Regents of the University of California. @@ -70,14 +70,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: job.c,v 1.1.1.10 2015/05/19 21:36:44 joerg Exp $"; +static char rcsid[] = "$NetBSD: job.c,v 1.1.1.11 2020/05/24 05:35:52 nia Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)job.c 8.2 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: job.c,v 1.1.1.10 2015/05/19 21:36:44 joerg Exp $"); +__RCSID("$NetBSD: job.c,v 1.1.1.11 2020/05/24 05:35:52 nia Exp $"); #endif #endif /* not lint */ #endif @@ -102,7 +102,7 @@ __RCSID("$NetBSD: job.c,v 1.1.1.10 2015/05/19 21:36:44 joerg Exp $"); * a time given by the SEL_* constants, below, * or until output is ready. * - * Job_Init Called to intialize this module. in addition, + * Job_Init Called to initialize this module. in addition, * any commands attached to the .BEGIN target * are executed before this function returns. * Hence, the makefile must have been parsed @@ -144,7 +144,6 @@ __RCSID("$NetBSD: job.c,v 1.1.1.10 2015/05/19 21:36:44 joerg Exp $"); #include <assert.h> #include <errno.h> -#include <fcntl.h> #if !defined(USE_SELECT) && defined(HAVE_POLL_H) #include <poll.h> #else @@ -343,17 +342,14 @@ static Job childExitJob; /* child exit pseudo-job */ #define CHILD_EXIT "." #define DO_JOB_RESUME "R" +static const int npseudojobs = 2; /* number of pseudo-jobs */ + #define TARG_FMT "%s %s ---\n" /* Default format */ #define MESSAGE(fp, gn) \ if (maxJobs != 1 && targPrefix && *targPrefix) \ (void)fprintf(fp, TARG_FMT, targPrefix, gn->name) static sigset_t caught_signals; /* Set of signals we handle */ -#if defined(SYSV) -#define KILLPG(pid, sig) kill(-(pid), (sig)) -#else -#define KILLPG(pid, sig) killpg((pid), (sig)) -#endif static void JobChildSig(int); static void JobContinueSig(int); @@ -374,7 +370,20 @@ static void JobSigLock(sigset_t *); static void JobSigUnlock(sigset_t *); static void JobSigReset(void); -const char *malloc_options="A"; +#if !defined(MALLOC_OPTIONS) +# define MALLOC_OPTIONS "A" +#endif +const char *malloc_options= MALLOC_OPTIONS; + +static unsigned +nfds_per_job(void) +{ +#if defined(USE_FILEMON) && !defined(USE_FILEMON_DEV) + if (useMeta) + return 2; +#endif + return 1; +} static void job_table_dump(const char *where) @@ -389,6 +398,21 @@ job_table_dump(const char *where) } /* + * Delete the target of a failed, interrupted, or otherwise + * unsuccessful job unless inhibited by .PRECIOUS. + */ +static void +JobDeleteTarget(GNode *gn) +{ + if ((gn->type & (OP_JOIN|OP_PHONY)) == 0 && !Targ_Precious(gn)) { + char *file = (gn->path == NULL ? gn->name : gn->path); + if (!noExecute && eunlink(file) != -1) { + Error("*** %s removed", file); + } + } +} + +/* * JobSigLock/JobSigUnlock * * Signal lock routines to get exclusive access. Currently used to @@ -410,7 +434,7 @@ static void JobSigUnlock(sigset_t *omaskp) static void JobCreatePipe(Job *job, int minfd) { - int i, fd; + int i, fd, flags; if (pipe(job->jobPipe) == -1) Punt("Cannot create pipe: %s", strerror(errno)); @@ -425,8 +449,10 @@ JobCreatePipe(Job *job, int minfd) } /* Set close-on-exec flag for both */ - (void)fcntl(job->jobPipe[0], F_SETFD, 1); - (void)fcntl(job->jobPipe[1], F_SETFD, 1); + if (fcntl(job->jobPipe[0], F_SETFD, FD_CLOEXEC) == -1) + Punt("Cannot set close-on-exec: %s", strerror(errno)); + if (fcntl(job->jobPipe[1], F_SETFD, FD_CLOEXEC) == -1) + Punt("Cannot set close-on-exec: %s", strerror(errno)); /* * We mark the input side of the pipe non-blocking; we poll(2) the @@ -434,8 +460,12 @@ JobCreatePipe(Job *job, int minfd) * race for the token when a new one becomes available, so the read * from the pipe should not block. */ - fcntl(job->jobPipe[0], F_SETFL, - fcntl(job->jobPipe[0], F_GETFL, 0) | O_NONBLOCK); + flags = fcntl(job->jobPipe[0], F_GETFL, 0); + if (flags == -1) + Punt("Cannot get flags: %s", strerror(errno)); + flags |= O_NONBLOCK; + if (fcntl(job->jobPipe[0], F_SETFL, flags) == -1) + Punt("Cannot set flags: %s", strerror(errno)); } /*- @@ -715,7 +745,7 @@ JobPrintCommand(void *cmdp, void *jobp) numCommands += 1; - cmdStart = cmd = Var_Subst(NULL, cmd, job->node, FALSE); + cmdStart = cmd = Var_Subst(NULL, cmd, job->node, VARF_WANTRES); cmdTemplate = "%s\n"; @@ -737,6 +767,7 @@ JobPrintCommand(void *cmdp, void *jobp) * but this one needs to be - use compat mode just for it. */ CompatRunCommand(cmdp, job->node); + free(cmdStart); return 0; } break; @@ -866,8 +897,7 @@ JobPrintCommand(void *cmdp, void *jobp) DBPRINTF(cmdTemplate, cmd); free(cmdStart); - if (escCmd) - free(escCmd); + free(escCmd); if (errOff) { /* * If echoing is already off, there's no point in issuing the @@ -903,7 +933,7 @@ JobPrintCommand(void *cmdp, void *jobp) static int JobSaveCommand(void *cmd, void *gn) { - cmd = Var_Subst(NULL, (char *)cmd, (GNode *)gn, FALSE); + cmd = Var_Subst(NULL, (char *)cmd, (GNode *)gn, VARF_WANTRES); (void)Lst_AtEnd(postCommands->commands, cmd); return(0); } @@ -1035,6 +1065,9 @@ JobFinish (Job *job, WAIT_T status) if (job->flags & JOB_IGNERR) { WAIT_STATUS(status) = 0; } else { + if (deleteOnError) { + JobDeleteTarget(job->node); + } PrintOnError(job->node, NULL); } } else if (DEBUG(JOB)) { @@ -1052,13 +1085,20 @@ JobFinish (Job *job, WAIT_T status) } (void)printf("*** [%s] Signal %d\n", job->node->name, WTERMSIG(status)); + if (deleteOnError) { + JobDeleteTarget(job->node); + } } (void)fflush(stdout); } #ifdef USE_META if (useMeta) { - meta_job_finish(job); + int x; + + if ((x = meta_job_finish(job)) != 0 && status == 0) { + status = x; + } } #endif @@ -1234,8 +1274,7 @@ Job_CheckCommands(GNode *gn, void (*abortProc)(const char *, ...)) */ Make_HandleUse(DEFAULT, gn); Var_Set(IMPSRC, Var_Value(TARGET, gn, &p1), gn, 0); - if (p1) - free(p1); + free(p1); } else if (Dir_MTime(gn, 0) == 0 && (gn->type & OP_SPECIAL) == 0) { /* * The node wasn't the target of an operator we have no .DEFAULT @@ -1357,15 +1396,27 @@ JobExec(Job *job, char **argv) execError("dup2", "job->cmdFILE"); _exit(1); } - (void)fcntl(0, F_SETFD, 0); - (void)lseek(0, (off_t)0, SEEK_SET); + if (fcntl(0, F_SETFD, 0) == -1) { + execError("fcntl clear close-on-exec", "stdin"); + _exit(1); + } + if (lseek(0, (off_t)0, SEEK_SET) == -1) { + execError("lseek to 0", "stdin"); + _exit(1); + } if (job->node->type & (OP_MAKE | OP_SUBMAKE)) { /* * Pass job token pipe to submakes. */ - fcntl(tokenWaitJob.inPipe, F_SETFD, 0); - fcntl(tokenWaitJob.outPipe, F_SETFD, 0); + if (fcntl(tokenWaitJob.inPipe, F_SETFD, 0) == -1) { + execError("clear close-on-exec", "tokenWaitJob.inPipe"); + _exit(1); + } + if (fcntl(tokenWaitJob.outPipe, F_SETFD, 0) == -1) { + execError("clear close-on-exec", "tokenWaitJob.outPipe"); + _exit(1); + } } /* @@ -1382,7 +1433,10 @@ JobExec(Job *job, char **argv) * it before routing the shell's error output to the same place as * its standard output. */ - (void)fcntl(1, F_SETFD, 0); + if (fcntl(1, F_SETFD, 0) == -1) { + execError("clear close-on-exec", "stdout"); + _exit(1); + } if (dup2(1, 2) == -1) { execError("dup2", "1, 2"); _exit(1); @@ -1416,6 +1470,12 @@ JobExec(Job *job, char **argv) Trace_Log(JOBSTART, job); +#ifdef USE_META + if (useMeta) { + meta_job_parent(job, cpid); + } +#endif + /* * Set the current position in the buffer to the beginning * and mark another stream to watch in the outputs mask @@ -1598,7 +1658,7 @@ JobStart(GNode *gn, int flags) if (job->cmdFILE == NULL) { Punt("Could not fdopen %s", tfile); } - (void)fcntl(FILENO(job->cmdFILE), F_SETFD, 1); + (void)fcntl(FILENO(job->cmdFILE), F_SETFD, FD_CLOEXEC); /* * Send the commands to the command file, flush all its buffers then * rewind and remove the thing. @@ -2098,12 +2158,24 @@ Job_CatchOutput(void) if (nready == 0) return; - for (i = 2; i < nfds; i++) { + for (i = npseudojobs*nfds_per_job(); i < nfds; i++) { if (!fds[i].revents) continue; job = jobfds[i]; if (job->job_state == JOB_ST_RUNNING) JobDoOutput(job, FALSE); +#if defined(USE_FILEMON) && !defined(USE_FILEMON_DEV) + /* + * With meta mode, we may have activity on the job's filemon + * descriptor too, which at the moment is any pollfd other than + * job->inPollfd. + */ + if (useMeta && job->inPollfd != &fds[i]) { + if (meta_job_event(job) <= 0) { + fds[i].events = 0; /* never mind */ + } + } +#endif if (--nready == 0) return; } @@ -2194,7 +2266,8 @@ Job_SetPrefix(void) Var_Set(MAKE_JOB_PREFIX, "---", VAR_GLOBAL, 0); } - targPrefix = Var_Subst(NULL, "${" MAKE_JOB_PREFIX "}", VAR_GLOBAL, 0); + targPrefix = Var_Subst(NULL, "${" MAKE_JOB_PREFIX "}", + VAR_GLOBAL, VARF_WANTRES); } /*- @@ -2247,9 +2320,11 @@ Job_Init(void) JobCreatePipe(&childExitJob, 3); - /* We can only need to wait for tokens, children and output from each job */ - fds = bmake_malloc(sizeof (*fds) * (2 + maxJobs)); - jobfds = bmake_malloc(sizeof (*jobfds) * (2 + maxJobs)); + /* Preallocate enough for the maximum number of jobs. */ + fds = bmake_malloc(sizeof(*fds) * + (npseudojobs + maxJobs) * nfds_per_job()); + jobfds = bmake_malloc(sizeof(*jobfds) * + (npseudojobs + maxJobs) * nfds_per_job()); /* These are permanent entries and take slots 0 and 1 */ watchfd(&tokenWaitJob); @@ -2401,8 +2476,7 @@ Job_ParseShell(char *line) line++; } - if (shellArgv) - free(UNCONST(shellArgv)); + free(UNCONST(shellArgv)); memset(&newShell, 0, sizeof(newShell)); @@ -2577,12 +2651,7 @@ JobInterrupt(int runINTERRUPT, int signo) gn = job->node; - if ((gn->type & (OP_JOIN|OP_PHONY)) == 0 && !Targ_Precious(gn)) { - char *file = (gn->path == NULL ? gn->name : gn->path); - if (!noExecute && eunlink(file) != -1) { - Error("*** %s removed", file); - } - } + JobDeleteTarget(gn); if (job->pid) { if (DEBUG(JOB)) { (void)fprintf(debug_file, @@ -2650,8 +2719,7 @@ void Job_End(void) { #ifdef CLEANUP - if (shellArgv) - free(shellArgv); + free(shellArgv); #endif } @@ -2775,6 +2843,14 @@ watchfd(Job *job) jobfds[nfds] = job; job->inPollfd = &fds[nfds]; nfds++; +#if defined(USE_FILEMON) && !defined(USE_FILEMON_DEV) + if (useMeta) { + fds[nfds].fd = meta_job_fd(job); + fds[nfds].events = fds[nfds].fd == -1 ? 0 : POLLIN; + jobfds[nfds] = job; + nfds++; + } +#endif } static void @@ -2785,6 +2861,18 @@ clearfd(Job *job) Punt("Unwatching unwatched job"); i = job->inPollfd - fds; nfds--; +#if defined(USE_FILEMON) && !defined(USE_FILEMON_DEV) + if (useMeta) { + /* + * Sanity check: there should be two fds per job, so the job's + * pollfd number should be even. + */ + assert(nfds_per_job() == 2); + if (i % 2) + Punt("odd-numbered fd with meta"); + nfds--; + } +#endif /* * Move last job in table into hole made by dead job. */ @@ -2792,6 +2880,12 @@ clearfd(Job *job) fds[i] = fds[nfds]; jobfds[i] = jobfds[nfds]; jobfds[i]->inPollfd = &fds[i]; +#if defined(USE_FILEMON) && !defined(USE_FILEMON_DEV) + if (useMeta) { + fds[i + 1] = fds[nfds + 1]; + jobfds[i + 1] = jobfds[nfds + 1]; + } +#endif } job->inPollfd = NULL; } @@ -2850,8 +2944,8 @@ Job_ServerStart(int max_tokens, int jp_0, int jp_1) /* Pipe passed in from parent */ tokenWaitJob.inPipe = jp_0; tokenWaitJob.outPipe = jp_1; - (void)fcntl(jp_0, F_SETFD, 1); - (void)fcntl(jp_1, F_SETFD, 1); + (void)fcntl(jp_0, F_SETFD, FD_CLOEXEC); + (void)fcntl(jp_1, F_SETFD, FD_CLOEXEC); return; } @@ -2933,7 +3027,6 @@ Job_TokenWithdraw(void) } if (DEBUG(JOB)) fprintf(debug_file, "(%d) blocked for token\n", getpid()); - wantToken = 1; return FALSE; } diff --git a/devel/bmake/files/machine.sh b/devel/bmake/files/machine.sh index ecc269cc4e2..774a289de11 100755 --- a/devel/bmake/files/machine.sh +++ b/devel/bmake/files/machine.sh @@ -2,7 +2,7 @@ # derrived from /etc/rc_d/os.sh # RCSid: -# $Id: machine.sh,v 1.1.1.5 2015/05/19 21:36:44 joerg Exp $ +# $Id: machine.sh,v 1.1.1.6 2020/05/24 05:35:52 nia Exp $ # # @(#) Copyright (c) 1994-2002 Simon J. Gerraty # @@ -44,6 +44,12 @@ Which() { } case $OS in +AIX) # from http://gnats.netbsd.org/29386 + OSMAJOR=`uname -v` + OSMINOR=`uname -r` + MACHINE=$OS$OSMAJOR.$OSMINOR + MACHINE_ARCH=`bootinfo -T` + ;; OpenBSD) MACHINE=$OS$OSMAJOR.$machine arch=`Which arch /usr/bin:/usr/ucb:$PATH` diff --git a/devel/bmake/files/main.c b/devel/bmake/files/main.c index 36ac02ced02..92477000316 100644 --- a/devel/bmake/files/main.c +++ b/devel/bmake/files/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.1.1.11 2015/05/19 21:36:44 joerg Exp $ */ +/* $NetBSD: main.c,v 1.1.1.12 2020/05/24 05:35:52 nia Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,7 +69,7 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: main.c,v 1.1.1.11 2015/05/19 21:36:44 joerg Exp $"; +static char rcsid[] = "$NetBSD: main.c,v 1.1.1.12 2020/05/24 05:35:52 nia Exp $"; #else #include <sys/cdefs.h> #ifndef lint @@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\ #if 0 static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: main.c,v 1.1.1.11 2015/05/19 21:36:44 joerg Exp $"); +__RCSID("$NetBSD: main.c,v 1.1.1.12 2020/05/24 05:35:52 nia Exp $"); #endif #endif /* not lint */ #endif @@ -125,7 +125,6 @@ __RCSID("$NetBSD: main.c,v 1.1.1.11 2015/05/19 21:36:44 joerg Exp $"); #include "wait.h" #include <errno.h> -#include <fcntl.h> #include <signal.h> #include <stdarg.h> #include <stdio.h> @@ -156,10 +155,13 @@ Lst create; /* Targets to be made */ time_t now; /* Time at start of make */ GNode *DEFAULT; /* .DEFAULT node */ Boolean allPrecious; /* .PRECIOUS given on line by itself */ +Boolean deleteOnError; /* .DELETE_ON_ERROR: set */ static Boolean noBuiltins; /* -r flag */ static Lst makefiles; /* ordered list of makefiles to read */ -static Boolean printVars; /* print value of one or more vars */ +static int printVars; /* -[vV] argument */ +#define COMPAT_VARS 1 +#define EXPAND_VARS 2 static Lst variables; /* list of variables to print */ int maxJobs; /* -j argument */ static int maxJobTokens; /* -j argument */ @@ -172,6 +174,7 @@ Boolean keepgoing; /* -k flag */ Boolean queryFlag; /* -q flag */ Boolean touchFlag; /* -t flag */ Boolean enterFlag; /* -w flag */ +Boolean enterFlagObj; /* -w and objdir != srcdir */ Boolean ignoreErrors; /* -i flag */ Boolean beSilent; /* -s flag */ Boolean oldVars; /* variable substitution style */ @@ -186,6 +189,7 @@ static const char * tracefile; static void MainParseArgs(int, char **); static int ReadMakefile(const void *, const void *); static void usage(void) MAKE_ATTR_DEAD; +static void purge_cached_realpaths(void); static Boolean ignorePWD; /* if we use -C, PWD is meaningless */ static char objdir[MAXPATHLEN + 1]; /* where we chdir'ed to */ @@ -195,6 +199,8 @@ char *makeDependfile; pid_t myPid; int makelevel; +FILE *debug_file; + Boolean forceJobs = FALSE; /* @@ -335,7 +341,7 @@ parse_debug_options(const char *argvalue) goto debug_setbuf; } len = strlen(modules); - fname = malloc(len + 20); + fname = bmake_malloc(len + 20); memcpy(fname, modules, len + 1); /* Let the filename be modified by the pid */ if (strcmp(fname + len - 3, ".%d") == 0) @@ -366,6 +372,32 @@ debug_setbuf: } } +/* + * does path contain any relative components + */ +static int +is_relpath(const char *path) +{ + const char *cp; + + if (path[0] != '/') + return TRUE; + cp = path; + do { + cp = strstr(cp, "/."); + if (!cp) + break; + cp += 2; + if (cp[0] == '/' || cp[0] == '\0') + return TRUE; + else if (cp[0] == '.') { + if (cp[1] == '/' || cp[1] == '\0') + return TRUE; + } + } while (cp); + return FALSE; +} + /*- * MainParseArgs -- * Parse a given argument vector. Called from main() and from @@ -388,11 +420,12 @@ MainParseArgs(int argc, char **argv) int arginc; char *argvalue; const char *getopt_def; + struct stat sa, sb; char *optscan; Boolean inOption, dashDash = FALSE; char found_path[MAXPATHLEN + 1]; /* for searching for sys.mk */ -#define OPTFLAGS "BC:D:I:J:NST:V:WXd:ef:ij:km:nqrstw" +#define OPTFLAGS "BC:D:I:J:NST:V:WXd:ef:ij:km:nqrstv:w" /* Can't actually use getopt(3) because rescanning is not portable */ getopt_def = OPTFLAGS; @@ -456,6 +489,12 @@ rearg: (void)fprintf(stderr, "%s: %s.\n", progname, strerror(errno)); exit(2); } + if (!is_relpath(argvalue) && + stat(argvalue, &sa) != -1 && + stat(curdir, &sb) != -1 && + sa.st_ino == sb.st_ino && + sa.st_dev == sb.st_dev) + strncpy(curdir, argvalue, MAXPATHLEN); ignorePWD = TRUE; break; case 'D': @@ -511,8 +550,9 @@ rearg: Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL); break; case 'V': + case 'v': if (argvalue == NULL) goto noarg; - printVars = TRUE; + printVars = c == 'v' ? EXPAND_VARS : COMPAT_VARS; (void)Lst_AtEnd(variables, argvalue); Var_Append(MAKEFLAGS, "-V", VAR_GLOBAL); Var_Append(MAKEFLAGS, argvalue, VAR_GLOBAL); @@ -695,8 +735,7 @@ Main_ParseArgLine(const char *line) #endif buf = bmake_malloc(len = strlen(line) + strlen(argv0) + 2); (void)snprintf(buf, len, "%s %s", argv0, line); - if (p1) - free(p1); + free(p1); argv = brk_string(buf, &argc, TRUE, &args); if (argv == NULL) { @@ -712,22 +751,22 @@ Main_ParseArgLine(const char *line) } Boolean -Main_SetObjdir(const char *path) +Main_SetObjdir(const char *fmt, ...) { struct stat sb; - char *p = NULL; + char *path; char buf[MAXPATHLEN + 1]; + char buf2[MAXPATHLEN + 1]; Boolean rc = FALSE; + va_list ap; - /* expand variable substitutions */ - if (strchr(path, '$') != 0) { - snprintf(buf, MAXPATHLEN, "%s", path); - path = p = Var_Subst(NULL, buf, VAR_GLOBAL, 0); - } + va_start(ap, fmt); + vsnprintf(path = buf, MAXPATHLEN, fmt, ap); + va_end(ap); if (path[0] != '/') { - snprintf(buf, MAXPATHLEN, "%s/%s", curdir, path); - path = buf; + snprintf(buf2, MAXPATHLEN, "%s/%s", curdir, path); + path = buf2; } /* look for the directory and try to chdir there */ @@ -740,15 +779,39 @@ Main_SetObjdir(const char *path) Var_Set(".OBJDIR", objdir, VAR_GLOBAL, 0); setenv("PWD", objdir, 1); Dir_InitDot(); + purge_cached_realpaths(); rc = TRUE; + if (enterFlag && strcmp(objdir, curdir) != 0) + enterFlagObj = TRUE; } } - if (p) - free(p); return rc; } +static Boolean +Main_SetVarObjdir(const char *var, const char *suffix) +{ + char *p, *path, *xpath; + + if ((path = Var_Value(var, VAR_CMD, &p)) == NULL || + *path == '\0') + return FALSE; + + /* expand variable substitutions */ + if (strchr(path, '$') != 0) + xpath = Var_Subst(NULL, path, VAR_GLOBAL, VARF_WANTRES); + else + xpath = path; + + (void)Main_SetObjdir("%s%s", xpath, suffix); + + if (xpath != path) + free(xpath); + free(p); + return TRUE; +} + /*- * ReadAllMakefiles -- * wrapper around ReadMakefile() to read all. @@ -803,7 +866,8 @@ MakeMode(const char *mode) char *mp = NULL; if (!mode) - mode = mp = Var_Subst(NULL, "${" MAKE_MODE ":tl}", VAR_GLOBAL, 0); + mode = mp = Var_Subst(NULL, "${" MAKE_MODE ":tl}", + VAR_GLOBAL, VARF_WANTRES); if (mode && *mode) { if (strstr(mode, "compat")) { @@ -815,8 +879,91 @@ MakeMode(const char *mode) meta_mode_init(mode); #endif } - if (mp) - free(mp); + + free(mp); +} + +static void +doPrintVars(void) +{ + LstNode ln; + Boolean expandVars; + + if (printVars == EXPAND_VARS) + expandVars = TRUE; + else if (debugVflag) + expandVars = FALSE; + else + expandVars = getBoolean(".MAKE.EXPAND_VARIABLES", FALSE); + + for (ln = Lst_First(variables); ln != NULL; + ln = Lst_Succ(ln)) { + char *var = (char *)Lst_Datum(ln); + char *value; + char *p1; + + if (strchr(var, '$')) { + value = p1 = Var_Subst(NULL, var, VAR_GLOBAL, + VARF_WANTRES); + } else if (expandVars) { + char tmp[128]; + int len = snprintf(tmp, sizeof(tmp), "${%s}", var); + + if (len >= (int)sizeof(tmp)) + Fatal("%s: variable name too big: %s", + progname, var); + value = p1 = Var_Subst(NULL, tmp, VAR_GLOBAL, + VARF_WANTRES); + } else { + value = Var_Value(var, VAR_GLOBAL, &p1); + } + printf("%s\n", value ? value : ""); + free(p1); + } +} + +static Boolean +runTargets(void) +{ + Lst targs; /* target nodes to create -- passed to Make_Init */ + Boolean outOfDate; /* FALSE if all targets up to date */ + + /* + * Have now read the entire graph and need to make a list of + * targets to create. If none was given on the command line, + * we consult the parsing module to find the main target(s) + * to create. + */ + if (Lst_IsEmpty(create)) + targs = Parse_MainName(); + else + targs = Targ_FindList(create, TARG_CREATE); + + if (!compatMake) { + /* + * Initialize job module before traversing the graph + * now that any .BEGIN and .END targets have been read. + * This is done only if the -q flag wasn't given + * (to prevent the .BEGIN from being executed should + * it exist). + */ + if (!queryFlag) { + Job_Init(); + jobsRunning = TRUE; + } + + /* Traverse the graph, checking on all the targets */ + outOfDate = Make_Run(targs); + } else { + /* + * Compat_Init will take care of creating all the + * targets as well as initializing the module. + */ + Compat_Run(targs); + outOfDate = FALSE; + } + Lst_Destroy(targs, NULL); + return outOfDate; } /*- @@ -839,8 +986,7 @@ MakeMode(const char *mode) int main(int argc, char **argv) { - Lst targs; /* target nodes to create -- passed to Make_Init */ - Boolean outOfDate = FALSE; /* FALSE if all targets up to date */ + Boolean outOfDate; /* FALSE if all targets up to date */ struct stat sb, sa; char *p1, *path; char mdpath[MAXPATHLEN]; @@ -969,7 +1115,7 @@ main(int argc, char **argv) create = Lst_Init(FALSE); makefiles = Lst_Init(FALSE); - printVars = FALSE; + printVars = 0; debugVflag = FALSE; variables = Lst_Init(FALSE); beSilent = FALSE; /* Print commands as executed */ @@ -978,6 +1124,7 @@ main(int argc, char **argv) noRecursiveExecute = FALSE; /* Execute all .MAKE targets */ keepgoing = FALSE; /* Stop on error */ allPrecious = FALSE; /* Remove targets when interrupted */ + deleteOnError = FALSE; /* Historical default behavior */ queryFlag = FALSE; /* This is not just a check-run */ noBuiltins = FALSE; /* Read the built-in rules */ touchFlag = FALSE; /* Actually update targets */ @@ -1013,7 +1160,7 @@ main(int argc, char **argv) /* * A relative path, canonicalize it. */ - p1 = realpath(argv[0], mdpath); + p1 = cached_realpath(argv[0], mdpath); if (!p1 || *p1 != '/' || stat(p1, &sb) < 0) { p1 = argv[0]; /* realpath failed */ } @@ -1052,6 +1199,8 @@ main(int argc, char **argv) #ifdef USE_META meta_init(); #endif + Dir_Init(NULL); /* Dir_* safe to call from MainParseArgs */ + /* * First snag any flags out of the MAKE environment variable. * (Note this is *not* MAKEFLAGS since /bin/make uses that and it's @@ -1127,38 +1276,21 @@ main(int argc, char **argv) * MAKEOBJDIR is set in the environment, try only that value * and fall back to .CURDIR if it does not exist. * - * Otherwise, try _PATH_OBJDIR.MACHINE, _PATH_OBJDIR, and - * finally _PATH_OBJDIRPREFIX`pwd`, in that order. If none + * Otherwise, try _PATH_OBJDIR.MACHINE-MACHINE_ARCH, _PATH_OBJDIR.MACHINE, + * and * finally _PATH_OBJDIRPREFIX`pwd`, in that order. If none * of these paths exist, just use .CURDIR. */ Dir_Init(curdir); - (void)Main_SetObjdir(curdir); + (void)Main_SetObjdir("%s", curdir); - if ((path = Var_Value("MAKEOBJDIRPREFIX", VAR_CMD, &p1)) != NULL) { - (void)snprintf(mdpath, MAXPATHLEN, "%s%s", path, curdir); - (void)Main_SetObjdir(mdpath); - free(p1); - } else if ((path = Var_Value("MAKEOBJDIR", VAR_CMD, &p1)) != NULL) { - (void)Main_SetObjdir(path); - free(p1); - } else { - (void)snprintf(mdpath, MAXPATHLEN, "%s.%s", _PATH_OBJDIR, machine); - if (!Main_SetObjdir(mdpath) && !Main_SetObjdir(_PATH_OBJDIR)) { - (void)snprintf(mdpath, MAXPATHLEN, "%s%s", - _PATH_OBJDIRPREFIX, curdir); - (void)Main_SetObjdir(mdpath); - } - } + if (!Main_SetVarObjdir("MAKEOBJDIRPREFIX", curdir) && + !Main_SetVarObjdir("MAKEOBJDIR", "") && + !Main_SetObjdir("%s.%s-%s", _PATH_OBJDIR, machine, machine_arch) && + !Main_SetObjdir("%s.%s", _PATH_OBJDIR, machine) && + !Main_SetObjdir("%s", _PATH_OBJDIR)) + (void)Main_SetObjdir("%s%s", _PATH_OBJDIRPREFIX, curdir); /* - * Be compatible if user did not specify -j and did not explicitly - * turned compatibility on - */ - if (!compatMake && !forceJobs) { - compatMake = TRUE; - } - - /* * Initialize archive, target and suffix modules in preparation for * parsing the makefile(s) */ @@ -1249,7 +1381,7 @@ main(int argc, char **argv) (char *)Lst_Datum(ln)); } else { p1 = Var_Subst(NULL, "${" MAKEFILE_PREFERENCE "}", - VAR_CMD, 0); + VAR_CMD, VARF_WANTRES); if (p1) { (void)str2Lst_Append(makefiles, p1, NULL); (void)Lst_Find(makefiles, NULL, ReadMakefile); @@ -1260,17 +1392,49 @@ main(int argc, char **argv) /* In particular suppress .depend for '-r -V .OBJDIR -f /dev/null' */ if (!noBuiltins || !printVars) { makeDependfile = Var_Subst(NULL, "${.MAKE.DEPENDFILE:T}", - VAR_CMD, 0); + VAR_CMD, VARF_WANTRES); doing_depend = TRUE; (void)ReadMakefile(makeDependfile, NULL); doing_depend = FALSE; } + if (enterFlagObj) + printf("%s: Entering directory `%s'\n", progname, objdir); + MakeMode(NULL); Var_Append("MFLAGS", Var_Value(MAKEFLAGS, VAR_GLOBAL, &p1), VAR_GLOBAL); - if (p1) - free(p1); + free(p1); + + if (!forceJobs && !compatMake && + Var_Exists(".MAKE.JOBS", VAR_GLOBAL)) { + char *value; + int n; + + value = Var_Subst(NULL, "${.MAKE.JOBS}", VAR_GLOBAL, VARF_WANTRES); + n = strtol(value, NULL, 0); + if (n < 1) { + (void)fprintf(stderr, "%s: illegal value for .MAKE.JOBS -- must be positive integer!\n", + progname); + exit(1); + } + if (n != maxJobs) { + Var_Append(MAKEFLAGS, "-j", VAR_GLOBAL); + Var_Append(MAKEFLAGS, value, VAR_GLOBAL); + } + maxJobs = n; + maxJobTokens = maxJobs; + forceJobs = TRUE; + free(value); + } + + /* + * Be compatible if user did not specify -j and did not explicitly + * turned compatibility on + */ + if (!compatMake && !forceJobs) { + compatMake = TRUE; + } if (!compatMake) Job_ServerStart(maxJobTokens, jp_0, jp_1); @@ -1278,8 +1442,9 @@ main(int argc, char **argv) fprintf(debug_file, "job_pipe %d %d, maxjobs %d, tokens %d, compat %d\n", jp_0, jp_1, maxJobs, maxJobTokens, compatMake); - Main_ExportMAKEFLAGS(TRUE); /* initial export */ - + if (!printVars) + Main_ExportMAKEFLAGS(TRUE); /* initial export */ + /* * For compatibility, look at the directories in the VPATH variable * and add them to the search path, if the variable is defined. The @@ -1295,7 +1460,7 @@ main(int argc, char **argv) */ static char VPATH[] = "${VPATH}"; - vpath = Var_Subst(NULL, VPATH, VAR_CMD, FALSE); + vpath = Var_Subst(NULL, VPATH, VAR_CMD, VARF_WANTRES); path = vpath; do { /* skip to end of directory */ @@ -1329,72 +1494,13 @@ main(int argc, char **argv) /* print the values of any variables requested by the user */ if (printVars) { - LstNode ln; - Boolean expandVars; - - if (debugVflag) - expandVars = FALSE; - else - expandVars = getBoolean(".MAKE.EXPAND_VARIABLES", FALSE); - for (ln = Lst_First(variables); ln != NULL; - ln = Lst_Succ(ln)) { - char *var = (char *)Lst_Datum(ln); - char *value; - - if (strchr(var, '$')) { - value = p1 = Var_Subst(NULL, var, VAR_GLOBAL, 0); - } else if (expandVars) { - char tmp[128]; - - if (snprintf(tmp, sizeof(tmp), "${%s}", var) >= (int)(sizeof(tmp))) - Fatal("%s: variable name too big: %s", - progname, var); - value = p1 = Var_Subst(NULL, tmp, VAR_GLOBAL, 0); - } else { - value = Var_Value(var, VAR_GLOBAL, &p1); - } - printf("%s\n", value ? value : ""); - if (p1) - free(p1); - } + doPrintVars(); + outOfDate = FALSE; } else { - /* - * Have now read the entire graph and need to make a list of - * targets to create. If none was given on the command line, - * we consult the parsing module to find the main target(s) - * to create. - */ - if (Lst_IsEmpty(create)) - targs = Parse_MainName(); - else - targs = Targ_FindList(create, TARG_CREATE); - - if (!compatMake) { - /* - * Initialize job module before traversing the graph - * now that any .BEGIN and .END targets have been read. - * This is done only if the -q flag wasn't given - * (to prevent the .BEGIN from being executed should - * it exist). - */ - if (!queryFlag) { - Job_Init(); - jobsRunning = TRUE; - } - - /* Traverse the graph, checking on all the targets */ - outOfDate = Make_Run(targs); - } else { - /* - * Compat_Init will take care of creating all the - * targets as well as initializing the module. - */ - Compat_Run(targs); - } + outOfDate = runTargets(); } #ifdef CLEANUP - Lst_Destroy(targs, NULL); Lst_Destroy(variables, NULL); Lst_Destroy(makefiles, NULL); Lst_Destroy(create, (FreeProc *)free); @@ -1406,9 +1512,14 @@ main(int argc, char **argv) Trace_Log(MAKEEND, 0); + if (enterFlagObj) + printf("%s: Leaving directory `%s'\n", progname, objdir); if (enterFlag) printf("%s: Leaving directory `%s'\n", progname, curdir); +#ifdef USE_META + meta_finish(); +#endif Suff_End(); Targ_End(); Arch_End(); @@ -1477,8 +1588,7 @@ ReadMakefile(const void *p, const void *q MAKE_ATTR_UNUSED) name = Dir_FindFile(fname, Lst_IsEmpty(sysIncPath) ? defIncPath : sysIncPath); if (!name || (fd = open(name, O_RDONLY)) == -1) { - if (name) - free(name); + free(name); free(path); return(-1); } @@ -1849,10 +1959,70 @@ usage(void) "usage: %s [-BeikNnqrstWwX] \n\ [-C directory] [-D variable] [-d flags] [-f makefile]\n\ [-I directory] [-J private] [-j max_jobs] [-m directory] [-T file]\n\ - [-V variable] [variable=value] [target ...]\n", progname); + [-V variable] [-v variable] [variable=value] [target ...]\n", + progname); exit(2); } +/* + * realpath(3) can get expensive, cache results... + */ +static GNode *cached_realpaths = NULL; + +static GNode * +get_cached_realpaths(void) +{ + + if (!cached_realpaths) { + cached_realpaths = Targ_NewGN("Realpath"); +#ifndef DEBUG_REALPATH_CACHE + cached_realpaths->flags = INTERNAL; +#endif + } + + return cached_realpaths; +} + +/* purge any relative paths */ +static void +purge_cached_realpaths(void) +{ + GNode *cache = get_cached_realpaths(); + Hash_Entry *he, *nhe; + Hash_Search hs; + + he = Hash_EnumFirst(&cache->context, &hs); + while (he) { + nhe = Hash_EnumNext(&hs); + if (he->name[0] != '/') { + if (DEBUG(DIR)) + fprintf(stderr, "cached_realpath: purging %s\n", he->name); + Hash_DeleteEntry(&cache->context, he); + } + he = nhe; + } +} + +char * +cached_realpath(const char *pathname, char *resolved) +{ + GNode *cache; + char *rp, *cp; + + if (!pathname || !pathname[0]) + return NULL; + + cache = get_cached_realpaths(); + + if ((rp = Var_Value(pathname, cache, &cp)) != NULL) { + /* a hit */ + strlcpy(resolved, rp, MAXPATHLEN); + } else if ((rp = realpath(pathname, resolved)) != NULL) { + Var_Set(pathname, rp, cache, 0); + } + free(cp); + return rp ? resolved : NULL; +} int PrintAddr(void *a, void *b) @@ -1862,6 +2032,14 @@ PrintAddr(void *a, void *b) } +static int +addErrorCMD(void *cmdp, void *gnp MAKE_ATTR_UNUSED) +{ + if (cmdp == NULL) + return 1; /* stop */ + Var_Append(".ERROR_CMD", cmdp, VAR_GLOBAL); + return 0; +} void PrintOnError(GNode *gn, const char *s) @@ -1882,15 +2060,19 @@ PrintOnError(GNode *gn, const char *s) * We can print this even if there is no .ERROR target. */ Var_Set(".ERROR_TARGET", gn->name, VAR_GLOBAL, 0); + Var_Delete(".ERROR_CMD", VAR_GLOBAL); + Lst_ForEach(gn->commands, addErrorCMD, gn); } strncpy(tmp, "${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'\n@}", sizeof(tmp) - 1); - cp = Var_Subst(NULL, tmp, VAR_GLOBAL, 0); + cp = Var_Subst(NULL, tmp, VAR_GLOBAL, VARF_WANTRES); if (cp) { if (*cp) printf("%s", cp); free(cp); } + fflush(stdout); + /* * Finally, see if there is a .ERROR target, and run it if so. */ @@ -1914,7 +2096,7 @@ Main_ExportMAKEFLAGS(Boolean first) strncpy(tmp, "${.MAKEFLAGS} ${.MAKEOVERRIDES:O:u:@v@$v=${$v:Q}@}", sizeof(tmp)); - s = Var_Subst(NULL, tmp, VAR_CMD, 0); + s = Var_Subst(NULL, tmp, VAR_CMD, VARF_WANTRES); if (s && *s) { #ifdef POSIX setenv("MAKEFLAGS", s, 1); @@ -1936,7 +2118,8 @@ getTmpdir(void) * Honor $TMPDIR but only if it is valid. * Ensure it ends with /. */ - tmpdir = Var_Subst(NULL, "${TMPDIR:tA:U" _PATH_TMP "}/", VAR_GLOBAL, 0); + tmpdir = Var_Subst(NULL, "${TMPDIR:tA:U" _PATH_TMP "}/", VAR_GLOBAL, + VARF_WANTRES); if (stat(tmpdir, &st) < 0 || !S_ISDIR(st.st_mode)) { free(tmpdir); tmpdir = bmake_strdup(_PATH_TMP); @@ -1976,6 +2159,44 @@ mkTempFile(const char *pattern, char **fnamep) return fd; } +/* + * Convert a string representation of a boolean. + * Anything that looks like "No", "False", "Off", "0" etc, + * is FALSE, otherwise TRUE. + */ +Boolean +s2Boolean(const char *s, Boolean bf) +{ + if (s) { + switch(*s) { + case '\0': /* not set - the default wins */ + break; + case '0': + case 'F': + case 'f': + case 'N': + case 'n': + bf = FALSE; + break; + case 'O': + case 'o': + switch (s[1]) { + case 'F': + case 'f': + bf = FALSE; + break; + default: + bf = TRUE; + break; + } + break; + default: + bf = TRUE; + break; + } + } + return (bf); +} /* * Return a Boolean based on setting of a knob. @@ -1990,32 +2211,11 @@ getBoolean(const char *name, Boolean bf) char tmp[64]; char *cp; - if (snprintf(tmp, sizeof(tmp), "${%s:tl}", name) < (int)(sizeof(tmp))) { - cp = Var_Subst(NULL, tmp, VAR_GLOBAL, 0); + if (snprintf(tmp, sizeof(tmp), "${%s:U:tl}", name) < (int)(sizeof(tmp))) { + cp = Var_Subst(NULL, tmp, VAR_GLOBAL, VARF_WANTRES); if (cp) { - switch(*cp) { - case '\0': /* not set - the default wins */ - break; - case '0': - case 'f': - case 'n': - bf = FALSE; - break; - case 'o': - switch (cp[1]) { - case 'f': - bf = FALSE; - break; - default: - bf = TRUE; - break; - } - break; - default: - bf = TRUE; - break; - } + bf = s2Boolean(cp, bf); free(cp); } } diff --git a/devel/bmake/files/make-bootstrap.sh.in b/devel/bmake/files/make-bootstrap.sh.in index 2bb4c25a705..ec100138b6d 100644 --- a/devel/bmake/files/make-bootstrap.sh.in +++ b/devel/bmake/files/make-bootstrap.sh.in @@ -13,7 +13,7 @@ esac CC="@CC@" CFLAGS="@CFLAGS@ -I. -I${srcdir} @DEFS@ @CPPFLAGS@ -DMAKE_NATIVE ${XDEFS} -DBMAKE_PATH_MAX=@bmake_path_max@" -MAKE_VERSION=`sed -n '/^MAKE_VERSION=/s,.*=[^0-9]*,,p' $srcdir/Makefile` +MAKE_VERSION=@_MAKE_VERSION@ MDEFS="-DMAKE_VERSION=\"$MAKE_VERSION\" \ -D@force_machine@MACHINE=\"@machine@\" -DMACHINE_ARCH=\"@machine_arch@\" \ @@ -23,6 +23,10 @@ MDEFS="-DMAKE_VERSION=\"$MAKE_VERSION\" \ LDFLAGS="@LDFLAGS@" LIBS="@LIBS@" +toUpper() { + ${TR:-tr} abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ +} + do_compile2() { obj="$1"; shift src="$1"; shift @@ -32,7 +36,10 @@ do_compile2() { do_compile() { obj="$1"; shift - src=`basename "$obj" .o`.c + case "$1" in + *.c) src=$1; shift;; + *) src=`basename "$obj" .o`.c;; + esac for d in "$srcdir" "$srcdir/lst.lib" do @@ -52,7 +59,7 @@ do_link() { } BASE_OBJECTS="arch.o buf.o compat.o cond.o dir.o for.o getopt hash.o \ -job.o make.o make_malloc.o parse.o sigcompat.o str.o strlist.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 \ @@ -73,12 +80,22 @@ done case "@use_meta@" in yes) - case "@filemon_h@" in - */filemon.h) FDEFS="-DHAVE_FILEMON_H -I`dirname @filemon_h@`";; + 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 ${FDEFS} - BASE_OBJECTS="meta.o ${BASE_OBJECTS}" - ;; + do_compile meta.o ${MDEFS} + BASE_OBJECTS="meta.o ${BASE_OBJECTS}" + ;; esac +do_compile job.o ${MDEFS} -do_link bmake main.o ${BASE_OBJECTS} ${LST_OBJECTS} ${LIB_OBJECTS} +do_link bmake main.o job.o ${BASE_OBJECTS} ${LST_OBJECTS} ${LIB_OBJECTS} diff --git a/devel/bmake/files/make.1 b/devel/bmake/files/make.1 index 5241ec12307..e2390288566 100644 --- a/devel/bmake/files/make.1 +++ b/devel/bmake/files/make.1 @@ -1,4 +1,4 @@ -.\" $NetBSD: make.1,v 1.1.1.10 2015/05/19 21:36:44 joerg Exp $ +.\" $NetBSD: make.1,v 1.1.1.11 2020/05/24 05:35:52 nia Exp $ .\" .\" Copyright (c) 1990, 1993 .\" The Regents of the University of California. All rights reserved. @@ -29,7 +29,7 @@ .\" .\" from: @(#)make.1 8.4 (Berkeley) 3/19/94 .\" -.Dd April 9, 2015 +.Dd April 27, 2020 .Dt MAKE 1 .Os .Sh NAME @@ -48,6 +48,7 @@ .Op Fl m Ar directory .Op Fl T Ar file .Op Fl V Ar variable +.Op Fl v Ar variable .Op Ar variable=value .Op Ar target ... .Sh DESCRIPTION @@ -206,7 +207,9 @@ Print debugging information about target list maintenance. .It Ar V Force the .Fl V -option to print raw values of variables. +option to print raw values of variables, overriding the default behavior +set via +.Va .MAKE.EXPAND_VARIABLES . .It Ar v Print debugging information about variable assignment. .It Ar x @@ -269,7 +272,7 @@ that do not depend on the target whose creation caused the error. .It Fl m Ar directory Specify a directory in which to search for sys.mk and makefiles included via the -.Ao Ar file Ac Ns -style +.Li \&< Ns Ar file Ns Li \&> Ns -style include statement. The .Fl m @@ -277,7 +280,7 @@ option can be used multiple times to form a search path. This path will override the default system include path: /usr/share/mk. Furthermore the system include path will be appended to the search path used for -.Qo Ar file Qc Ns -style +.Li \*q Ns Ar file Ns Li \*q Ns -style include statements (see the .Fl I option). @@ -293,7 +296,7 @@ then will search for the specified file or directory named in the remaining part of the argument string. The search starts with the current directory of -the Makefile and then works upward towards the root of the filesystem. +the Makefile and then works upward towards the root of the file system. If the search is successful, then the resulting directory replaces the .Qq \&.../ specification in the @@ -334,20 +337,39 @@ for each job started and completed. Rather than re-building a target as specified in the makefile, create it or update its modification time to make it appear up-to-date. .It Fl V Ar variable -Print -.Nm Ns 's -idea of the value of -.Ar variable , -in the global context. +Print the value of +.Ar variable . Do not build any targets. Multiple instances of this option may be specified; the variables will be printed one per line, with a blank line for each null or undefined variable. +The value printed is extracted from the global context after all +makefiles have been read. +By default, the raw variable contents (which may +include additional unexpanded variable references) are shown. If .Ar variable contains a .Ql \&$ -then the value will be expanded before printing. +then the value will be recursively expanded to its complete resultant +text before printing. +The expanded value will also be printed if +.Va .MAKE.EXPAND_VARIABLES +is set to true and +the +.Fl dV +option has not been used to override it. +Note that loop-local and target-local variables, as well as values +taken temporarily by global variables during makefile processing, are +not accessible via this option. +The +.Fl dv +debug mode can be used to see these at the cost of generating +substantial extraneous output. +.It Fl v Ar variable +Like +.Fl V +but the variable is always expanded to its complete value. .It Fl W Treat any warnings during makefile parsing as errors. .It Fl w @@ -657,7 +679,7 @@ The seven local variables are as follows: .Bl -tag -width ".ARCHIVE" -offset indent .It Va .ALLSRC The list of all sources for this target; also known as -.Ql Va \&\*[Gt] . +.Ql Va \&> . .It Va .ARCHIVE The name of the archive file; also known as .Ql Va \&! . @@ -666,7 +688,7 @@ In suffix-transformation rules, the name/path of the source from which the target is to be transformed (the .Dq implied source); also known as -.Ql Va \&\*[Lt] . +.Ql Va \&< . It is not defined in explicit rules. .It Va .MEMBER The name of the archive member; also known as @@ -685,12 +707,15 @@ or it will not be recognized. .It Va .TARGET The name of the target; also known as .Ql Va @ . +For compatibility with other makes this is an alias for +.Ic .ARCHIVE +in archive member rules. .El .Pp The shorter forms -.Ql ( Va \*[Gt] , +.Ql ( Va > , .Ql Va \&! , -.Ql Va \*[Lt] , +.Ql Va < , .Ql Va % , .Ql Va \&? , .Ql Va * , @@ -773,6 +798,10 @@ from which generated dependencies are read. A boolean that controls the default behavior of the .Fl V option. +If true, variable values printed with +.Fl V +are fully expanded; if false, the raw variable contents (which may +include additional unexpanded variable references) are shown. .It Va .MAKE.EXPORTED The list of variables exported by .Nm . @@ -843,7 +872,7 @@ Can affect the mode that .Nm runs in. It can contain a number of keywords: -.Bl -hang -width ignore-cmd +.Bl -hang -width missing-filemon=bf. .It Pa compat Like .Fl B , @@ -867,8 +896,19 @@ will not create .meta files in This can be overridden by setting .Va bf to a value which represents True. +.It Pa missing-meta= Ar bf +If +.Va bf +is True, then a missing .meta file makes the target out-of-date. +.It Pa missing-filemon= Ar bf +If +.Va bf +is True, then missing filemon data makes the target out-of-date. +.It Pa nofilemon +Do not use +.Xr filemon 4 . .It Pa env -For debugging, it can be useful to inlcude the environment +For debugging, it can be useful to include the environment in the .meta file. .It Pa verbose If in "meta" mode, print a clue about the target being built. @@ -910,6 +950,12 @@ Provides a list of path prefixes that should be ignored; because the contents are expected to change over time. The default list includes: .Ql Pa /dev /etc /proc /tmp /var/run /var/tmp +.It Va .MAKE.META.IGNORE_PATTERNS +Provides a list of patterns to match against pathnames. +Ignore any that match. +.It Va .MAKE.META.IGNORE_FILTER +Provides a list of variable modifiers to apply to each pathname. +Ignore if the expansion is an empty string. .It Va .MAKE.META.PREFIX Defines the message printed for each meta file updated in "meta verbose" mode. The default value is: @@ -918,7 +964,7 @@ The default value is: This variable is used to record the names of variables assigned to on the command line, so that they may be exported as part of .Ql Ev MAKEFLAGS . -This behaviour can be disabled by assigning an empty value to +This behavior can be disabled by assigning an empty value to .Ql Va .MAKEOVERRIDES within a makefile. Extra variables can be exported from a makefile @@ -941,10 +987,35 @@ The process-id of .It Va .MAKE.PPID The parent process-id of .Nm . +.It Va .MAKE.SAVE_DOLLARS +value should be a boolean that controls whether +.Ql $$ +are preserved when doing +.Ql := +assignments. +The default is false, for backwards compatibility. +Set to true for compatability with other makes. +If set to false, +.Ql $$ +becomes +.Ql $ +per normal evaluation rules. .It Va MAKE_PRINT_VAR_ON_ERROR When .Nm -stops due to an error, it prints its name and the value of +stops due to an error, it sets +.Ql Va .ERROR_TARGET +to the name of the target that failed, +.Ql Va .ERROR_CMD +to the commands of the failed target, +and in "meta" mode, it also sets +.Ql Va .ERROR_CWD +to the +.Xr getcwd 3 , +and +.Ql Va .ERROR_META_FILE +to the path of the meta file (if any) describing the failed target. +It then prints its name and the value of .Ql Va .CURDIR as well as the value of any variables named in .Ql Va MAKE_PRINT_VAR_ON_ERROR . @@ -993,14 +1064,15 @@ This is especially useful with .Ql Ev MAKEOBJDIR . .Pp .Ql Va .OBJDIR -may be modified in the makefile as a global variable. +may be modified in the makefile via the special target +.Ql Ic .OBJDIR . In all cases, .Nm will .Xr chdir 2 -to +to the specified directory if it exists, and set .Ql Va .OBJDIR -and set +and .Ql Ev PWD to that directory before executing any targets. . @@ -1043,7 +1115,7 @@ sets to the value of .Ql Ev PWD instead. -This behaviour is disabled if +This behavior is disabled if .Ql Ev MAKEOBJDIRPREFIX is set or .Ql Ev MAKEOBJDIR @@ -1113,7 +1185,7 @@ The wildcard characters may be escaped with a backslash As a consequence of the way values are split into words, matched, and then joined, a construct like .Dl ${VAR:M*} -will normalise the inter-word spacing, removing all leading and +will normalize the inter-word spacing, removing all leading and trailing space, and converting multiple consecutive spaces to single spaces. . @@ -1133,7 +1205,7 @@ Randomize words in variable. The results will be different each time you are referring to the modified variable; use the assignment with expansion .Pq Ql Cm \&:= -to prevent such behaviour. +to prevent such behavior. For example, .Bd -literal -offset indent LIST= uno due tre quattro @@ -1155,22 +1227,39 @@ due uno quattro tre .Ed .It Cm \&:Q Quotes every shell meta-character in the variable, so that it can be passed +safely to the shell. +.It Cm \&:q +Quotes every shell meta-character in the variable, and also doubles +.Sq $ +characters so that it can be passed safely through recursive invocations of .Nm . +This is equivalent to: +.Sq \&:S/\e\&$/&&/g:Q . .It Cm \&:R Replaces each word in the variable with everything but its suffix. -.It Cm \&:gmtime +.It Cm \&:range[=count] +The value is an integer sequence representing the words of the original +value, or the supplied +.Va count . +.It Cm \&:gmtime[=utc] The value is a format string for .Xr strftime 3 , -using the current +using .Xr gmtime 3 . +If a +.Va utc +value is not provided or is 0, the current time is used. .It Cm \&:hash -Compute a 32bit hash of the value and encode it as hex digits. -.It Cm \&:localtime +Compute a 32-bit hash of the value and encode it as hex digits. +.It Cm \&:localtime[=utc] The value is a format string for .Xr strftime 3 , -using the current +using .Xr localtime 3 . +If a +.Va utc +value is not provided or is 0, the current time is used. .It Cm \&:tA Attempt to convert variable to an absolute path using .Xr realpath 3 , @@ -1231,7 +1320,7 @@ it is anchored at the end of each word. Inside .Ar new_string , an ampersand -.Pq Ql \*[Am] +.Pq Ql & is replaced by .Ar old_string (without any @@ -1340,6 +1429,29 @@ is the substring of .Ar old_string to be replaced in .Ar new_string . +If only +.Ar old_string +contains the pattern matching character +.Ar % , +and +.Ar old_string +matches, then the result is the +.Ar new_string . +If only the +.Ar new_string +contains the pattern matching character +.Ar % , +then it is not treated specially and it is printed as a literal +.Ar % +on match. +If there is more than one pattern matching character +.Ar ( % ) +in either the +.Ar new_string +or +.Ar old_string , +only the first instance is treated specially (as the pattern character); +all subsequent instances are treated as regular characters .Pp Variable expansion occurs in the normal fashion inside both .Ar old_string @@ -1370,6 +1482,27 @@ For example. .Pp However a single character variable is often more readable: .Dl ${MAKE_PRINT_VAR_ON_ERROR:@v@$v='${$v}'${.newline}@} +.It Cm \&:_[=var] +Save the current variable value in +.Ql $_ +or the named +.Va var +for later reference. +Example usage: +.Bd -literal -offset indent +M_cmpv.units = 1 1000 1000000 +M_cmpv = S,., ,g:_:range:@i@+ $${_:[-$$i]} \&\\ +\\* $${M_cmpv.units:[$$i]}@:S,^,expr 0 ,1:sh + +.Dv .if ${VERSION:${M_cmpv}} < ${3.1.12:L:${M_cmpv}} + +.Ed +Here +.Ql $_ +is used to save the result of the +.Ql :S +modifier which is later referenced using the index values from +.Ql :range . .It Cm \&:U Ns Ar newval If the variable is undefined .Ar newval @@ -1443,7 +1576,7 @@ value is divided into words. .Pp Ordinarily, a value is treated as a sequence of words delimited by white space. -Some modifiers suppress this behaviour, +Some modifiers suppress this behavior, causing a value to be treated as a single word (possibly containing embedded white space). An empty value, or a value that consists entirely of white-space, @@ -1513,9 +1646,9 @@ dot .Pq Ql \&. character. Files are included with either -.Cm \&.include Aq Ar file +.Cm \&.include \&< Ns Ar file Ns Cm \&> or -.Cm \&.include Pf \*q Ar file Ns \*q . +.Cm \&.include \&\*q Ns Ar file Ns Cm \&\*q . Variables between the angle brackets or double quotes are expanded to form the file name. If angle brackets are used, the included makefile is expected to be in @@ -1529,12 +1662,20 @@ For compatibility with other versions of .Nm .Ql include file ... is also accepted. +.Pp If the include statement is written as .Cm .-include or as .Cm .sinclude then errors locating and/or opening include files are ignored. .Pp +If the include statement is written as +.Cm .dinclude +not only are errors locating and/or opening include files ignored, +but stale dependencies within the included file will be ignored +just like +.Va .MAKE.DEPENDFILE . +.Pp Conditional expressions are also preceded by a single dot as the first character of a line. The possible conditionals are as follows: @@ -1570,6 +1711,10 @@ This allows exporting a value to the environment which is different from that used by .Nm internally. +.It Ic .export-literal Ar variable ... +The same as +.Ql .export-env , +except that variables in the value are not expanded. .It Ic .info Ar message The message is printed along with the name of the makefile and line number. .It Ic .undef Ar variable @@ -1662,7 +1807,7 @@ may be any one of the following: .Bl -tag -width "Cm XX" .It Cm \&|\&| Logical OR. -.It Cm \&\*[Am]\*[Am] +.It Cm \&&& Logical .Tn AND ; of higher precedence than @@ -1679,7 +1824,7 @@ The boolean operator may be used to logically negate an entire conditional. It is of higher precedence than -.Ql Ic \&\*[Am]\*[Am] . +.Ql Ic \&&& . .Pp The value of .Ar expression @@ -1750,7 +1895,8 @@ expression is applied. Similarly, if the form is .Ql Ic .ifmake or -.Ql Ic .ifnmake , the +.Ql Ic .ifnmake , +the .Dq make expression is applied. .Pp @@ -1953,6 +2099,14 @@ variable of a target that inherits .Ic .DEFAULT Ns 's commands is set to the target's own name. +.It Ic .DELETE_ON_ERROR +If this target is present in the makefile, it globally causes make to +delete targets whose commands fail. +(By default, only targets whose commands are interrupted during +execution are deleted. +This is the historical behavior.) +This setting can be used to help prevent half-finished or malformed +targets from being left around and corrupting future rebuilds. .It Ic .END Any command lines attached to this target are executed after everything else is done. @@ -2001,6 +2155,15 @@ Disable parallel mode. Synonym for .Ic .NOTPARALLEL , for compatibility with other pmake variants. +.It Ic .OBJDIR +The source is a new value for +.Ql Va .OBJDIR . +If it exists, +.Nm +will +.Xr chdir 2 +to it and update the value of +.Ql Va .OBJDIR . .It Ic .ORDER The named targets are made in sequence. This ordering does not add targets to the list of targets to be made. @@ -2058,7 +2221,7 @@ The sources are a set of pairs. .Bl -tag -width hasErrCtls .It Ar name -This is the minimal specification, used to select one of the builtin +This is the minimal specification, used to select one of the built-in shell specs; .Ar sh , .Ar ksh , @@ -2264,9 +2427,9 @@ file). .Sh BUGS The .Nm -syntax is difficult to parse without actually acting of the data. -For instance finding the end of a variable use should involve scanning each -the modifiers using the correct terminator for each field. +syntax is difficult to parse without actually acting on the data. +For instance, finding the end of a variable's use should involve scanning +each of the modifiers, using the correct terminator for each field. In many places .Nm just counts {} and () in order to find the end of a variable expansion. diff --git a/devel/bmake/files/make.c b/devel/bmake/files/make.c index 8cab32254c7..57a90ac854d 100644 --- a/devel/bmake/files/make.c +++ b/devel/bmake/files/make.c @@ -1,4 +1,4 @@ -/* $NetBSD: make.c,v 1.1.1.8 2015/05/19 21:36:44 joerg Exp $ */ +/* $NetBSD: make.c,v 1.1.1.9 2020/05/24 05:35:52 nia Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: make.c,v 1.1.1.8 2015/05/19 21:36:44 joerg Exp $"; +static char rcsid[] = "$NetBSD: make.c,v 1.1.1.9 2020/05/24 05:35:52 nia Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)make.c 8.1 (Berkeley) 6/6/93"; #else -__RCSID("$NetBSD: make.c,v 1.1.1.8 2015/05/19 21:36:44 joerg Exp $"); +__RCSID("$NetBSD: make.c,v 1.1.1.9 2020/05/24 05:35:52 nia Exp $"); #endif #endif /* not lint */ #endif @@ -308,7 +308,7 @@ Make_OODate(GNode *gn) if (DEBUG(MAKE)) { if (gn->cmgn != NULL && gn->mtime < gn->cmgn->mtime) { fprintf(debug_file, "modified before source %s...", - gn->cmgn->path); + gn->cmgn->path ? gn->cmgn->path : gn->cmgn->name); } else if (gn->mtime == 0) { fprintf(debug_file, "non-existent and no sources..."); } else { @@ -482,10 +482,9 @@ Make_HandleUse(GNode *cgn, GNode *pgn) if (gn->uname == NULL) { gn->uname = gn->name; } else { - if (gn->name) - free(gn->name); + free(gn->name); } - gn->name = Var_Subst(NULL, gn->uname, pgn, FALSE); + gn->name = Var_Subst(NULL, gn->uname, pgn, VARF_WANTRES); if (gn->name && gn->uname && strcmp(gn->name, gn->uname) != 0) { /* See if we have a target for this node. */ tgn = Targ_FindNode(gn->name, TARG_NOCREATE); @@ -692,8 +691,7 @@ Make_Update(GNode *cgn) checked++; cname = Var_Value(TARGET, cgn, &p1); - if (p1) - free(p1); + free(p1); if (DEBUG(MAKE)) fprintf(debug_file, "Make_Update: %s%s\n", cgn->name, cgn->cohort_num); @@ -838,8 +836,7 @@ Make_Update(GNode *cgn) Var_Set(PREFIX, cpref, pgn, 0); } } - if (p1) - free(p1); + free(p1); Lst_Close(cgn->iParents); } } @@ -907,8 +904,7 @@ MakeAddAllSrc(void *cgnp, void *pgnp) } if (allsrc != NULL) Var_Append(ALLSRC, allsrc, pgn); - if (p2) - free(p2); + free(p2); if (pgn->type & OP_JOIN) { if (cgn->made == MADE) { Var_Append(OODATE, child, pgn); @@ -934,8 +930,7 @@ MakeAddAllSrc(void *cgnp, void *pgnp) */ Var_Append(OODATE, child, pgn); } - if (p1) - free(p1); + free(p1); } return (0); } @@ -981,8 +976,7 @@ Make_DoAllVar(GNode *gn) if (gn->type & OP_JOIN) { char *p1; Var_Set(TARGET, Var_Value(ALLSRC, gn, &p1), gn, 0); - if (p1) - free(p1); + free(p1); } gn->flags |= DONE_ALLSRC; } diff --git a/devel/bmake/files/make.h b/devel/bmake/files/make.h index 61e7577d815..c5b373d7d6d 100644 --- a/devel/bmake/files/make.h +++ b/devel/bmake/files/make.h @@ -1,4 +1,4 @@ -/* $NetBSD: make.h,v 1.1.1.8 2015/05/19 21:36:44 joerg Exp $ */ +/* $NetBSD: make.h,v 1.1.1.9 2020/05/24 05:35:52 nia Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -88,6 +88,7 @@ #include <sys/param.h> #include <ctype.h> +#include <fcntl.h> #include <stdio.h> #include <stdlib.h> #ifdef HAVE_STRING_H @@ -98,6 +99,10 @@ #include <unistd.h> #include <sys/cdefs.h> +#ifndef FD_CLOEXEC +#define FD_CLOEXEC 1 +#endif + #if defined(__GNUC__) #define MAKE_GNUC_PREREQ(x, y) \ ((__GNUC__ == (x) && __GNUC_MINOR__ >= (y)) || \ @@ -194,6 +199,7 @@ typedef struct GNode { #define DONE_ALLSRC 0x40 /* We do it once only */ #define CYCLE 0x1000 /* Used by MakePrintStatus */ #define DONECYCLE 0x2000 /* Used by MakePrintStatus */ +#define INTERNAL 0x4000 /* Internal use only */ enum enum_made { UNMADE, DEFERRED, REQUESTED, BEINGMADE, MADE, UPTODATE, ERROR, ABORTED @@ -340,6 +346,7 @@ typedef struct GNode { * once the makefile has been parsed. PARSE_WARNING means it can. Passed * as the first argument to Parse_Error. */ +#define PARSE_INFO 3 #define PARSE_WARNING 2 #define PARSE_FATAL 1 @@ -383,6 +390,7 @@ extern Boolean beSilent; /* True if should print no commands */ extern Boolean noExecute; /* True if should execute nothing */ extern Boolean noRecursiveExecute; /* True if should execute nothing */ extern Boolean allPrecious; /* True if every target is precious */ +extern Boolean deleteOnError; /* True if failed targets should be deleted */ extern Boolean keepgoing; /* True if should continue on unaffected * portions of the graph when have an error * in one portion */ @@ -456,7 +464,7 @@ extern pid_t myPid; * There is one bit per module. It is up to the module what debug * information to print. */ -FILE *debug_file; /* Output written here - default stdout */ +extern FILE *debug_file; /* Output written here - default stdout */ extern int debug; #define DEBUG_ARCH 0x00001 #define DEBUG_COND 0x00002 @@ -497,9 +505,15 @@ char * Check_Cwd_Cmd(const char *); void Check_Cwd(const char **); void PrintOnError(GNode *, const char *); void Main_ExportMAKEFLAGS(Boolean); -Boolean Main_SetObjdir(const char *); +Boolean Main_SetObjdir(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2); int mkTempFile(const char *, char **); int str2Lst_Append(Lst, char *, const char *); +int cached_lstat(const char *, void *); +int cached_stat(const char *, void *); + +#define VARF_UNDEFERR 1 +#define VARF_WANTRES 2 +#define VARF_ASSIGN 4 #ifdef __GNUC__ #define UNCONST(ptr) ({ \ @@ -519,8 +533,21 @@ int str2Lst_Append(Lst, char *, const char *); #define MAX(a, b) ((a > b) ? a : b) #endif +/* At least GNU/Hurd systems lack hardcoded MAXPATHLEN/PATH_MAX */ +#ifdef HAVE_LIMITS_H +#include <limits.h> +#endif #ifndef MAXPATHLEN -#define MAXPATHLEN BMAKE_PATH_MAX +#define MAXPATHLEN BMAKE_PATH_MAX +#endif +#ifndef PATH_MAX +#define PATH_MAX MAXPATHLEN +#endif + +#if defined(SYSV) +#define KILLPG(pid, sig) kill(-(pid), (sig)) +#else +#define KILLPG(pid, sig) killpg((pid), (sig)) #endif #endif /* _MAKE_H_ */ diff --git a/devel/bmake/files/make_malloc.c b/devel/bmake/files/make_malloc.c index 7802ea30c2e..8aad2bbcbc1 100644 --- a/devel/bmake/files/make_malloc.c +++ b/devel/bmake/files/make_malloc.c @@ -1,4 +1,4 @@ -/* $NetBSD: make_malloc.c,v 1.1.1.3 2015/05/19 21:36:44 joerg Exp $ */ +/* $NetBSD: make_malloc.c,v 1.1.1.4 2020/05/24 05:35:52 nia Exp $ */ /*- * Copyright (c) 2009 The NetBSD Foundation, Inc. @@ -28,7 +28,7 @@ #ifdef MAKE_NATIVE #include <sys/cdefs.h> -__RCSID("$NetBSD: make_malloc.c,v 1.1.1.3 2015/05/19 21:36:44 joerg Exp $"); +__RCSID("$NetBSD: make_malloc.c,v 1.1.1.4 2020/05/24 05:35:52 nia Exp $"); #endif #include <stdio.h> @@ -39,13 +39,13 @@ __RCSID("$NetBSD: make_malloc.c,v 1.1.1.3 2015/05/19 21:36:44 joerg Exp $"); #include "make.h" #ifndef USE_EMALLOC -static void enomem(void) MAKE_ATTR_DEAD; +static MAKE_ATTR_DEAD void enomem(void); /* * enomem -- * die when out of memory. */ -static void +static MAKE_ATTR_DEAD void enomem(void) { (void)fprintf(stderr, "%s: %s.\n", progname, strerror(ENOMEM)); diff --git a/devel/bmake/files/meta.c b/devel/bmake/files/meta.c index 7a7816f4105..b1563208f4c 100644 --- a/devel/bmake/files/meta.c +++ b/devel/bmake/files/meta.c @@ -1,4 +1,4 @@ -/* $NetBSD: meta.c,v 1.1.1.2 2015/05/19 21:36:44 joerg Exp $ */ +/* $NetBSD: meta.c,v 1.1.1.3 2020/05/24 05:35:52 nia Exp $ */ /* * Implement 'meta' mode. @@ -6,7 +6,7 @@ * --sjg */ /* - * Copyright (c) 2009-2010, Juniper Networks, Inc. + * Copyright (c) 2009-2016, Juniper Networks, Inc. * Portions Copyright (c) 2009, John Birrell. * * Redistribution and use in source and binary forms, with or without @@ -36,9 +36,11 @@ # include "config.h" #endif #include <sys/stat.h> -#include <sys/ioctl.h> -#include <fcntl.h> +#ifdef HAVE_LIBGEN_H #include <libgen.h> +#elif !defined(HAVE_DIRNAME) +char * dirname(char *); +#endif #include <errno.h> #if !defined(HAVE_CONFIG_H) || defined(HAVE_ERR_H) #include <err.h> @@ -47,27 +49,36 @@ #include "make.h" #include "job.h" -#ifdef HAVE_FILEMON_H -# include <filemon.h> -#endif -#if !defined(USE_FILEMON) && defined(FILEMON_SET_FD) -# define USE_FILEMON +#ifdef USE_FILEMON +#include "filemon/filemon.h" #endif static BuildMon Mybm; /* for compat */ static Lst metaBailiwick; /* our scope of control */ +static char *metaBailiwickStr; /* string storage for the list */ static Lst metaIgnorePaths; /* paths we deliberately ignore */ +static char *metaIgnorePathsStr; /* string storage for the list */ #ifndef MAKE_META_IGNORE_PATHS #define MAKE_META_IGNORE_PATHS ".MAKE.META.IGNORE_PATHS" #endif +#ifndef MAKE_META_IGNORE_PATTERNS +#define MAKE_META_IGNORE_PATTERNS ".MAKE.META.IGNORE_PATTERNS" +#endif +#ifndef MAKE_META_IGNORE_FILTER +#define MAKE_META_IGNORE_FILTER ".MAKE.META.IGNORE_FILTER" +#endif Boolean useMeta = FALSE; static Boolean useFilemon = FALSE; static Boolean writeMeta = FALSE; +static Boolean metaMissing = FALSE; /* oodate if missing */ +static Boolean filemonMissing = FALSE; /* oodate if missing */ static Boolean metaEnv = FALSE; /* don't save env unless asked */ static Boolean metaVerbose = FALSE; static Boolean metaIgnoreCMDs = FALSE; /* ignore CMDs in .meta files */ +static Boolean metaIgnorePatterns = FALSE; /* do we need to do pattern matches */ +static Boolean metaIgnoreFilter = FALSE; /* do we have more complex filtering? */ static Boolean metaCurdirOk = FALSE; /* write .meta in .CURDIR Ok? */ static Boolean metaSilent = FALSE; /* if we have a .meta be SILENT */ @@ -106,30 +117,24 @@ extern char **environ; * the benefits are more limited. */ #ifdef USE_FILEMON -# ifndef _PATH_FILEMON -# define _PATH_FILEMON "/dev/filemon" -# endif /* * Open the filemon device. */ static void -filemon_open(BuildMon *pbm) +meta_open_filemon(BuildMon *pbm) { - int retry; - - pbm->mon_fd = pbm->filemon_fd = -1; - if (!useFilemon) - return; + int dupfd; - for (retry = 5; retry >= 0; retry--) { - if ((pbm->filemon_fd = open(_PATH_FILEMON, O_RDWR)) >= 0) - break; - } + pbm->mon_fd = -1; + pbm->filemon = NULL; + if (!useFilemon || !pbm->mfp) + return; - if (pbm->filemon_fd < 0) { + pbm->filemon = filemon_open(); + if (pbm->filemon == NULL) { useFilemon = FALSE; - warn("Could not open %s", _PATH_FILEMON); + warn("Could not open filemon %s", filemon_path()); return; } @@ -140,40 +145,48 @@ filemon_open(BuildMon *pbm) * We only care about the descriptor. */ pbm->mon_fd = mkTempFile("filemon.XXXXXX", NULL); - if (ioctl(pbm->filemon_fd, FILEMON_SET_FD, &pbm->mon_fd) < 0) { + if ((dupfd = dup(pbm->mon_fd)) == -1) { + err(1, "Could not dup filemon output!"); + } + (void)fcntl(dupfd, F_SETFD, FD_CLOEXEC); + if (filemon_setfd(pbm->filemon, dupfd) == -1) { err(1, "Could not set filemon file descriptor!"); } /* we don't need these once we exec */ - (void)fcntl(pbm->mon_fd, F_SETFD, 1); - (void)fcntl(pbm->filemon_fd, F_SETFD, 1); + (void)fcntl(pbm->mon_fd, F_SETFD, FD_CLOEXEC); } /* * Read the build monitor output file and write records to the target's * metadata file. */ -static void +static int filemon_read(FILE *mfp, int fd) { char buf[BUFSIZ]; int n; + int error; /* Check if we're not writing to a meta data file.*/ if (mfp == NULL) { if (fd >= 0) close(fd); /* not interested */ - return; + return 0; } /* rewind */ (void)lseek(fd, (off_t)0, SEEK_SET); + error = 0; fprintf(mfp, "\n-- filemon acquired metadata --\n"); while ((n = read(fd, buf, sizeof(buf))) > 0) { - fwrite(buf, 1, n, mfp); + if ((int)fwrite(buf, 1, n, mfp) < n) + error = EIO; } fflush(mfp); - close(fd); + if (close(fd) < 0) + error = errno; + return error; } #endif @@ -221,26 +234,17 @@ eat_dots(char *buf, size_t bufsz, int dots) } static char * -meta_name(struct GNode *gn, char *mname, size_t mnamelen, +meta_name(char *mname, size_t mnamelen, const char *dname, - const char *tname) + const char *tname, + const char *cwd) { char buf[MAXPATHLEN]; - char cwd[MAXPATHLEN]; char *rp; char *cp; char *tp; - char *p[4]; /* >= number of possible uses */ - int i; - - i = 0; - if (!dname) - dname = Var_Value(".OBJDIR", gn, &p[i++]); - if (!tname) - tname = Var_Value(TARGET, gn, &p[i++]); - - if (realpath(dname, cwd)) - dname = cwd; + char *dtp; + size_t ldname; /* * Weed out relative paths from the target file name. @@ -250,7 +254,7 @@ meta_name(struct GNode *gn, char *mname, size_t mnamelen, * basename as given to us. */ if ((cp = strrchr(tname, '/'))) { - if (realpath(tname, buf)) { + if (cached_realpath(tname, buf)) { if ((rp = strrchr(buf, '/'))) { rp++; cp++; @@ -277,10 +281,15 @@ meta_name(struct GNode *gn, char *mname, size_t mnamelen, } /* on some systems dirname may modify its arg */ tp = bmake_strdup(tname); - if (strcmp(dname, dirname(tp)) == 0) + dtp = dirname(tp); + if (strcmp(dname, dtp) == 0) snprintf(mname, mnamelen, "%s.meta", tname); else { - snprintf(mname, mnamelen, "%s/%s.meta", dname, tname); + ldname = strlen(dname); + if (strncmp(dname, dtp, ldname) == 0 && dtp[ldname] == '/') + snprintf(mname, mnamelen, "%s/%s.meta", dname, &tname[ldname+1]); + else + snprintf(mname, mnamelen, "%s/%s.meta", dname, tname); /* * Replace path separators in the file name after the @@ -295,10 +304,6 @@ meta_name(struct GNode *gn, char *mname, size_t mnamelen, } } free(tp); - for (i--; i >= 0; i--) { - if (p[i]) - free(p[i]); - } return (mname); } @@ -324,7 +329,7 @@ is_submake(void *cmdp, void *gnp) } cp = strchr(cmd, '$'); if ((cp)) { - mp = Var_Subst(NULL, cmd, gn, FALSE); + mp = Var_Subst(NULL, cmd, gn, VARF_WANTRES); cmd = mp; } cp2 = strstr(cmd, p_make); @@ -349,8 +354,7 @@ is_submake(void *cmdp, void *gnp) } } } - if (mp) - free(mp); + free(mp); return (rc); } @@ -367,11 +371,10 @@ printCMD(void *cmdp, void *mfpp) char *cp = NULL; if (strchr(cmd, '$')) { - cmd = cp = Var_Subst(NULL, cmd, mfp->gn, FALSE); + cmd = cp = Var_Subst(NULL, cmd, mfp->gn, VARF_WANTRES); } fprintf(mfp->fp, "CMD %s\n", cmd); - if (cp) - free(cp); + free(cp); return 0; } @@ -380,29 +383,26 @@ printCMD(void *cmdp, void *mfpp) */ #define SKIP_META_TYPE(_type) do { \ if ((gn->type & __CONCAT(OP_, _type))) { \ - if (DEBUG(META)) { \ + if (verbose) { \ fprintf(debug_file, "Skipping meta for %s: .%s\n", \ gn->name, __STRING(_type)); \ } \ - return (NULL); \ + return FALSE; \ } \ } while (0) -static FILE * -meta_create(BuildMon *pbm, GNode *gn) + +/* + * Do we need/want a .meta file ? + */ +static Boolean +meta_needed(GNode *gn, const char *dname, + char *objdir, int verbose) { - meta_file_t mf; - char buf[MAXPATHLEN]; - char objdir[MAXPATHLEN]; - char **ptr; - const char *dname; - const char *tname; - char *fname; - const char *cp; - char *p[4]; /* >= possible uses */ - int i; struct stat fs; + if (verbose) + verbose = DEBUG(META); /* This may be a phony node which we don't want meta data for... */ /* Skip .meta for .BEGIN, .END, .ERROR etc as well. */ @@ -415,54 +415,76 @@ meta_create(BuildMon *pbm, GNode *gn) SKIP_META_TYPE(MAKE); } - mf.fp = NULL; - - i = 0; - - dname = Var_Value(".OBJDIR", gn, &p[i++]); - tname = Var_Value(TARGET, gn, &p[i++]); - - /* The object directory may not exist. Check it.. */ - if (stat(dname, &fs) != 0) { - if (DEBUG(META)) - fprintf(debug_file, "Skipping meta for %s: no .OBJDIR\n", - gn->name); - goto out; - } /* Check if there are no commands to execute. */ if (Lst_IsEmpty(gn->commands)) { - if (DEBUG(META)) + if (verbose) fprintf(debug_file, "Skipping meta for %s: no commands\n", gn->name); - goto out; + return FALSE; + } + if ((gn->type & (OP_META|OP_SUBMAKE)) == OP_SUBMAKE) { + /* OP_SUBMAKE is a bit too aggressive */ + if (Lst_ForEach(gn->commands, is_submake, gn)) { + if (DEBUG(META)) + fprintf(debug_file, "Skipping meta for %s: .SUBMAKE\n", + gn->name); + return FALSE; + } + } + + /* The object directory may not exist. Check it.. */ + if (cached_stat(dname, &fs) != 0) { + if (verbose) + fprintf(debug_file, "Skipping meta for %s: no .OBJDIR\n", + gn->name); + return FALSE; } /* make sure these are canonical */ - if (realpath(dname, objdir)) + if (cached_realpath(dname, objdir)) dname = objdir; /* If we aren't in the object directory, don't create a meta file. */ if (!metaCurdirOk && strcmp(curdir, dname) == 0) { - if (DEBUG(META)) + if (verbose) fprintf(debug_file, "Skipping meta for %s: .OBJDIR == .CURDIR\n", gn->name); - goto out; - } - if (!(gn->type & OP_META)) { - /* We do not generate .meta files for sub-makes */ - if (Lst_ForEach(gn->commands, is_submake, gn)) { - if (DEBUG(META)) - fprintf(debug_file, "Skipping meta for %s: .MAKE\n", - gn->name); - goto out; - } + return FALSE; } + return TRUE; +} + + +static FILE * +meta_create(BuildMon *pbm, GNode *gn) +{ + meta_file_t mf; + char buf[MAXPATHLEN]; + char objdir[MAXPATHLEN]; + char **ptr; + const char *dname; + const char *tname; + char *fname; + const char *cp; + char *p[5]; /* >= possible uses */ + int i; + + mf.fp = NULL; + i = 0; + + dname = Var_Value(".OBJDIR", gn, &p[i++]); + tname = Var_Value(TARGET, gn, &p[i++]); + + /* if this succeeds objdir is realpath of dname */ + if (!meta_needed(gn, dname, objdir, TRUE)) + goto out; + dname = objdir; if (metaVerbose) { char *mp; /* Describe the target we are building */ - mp = Var_Subst(NULL, "${" MAKE_META_PREFIX "}", gn, 0); + mp = Var_Subst(NULL, "${" MAKE_META_PREFIX "}", gn, VARF_WANTRES); if (*mp) fprintf(stdout, "%s\n", mp); free(mp); @@ -476,15 +498,12 @@ meta_create(BuildMon *pbm, GNode *gn) fflush(stdout); - if (strcmp(cp, makeDependfile) == 0) - goto out; - if (!writeMeta) /* Don't create meta data. */ goto out; - fname = meta_name(gn, pbm->meta_fname, sizeof(pbm->meta_fname), - dname, tname); + fname = meta_name(pbm->meta_fname, sizeof(pbm->meta_fname), + dname, tname, objdir); #ifdef DEBUG_META_MODE if (DEBUG(META)) @@ -502,7 +521,10 @@ meta_create(BuildMon *pbm, GNode *gn) fprintf(mf.fp, "CWD %s\n", getcwd(buf, sizeof(buf))); fprintf(mf.fp, "TARGET %s\n", tname); - + cp = Var_Value(".OODATE", gn, &p[i++]); + if (cp && *cp) { + fprintf(mf.fp, "OODATE %s\n", cp); + } if (metaEnv) { for (ptr = environ; *ptr != NULL; ptr++) fprintf(mf.fp, "ENV %s\n", *ptr); @@ -520,8 +542,7 @@ meta_create(BuildMon *pbm, GNode *gn) } out: for (i--; i >= 0; i--) { - if (p[i]) - free(p[i]); + free(p[i]); } return (mf.fp); @@ -549,11 +570,15 @@ meta_init(void) { #ifdef USE_FILEMON /* this allows makefiles to test if we have filemon support */ - Var_Set(".MAKE.PATH_FILEMON", _PATH_FILEMON, VAR_GLOBAL, 0); + Var_Set(".MAKE.PATH_FILEMON", filemon_path(), VAR_GLOBAL, 0); #endif } +#define get_mode_bf(bf, token) \ + if ((cp = strstr(make_mode, token))) \ + bf = boolValue(&cp[sizeof(token) - 1]) + /* * Initialization we need after reading makefiles. */ @@ -576,17 +601,13 @@ meta_mode_init(const char *make_mode) writeMeta = FALSE; if (strstr(make_mode, "nofilemon")) useFilemon = FALSE; - if ((cp = strstr(make_mode, "curdirok="))) { - metaCurdirOk = boolValue(&cp[9]); - } - if ((cp = strstr(make_mode, "silent="))) { - metaSilent = boolValue(&cp[7]); - } if (strstr(make_mode, "ignore-cmd")) metaIgnoreCMDs = TRUE; - /* for backwards compatability */ - Var_Set(".MAKE.META_CREATED", "${.MAKE.META.CREATED}", VAR_GLOBAL, 0); - Var_Set(".MAKE.META_FILES", "${.MAKE.META.FILES}", VAR_GLOBAL, 0); + if (useFilemon) + get_mode_bf(filemonMissing, "missing-filemon="); + get_mode_bf(metaCurdirOk, "curdirok="); + get_mode_bf(metaMissing, "missing-meta="); + get_mode_bf(metaSilent, "silent="); } if (metaVerbose && !Var_Exists(MAKE_META_PREFIX, VAR_GLOBAL)) { /* @@ -605,9 +626,10 @@ meta_mode_init(const char *make_mode) * We consider ourselves master of all within ${.MAKE.META.BAILIWICK} */ metaBailiwick = Lst_Init(FALSE); - cp = Var_Subst(NULL, "${.MAKE.META.BAILIWICK:O:u:tA}", VAR_GLOBAL, 0); - if (cp) { - str2Lst_Append(metaBailiwick, cp, NULL); + metaBailiwickStr = Var_Subst(NULL, "${.MAKE.META.BAILIWICK:O:u:tA}", + VAR_GLOBAL, VARF_WANTRES); + if (metaBailiwickStr) { + str2Lst_Append(metaBailiwick, metaBailiwickStr, NULL); } /* * We ignore any paths that start with ${.MAKE.META.IGNORE_PATHS} @@ -615,10 +637,25 @@ meta_mode_init(const char *make_mode) metaIgnorePaths = Lst_Init(FALSE); Var_Append(MAKE_META_IGNORE_PATHS, "/dev /etc /proc /tmp /var/run /var/tmp ${TMPDIR}", VAR_GLOBAL); - cp = Var_Subst(NULL, - "${" MAKE_META_IGNORE_PATHS ":O:u:tA}", VAR_GLOBAL, 0); - if (cp) { - str2Lst_Append(metaIgnorePaths, cp, NULL); + metaIgnorePathsStr = Var_Subst(NULL, + "${" MAKE_META_IGNORE_PATHS ":O:u:tA}", VAR_GLOBAL, + VARF_WANTRES); + if (metaIgnorePathsStr) { + str2Lst_Append(metaIgnorePaths, metaIgnorePathsStr, NULL); + } + + /* + * We ignore any paths that match ${.MAKE.META.IGNORE_PATTERNS} + */ + cp = NULL; + if (Var_Value(MAKE_META_IGNORE_PATTERNS, VAR_GLOBAL, &cp)) { + metaIgnorePatterns = TRUE; + free(cp); + } + cp = NULL; + if (Var_Value(MAKE_META_IGNORE_FILTER, VAR_GLOBAL, &cp)) { + metaIgnoreFilter = TRUE; + free(cp); } } @@ -643,9 +680,10 @@ meta_job_start(Job *job, GNode *gn) #endif #ifdef USE_FILEMON if (pbm->mfp != NULL && useFilemon) { - filemon_open(pbm); + meta_open_filemon(pbm); } else { - pbm->mon_fd = pbm->filemon_fd = -1; + pbm->mon_fd = -1; + pbm->filemon = NULL; } #endif } @@ -667,11 +705,11 @@ meta_job_child(Job *job) } if (pbm->mfp != NULL) { close(fileno(pbm->mfp)); - if (useFilemon) { + if (useFilemon && pbm->filemon) { pid_t pid; pid = getpid(); - if (ioctl(pbm->filemon_fd, FILEMON_SET_PID, &pid) < 0) { + if (filemon_setpid_child(pbm->filemon, pid) == -1) { err(1, "Could not set filemon pid!"); } } @@ -680,6 +718,59 @@ meta_job_child(Job *job) } void +meta_job_parent(Job *job, pid_t pid) +{ +#if defined(USE_FILEMON) && !defined(USE_FILEMON_DEV) + BuildMon *pbm; + + if (job != NULL) { + pbm = &job->bm; + } else { + pbm = &Mybm; + } + if (useFilemon && pbm->filemon) { + filemon_setpid_parent(pbm->filemon, pid); + } +#endif +} + +int +meta_job_fd(Job *job) +{ +#if defined(USE_FILEMON) && !defined(USE_FILEMON_DEV) + BuildMon *pbm; + + if (job != NULL) { + pbm = &job->bm; + } else { + pbm = &Mybm; + } + if (useFilemon && pbm->filemon) { + return filemon_readfd(pbm->filemon); + } +#endif + return -1; +} + +int +meta_job_event(Job *job) +{ +#if defined(USE_FILEMON) && !defined(USE_FILEMON_DEV) + BuildMon *pbm; + + if (job != NULL) { + pbm = &job->bm; + } else { + pbm = &Mybm; + } + if (useFilemon && pbm->filemon) { + return filemon_process(pbm->filemon); + } +#endif + return 0; +} + +void meta_job_error(Job *job, GNode *gn, int flags, int status) { char cwd[MAXPATHLEN]; @@ -687,13 +778,13 @@ meta_job_error(Job *job, GNode *gn, int flags, int status) if (job != NULL) { pbm = &job->bm; - } else { if (!gn) gn = job->node; + } else { pbm = &Mybm; } if (pbm->mfp != NULL) { - fprintf(pbm->mfp, "*** Error code %d%s\n", + fprintf(pbm->mfp, "\n*** Error code %d%s\n", status, (flags & JOB_IGNERR) ? "(ignored)" : ""); @@ -703,7 +794,7 @@ meta_job_error(Job *job, GNode *gn, int flags, int status) } getcwd(cwd, sizeof(cwd)); Var_Set(".ERROR_CWD", cwd, VAR_GLOBAL, 0); - if (pbm && pbm->meta_fname[0]) { + if (pbm->meta_fname[0]) { Var_Set(".ERROR_META_FILE", pbm->meta_fname, VAR_GLOBAL, 0); } meta_job_finish(job); @@ -727,7 +818,8 @@ meta_job_output(Job *job, char *cp, const char *nl) if (!meta_prefix) { char *cp2; - meta_prefix = Var_Subst(NULL, "${" MAKE_META_PREFIX "}", VAR_GLOBAL, 0); + meta_prefix = Var_Subst(NULL, "${" MAKE_META_PREFIX "}", + VAR_GLOBAL, VARF_WANTRES); if ((cp2 = strchr(meta_prefix, '$'))) meta_prefix_len = cp2 - meta_prefix; else @@ -743,27 +835,41 @@ meta_job_output(Job *job, char *cp, const char *nl) } } -void +int meta_cmd_finish(void *pbmp) { -#ifdef USE_FILEMON + int error = 0; BuildMon *pbm = pbmp; +#ifdef USE_FILEMON + int x; +#endif if (!pbm) pbm = &Mybm; - if (pbm->filemon_fd >= 0) { - close(pbm->filemon_fd); - filemon_read(pbm->mfp, pbm->mon_fd); - pbm->filemon_fd = pbm->mon_fd = -1; - } +#ifdef USE_FILEMON + if (pbm->filemon) { + while (filemon_process(pbm->filemon) > 0) + continue; + if (filemon_close(pbm->filemon) == -1) + error = errno; + x = filemon_read(pbm->mfp, pbm->mon_fd); + if (error == 0 && x != 0) + error = x; + pbm->mon_fd = -1; + pbm->filemon = NULL; + } else #endif + fprintf(pbm->mfp, "\n"); /* ensure end with newline */ + return error; } -void +int meta_job_finish(Job *job) { BuildMon *pbm; + int error = 0; + int x; if (job != NULL) { pbm = &job->bm; @@ -771,11 +877,23 @@ meta_job_finish(Job *job) pbm = &Mybm; } if (pbm->mfp != NULL) { - meta_cmd_finish(pbm); - fclose(pbm->mfp); + error = meta_cmd_finish(pbm); + x = fclose(pbm->mfp); + if (error == 0 && x != 0) + error = errno; pbm->mfp = NULL; pbm->meta_fname[0] = '\0'; } + return error; +} + +void +meta_finish(void) +{ + Lst_Destroy(metaBailiwick, NULL); + free(metaBailiwickStr); + Lst_Destroy(metaIgnorePaths, NULL); + free(metaIgnorePathsStr); } /* @@ -806,6 +924,8 @@ fgetLine(char **bufp, size_t *szp, int o, FILE *fp) newsz = ROUNDUP((fs.st_size / 2), BUFSIZ); if (newsz <= bufsz) newsz = ROUNDUP(fs.st_size, BUFSIZ); + if (newsz <= bufsz) + return x; /* truncated */ if (DEBUG(META)) fprintf(debug_file, "growing buffer %u -> %u\n", (unsigned)bufsz, (unsigned)newsz); @@ -823,6 +943,7 @@ fgetLine(char **bufp, size_t *szp, int o, FILE *fp) return 0; } +/* Lst_ForEach wants 1 to stop search */ static int prefix_match(void *p, void *q) { @@ -833,6 +954,32 @@ prefix_match(void *p, void *q) return (0 == strncmp(path, prefix, n)); } +/* + * looking for exact or prefix/ match to + * Lst_Find wants 0 to stop search + */ +static int +path_match(const void *p, const void *q) +{ + const char *prefix = q; + const char *path = p; + size_t n = strlen(prefix); + int rc; + + if ((rc = strncmp(path, prefix, n)) == 0) { + switch (path[n]) { + case '\0': + case '/': + break; + default: + rc = 1; + break; + } + } + return rc; +} + +/* Lst_Find wants 0 to stop search */ static int string_match(const void *p, const void *q) { @@ -843,6 +990,67 @@ string_match(const void *p, const void *q) } +static int +meta_ignore(GNode *gn, const char *p) +{ + char fname[MAXPATHLEN]; + + if (p == NULL) + return TRUE; + + if (*p == '/') { + cached_realpath(p, fname); /* clean it up */ + if (Lst_ForEach(metaIgnorePaths, prefix_match, fname)) { +#ifdef DEBUG_META_MODE + if (DEBUG(META)) + fprintf(debug_file, "meta_oodate: ignoring path: %s\n", + p); +#endif + return TRUE; + } + } + + if (metaIgnorePatterns) { + char *pm; + + Var_Set(".p.", p, gn, 0); + pm = Var_Subst(NULL, + "${" MAKE_META_IGNORE_PATTERNS ":@m@${.p.:M$m}@}", + gn, VARF_WANTRES); + if (*pm) { +#ifdef DEBUG_META_MODE + if (DEBUG(META)) + fprintf(debug_file, "meta_oodate: ignoring pattern: %s\n", + p); +#endif + free(pm); + return TRUE; + } + free(pm); + } + + if (metaIgnoreFilter) { + char *fm; + + /* skip if filter result is empty */ + snprintf(fname, sizeof(fname), + "${%s:L:${%s:ts:}}", + p, MAKE_META_IGNORE_FILTER); + fm = Var_Subst(NULL, fname, gn, VARF_WANTRES); + if (*fm == '\0') { +#ifdef DEBUG_META_MODE + if (DEBUG(META)) + fprintf(debug_file, "meta_oodate: ignoring filtered: %s\n", + p); +#endif + free(fm); + return TRUE; + } + free(fm); + } + return FALSE; +} + /* * When running with 'meta' functionality, a target can be out-of-date * if any of the references in its meta data file is more recent. @@ -882,6 +1090,8 @@ meta_oodate(GNode *gn, Boolean oodate) char fname1[MAXPATHLEN]; char fname2[MAXPATHLEN]; char fname3[MAXPATHLEN]; + const char *dname; + const char *tname; char *p; char *cp; char *link_src; @@ -891,10 +1101,23 @@ meta_oodate(GNode *gn, Boolean oodate) FILE *fp; Boolean needOODATE = FALSE; Lst missingFiles; - + char *pa[4]; /* >= possible uses */ + int i; + int have_filemon = FALSE; + if (oodate) return oodate; /* we're done */ + i = 0; + + dname = Var_Value(".OBJDIR", gn, &pa[i++]); + tname = Var_Value(TARGET, gn, &pa[i++]); + + /* if this succeeds fname3 is realpath of dname */ + if (!meta_needed(gn, dname, fname3, FALSE)) + goto oodate_out; + dname = fname3; + missingFiles = Lst_Init(FALSE); /* @@ -905,7 +1128,7 @@ meta_oodate(GNode *gn, Boolean oodate) */ Make_DoAllVar(gn); - meta_name(gn, fname, sizeof(fname), NULL, NULL); + meta_name(fname, sizeof(fname), dname, tname, dname); #ifdef DEBUG_META_MODE if (DEBUG(META)) @@ -918,7 +1141,6 @@ meta_oodate(GNode *gn, Boolean oodate) int lineno = 0; int lastpid = 0; int pid; - int f = 0; int x; LstNode ln; struct stat fs; @@ -957,13 +1179,13 @@ meta_oodate(GNode *gn, Boolean oodate) link_src = NULL; move_target = NULL; /* Find the start of the build monitor section. */ - if (!f) { + if (!have_filemon) { if (strncmp(buf, "-- filemon", 10) == 0) { - f = 1; + have_filemon = TRUE; continue; } if (strncmp(buf, "# buildmon", 10) == 0) { - f = 1; + have_filemon = TRUE; continue; } } @@ -975,7 +1197,7 @@ meta_oodate(GNode *gn, Boolean oodate) fprintf(debug_file, "%s: %d: %s\n", fname, lineno, buf); #endif strsep(&p, " "); - if (f) { + if (have_filemon) { /* * We are in the 'filemon' output section. * Each record from filemon follows the general form: @@ -1028,14 +1250,12 @@ meta_oodate(GNode *gn, Boolean oodate) ldir = Var_Value(ldir_vname, VAR_GLOBAL, &tp); if (ldir) { strlcpy(latestdir, ldir, sizeof(latestdir)); - if (tp) - free(tp); + free(tp); } ldir = Var_Value(lcwd_vname, VAR_GLOBAL, &tp); if (ldir) { strlcpy(lcwd, ldir, sizeof(lcwd)); - if (tp) - free(tp); + free(tp); } } /* Skip past the pid. */ @@ -1112,12 +1332,19 @@ meta_oodate(GNode *gn, Boolean oodate) /* FALLTHROUGH */ case 'D': /* unlink */ if (*p == '/' && !Lst_IsEmpty(missingFiles)) { - /* remove p from the missingFiles list if present */ - if ((ln = Lst_Find(missingFiles, p, string_match)) != NULL) { - char *tp = Lst_Datum(ln); - Lst_Remove(missingFiles, ln); - free(tp); - ln = NULL; /* we're done with it */ + /* remove any missingFiles entries that match p */ + if ((ln = Lst_Find(missingFiles, p, + path_match)) != NULL) { + LstNode nln; + char *tp; + + do { + nln = Lst_FindFrom(missingFiles, Lst_Succ(ln), + p, path_match); + tp = Lst_Datum(ln); + Lst_Remove(missingFiles, ln); + free(tp); + } while ((ln = nln) != NULL); } } if (buf[0] == 'M') { @@ -1180,8 +1407,12 @@ meta_oodate(GNode *gn, Boolean oodate) if ((strstr("tmp", p))) break; - if (stat(p, &fs) < 0) { - Lst_AtEnd(missingFiles, bmake_strdup(p)); + if ((link_src != NULL && cached_lstat(p, &fs) < 0) || + (link_src == NULL && cached_stat(p, &fs) < 0)) { + if (!meta_ignore(gn, p)) { + if (Lst_Find(missingFiles, p, string_match) == NULL) + Lst_AtEnd(missingFiles, bmake_strdup(p)); + } } break; check_link_src: @@ -1199,26 +1430,9 @@ meta_oodate(GNode *gn, Boolean oodate) * be part of the dependencies because * they are _expected_ to change. */ - if (*p == '/' && - Lst_ForEach(metaIgnorePaths, prefix_match, p)) { -#ifdef DEBUG_META_MODE - if (DEBUG(META)) - fprintf(debug_file, "meta_oodate: ignoring: %s\n", - p); -#endif + if (meta_ignore(gn, p)) break; - } - - if ((cp = strrchr(p, '/'))) { - cp++; - /* - * We don't normally expect to see this, - * but we do expect it to change. - */ - if (strcmp(cp, makeDependfile) == 0) - break; - } - + /* * The rest of the record is the file name. * Check if it's not an absolute path. @@ -1257,7 +1471,7 @@ meta_oodate(GNode *gn, Boolean oodate) if (DEBUG(META)) fprintf(debug_file, "%s: %d: looking for: %s\n", fname, lineno, *sdp); #endif - if (stat(*sdp, &fs) == 0) { + if (cached_stat(*sdp, &fs) == 0) { found = 1; p = *sdp; } @@ -1274,7 +1488,7 @@ meta_oodate(GNode *gn, Boolean oodate) oodate = TRUE; } else if (S_ISDIR(fs.st_mode)) { /* Update the latest directory. */ - realpath(p, latestdir); + cached_realpath(p, latestdir); } } else if (errno == ENOENT && *p == '/' && strncmp(p, cwd, cwdlen) != 0) { @@ -1282,9 +1496,8 @@ meta_oodate(GNode *gn, Boolean oodate) * A referenced file outside of CWD is missing. * We cannot catch every eventuality here... */ - if (DEBUG(META)) - fprintf(debug_file, "%s: %d: file '%s' may have moved?...\n", fname, lineno, p); - oodate = TRUE; + if (Lst_Find(missingFiles, p, string_match) == NULL) + Lst_AtEnd(missingFiles, bmake_strdup(p)); } } if (buf[0] == 'E') { @@ -1322,7 +1535,7 @@ meta_oodate(GNode *gn, Boolean oodate) if (DEBUG(META)) fprintf(debug_file, "%s: %d: cannot compare command using .OODATE\n", fname, lineno); } - cmd = Var_Subst(NULL, cmd, gn, TRUE); + cmd = Var_Subst(NULL, cmd, gn, VARF_WANTRES|VARF_UNDEFERR); if ((cp = strchr(cmd, '\n'))) { int n; @@ -1349,7 +1562,8 @@ meta_oodate(GNode *gn, Boolean oodate) if (buf[x - 1] == '\n') buf[x - 1] = '\0'; } - if (!hasOODATE && + if (p && + !hasOODATE && !(gn->type & OP_NOMETA_CMP) && strcmp(p, cmd) != 0) { if (DEBUG(META)) @@ -1370,6 +1584,7 @@ meta_oodate(GNode *gn, Boolean oodate) fprintf(debug_file, "%s: %d: there are extra build commands now that weren't in the meta data file\n", fname, lineno); oodate = TRUE; } + CHECK_VALID_META(p); if (strcmp(p, cwd) != 0) { if (DEBUG(META)) fprintf(debug_file, "%s: %d: the current working directory has changed from '%s' to '%s'\n", fname, lineno, p, curdir); @@ -1384,15 +1599,33 @@ meta_oodate(GNode *gn, Boolean oodate) fprintf(debug_file, "%s: missing files: %s...\n", fname, (char *)Lst_Datum(Lst_First(missingFiles))); oodate = TRUE; - Lst_Destroy(missingFiles, (FreeProc *)free); } - } else { - if ((gn->type & OP_META)) { + if (!oodate && !have_filemon && filemonMissing) { if (DEBUG(META)) - fprintf(debug_file, "%s: required but missing\n", fname); + fprintf(debug_file, "%s: missing filemon data\n", fname); oodate = TRUE; } + } else { + if (writeMeta && metaMissing) { + cp = NULL; + + /* if target is in .CURDIR we do not need a meta file */ + if (gn->path && (cp = strrchr(gn->path, '/')) && cp > gn->path) { + if (strncmp(curdir, gn->path, (cp - gn->path)) != 0) { + cp = NULL; /* not in .CURDIR */ + } + } + if (!cp) { + if (DEBUG(META)) + fprintf(debug_file, "%s: required but missing\n", fname); + oodate = TRUE; + needOODATE = TRUE; /* assume the worst */ + } + } } + + Lst_Destroy(missingFiles, (FreeProc *)free); + if (oodate && needOODATE) { /* * Target uses .OODATE which is empty; or we wouldn't be here. @@ -1401,8 +1634,12 @@ meta_oodate(GNode *gn, Boolean oodate) */ Var_Delete(OODATE, gn); Var_Set(OODATE, Var_Value(ALLSRC, gn, &cp), gn, 0); - if (cp) - free(cp); + free(cp); + } + + oodate_out: + for (i--; i >= 0; i--) { + free(pa[i]); } return oodate; } @@ -1421,16 +1658,17 @@ meta_compat_start(void) BuildMon *pbm = &Mybm; if (pbm->mfp != NULL && useFilemon) { - filemon_open(pbm); + meta_open_filemon(pbm); } else { - pbm->mon_fd = pbm->filemon_fd = -1; + pbm->mon_fd = -1; + pbm->filemon = NULL; } #endif if (pipe(childPipe) < 0) Punt("Cannot create pipe: %s", strerror(errno)); /* Set close-on-exec flag for both */ - (void)fcntl(childPipe[0], F_SETFD, 1); - (void)fcntl(childPipe[1], F_SETFD, 1); + (void)fcntl(childPipe[0], F_SETFD, FD_CLOEXEC); + (void)fcntl(childPipe[1], F_SETFD, FD_CLOEXEC); } void @@ -1445,18 +1683,61 @@ meta_compat_child(void) } void -meta_compat_parent(void) +meta_compat_parent(pid_t child) { - FILE *fp; - char buf[BUFSIZ]; - + int outfd, metafd, maxfd, nfds; + char buf[BUFSIZ+1]; + fd_set readfds; + + meta_job_parent(NULL, child); close(childPipe[1]); /* child side */ - fp = fdopen(childPipe[0], "r"); - while (fgets(buf, sizeof(buf), fp)) { - meta_job_output(NULL, buf, ""); - printf("%s", buf); + outfd = childPipe[0]; +#ifdef USE_FILEMON + metafd = Mybm.filemon ? filemon_readfd(Mybm.filemon) : -1; +#else + metafd = -1; +#endif + maxfd = -1; + if (outfd > maxfd) + maxfd = outfd; + if (metafd > maxfd) + maxfd = metafd; + + while (outfd != -1 || metafd != -1) { + FD_ZERO(&readfds); + if (outfd != -1) { + FD_SET(outfd, &readfds); + } + if (metafd != -1) { + FD_SET(metafd, &readfds); + } + nfds = select(maxfd + 1, &readfds, NULL, NULL, NULL); + if (nfds == -1) { + if (errno == EINTR) + continue; + err(1, "select"); + } + + if (outfd != -1 && FD_ISSET(outfd, &readfds)) do { + /* XXX this is not line-buffered */ + ssize_t nread = read(outfd, buf, sizeof(buf) - 1); + if (nread == -1) + err(1, "read"); + if (nread == 0) { + close(outfd); + outfd = -1; + break; + } + fwrite(buf, 1, (size_t)nread, stdout); + fflush(stdout); + buf[nread] = '\0'; + meta_job_output(NULL, buf, ""); + } while (0); + if (metafd != -1 && FD_ISSET(metafd, &readfds)) { + if (meta_job_event(NULL) <= 0) + metafd = -1; + } } - fclose(fp); } #endif /* USE_META */ diff --git a/devel/bmake/files/meta.h b/devel/bmake/files/meta.h index 1d522efb1a5..1fb0d778bde 100644 --- a/devel/bmake/files/meta.h +++ b/devel/bmake/files/meta.h @@ -1,4 +1,4 @@ -/* $NetBSD: meta.h,v 1.1.1.2 2015/05/19 21:36:44 joerg Exp $ */ +/* $NetBSD: meta.h,v 1.1.1.3 2020/05/24 05:35:52 nia Exp $ */ /* * Things needed for 'meta' mode. @@ -33,7 +33,7 @@ typedef struct BuildMon { char meta_fname[MAXPATHLEN]; - int filemon_fd; + struct filemon *filemon; int mon_fd; FILE *mfp; } BuildMon; @@ -42,14 +42,18 @@ extern Boolean useMeta; struct Job; /* not defined yet */ void meta_init(void); +void meta_finish(void); void meta_mode_init(const char *); void meta_job_start(struct Job *, GNode *); void meta_job_child(struct Job *); +void meta_job_parent(struct Job *, pid_t); +int meta_job_fd(struct Job *); +int meta_job_event(struct Job *); void meta_job_error(struct Job *, GNode *, int, int); void meta_job_output(struct Job *, char *, const char *); -void meta_cmd_finish(void *); -void meta_job_finish(struct Job *); +int meta_cmd_finish(void *); +int meta_job_finish(struct Job *); Boolean meta_oodate(GNode *, Boolean); void meta_compat_start(void); void meta_compat_child(void); -void meta_compat_parent(void); +void meta_compat_parent(pid_t); diff --git a/devel/bmake/files/metachar.c b/devel/bmake/files/metachar.c new file mode 100644 index 00000000000..6ce1eb31f8a --- /dev/null +++ b/devel/bmake/files/metachar.c @@ -0,0 +1,88 @@ +/* $NetBSD: metachar.c,v 1.1.1.1 2020/05/24 05:35:52 nia Exp $ */ + +/*- + * Copyright (c) 2015 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#if HAVE_NBTOOL_CONFIG_H +#include "nbtool_config.h" +#endif + +#if defined(MAKE_NATIVE) || defined(HAVE_NBTOOL_CONFIG_H) +#include <sys/cdefs.h> +#endif + +#if defined(__RCSID) && !defined(lint) +__RCSID("$NetBSD: metachar.c,v 1.1.1.1 2020/05/24 05:35:52 nia Exp $"); +#endif + +#include "metachar.h" +/* + * The following array is used to make a fast determination of which + * characters are interpreted specially by the shell. If a command + * contains any of these characters, it is executed by the shell, not + * directly by us. + * + * perhaps move it to ctype? + */ + +unsigned char _metachar[128] = { +// nul soh stx etx eot enq ack bel + 1, 0, 0, 0, 0, 0, 0, 0, +// bs ht nl vt np cr so si + 0, 0, 1, 0, 0, 0, 0, 0, +// dle dc1 dc2 dc3 dc4 nak syn etb + 0, 0, 0, 0, 0, 0, 0, 0, +// can em sub esc fs gs rs us + 0, 0, 0, 0, 0, 0, 0, 0, +// sp ! " # $ % & ' + 0, 1, 1, 1, 1, 0, 1, 1, +// ( ) * + , - . / + 1, 1, 1, 0, 0, 0, 0, 0, +// 0 1 2 3 4 5 6 7 + 0, 0, 0, 0, 0, 0, 0, 0, +// 8 9 : ; < = > ? + 0, 0, 0, 1, 1, 0, 1, 1, +// @ A B C D E F G + 0, 0, 0, 0, 0, 0, 0, 0, +// H I J K L M N O + 0, 0, 0, 0, 0, 0, 0, 0, +// P Q R S T U V W + 0, 0, 0, 0, 0, 0, 0, 0, +// X Y Z [ \ ] ^ _ + 0, 0, 0, 1, 1, 1, 1, 0, +// ` a b c d e f g + 1, 0, 0, 0, 0, 0, 0, 0, +// h i j k l m n o + 0, 0, 0, 0, 0, 0, 0, 0, +// p q r s t u v w + 0, 0, 0, 0, 0, 0, 0, 0, +// x y z { | } ~ del + 0, 0, 0, 1, 1, 1, 1, 0, +}; + diff --git a/devel/bmake/files/metachar.h b/devel/bmake/files/metachar.h new file mode 100644 index 00000000000..89a9f8bbd0d --- /dev/null +++ b/devel/bmake/files/metachar.h @@ -0,0 +1,61 @@ +/* $NetBSD: metachar.h,v 1.1.1.1 2020/05/24 05:35:52 nia Exp $ */ + +/*- + * Copyright (c) 2015 The NetBSD Foundation, Inc. + * All rights reserved. + * + * This code is derived from software contributed to The NetBSD Foundation + * by Christos Zoulas. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS + * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS + * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef _METACHAR_H +#define _METACHAR_H + +#include <ctype.h> + +extern unsigned char _metachar[]; + +#define ismeta(c) _metachar[(c) & 0x7f] + +static inline int +hasmeta(const char *cmd) +{ + while (!ismeta(*cmd)) + cmd++; + + return *cmd != '\0'; +} + +static inline int +needshell(const char *cmd, int white) +{ + while (!ismeta(*cmd) && *cmd != ':' && *cmd != '=') { + if (white && isspace((unsigned char)*cmd)) + break; + cmd++; + } + + return *cmd != '\0'; +} + +#endif /* _METACHAR_H */ diff --git a/devel/bmake/files/mk/ChangeLog b/devel/bmake/files/mk/ChangeLog new file mode 100644 index 00000000000..9ce9b33f8f6 --- /dev/null +++ b/devel/bmake/files/mk/ChangeLog @@ -0,0 +1,1540 @@ +2020-05-15 Simon J Gerraty <sjg@beast.crufty.net> + + * install-mk (MK_VERSION): 20200515 + + * dirdeps.mk: set _debug_* earlier and allow passing -d* + flags to submake when building DIRDEPS_CACHE + +2020-05-09 Simon J Gerraty <sjg@beast.crufty.net> + + * whats.mk: more easily extensible + +2020-05-02 Simon J Gerraty <sjg@beast.crufty.net> + + * whats.mk: greatly simplify by adding what.c to SRCS + +2020-05-01 Simon J Gerraty <sjg@beast.crufty.net> + + * whats.mk: for libs take care how we add to *OBJS + + * lib.mk: : works better with whats.mk + +2020-04-25 Simon J Gerraty <sjg@beast.crufty.net> + + * install-mk (MK_VERSION): 20200420 + + * meta.stage.mk: it is not a STAGE_CONFLICT if some-target.dirdep + contains the same ${RELDIR} and a prefix match for our ${TARGET_SPEC} + +2020-04-16 Simon J Gerraty <sjg@beast.crufty.net> + + * install-mk (MK_VERSION): 20200416 + + * sys/*.mk: set MAKE_SHELL rather than SHELL so as not to + interfere with user env. + + * sys.mk: default MAKE_SHELL to sh and SHELL to MAKE_SHELL + + * autodep.mk: use MAKE_SHELL. + +2019-11-21 Simon J Gerraty <sjg@beast.crufty.net> + + * gendirdeps.mk: clear .SUFFIXES to avoid a lot of + wasted effort, and unexport _meta_files when no longer needed as + it consumes space we need for command line. + +2019-11-11 Simon J Gerraty <sjg@beast.crufty.net> + + * dirdeps.mk _DIRDEP_USE: use DIRDEP_DIR and add + DIRDEP_USE_PRELUDE at start - facilitates job distribution + +2019-10-04 Simon J Gerraty <sjg@beast.crufty.net> + + * dirdeps-targets.mk: Use TARGET_SPEC_LAST_LIST + defaults to ${${TARGET_SPEC_VARS:[-1]}_LIST} to match valid + TARGET_SPEC qualified depend files. + +2019-10-02 Simon J Gerraty <sjg@beast.crufty.net> + + * dirdeps-targets.mk: encapsulate logic for finding top-level + targets to set initial DIRDEPS for DIRDEPS_BUILD + +2019-09-27 Simon J Gerraty <sjg@beast.crufty.net> + + * install-mk (MK_VERSION): 20190911 + + * compiler.mk: set COMPILER_TYPE + +2019-07-17 Simon J Gerraty <sjg@beast.crufty.net> + + * install-mk (MK_VERSION): 20190704 + + * sys/Darwin.mk: support for Objective-C and clang + +2019-05-30 Simon J Gerraty <sjg@beast.crufty.net> + + * dirdeps.mk: avoid insanely long command line when generating cache + +2019-05-23 Simon J Gerraty <sjg@beast.crufty.net> + + * install-mk (MK_VERSION): 20190505 + + * whats.mk: handle corner case SHLIB defined but not LIB + +2018-09-19 Simon J Gerraty <sjg@beast.crufty.net> + + * install-mk (MK_VERSION): 20180919 + + * dirdeps-options.mk: .undef cannot handle var that expands to + more than one var. + +2018-07-08 Simon J Gerraty <sjg@beast.crufty.net> + + * meta.stage.mk: allow wildcards in STAGE_FILES.* etc. + +2018-06-01 Simon J Gerraty <sjg@beast.crufty.net> + + * meta.autodep.mk: export META_FILES to avoid command line limit + * gendirdeps.mk: if we have lots of .meta files put them in + an @list + +2018-05-28 Simon J Gerraty <sjg@beast.crufty.net> + + * dirdeps-options.mk: use local.dirdeps-options.mk + not local.dirdeps-option.mk + +2018-04-20 Simon J Gerraty <sjg@beast.crufty.net> + + * install-mk (MK_VERSION): 20180420 + * dirdeps.mk: include local.dirdeps-build.mk when .MAKE.LEVEL > 0 + ie. we are building something. + +2018-04-14 Simon J Gerraty <sjg@beast.crufty.net> + + * FILES: add dirdeps-options.mk to deal with optional DIRDEPS. + +2018-04-05 Simon J Gerraty <sjg@beast.crufty.net> + + * install-mk (MK_VERSION): 20180405 + + * ldorder.mk: describe how to use LDORDER_EXTERN_BARRIER + if needed. + +2018-01-18 Simon J Gerraty <sjg@beast.crufty.net> + + * install-mk (MK_VERSION): 20180118 + + * ldorder.mk: let make compute correct link order + +2017-12-12 Simon J Gerraty <sjg@beast.crufty.net> + + * install-mk (MK_VERSION): 20171212 + + * gendirdeps.mk: guard against bogus entries in GENDIRDEPS_FILTER + +2017-11-14 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20171111 + + * lib.mk: ensure META_NOECHO is set + +2017-10-25 Simon J. Gerraty <sjg@bad.crufty.net> + + * Allow for host32 on rare occasions. + +2017-10-18 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20171018 + + * whats.mk: include what_thing in what_uuid to avoid problem + when building multiple apps in the same directory. + +2017-08-12 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20170812 + + * autoconf.mk: Use CONFIGURE_DEPS so Makefile can + add dependencies for config.recheck and config.gen + +2017-06-30 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20170630 + + * meta.stage.mk: avoid triggering stage_* targets with nothing to do. + +2017-05-23 Simon J. Gerraty <sjg@bad.crufty.net> + + * meta2deps.py: take special care of '..' + +2017-05-15 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20170515 + + * dirdeps.mk (DEP_EXPORT_VARS): on rare occasions it is + useful/necessary for a Makefile.depend file to export some knobs. + This is complicated when we are doing DIRDEPS_CACHE, so we will + handle export of any variables listed in DEP_EXPORT_VARS. + +2017-05-08 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20170505 + + * meta2deps.py: fix botched indenation. + +2017-05-05 Simon J. Gerraty <sjg@bad.crufty.net> + + * sys/*.mk: Remove setting of MAKE it is unnecessary and + in many cases wrong (basname rather than full path) + + * scripts.mk (SCRIPTSGROUPS): make this more like files.mk and inc.mk + + * init.mk: define realbuild to simplify logic in {lib,prog}.mk etc + +2017-05-01 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20170501 + + * doc.mk: fix typo in DOC_INSTALL_OWN + + * inc.mk: handle INCGROUPS similar to freebsd + + * files.mk: add something for files too + + * add staging logic to lib.mk prog.mk etc. + +2017-04-24 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20170424 + + * dirdeps.mk: set NO_DIRDEPS when bootstrapping. + also target of bootstrap-this when sed is needed should be ${_want:T} + +2017-04-18 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20170418 + + * auto.obj.mk: if using MAKEOBJDIRPREFIX check if it is a + prefix match for .CURDIR - in which case .CURDIR *is* __objdir. + +2017-04-01 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20170401 + + * meta2deps.py: add is_src so we can check if obj dependency + is also a src dependency. + +2017-03-26 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20170326 + + * meta.stage.mk: do nothing if NO_STAGING is defined. + +2017-03-24 Simon J. Gerraty <sjg@bad.crufty.net> + + * auto.obj.mk: handle the case of __objdir=obj or obj.${MACHINE} etc. + +2017-03-18 Simon J. Gerraty <sjg@bad.crufty.net> + + * mkopt.sh: treat WITH_*=NO like no; ie. WITHOUT_* + +2017-03-01 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20170301 + + * dirdeps.mk (_build_all_dirs): update this outside test for empty + DIRDEPS. + + * meta.stage.mk: allow multiple inclusion to the extent it makes + sense. + +2017-02-14 Simon J. Gerraty <sjg@bad.crufty.net> + + * prog.mk (install_links): depends on realinstall + +2017-02-12 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20170212 + + * dpadd.mk: avoid applying :T:R twice to DPLIBS entries + +2017-01-30 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20170130 + + * dirdeps.mk: use :range if we can. + + * sys.vars.mk: provide M_cmpv if MAKE_VERSION >= 20170130 + + * meta2deps.py: clean paths without using realpath() where possible. + fix sort_unique. + +2016-12-12 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20161212 + + * meta2deps.py: set pid_cwd[pid] when we process 'C'hdir, + rather than when we detect pid change. + +2016-12-07 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20161207 + + * meta.stage.mk: add stage_as_and_symlink for staging packages. + We build foo.tgz stage_as foo-${VERSION}.tgz but want to be able + to use foo.tgz to reference the latest staged version - so we + make foo.tgz a symlink to it. + Using a target to do both operations ensures we stay in sync. + +2016-11-26 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20161126 + + * dirdeps.mk: set DIRDEPS_CACHE before we include local.dirdeps.mk + so it can add dependencies. + +2016-10-10 Simon J. Gerraty <sjg@bad.crufty.net> + + * dirdeps.mk: set DEP_* before we expand .MAKE.DEPENDFILE_PREFERENCE + do that they can influence the result correctly. + + * dirdeps.mk (${DIRDEPS_CACHE}): make sure we pass on TARGET_SPEC + + * dirdeps.mk: Add ONLY_TARGET_SPEC_LIST and NOT_TARGET_SPEC_LIST + similar to ONLY_MACHINE_LIST and NOT_MACHINE_LIST + +2016-10-05 Simon J. Gerraty <sjg@bad.crufty.net> + + * dirdeps.mk: remove dependence on jot (normal situations anyway). + Before we read another Makefile.depend* set DEP_* vars from + _DEP_TARGET_SPEC in case it uses any of them with := + When bootstrapping, trim any ,* from extention of chosen _src + Makefile.depend* to get the machine value we subst for. + +2016-09-30 Simon J. Gerraty <sjg@bad.crufty.net> + + * dirdeps.mk: use TARGET_SPEC_VARS to qualify components added to + DEP_SKIP_DIR and DEP_DIRDEPS_FILTER + + * sys.mk: extract some bits to sys.{debug,vars}.mk + for easier re-use by others. + +2016-09-23 Simon Gerraty <sjg@sjg-mba13> + + * lib.mk: Use ${PICO} for extension for PIC objects. + default to .pico (like NetBSD) safe on case insensitive filesystem. + +2016-08-19 Simon J. Gerraty <sjg@bad.crufty.net> + + * meta.sys.mk (META_COOKIE_TOUCH): use ${.OBJDIR}/${.TARGET:T} as default + +2016-08-15 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20160815 + + * dirdeps.mk (.MAKE.META.IGNORE_FILTER): set filter to only + consider Makefile.depend* when checking if DIRDEPS_CACHE is up-to-date. + +2016-08-13 Simon J. Gerraty <sjg@bad.crufty.net> + + * meta.sys.mk (.MAKE.META.IGNORE_PATHS): + in meta mode we can ignore the mtime of makefiles + +2016-08-02 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20160802 + + * lib.mk (libinstall): depends on beforinstall + + * prog.mk (proginstall): depends on beforinstall + patch from Lauri Tirkkonen + + * dirdeps.mk (bootstrap): When bootstrapping; creat + .MAKE.DEPENDFILE_DEFAULT and allow additional filtering via + .MAKE.DEPENDFILE_BOOTSTRAP_SED + + * dirdeps.mk: move some comments to where they make sense. + +2016-07-27 Simon J. Gerraty <sjg@bad.crufty.net> + + * dirdeps.mk (DIRDEPS_CACHE): no dirname. + +2016-06-02 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20160602 + * meta.autodep.mk: when passing META_FILES to gendirdeps.mk + do not apply :T to META_XTRAS + patch from Bryan Drewery at FreeBSD.org. + +2016-05-30 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20160530 + * meta.stage.mk: we assume ${CLEANFILES} gets .NOPATH + make it so. + +2016-05-12 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20160512 + + * dpadd.mk: always include local.dpadd.mk if it exists + remove some things that better belong in local.dpadd.mk + skip INCLUDES_* for staged libs unless SRC_* defined. + + * own.mk: add INCLUDEDIR + +2016-04-18 Simon J. Gerraty <sjg@bad.crufty.net> + + * dirdeps.mk: when doing -f dirdeps.mk if target suppies no + TARGET_MACHINE - :E will be empty or match part of path, use + ${MACHINE} + +2016-04-07 Simon J. Gerraty <sjg@bad.crufty.net> + + * meta.autodep.mk: issue a warning if UPDATE_DEPENDFILE=NO due to + NO_FILEMON_COOKIE + + * dirdeps.mk: move the logic that allows for + make -f dirdeps.mk some/dir.${TARGET_SPEC} + inside the check for !target(_DIRDEP_USE) + +2016-04-04 Simon J. Gerraty <sjg@bad.crufty.net> + + * Use <> when including local*.mk and others which may exist + elsewhere so that user can better control what they get. + + * meta.autodep.mk (NO_FILEMON_COOKIE): + create a cookie if we ever build dir with nofilemon + so that UPDATE_DEPENDFILE will be forced to NO until cleaned. + +2016-04-01 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20160401 + + * meta2deps.py: fix old print statement when debugging. + + * gendirdeps.mk: META2DEPS_CMD append M2D_EXCLUDES with -X + patch from Bryan Drewery + +2016-03-22 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20160317 (St. Pats) + + * warnings.mk: g++ does not like -Wimplicit + + * sys.mk sys/*.mk lib.mk prog.mk: use CXX_SUFFIXES to handle the + pelthora of common suffixes for C++ + + * lib.mk: use .So for shared objects + +2016-03-15 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20160315 + + * meta.stage.mk (LN_CP_SCRIPT): do not ln(1) if we have to chmod(1) + normally only applies to scripts. + + * dirdeps.mk: NO_DIRDEPS_BELOW to supress DIRDEPS below RELDIR as + well as outside it. + +2016-03-10 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20160310 + + * dirdeps.mk: use targets rather than a list to track DIRDEPS that + we have processed; the list gets very inefficient as number of + DIRDEPS gets large. + + * sys.dependfile.mk: fix comment wrt MACHINE + + * meta.autodep.mk: ignore staged DPADDs when bootstrapping. + patch from Bryan Drewery + +2016-03-02 Simon J. Gerraty <sjg@bad.crufty.net> + + * meta2deps.sh: don't ignore subdirs. + patch from Bryan Drewery + +2016-02-26 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20160226 + + * gendirdeps.mk: mark _DEPENDFILE .NOMETA + +2016-02-20 Simon J. Gerraty <sjg@bad.crufty.net> + + * dirdeps.mk: we shouldn't normally include .depend but if we do + use .dinclude if we can. + +2016-02-18 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20160218 + * sys.clean-env.mk: with recent change to Var_Subst() + we cannot use the '$$' trick, but .export-literal does the job + we need. + * auto.dep.mk: make use .dinclude if we can. + + +2016-02-05 Simon J. Gerraty <sjg@bad.crufty.net> + + * dirdeps.mk: + Add _build_all_dirs such that local.dirdeps.mk can + add fully qualified dirs to it. + These will be built normally but the current + DEP_RELDIR will not depend on then (to avoid cycles). + This makes it easy to hook things like unit-tests into build. + + +2016-01-21 Simon J. Gerraty <sjg@bad.crufty.net> + + * dirdeps.mk: add bootstrap-empty + +2015-12-12 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20151212 + * auto.obj.mk: do not require MAKEOBJDIRPREFIX to exist. + only apply :tA to __objdir when comparing to .OBJDIR + +2015-11-14 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20151111 + + * meta.sys.mk: include sys.dependfile.mk + + * sys.mk (OPTIONS_DEFAULT_NO): use options.mk + to set MK_AUTO_OBJ and MK_DIRDEPS_BUILD + include local.sys.env.mk early + include local.sys.mk later + + * own.mk (OPTIONS_DEFAULT_NO): AUTO_OBJ etc moved to sys.mk + +2015-11-13 Simon J. Gerraty <sjg@bad.crufty.net> + + * meta.sys.mk (META_COOKIE_TOUCH): + add ${META_COOKIE_TOUCH} to the end of scripts to touch cookie + + * meta.stage.mk: stage_libs should ignore SYMLINKS. + +2015-10-23 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20151022 + + * sys.mk: BSD/OS does not have 'type' as a shell builtin. + +2015-10-20 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20151020 + + * dirdeps.mk: Add logic for + make -f dirdeps.mk some/dir.${TARGET_SPEC} + +2015-10-14 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20151010 + +2015-10-02 Simon J. Gerraty <sjg@bad.crufty.net> + + * meta.stage.mk: use staging: ${STAGE_TARGETS:... + to have stage_lins run last in non-jobs mode. + Use .ORDER only for jobs mode. + +2015-09-02 Simon J. Gerraty <sjg@bad.crufty.net> + + * rst2htm.mk: allow for per target flags etc. + +2015-09-01 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20150901 + + * doc.mk: create dir if needed use DOC_INSTALL_OWN + +2015-06-15 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20150615 + + * auto.obj.mk: allow use of MAKEOBJDIRPREFIX too. + Follow make's normal precedence rules. + + * gendirdeps.mk: allow customization of the header. + eg. for FreeBSD: + GENDIRDEPS_HEADER= echo '\# ${FreeBSD:L:@v@$$$v$$ @:M*F*}'; + + * meta.autodep.mk: ignore dirdeps.cache* + + * meta.stage.mk: when bootstrapping options it can be handy to + throw warnings rather than errors for staging conflicts. + + * meta.sys.mk: include local.meta.sys.mk for customization + +2015-06-06 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20150606 + + * dirdeps.mk: don't rely on manually maintained Makefile.depend + to set DEP_RELDIR and reset DIRDEPS. + By setting DEP_RELDIR ourselves we can skip :tA + + * gendirdeps.mk: skip setting DEP_RELDIR. + +2015-05-24 Simon J. Gerraty <sjg@bad.crufty.net> + + * dirdeps.mk: avoid wildcards like make(bootstrap*) + +2015-05-20 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20150520 + + * dirdeps.mk: when we are building dirdeps cache file we *want* + meta_oodate to look at all the Makefile.depend files, so + set .MAKE.DEPENDFILE to something that won't match. + + * meta.stage.mk: for STAGE_AS_* basename of file may not be unique + so first use absolute path as key. + Also skip staging at level 0. + +2015-04-30 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20150430 + + * dirdeps.mk: fix _count_dirdeps for non-cache case. + +2015-04-16 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20150411 + bump version + + * own.mk: put AUTO_OBJ in OPTIONS_DEFAULT_NO rather than YES. + it is here mainly for documentation purposes, since + if using auto.obj.mk it is better done via sys.mk + +2015-04-01 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20150401 + + * meta2deps.sh: support @list + + * meta2deps.py: updates from Juniper + o add EXCLUDES + o skip bogus input files. + o treat 'M' and 'L' as both an 'R' and a 'W' + +2015-03-03 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20150303 + + * dirdeps.mk: if MK_DIRDEPS_CACHE is yes, use dirdeps-cache + which is built via sub-make so we have a .meta file to tell if + it is out-of-date. + The dirdeps-cache contains the same dependency rules that we + normaly construct on the fly. + This adds a few seconds overhead when the cache is out of date, + but for a large target, the savings can be significant (10-20min). + +2014-11-18 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20141118 + + * meta.stage.mk: add stale_staged + + * dirdeps.mk (_DIRDEP_USE_LEVEL): allow this to be tweaked + only useful under very rare conditions such as + FreeBSD's make universe. + + * auto.obj.mk: Allow MK_AUTO_OBJ to set MKOBJDIRS=auto + +2014-11-11 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20141111 + + * mkopt.sh: use consistent semantics for _mk_opt and _mk_opts + +2014-11-09 Simon J. Gerraty <sjg@bad.crufty.net> + + * FILES: include mkopt.sh which allows handling options in shell + scripts in a manner compatible with options.mk + +2014-10-12 Simon J. Gerraty <sjg@bad.crufty.net> + + * meta.stage.mk: ensure only _STAGED_DIRS under objroot are used + for GENDIRDEPS_FILTER to avoid surprises. + +2014-10-10 Simon J. Gerraty <sjg@bad.crufty.net> + + * dirdeps.mk (NSkipHostDir): this needs SRCTOP prepended since by + the time it is applied to __depdirs they have. + + * dirdeps.mk fix filtering of _machines since M_dep_qual_fixes + expects patterns like *.${MACHINE} + + * cython.mk (pyprefix?): use pyprefix to find python bits + since prefix might be something else (where we install our + stuff) + +2014-09-11 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20140911 + + * dirdeps.mk: add bootstrap target to simplify adding support for + new MACHINE. + +2014-09-01 Simon J. Gerraty <sjg@bad.crufty.net> + + * gendirdeps.mk: Add handling of GENDIRDEPS_FILTER_DIR_VARS and + GENDIRDEPS_FILTER_VARS to make it easier to produce sharable + Makefile.depend files. + +2014-08-28 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20140828 + + * cython.mk: capture logic for building python extension modules + with Cython. + +2014-08-08 Simon J. Gerraty <sjg@bad.crufty.net> + + * meta.stage.mk (_STAGE_AS_BASENAME_USE): Add StageAs variant + +2014-08-02 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20140801 + + * dep.mk: use explicit MKDEP_MK rather than overload MKDEP to + identify the autodep.mk variant. + + * sys.dependfile.mk: delete .MAKE.DEPENDFILE if its + initial value does not match .MAKE.DEPENDFILE_PREFIX + + * meta.autodep.mk: if _bootstrap_dirdeps add RELDIR to DIRDEPS + +2014-05-22 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20140522 + + * lib.mk: use CC to link shlib for linux too + patch from Brendan MacDonell + +2014-05-05 Simon J. Gerraty <sjg@bad.crufty.net> + + * meta.autodep.mk: add _reldir_{finish,failed} for gathering stats + if WITH_META_STATS is defined. + +2014-05-02 Simon J. Gerraty <sjg@bad.crufty.net> + + * dirdeps.mk: accept -DWITHOUT_DIRDEPS (same a as -DNO_DIRDEPS) + to supress dirdeps outside of .CURDIR. + +2014-04-05 Simon J. Gerraty <sjg@bad.crufty.net> + + * Fix spelling errors - patch from Pedro Giffuni + +2014-03-14 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20140314 + + * dirdeps.mk (beforedirdeps): a handy hook + + * dirdeps.mk (DIRDEP_MAKE): allow the actual command we run + to visit leaf dirs to be intercepted (eg. for distributed + build). + + * dirdeps.mk (__depdirs): ensure // don't sneak in + + * gendirdeps.mk (DIRDEPS): ensure // don't sneak in + + +2014-02-21 Simon J. Gerraty <sjg@bad.crufty.net> + + * rst2htm.mk (RST2PDF): add support for rst2pdf + +2014-02-14 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): bump version + * dirdeps.mk (_last_dependfile): use .INCLUDEDFROMFILE if + available. + +2014-02-10 Simon J. Gerraty <sjg@bad.crufty.net> + + * options.mk: avoid :U so this isn't bmake dependent + +2014-02-09 Simon J. Gerraty <sjg@bad.crufty.net> + + * options.mk: cleanup and simplify semanitcs + NO_* dominates all, if both WITH_* and WITHOUT_* + are defined then result is DOMINATE_* which defaults to "no". + Ie. WITHOUT_ normally wins. + +2013-12-12 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): bump version + * meta2deps.py: convert to print function for python3 compat. + we also need to open files with mode 'r' rather than 'rb' + otherwise we get bytes instead of strings. + +2013-10-10 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): bump version + + * dirdeps.mk: when TARGET_SPEC_VARS is more than just MACHINE + apply the same filtering (M_dep_qual_fixes) when setting _machines + as _build_dirs. + Also fix the filtering of Makefile.depend files - for reporting + what we are looking for (M_dep_qual_fixes can get confused by + Makefile.depend) + Add some more debug info. + +2013-09-04 Simon J. Gerraty <sjg@bad.crufty.net> + + * gendirdeps.mk (_objtops): fix typo also + while processing M2D_OBJROOTS to gather qualdir_list + qualify $ql with loop iterator to ensure correct results. + +2013-08-01 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20130801 + * libs.mk: update to match progs.mk + +2013-07-26 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20130726 + some updates from Juniper and FreeBSD + o meta2deps.py: indicate file and line number when we hit parse + errors + also allow @file to provide huge list of .meta files. + * meta2deps.py: add try_parse() to cleanup the above. + +2013-07-16 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20130716 + * own.mk: add GPROG as an option + * prog.mk: honor MK_GPROF==yes + +2013-05-10 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20130505 + * gendirdeps.mk, meta2deps.py, meta2deps.sh: handle $TARGET_SPEC + for when $MACHINE isn't enough for objdir distinction. + Bring meta2deps.sh closer to par with meta2deps.py. + +2013-04-18 Simon J. Gerraty <sjg@bad.crufty.net> + + * meta.stage.mk: set INSTALL to STAGE_INSTALL when making 'all' + also if the target 'beforeinstall' exists, make it depend on + .dirdep (incase it uses STAGE_INSTALL). + +2013-04-17 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): 20130401 ;-) + * meta.stage.mk (STAGE_INSTALL_SH): add stage-install.sh as + wrapper around install(1). + * options.mk (OPTION_PREFIX): Allow a prefix other than MK_ + +2013-03-30 Simon J. Gerraty <sjg@bad.crufty.net> + + * meta2deps.py (MetaFile.__init__): ensure self.cwd is initialized. + * install-mk (MK_VERSION): bump version + +2013-03-21 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): bump version + * gendirdeps.mk: do not apply :tA to DPADD entries, since we lose + any trailing /., rather apply :tA only when needed. + * gendirdeps.mk: better mimic meta2deps handling of .dirdep files. + * meta.stage.mk (LN_CP_SCRIPT): Add LnCp to do the ln||cp dance + consistently. + * dirdeps.mk: better describe the dance in sys.mk for TARGET_SPEC. + +2013-03-18 Simon J. Gerraty <sjg@bad.crufty.net> + + * gendirdeps.mk: revert the dance around .MAKE.DEPENDFILE_DEFAULT + it is simpler to just not update when say building for "host" + (where we know we apply filters to DIRDEPS), and using a + non-machine qualified dependfile. + +2013-03-16 Simon J. Gerraty <sjg@bad.crufty.net> + + * dirdeps.mk: improve DIRDEPS filtering by allowing DEP_SKIP_DIR + and DEP_DIRDEPS_FILTER to vary by DEP_MACHINE and DEP_TARGET_SPEC + * gendirdeps.mk: ensure _objroot has trailing / if it needs it. + * meta2deps.py: if machine is "host", then also trim + self.host_target from any OBJROOTS. + + +2013-03-11 Simon J. Gerraty <sjg@bad.crufty.net> + + * gendirdeps.mk: if .MAKE.DEPENDFILE_DEFAULT is not machine + qualified but _DEPENDFILE is, and .MAKE.DEPENDFILE_DEFAULT exists + but _DEPENDFILE does not, compare the new _DEPENDFILE against + .MAKE.DEPENDFILE_DEFAULT and discard if the same. + +2013-03-08 Simon J. Gerraty <sjg@bad.crufty.net> + + * meta.stage.mk: use STAGE_TARGETS to control .ORDER + and hook to all: via staging: + +2013-03-07 Simon J. Gerraty <sjg@bad.crufty.net> + + * sys.dependfile.mk (.MAKE.DEPENDFILE_DEFAULT): + use a separate variable for the default .MAKE.DEPENDFILE value + so that it can be controlled independently of + .MAKE.DEPENDFILE_PREFERENCE + + * meta.stage.mk: throw error if cp fails etc. + Stage*() return early if passed no args. + .ORDER stage_* + +2013-03-03 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): bump version + * gendirdeps.mk: handle multiple M2D_OBJROOTS better. + +2013-02-10 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): bump version to 20130210 + * import latest dirdeps.mk, gendirdeps.mk and meta2deps.py + from Juniper. + o dirdeps.mk now fully supports TARGET_SPEC consisting of more + than just MACHINE. + o no longer use DEP_MACHINE from Makefile.depend* so remove it. + +2013-01-23 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): bump version to 20130123 + * meta.stage.mk: add stage_links (hard links). + if doing hard links, we add dest to link as well. + Default the stage dir for [sym]links to STAGE_OBJTOP since + these are typically specified as absolute paths. + Add -m "mode" flag to StageFiles and StageAs. + +2012-11-11 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): bump version to 20121111 + * autoconf.mk: avoid meta mode seeing changed commands for config.status + * meta.autodep.mk: pass resolved MAKESYSPATH to gendirdeps + in case we were found via .../mk + * sys.clean-env.mk: move it from examples, we and others use it + "as is". + * FILES: add srctop.mk and options.mk + * own.mk: convert to using options.mk + which is modeled after FreeBSD's handling of MK_* + but more flexible. + This allows MK_* for boolean knobs to not be confused + with MK* which can be commands. + + * examples/sys.clean-env.mk: add WITH[OUT]_ to + MAKE_ENV_SAVE_PREFIX_LIST. + Mention that HOME=/var/empty might be a good idea. + +2012-11-08 Simon J. Gerraty <sjg@bad.crufty.net> + + * sys.dependfile.mk: if not depend file exists, $MACHINE + specific ones are supported but not the default, + check if any exist and follow suit. + +2012-11-06 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): bump version to 20121106 + +2012-11-05 Simon J. Gerraty <sjg@bad.crufty.net> + + * import latest dirdeps.mk and meta2deps.py from Juniper. + * progs.mk: add MAN and CXXFLAGS to PROG_VARS + also add PROGS_TARGETS and pass on PROG_CXX if it seems + appropriate. + +2012-11-04 Simon J. Gerraty <sjg@bad.crufty.net> + + * meta.stage.mk: update CLEANFILES + remove redundant cp of .dirdep from STAGE_AS_SCRIPT. + * progs.mk: Add LDADD to PROG_VARS + +2012-10-12 Simon J. Gerraty <sjg@bad.crufty.net> + + * meta.stage.mk (STAGE_DIR_FILTER): track dirs we stage to in + _STAGED_DIRS so that these can be turned into filters for + GENDIRDEPS_FILTER. + +2012-10-10 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): bump version to 20121010 + * meta.stage.mk (STAGE_DIRDEP_SCRIPT): check that an existing + target.dirdep matches .dirdep + +2012-08-08 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): bump version to 20120808 + * import latest meta2deps.py from Juniper. + +2012-07-11 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): bump version to 20120711 + * dep.mk: add explicit dependencies on SRCS after applying + SRCS_DEP_FILTER + * meta.autodep.mk: add explicit dependencies on SRCS after + applying SRCS_DEP_FILTER + * meta.autodep.mk: ensure GENDIRDEPS_FILTER is exported if needed. + +2012-06-26 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): bump version to 20120626 + * meta.sys.mk: ignore PYTHON if it does not exist + compare ${.MAKE.DEPENDFILE:E} against ${MACHINE} is more reliable. + * meta.stage.mk: examine .MAKE.DEPENDFILE_PREFERENCE for any + entries ending in .${MACHINE} to decide if qualified _dirdep is + needed. + * gendirdeps.mk: only produce unqualified deps if no + .MAKE.DEPENDFILE_PREFERENCE ends in .${MACHINE} + * meta.subdir.mk: apply SUBDIRDEPS_FILTER + +2012-04-20 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): bump version to 20120420 + * add sys.dependfile.mk so we can experiment with + .MAKE.DEPENDFILE_PREFERENCE + * meta.autodep.mk: _DEPENDFILE is precious! + +2012-03-15 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): bump version to 20120315 + * install-new.mk: avoid being interrupted + +2012-02-26 Simon J. Gerraty <sjg@bad.crufty.net> + + * man.mk: MAN might have multiple values so be careful with exists(). + +2012-01-19 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): bump version to 20120112 + * fix examples/sys.clean-env.mk so that MAKEOBJDIR is handled + as: MAKEOBJDIR='${.CURDIR:S,${SRCTOP},${OBJTOP},}' + +2011-12-03 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): bump version to 20111201 + * import dirdeps.mk from Juniper sjg@ + o more consistent handling of DEP_MACHINE, especially when + dealing with an odd Makefile.depend, when normally using + Makefile.depend.${MACHINE} + +2011-11-22 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): bump version to 20111122 + * meta.autodep.mk: add some debug output, be more crisp about + updating. Use ${.ALLTARGETS:M*.o} as a clue for .depend + +2011-11-13 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): bump version to 20111111 + it's too cool to miss + * import meta* updates from Juniper sjg@ + o dirdeps.mk set DEP_MACHINE for Makefile.depend (when we are + normally using Makefile.depend.${MACHINE}), handy for + read-only manually maintained dependencies. + o meta2deps.py add a clear 'ERROR:' token if an exception is raised. + o gendirdeps.mk if ERROR: from meta2deps.py do not update + anything. + +2011-10-30 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-new.mk separate the cmp and copy logic to its own function. + +2011-10-28 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): bump version to 20111028 + * sys.mk: include auto.obj.mk if MKOBJDIRS is set to auto + * subdir.mk: ensure _SUBDIRUSE is provided + * meta.autodep.mk: remove dependency of gendirdeps.mk on auto.obj.mk + * meta.subdir.mk: always allow for Makefile.depend + +2011-10-10 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): bump version to 20111010 + o minor tweak to *dirdeps.mk from Juniper sjg@ + +2011-10-01 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): bump version to 20111001 + o add meta2deps.py from Juniper sjg@ + o tweak gendirdeps.mk to work with meta2deps.py when not + cross-building + * autoconf.mk: add autoconf-input as a hook for regenerating + AUTOCONF_INPUTS (configure). + +2011-08-24 Simon J. Gerraty <sjg@bad.crufty.net> + + * meta.autodep.mk: if we do not have OBJS, .depend isn't a useful + trigger for updating Makefile.depend* + +2011-08-08 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): bump version to 20110808 + * obj.mk: minor cleanup + * auto.obj.mk: improve description of Mkdirs and honor NO_OBJ too. + +2011-08-01 Simon J. Gerraty <sjg@bad.crufty.net> + + * auto.obj.mk (.OBJDIR): throw an error if we cannot use the + specified dir. + +2011-06-28 Simon J. Gerraty <sjg@bad.crufty.net> + + * meta.autodep.mk: if XMAKE_META_FILE is set + the makefile uses a foreign make, and so dependencies + can only be gathered from a clean tree build. + +2011-06-24 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): bump version to 20110622 + * meta.autodep.mk: improve bootstraping + +2011-06-10 Simon J. Gerraty <sjg@bad.crufty.net> + + * yacc.mk: handle the corner case of .c being removed + while .h remains. + +2011-06-08 Simon J. Gerraty <sjg@bad.crufty.net> + + * yacc.mk: do .y.h and .y.c separately + +2011-06-04 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): bump version to 20110606 + * don't store SRC_DIRDEPS in Makefile.depend* by default + not everyone needs it. + +2011-05-04 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): bump version to 20110505 + first release including meta mode makefiles + +2011-05-02 Simon J. Gerraty <sjg@bad.crufty.net> + + * meta.stage.mk: add STAGE_AS_SETS and stage_as + for things that need to be staged with different names. + +2011-05-01 Simon J. Gerraty <sjg@bad.crufty.net> + + * meta.stage.mk: add notion of STAGE_SETS + so a makefile can stage to multiple dirs + +2011-04-03 Simon J. Gerraty <sjg@bad.crufty.net> + + * rst2htm.mk: convert rst to s5 (slides) or plain html depending + on target name. + +2011-03-30 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): bump version to 20110330 + +2011-03-29 Simon J. Gerraty <sjg@bad.crufty.net> + + * sys.mk (_DEBUG_MAKE_FLAGS): use indirection so that DEBUG_MAKE_FLAGS0 + can be used to debug level 0 only and DEBUG_MAKE_FLAGS for the rest. + * sys.mk: re-define M_whence in terms of M_type. + M_type is useful for checking if something is a builtin. + +2011-03-16 Simon J. Gerraty <sjg@bad.crufty.net> + + * meta.stage.mk: add stage_symlinks and leverage StageLinks for + stage_libs + +2011-03-10 Simon J. Gerraty <sjg@bad.crufty.net> + + * dirdeps.mk: correct value for _depdir_files depends on + .MAKE.DEPENDFILE + Add our copyright - just to make it clear we have frobbed this + quite a bit. + DEP_MACHINE needs to be set to MACHINE each time, if using only + Makefile.depend (cf. Makefile.depend.${MACHINE}) + + * meta.stage.mk: meta mode version of staging + + * init.mk, final.mk: include local.*.mk to simplify customization + +2011-03-03 Simon J. Gerraty <sjg@bad.crufty.net> + + * auto.obj.mk: just because we are doing mk destroy, we should + still set .OBJDIR correctly if it exists. + + * install-mk (mksrc): do not exclude meta.sys.mk + +2011-03-01 Simon J. Gerraty <sjg@bad.crufty.net> + + * host-target.mk: set/export _HOST_ARCH etc separately, + catch junk resulting from uname -p, so we can find sys/Linux.mk + correctly. + +2011-02-18 Simon J. Gerraty <sjg@bad.crufty.net> + + * meta.sys.mk: throw an error if /dev/filemon is missing and we + expected to be updating Makefile.depend* + +2011-02-14 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): bump version to 20110214 + * meta.subdir.mk: add support for -DBOOTSTRAP_DEPENDFILES + +2010-09-25 Simon J. Gerraty <sjg@bad.crufty.net> + + * meta.sys.mk: not valid for older bmake + +2010-09-24 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): bump version to 20100919 + include dirdeps.mk et al from Juniper Networks, + for meta mode - requires filemon(9). + * sys.mk, subdir.mk: Add hooks for meta mode. + we do this as meta.sys.mk, meta.autodep.mk and meta.subdir.mk + to make turning it on/off simple. + +2010-06-16 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): bump version to 20100616 + * fix typo in sys.mk + +2010-06-12 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): bump version to 20100612 + * lib.mk: remove duplicate addition to SOBJS + +2010-06-10 Simon J. Gerraty <sjg@bad.crufty.net> + + * sys.mk: Add a means of selectively turning on debug flags. + Eg. DEBUG_MAKE_FLAGS=-dv DEBUG_MAKE_DIRS="*lib/sjg" + will act as if we did make -dv if .CURDIR ends in lib/sjg + DEBUG_MAKE_SYS_DIRS does the same thing, but we set the flags at + the start of sys.mk rather than the end. + This only makes sense for leaf dirs, so we check that + .MAKE.LEVEL > 0 + +2010-06-09 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): bump version to 20100608 + * sys.mk: include sys.env.mk later so it can use M_ListToSkip et al. + * examples/sys.clean-env.mk: require MAKE_VERIONS >= 20100606 + also make it easier for folk to tweak + +2010-06-08 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): bump version to 20100606 + do not install examples/* + * FILES: add examples/sys.clean-env.mk + * examples/sys.clean-env.mk: use .export-env to handle MAKEOBJDIR + this requires bmake-20100606 or later to work. + +2010-05-13 Simon J. Gerraty <sjg@bad.crufty.net> + + * sys.mk (M_tA): better simulate the result of :tA if not available. + +2010-05-04 Simon J. Gerraty <sjg@bad.crufty.net> + + * sys.mk: canonicalize MAKE_VERSION + old versions reported bmake-<src-date> build-<build-date> + whereas we only care about <src-date> + +2010-04-25 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk: just warn about FORCE_{BSD,SYS}_MK being ignored + * lib.mk: we only build the shared lib if SHLIB_FULLVERSION + is !empty + +2010-04-22 Simon J. Gerraty <sjg@bad.crufty.net> + + * dpadd.mk: use LDADD_* if defined. + +2010-04-21 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): bump version to 20100420 + * sys/NetBSD.mk: add MACHINE_CPU to keep netbsd makefiles happy + * autoconf.mk allow AUTO_AUTOCONF + +2010-04-19 Simon J. Gerraty <sjg@bad.crufty.net> + + * obj.mk: add objwarn to keep freebsd makefiles happy + * auto.obj.mk: ensure Mkdirs is available. + * FILES: add auto.dep.mk - a simpler version of autodep.mk + * dep.mk: auto.dep.mk does not do 'make depend' so ignore it if + asked to do that. + fix/simplify the tests for when to run mkdep. + * auto.dep.mk: add some explanation of how/what we do. + * autodep.mk: skip the .OPTIONAL frobbing of .depend + bmake's FROM_DEPEND flag makes it redundant. + +2010-04-13 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): bump version to 20100404 + * subdir.mk: protect from multiple inclusion using _SUBDIRUSE. + * obj.mk: protect from multiple inclusion even as bsd.obj.mk + Also create a target _SUBDIRUSE so that we can be used without + subdir.mk + +2010-04-12 Simon J. Gerraty <sjg@bad.crufty.net> + + * dep.mk: use <> when .including so can override. + +2010-01-11 Simon J. Gerraty <sjg@bad.crufty.net> + + * lib.mk (SHLIB_LINKS): ensure a string comparison. + +2010-01-04 Simon J. Gerraty <sjg@bad.crufty.net> + + * install-mk (MK_VERSION): bump version to 20100102 + * own.mk: ensure PRINTOBJDIR works + * autoconf.mk: pass on CONFIGURE_ARGS + * init.mk: handle COPTS.${.IMPSRC:T} etc. + * lib.mk: allow sys.mk to control SHLIB_FULLVERSION + fix handling of symlinks for darwin + * libnames.mk: add DSHLIBEXT for libs which only exist as shared. + * man.mk: suppress chown when not root. + * rst2htm.mk: allow srcs from multiple locations. + * sys.mk: M_whence, stop after 1st line of output. + * sys/Darwin.mk: Use .dylib for DSHLIBEXT and HOST_LIBEXT + * sys/SunOS.mk: we need to export PATH + +2009-12-23 Simon J. Gerraty <sjg@void.crufty.net> + + * install-mk (MK_VERSION): bump version + include rst2htm.mk + +2009-12-17 Simon J. Gerraty <sjg@void.crufty.net> + + * sys.mk,libnames.mk add .-include <local.*> + this allows local customization without the need to edit the + distributed files. + +2009-12-14 Simon J. Gerraty <sjg@void.crufty.net> + + * dpadd.mk (__dpadd_libdirs): order -L's to avoid picking up + older versions already installed. + +2009-12-13 Simon J. Gerraty <sjg@void.crufty.net> + + * stage.mk (.stage-install): generalize lib.mk's .libinstall + * rules.mk rules for generic Makefile. + * inc.mk install for includes. + +2009-12-11 Simon J. Gerraty <sjg@void.crufty.net> + + * sys/NetBSD.mk (MAKE_VERSION): some of our *.mk want to check + this, so provide it if using native make. + +2009-12-10 Simon J. Gerraty <sjg@void.crufty.net> + + * FILES: move all the platform *.sys.mk files to sys/*.mk + * Rename Generic.sys.mk to sys.mk - we always want it. + +2009-11-17 Simon J. Gerraty <sjg@void.crufty.net> + + * install-mk (MK_VERSION): bump version + * host-target.mk: only export the expensive stuff + * Generic.sys.mk (sys_mk): for SunOS we need to look for + ${HOST_OS}.${HOST_OSMAJOR} too! + +2009-11-07 Simon J. Gerraty <sjg@void.crufty.net> + + * install-mk (MK_VERSION): bump version + * lib.mk: if sys.mk doesn't give us an lorder, don't use it. + based on patch from Greg Olszewski. + * Generic.sys.mk: if we have nothing to work with + set LORDER etc only if we can find it. + +2009-09-08 Simon J. Gerraty <sjg@void.crufty.net> + + * install-mk (MK_VERSION): bump version + * man.mk: cleanman: remove CLEANMAN if defined. + +2009-09-04 Simon J. Gerraty <sjg@void.crufty.net> + + * SunOS.5.sys.mk (CC): Use ?= like the other *sys.mk + +2009-07-17 Simon J. Gerraty <sjg@void.crufty.net> + + * install-mk (MK_VERSION): bump version + include auto.obj.mk + + +2009-03-26 Simon J. Gerraty <sjg@void.crufty.net> + + * prog.mk,lib.mk: ensure test of USE_DPADD_MK doesn't fail. + +2008-11-11 Simon J. Gerraty <sjg@void.crufty.net> + + * install-mk (MK_VERSION): bump version + man.mk: ensure we generate *.cat1 etc in . + +2008-07-16 Simon J. Gerraty <sjg@void.crufty.net> + + * install-mk (MK_VERSION): bump version + add prlist.mk + +2007-11-25 Simon J. Gerraty <sjg@void.crufty.net> + + * Generic.sys.mk: Allow os specific sys.mk to be in a + subdir of ${.PARSEDIR} + +2007-11-22 Simon J. Gerraty <sjg@void.crufty.net> + + * install-mk (MK_VERSION): bump version + * general cleanup + * dpadd.mk introduce DPMAGIC_LIBS_* + +2007-04-30 Simon J. Gerraty <sjg@void.crufty.net> + + * install-mk (MK_VERSION): bump version + + * libs.mk, progs.mk, autodep.mk: allow for per lib/prog + depend files and ensure clean is called for each lib/prog. + +2007-03-27 Simon J. Gerraty <sjg@void.crufty.net> + + * autodep.mk (.depend): delete lines that do not start with + space and do not contain ':' + +2007-02-16 Simon J. Gerraty <sjg@void.crufty.net> + + * autodep.mk (.depend): gcc may wrap lines if pathnames are long + so make sure the transform for .OPTIONAL copes. + +2007-02-03 Simon J. Gerraty <sjg@void.crufty.net> + + * install-mk (MK_VERSION): bump version + + * own.mk: make sure RM and LN are defined. + + * obj.mk: fix a typo, and objlink target. + +2006-12-30 Simon J. Gerraty <sjg@void.crufty.net> + + * install-mk (MK_VERSION): bump version + * added libs.mk - analogous to progs.mk + make both of them always inlcude {lib,prog}.mk + +2006-12-28 Simon J. Gerraty <sjg@void.crufty.net> + + * progs.mk: add a means of building multiple apps in one dir. + +2006-11-26 Simon J. Gerraty <sjg@void.crufty.net> + + * install-mk (MK_VERSION): bump version to 20061126 + + * warnings.mk: detect invalid WARNINGS_SET + + * warnings.mk: use ${.TARGET:T:R}.o when looking for target + specific warnings. + + * For .cc sources, turn off warnings that g++ vomits on. + +2006-11-08 Simon J. Gerraty <sjg@void.crufty.net> + + * own.mk: if __initialized__ target doesn't exist and we are + FreeBSD we got here directly from sys.mk + +2006-11-06 Simon J. Gerraty <sjg@void.crufty.net> + + * install-mk (MK_VERSION): bump version to 20061106 + add scripts.mk + +2006-03-18 Simon J. Gerraty <sjg@void.crufty.net> + + * install-mk (MK_VERSION): bump version to 20060318 + + * autodep.mk: avoid := when modifying OBJS into __dependsrcs + +2006-03-02 Simon J. Gerraty <sjg@void.crufty.net> + + * install-mk (MK_VERSION): bump version to 20060302 + * autodep.mk: use -MF et al to help gcc+ccache DTRT. + +2006-03-01 Simon J. Gerraty <sjg@void.crufty.net> + + * install-mk (MK_VERSION): bump version to 20060301 + * autodep.mk (.depend): + if MAKE_VERSION is newer than 20050530 we can make .END depend on + .depend and make .depend depend on __depsrcs that exist. + * dpadd.mk: add SRC_PATHADD + +2005-11-04 Simon J. Gerraty <sjg@void.crufty.net> + + * install-mk (MK_VERSION): bump version to 20051104 + * prog.mk: remove all the LIBC?= junk, use + .-include libnames.mk instead (none by default). + also if USE_DPADD_MK is set, include that. + +2005-10-09 Simon J. Gerraty <sjg@void.crufty.net> + + * install-mk (MK_VERSION): bump version to 20051001 + Add UnixWare.sys.mk from Klaus Heinz. + +2005-04-05 Simon J. Gerraty <sjg@void.crufty.net> + + * install-mk: always install *.sys.mk and if need be symlink one + to sys.mk + +2005-03-22 Simon J. Gerraty <sjg@void.crufty.net> + + * subdir.mk, own.mk: use .MAKE rather than MAKE + +2004-02-15 Simon J. Gerraty <sjg@void.crufty.net> + + * own.mk: don't use NetBSD's _SRC_TOP_ it can + cause confusion. Also don't take just 'mk' as a + srctop indicator. + +2004-02-14 Simon J. Gerraty <sjg@void.crufty.net> + + * warnings.mk: overhauled, now very powerful. + +2004-02-03 Simon J. Gerraty <sjg@void.crufty.net> + + * Generic.sys.mk: need to use ${.PARSEDIR} with exists(). + +2004-02-01 Simon J. Gerraty <sjg@void.crufty.net> + + * install-mk (MK_VERSION): bump version to 20040201 + * extract HOST_TARGET stuff to host-target.mk so own.mk and + Generic.sys.mk can share. + * fix typo in autodep.mk _SUBDIRUSE not _SUBDIR. + +2003-09-30 Simon J. Gerraty <sjg@void.crufty.net> + + * install-mk (MK_VERSION): 20030930 + * rename generic.sys.mk to Generic.sys.mk + so that it does not get installed (unless being used as sys.mk) + * set OS and ROOT_GROUP for those that we know the value. + for others (eg. Generic.sys.mk) wrap the != in an .ifndef so + we don't do it again for each sub-make. + +2003-09-28 Simon J. Gerraty <sjg@void.crufty.net> + + * install-mk (MK_VERSION): 20030928 + Add some extra *.sys.mk from bootstrap-pkgsrc + some of these likely still need work. + Make everything default to root:wheel ownership, + sys.mk can set ROOT_GROUP accordingly. + +2003-08-07 Simon J. Gerraty <sjg@void.crufty.net> + + * install-mk: if FORCE_BSD_MK={cp,ln} use the ones in SYS_MK_DIR + not the portable ones. + +2003-07-31 Simon J. Gerraty <sjg@void.crufty.net> + + * install-mk: add ability to use cp -f when updating + destination .mk files. Also now possible to play games with + FORCE_SYS_MK=ln etc on *BSD machines to link /usr/share/mk/sys.mk + into dest - not recommended unless you seriously want to. + +2003-07-28 Simon J. Gerraty <sjg@void.crufty.net> + + * own.mk (IMPFLAGS): add support for COPTS.${IMPSRC:T} etc + for semi-compatability with NetBSD. + +2003-07-23 Simon J. Gerraty <sjg@void.crufty.net> + + * install-mk: add a version indicator + +2003-07-22 Simon J. Gerraty <sjg@void.crufty.net> + + * prog.mk: don't try and use ${LIBCRT0} if its /dev/null + + * install-mk: Allow FORCE_SYS_MK to come from env + + + diff --git a/devel/bmake/files/mk/FILES b/devel/bmake/files/mk/FILES new file mode 100644 index 00000000000..dcd00ec2f58 --- /dev/null +++ b/devel/bmake/files/mk/FILES @@ -0,0 +1,72 @@ +ChangeLog +FILES +README +auto.obj.mk +autoconf.mk +autodep.mk +auto.dep.mk +compiler.mk +cython.mk +dep.mk +doc.mk +dpadd.mk +files.mk +final.mk +host-target.mk +host.libnames.mk +inc.mk +init.mk +install-mk +java.mk +ldorder.mk +lib.mk +libnames.mk +libs.mk +links.mk +man.mk +manifest.mk +mk-files.txt +mkopt.sh +nls.mk +obj.mk +options.mk +own.mk +prlist.mk +prog.mk +progs.mk +rst2htm.mk +scripts.mk +srctop.mk +stage-install.sh +subdir.mk +sys.mk +sys.clean-env.mk +sys.debug.mk +sys.dependfile.mk +sys.vars.mk +sys/AIX.mk +sys/Darwin.mk +sys/Generic.mk +sys/HP-UX.mk +sys/IRIX.mk +sys/Linux.mk +sys/NetBSD.mk +sys/OSF1.mk +sys/OpenBSD.mk +sys/SunOS.mk +sys/UnixWare.mk +target-flags.mk +warnings.mk +whats.mk +yacc.mk +dirdeps.mk +dirdeps-options.mk +dirdeps-targets.mk +gendirdeps.mk +install-new.mk +meta2deps.py +meta2deps.sh +meta.sys.mk +meta.autodep.mk +meta.stage.mk +meta.subdir.mk diff --git a/devel/bmake/files/mk/README b/devel/bmake/files/mk/README new file mode 100644 index 00000000000..a651259c858 --- /dev/null +++ b/devel/bmake/files/mk/README @@ -0,0 +1,401 @@ +# $Id: README,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ + +This directory contains some macro's derrived from the NetBSD bsd.*.mk +macros. They have the same names but without the bsd., separate macro +files are needed to ensure we can make them do what we want for +builing things outside of /usr/src. Nearly all the comments below +apply. + +# $NetBSD: README,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# @(#)bsd.README 5.1 (Berkeley) 5/11/90 + +This is the README file for the new make "include" files for the BSD +source tree. The files are installed in /usr/share/mk, and are, by +convention, named with the suffix ".mk". + +Note, this file is not intended to replace reading through the .mk +files for anything tricky. + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +RANDOM THINGS WORTH KNOWING: + +The files are simply C-style #include files, and pretty much behave like +you'd expect. The syntax is slightly different in that a single '.' is +used instead of the hash mark, i.e. ".include <bsd.prog.mk>". + +One difference that will save you lots of debugging time is that inclusion +of the file is normally done at the *end* of the Makefile. The reason for +this is because .mk files often modify variables and behavior based on the +values of variables set in the Makefile. To make this work, remember that +the FIRST target found is the target that is used, i.e. if the Makefile has: + + a: + echo a + a: + echo a number two + +the command "make a" will echo "a". To make things confusing, the SECOND +variable assignment is the overriding one, i.e. if the Makefile has: + + a= foo + a= bar + + b: + echo ${a} + +the command "make b" will echo "bar". This is for compatibility with the +way the V7 make behaved. + +It's fairly difficult to make the BSD .mk files work when you're building +multiple programs in a single directory. It's a lot easier split up the +programs than to deal with the problem. Most of the agony comes from making +the "obj" directory stuff work right, not because we switch to a new version +of make. So, don't get mad at us, figure out a better way to handle multiple +architectures so we can quit using the symbolic link stuff. (Imake doesn't +count.) + +The file .depend in the source directory is expected to contain dependencies +for the source files. This file is read automatically by make after reading +the Makefile. + +The variable DESTDIR works as before. It's not set anywhere but will change +the tree where the file gets installed. + +The profiled libraries are no longer built in a different directory than +the regular libraries. A new suffix, ".po", is used to denote a profiled +object. + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +The include file <sys.mk> has the default rules for all makes, in the BSD +environment or otherwise. You probably don't want to touch this file. + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +The include file <bsd.man.mk> handles installing manual pages and their +links. + +It has a single target: + + maninstall: + Install the manual pages and their links. + +It sets/uses the following variables: + +MANDIR Base path for manual installation. + +MANGRP Manual group. + +MANOWN Manual owner. + +MANMODE Manual mode. + +MANSUBDIR Subdirectory under the manual page section, i.e. "/vax" + or "/tahoe" for machine specific manual pages. + +MAN The manual pages to be installed (use a .1 - .9 suffix). + +MLINKS List of manual page links (using a .1 - .9 suffix). The + linked-to file must come first, the linked file second, + and there may be multiple pairs. The files are soft-linked. + +The include file <bsd.man.mk> includes a file named "../Makefile.inc" if +it exists. + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +The include file <bsd.own.mk> contains source tree configuration parameters, +such as the owners, groups, etc. for both manual pages and binaries, and +a few global "feature configuration" parameters. + +It has no targets. + +To get system-specific configuration parameters, bsd.own.mk will try to +include the file specified by the "MAKECONF" variable. If MAKECONF is not +set, or no such file exists, the system make configuration file, /etc/mk.conf +is included. These files may define any of the variables described below. + +bsd.own.mk sets the following variables, if they are not already defined +(defaults are in brackets): + +BSDSRCDIR The real path to the system sources, so that 'make obj' + will work correctly. [/usr/src] + +BSDOBJDIR The real path to the system 'obj' tree, so that 'make obj' + will work correctly. [/usr/obj] + +BINGRP Binary group. [bin] + +BINOWN Binary owner. [bin] + +BINMODE Binary mode. [555] + +NONBINMODE Mode for non-executable files. [444] + +MANDIR Base path for manual installation. [/usr/share/man/cat] + +MANGRP Manual group. [bin] + +MANOWN Manual owner. [bin] + +MANMODE Manual mode. [${NONBINMODE}] + +LIBDIR Base path for library installation. [/usr/lib] + +LINTLIBDIR Base path for lint(1) library installation. [/usr/libdata/lint] + +LIBGRP Library group. [${BINGRP}] + +LIBOWN Library owner. [${BINOWN}] + +LIBMODE Library mode. [${NONBINMODE}] + +DOCDIR Base path for system documentation (e.g. PSD, USD, etc.) + installation. [/usr/share/doc] + +DOCGRP Documentation group. [bin] + +DOCOWN Documentation owner. [bin] + +DOCMODE Documentation mode. [${NONBINMODE}] + +NLSDIR Base path for National Language Support files installation. + [/usr/share/nls] + +NLSGRP National Language Support files group. [bin] + +NLSOWN National Language Support files owner. [bin] + +NLSMODE National Language Support files mode. [${NONBINMODE}] + +STRIP The flag passed to the install program to cause the binary + to be stripped. This is to be used when building your + own install script so that the entire system can be made + stripped/not-stripped using a single knob. [-s] + +COPY The flag passed to the install program to cause the binary + to be copied rather than moved. This is to be used when + building our own install script so that the entire system + can either be installed with copies, or with moves using + a single knob. [-c] + +Additionally, the following variables may be set by bsd.own.mk or in a +make configuration file to modify the behaviour of the system build +process (default values are in brackets along with comments, if set by +bsd.own.mk): + +EXPORTABLE_SYSTEM + Do not build /usr/src/domestic, even if it is present. + +SKEY Compile in support for S/key authentication. [yes, set + unconditionally] + +KERBEROS Compile in support for Kerberos 4 authentication. + +KERBEROS5 Compile in support for Kerberos 5 authentication. + +MANZ Compress manual pages at installation time. + +SYS_INCLUDE Copy or symlink kernel include files into /usr/include. + Possible values are "symlinks" or "copies" (which is + the same as the variable being unset). + +NOPROFILE Do not build profiled versions of system libraries + +NOPIC Do not build PIC versions of system libraries, and + do not build shared libraries. [set if ${MACHINE_ARCH} + is "mips", "vax", "alpha" or "arm32", unset otherwise.] + +NOLINT Do not build lint libraries. [set, set unconditionally] + +bsd.own.mk is generally useful when building your own Makefiles so that +they use the same default owners etc. as the rest of the tree. + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +The include file <bsd.prog.mk> handles building programs from one or +more source files, along with their manual pages. It has a limited number +of suffixes, consistent with the current needs of the BSD tree. + +It has eight targets: + + all: + build the program and its manual page + clean: + remove the program, any object files and the files a.out, + Errs, errs, mklog, and core. + cleandir: + remove all of the files removed by the target clean, as + well as .depend, tags, and any manual pages. + depend: + make the dependencies for the source files, and store + them in the file .depend. + includes: + install any header files. + install: + install the program and its manual pages; if the Makefile + does not itself define the target install, the targets + beforeinstall and afterinstall may also be used to cause + actions immediately before and after the install target + is executed. + lint: + run lint on the source files + tags: + create a tags file for the source files. + +It sets/uses the following variables: + +BINGRP Binary group. + +BINOWN Binary owner. + +BINMODE Binary mode. + +CLEANFILES Additional files to remove for the clean and cleandir targets. + +COPTS Additional flags to the compiler when creating C objects. + +HIDEGAME If HIDEGAME is defined, the binary is installed in + /usr/games/hide, and a symbolic link is created to + /usr/games/dm. + +LDADD Additional loader objects. Usually used for libraries. + For example, to load with the compatibility and utility + libraries, use: + + LDADD+=-lutil -lcompat + +LDFLAGS Additional loader flags. + +LINKS The list of binary links; should be full pathnames, the + linked-to file coming first, followed by the linked + file. The files are hard-linked. For example, to link + /bin/test and /bin/[, use: + + LINKS= ${DESTDIR}/bin/test ${DESTDIR}/bin/[ + +MAN Manual pages (should end in .1 - .9). If no MAN variable is + defined, "MAN=${PROG}.1" is assumed. + +PROG The name of the program to build. If not supplied, nothing + is built. + +SRCS List of source files to build the program. If PROG is not + defined, it's assumed to be ${PROG}.c. + +DPADD Additional dependencies for the program. Usually used for + libraries. For example, to depend on the compatibility and + utility libraries use: + + DPADD+=${LIBCOMPAT} ${LIBUTIL} + + The following libraries are predefined for DPADD: + + LIBC /lib/libc.a + LIBCOMPAT /usr/lib/libcompat.a + LIBCRYPT /usr/lib/libcrypt.a + LIBCURSES /usr/lib/libcurses.a + LIBDBM /usr/lib/libdbm.a + LIBDES /usr/lib/libdes.a + LIBL /usr/lib/libl.a + LIBKDB /usr/lib/libkdb.a + LIBKRB /usr/lib/libkrb.a + LIBKVM /usr/lib/libkvm.a + LIBM /usr/lib/libm.a + LIBMP /usr/lib/libmp.a + LIBPC /usr/lib/libpc.a + LIBPLOT /usr/lib/libplot.a + LIBRPC /usr/lib/sunrpc.a + LIBTERM /usr/lib/libterm.a + LIBUTIL /usr/lib/libutil.a + +SHAREDSTRINGS If defined, a new .c.o rule is used that results in shared + strings, using xstr(1). Note that this will not work with + parallel makes. + +STRIP The flag passed to the install program to cause the binary + to be stripped. + +SUBDIR A list of subdirectories that should be built as well. + Each of the targets will execute the same target in the + subdirectories. + +The include file <bsd.prog.mk> includes the file named "../Makefile.inc" +if it exists, as well as the include file <bsd.man.mk>. + +Some simple examples: + +To build foo from foo.c with a manual page foo.1, use: + + PROG= foo + + .include <bsd.prog.mk> + +To build foo from foo.c with a manual page foo.2, add the line: + + MAN= foo.2 + +If foo does not have a manual page at all, add the line: + + NOMAN= noman + +If foo has multiple source files, add the line: + + SRCS= a.c b.c c.c d.c + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +The include file <bsd.subdir.mk> contains the default targets for building +subdirectories. It has the same eight targets as <bsd.prog.mk>: all, +clean, cleandir, depend, includes, install, lint, and tags. For all of +the directories listed in the variable SUBDIRS, the specified directory +will be visited and the target made. There is also a default target which +allows the command "make subdir" where subdir is any directory listed in +the variable SUBDIRS. + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +The include file <bsd.sys.mk> is used by <bsd.prog.mk> and +<bsd.lib.mk>. It contains overrides that are used when building +the NetBSD source tree. For instance, if "PARALLEL" is defined by +the program/library Makefile, it includes a set of rules for lex and +yacc that allow multiple lex and yacc targets to be built in parallel. + +=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= + +The include file <bsd.lib.mk> has support for building libraries. It has +the same eight targets as <bsd.prog.mk>: all, clean, cleandir, depend, +includes, install, lint, and tags. It has a limited number of suffixes, +consistent with the current needs of the BSD tree. + +It sets/uses the following variables: + +LIB The name of the library to build. + +LIBDIR Target directory for libraries. + +LINTLIBDIR Target directory for lint libraries. + +LIBGRP Library group. + +LIBOWN Library owner. + +LIBMODE Library mode. + +LDADD Additional loader objects. + +MAN The manual pages to be installed (use a .1 - .9 suffix). + +SRCS List of source files to build the library. Suffix types + .s, .c, and .f are supported. Note, .s files are preferred + to .c files of the same name. (This is not the default for + versions of make.) + +The include file <bsd.lib.mk> includes the file named "../Makefile.inc" +if it exists, as well as the include file <bsd.man.mk>. + +It has rules for building profiled objects; profiled libraries are +built by default. + +Libraries are ranlib'd when made. diff --git a/devel/bmake/files/mk/auto.dep.mk b/devel/bmake/files/mk/auto.dep.mk new file mode 100644 index 00000000000..d754bab6d38 --- /dev/null +++ b/devel/bmake/files/mk/auto.dep.mk @@ -0,0 +1,74 @@ +# +# RCSid: +# $Id: auto.dep.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 2010, 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 +# + +# This module provides automagic dependency generation along the +# lines suggested in the GNU make.info + +# set MKDEP_MK=auto.dep.mk and dep.mk will include us + +# This version differs from autodep.mk, in that +# we use ${.TARGET:T}.d rather than ${.TARGET:T:R}.d +# this makes it simpler to get the args to -MF and -MT right +# and ensure we can simply include all the .d files. +# +# However suffix rules do not work with something like .o.d so we +# don't even try to handle 'make depend' gracefully. +# dep.mk will handle that itself. +# +.if !target(__${.PARSEFILE}__) +__${.PARSEFILE}__: + +# this what bmake > 20100401 will look for +.MAKE.DEPENDFILE ?= .depend + +# set this to -MMD to ignore /usr/include +# actually it ignores <> so may not be a great idea +CFLAGS_MD ?= -MD +# -MF etc not available on all gcc versions. +CFLAGS_MF ?= -MF ${.TARGET:T}.d -MT ${.TARGET:T} +CFLAGS += ${CFLAGS_MD} ${CFLAGS_MF} +CXXFLAGS += ${CFLAGS_MD} ${CFLAGS_MF} + +CLEANFILES += .depend ${.MAKE.DEPENDFILE} *.d + +.if ${MAKE_VERSION} < 20160218 +# skip generating dependfile for misc targets +.if ${.TARGETS:Uall:M*all} != "" +.END: ${.MAKE.DEPENDFILE} +.endif + +# doing 'make depend' isn't a big win with this model +.if !target(depend) +depend: ${.MAKE.DEPENDFILE} +.endif + +# this is trivial +${.MAKE.DEPENDFILE}: ${OBJS} ${POBJS} ${SOBJS} + -@for f in ${.ALLSRC:M*o:T:O:u:%=%.d}; do \ + echo ".-include \"$$f\""; \ + done > $@ +.else +# we have .dinclude +.if empty(_SKIP_BUILD) +_all_objs = ${OBJS} ${POBJS} ${SOBJS} +.for d in ${_all_objs:M*o:T:O:u:%=%.d} +.dinclude <$d> +.endfor +.endif + +.endif +.endif diff --git a/devel/bmake/files/mk/auto.obj.mk b/devel/bmake/files/mk/auto.obj.mk new file mode 100644 index 00000000000..255d1a520a8 --- /dev/null +++ b/devel/bmake/files/mk/auto.obj.mk @@ -0,0 +1,76 @@ +# $Id: auto.obj.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 2004, 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 +# + +ECHO_TRACE ?= echo + +.ifndef Mkdirs +# A race condition in some versions of mkdir, means that it can bail +# if another process made a dir that mkdir expected to. +# We repeat the mkdir -p a number of times to try and work around this. +# We stop looping as soon as the dir exists. +# If we get to the end of the loop, a plain mkdir will issue an error. +Mkdirs= Mkdirs() { \ + for d in $$*; do \ + for i in 1 2 3 4 5 6; do \ + mkdir -p $$d; \ + test -d $$d && return 0; \ + done > /dev/null 2>&1; \ + mkdir $$d || exit $$?; \ + done; } +.endif + +# if MKOBJDIRS is set to auto (and NOOBJ isn't defined) do some magic... +# This will automatically create objdirs as needed. +# Skip it if we are just doing 'clean'. +.if ${MK_AUTO_OBJ:Uno} == "yes" +MKOBJDIRS= auto +.endif +.if !defined(NOOBJ) && !defined(NO_OBJ) && ${MKOBJDIRS:Uno} == auto +# Use __objdir here so it is easier to tweak without impacting +# the logic. +.if !empty(MAKEOBJDIRPREFIX) +.if ${.CURDIR:M${MAKEOBJDIRPREFIX}/*} != "" +# we are already in obj tree! +__objdir?= ${.CURDIR} +.endif +__objdir?= ${MAKEOBJDIRPREFIX}${.CURDIR} +.endif +__objdir?= ${MAKEOBJDIR:Uobj} +__objdir:= ${__objdir} +.if ${.OBJDIR:tA} != ${__objdir:tA} +# We need to chdir, make the directory if needed +.if !exists(${__objdir}/) && \ + (${.TARGETS} == "" || ${.TARGETS:Nclean*:N*clean:Ndestroy*} != "") +# This will actually make it... +__objdir_made != echo ${__objdir}/; umask ${OBJDIR_UMASK:U002}; \ + ${ECHO_TRACE} "[Creating objdir ${__objdir}...]" >&2; \ + ${Mkdirs}; Mkdirs ${__objdir} +.endif +# This causes make to use the specified directory as .OBJDIR +.OBJDIR: ${__objdir} +.if ${.OBJDIR:tA} != ${__objdir:tA} +# we did not get what we want - do we care? +.if ${__objdir_made:Uno:M${__objdir}/*} != "" +# watch out for __objdir being relative path +.if !(${__objdir:M/*} == "" && ${.OBJDIR:tA} == ${${.CURDIR}/${__objdir}:L:tA}) +.error could not use ${__objdir}: .OBJDIR=${.OBJDIR} +.endif +.endif +# apparently we can live with it +# make sure we know what we have +.OBJDIR: ${.CURDIR} +.endif +.endif +.endif diff --git a/devel/bmake/files/mk/autoconf.mk b/devel/bmake/files/mk/autoconf.mk new file mode 100644 index 00000000000..56111a0313e --- /dev/null +++ b/devel/bmake/files/mk/autoconf.mk @@ -0,0 +1,80 @@ +# $Id: autoconf.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 1996-2009, 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 +# + +.NOPATH: config.h config.status + +CONFIGURE_DEPS += ${.CURDIR}/config.h.in ${.CURDIR}/configure + +.if !target(config.h) +config.h: ${CONFIGURE_DEPS} config.status + ./config.status +.endif + +.if !target(config.status) +# avoid the targets behaving differently +.if exists(${.OBJDIR}/config.status) +config.status: config.recheck +.else +config.status: config.gen +.endif + +config.recheck: ${CONFIGURE_DEPS} + ./config.status --recheck + @touch $@ + +config.gen: ${CONFIGURE_DEPS} + CC="${CC} ${CCMODE}" ${.CURDIR}/configure --no-create ${CONFIGURE_ARGS} + @touch $@ config.recheck + +CLEANFILES+= config.recheck config.gen config.status *.meta +.endif + +# avoid things blowing up if these are not here... +# this is not quite per the autoconf manual, +# and is extremely convoluted - but all utterly necessary! + +.if make(autoconf-in) || make(configure) || make(config.h.in) || ${AUTO_AUTOCONF:Uno:tl} == "yes" +AUTOCONF ?= autoconf +AUTOHEADER ?= autoheader + +# expand it to a full path +AUTOCONF := ${AUTOCONF:${M_whence}} + +.if exists(${AUTOCONF}) + +.PRECIOUS: configure config.h.in config.status + +ACLOCAL = +ACCONFIG = + +.if exists(${.CURDIR}/aclocal.m4) +ACLOCAL += aclocal.m4 +.endif +# use of acconfig.h is deprecated! +.if exists(${.CURDIR}/acconfig.h) +ACCONFIG += acconfig.h +.endif + +config.h.in: ${.CURDIR}/configure.in ${ACCONFIG} + (cd ${.CURDIR} && ${AUTOHEADER}) + +configure: ${.CURDIR}/configure.in ${ACLOCAL} + (cd ${.CURDIR} && ${AUTOCONF}) + +AUTOCONF_INPUTS += configure +autoconf-input: ${AUTOCONF_INPUTS} + +.endif +.endif diff --git a/devel/bmake/files/mk/autodep.mk b/devel/bmake/files/mk/autodep.mk new file mode 100644 index 00000000000..cba90fb5f80 --- /dev/null +++ b/devel/bmake/files/mk/autodep.mk @@ -0,0 +1,219 @@ +# +# RCSid: +# $Id: autodep.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 1999-2010, 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 + +# This module provides automagic dependency generation along the +# lines suggested in the GNU make.info +# The depend target is mainly for backwards compatibility, +# dependencies are normally updated as part of compilation. + +.if !target(__${.PARSEFILE}__) +__${.PARSEFILE}__: + +DEPENDFILE?= .depend +.for d in ${DEPENDFILE:N.depend} +# bmake only groks .depend +.if ${MAKE_VERSION} < 20160218 +.-include <$d> +.else +.dinclude <$d> +.endif +.endfor + +# it does nothing if SRCS is not defined or is empty +.if defined(SRCS) && !empty(SRCS) +DEPSRCS?=${SRCS} +__depsrcs=${DEPSRCS:M*.c} +__depsrcs+=${DEPSRCS:M*.y} +__depsrcs+=${DEPSRCS:M*.l} +__depsrcs+=${DEPSRCS:M*.s} +__depsrcs+=${DEPSRCS:M*.S} +__depsrcs+=${DEPSRCS:M*.cc} +__depsrcs+=${DEPSRCS:M*.cpp} +__depsrcs+=${DEPSRCS:M*.C} +__depsrcs+=${DEPSRCS:M*.cxx} +__depsrcs+=${DEPSRCS:M*.pc} + +.for s in ${__depsrcs} +${s:T:R}.d: $s +.endfor + +__depsrcs:=${__depsrcs:T:R:S/$/.d/g} +# we also need to handle makefiles where the .d's from __depsrcs +# don't match those from OBJS +# we avoid using := here, since the modifier applied to OBJS +# can cause trouble if there are any undefined vars in OBJS. +__dependsrcsx?= ${__depsrcs} ${OBJS:S/.o/.d/} +__dependsrcs= ${__dependsrcsx:O:u} + +# clean up any .c files we may have generated +#__gensrcs:= ${DEPSRCS:M*.y} ${DEPSRCS:M*.l} +#CLEANFILES+= ${__gensrcs:T:R:S/$/.c/g} + +# set this to -MMD to ignore /usr/include +# actually it ignores <> so may not be a great idea +CFLAGS_MD?=-MD +# -MF etc not available on all gcc versions. +# we "fix" the .o later +CFLAGS_MF?=-MF ${.TARGET:T:R}.d -MT ${.TARGET:T:R}.o +CFLAGS+= ${CFLAGS_MD} ${CFLAGS_MF} +RM?= rm +MAKE_SHELL?= sh + +# watch out for people who don't use CPPFLAGS +CPPFLAGS_MD=${CFLAGS:M-[IUD]*} ${CPPFLAGS} +CXXFLAGS_MD=${CXXFLAGS:M-[IUD]*} ${CPPFLAGS} + +# just in case these need to be different +CC_MD?=${CC} +CXX_MD?=${CXX} + +# should have been set by sys.mk +CXX_SUFFIXES?= .cc .cpp .cxx .C + +# so we can do an explicit make depend, but not otherwise +.if make(depend) +.SUFFIXES: .d + +.if empty(CFLAGS_MD) +.y.d: + @echo updating dependencies for $< + @${YACC} ${YFLAGS} $< + @${MAKE_SHELL} -ec "${CC_MD} -M ${CPPFLAGS_MD} y.tab.c | sed '/:/s/^/$@ /' > $@" || { ${RM} -f y.tab.c $@; false; } + @${RM} -f y.tab.c + +.l.d: + @echo updating dependencies for $< + ${LEX} ${LFLAGS} $< + @${MAKE_SHELL} -ec "${CC_MD} -M ${CPPFLAGS_MD} lex.yy.c | sed '/:/s/^/$@ /' > $@" || { ${RM} -f lex.yy.c $@; false; } + @${RM} -f lex.yy.c + +.c.d: + @echo updating dependencies for $< + @${MAKE_SHELL} -ec "${CC_MD} -M ${CPPFLAGS_MD} $< | sed '/:/s/^/$@ /' > $@" || { ${RM} -f $@; false; } + +.s.d .S.d: + @echo updating dependencies for $< + @${MAKE_SHELL} -ec "${CC_MD} -M ${CPPFLAGS_MD} ${AINC} $< | sed '/:/s/^/$@ /' > $@" || { ${RM} -f $@; false; } + +${CXX_SUFFIXES:%=%.d}: + @echo updating dependencies for $< + @${MAKE_SHELL} -ec "${CXX_MD} -M ${CXXFLAGS_MD} $< | sed '/:/s/^/$@ /' > $@" || { ${RM} -f $@; false; } +.else +.y.d: + ${YACC} ${YFLAGS} $< + ${CC_MD} ${CFLAGS_MD:S/D//} ${CPPFLAGS_MD} y.tab.c > $@ || { ${RM} -f y.tab.c $@; false; } + ${RM} -f y.tab.c + +.l.d: + ${LEX} ${LFLAGS} $< + ${CC_MD} ${CFLAGS_MD:S/D//} ${CPPFLAGS_MD} lex.yy.c > $@ || { ${RM} -f lex.yy.c $@; false; } + ${RM} -f lex.yy.c + +.c.d: + ${CC_MD} ${CFLAGS_MD:S/D//} ${CPPFLAGS_MD} $< > $@ || { ${RM} -f $@; false; } + +.s.d .S.d: + ${CC_MD} ${CFLAGS_MD:S/D//} ${CPPFLAGS_MD} ${AINC} $< > $@ || { ${RM} -f $@; false; } + +${CXX_SUFFIXES:%=%.d}: + ${CXX_MD} ${CFLAGS_MD:S/D//} ${CXXFLAGS_MD} $< > $@ || { ${RM} -f $@; false; } +.endif + +.if !target(depend) +depend: beforedepend ${DEPENDFILE} afterdepend _SUBDIRUSE + +${DEPENDFILE}: ${DEPSRCS} ${__dependsrcs} +.NOPATH: ${__dependsrcs} +.OPTIONAL: ${__dependsrcs} +.endif +.endif # make(depend) + +.if empty(CFLAGS_MD) +# make sure the .d's are generated/updated +${PROG} ${_LIBS}: ${DEPENDFILE} +.endif + +.ORDER: beforedepend ${DEPENDFILE} afterdepend + +.if ${.OBJDIR} != ${.CURDIR} +__depfiles= *.d +.else +__depfiles= ${__dependsrcs} +.endif + +DEPCLEANFILES= ${DEPENDFILE} ${__depfiles} y.tab.d *.tmp.d + +cleandir: cleanautodepend +cleanautodepend: + ${RM} -f ${DEPCLEANFILES} + +CLEANFILES+= ${DEPCLEANFILES} + +.if defined(__dependsrcs) && !empty(__dependsrcs) +.if make(depend) || !(make(clean*) || make(destroy*) || make(obj) || make(*install) || make(install-*)) +# this ensures we do the right thing if only building a shared or +# profiled lib +OBJ_EXTENSIONS?=.o .po .so .So +MDLIB_SED= -e '/:/s,^\([^\.:]*\)\.[psS]*o,${OBJ_EXTENSIONS:S,^,\1,},' +.ifdef NOMD_SED +.ifdef LIB +MD_SED=sed ${MDLIB_SED} +.else +MD_SED=cat +.endif +.else +# arrange to put some variable names into ${DEPENDFILE} +.ifdef LIB +MD_SED=sed ${MDLIB_SED} +.else +MD_SED=sed +.endif +SUBST_DEPVARS+= SB TOP BACKING SRC SRCDIR BASE BASEDIR +.for v in ${SUBST_DEPVARS} +.if defined(${v}) && !empty(${v}) +MD_SED+= -e 's,${$v},$${$v},' +.endif +.endfor +.endif +.if (${MD_SED} == "sed") +MD_SED=cat +.endif + +# this will be done whenever make finishes successfully +.if ${MAKE_VERSION:U0:[1]:C/.*-//} < 20050530 +.END: +.else +.END: ${DEPENDFILE} +# we do not want to trigger building .d's just use them if they exist +${DEPENDFILE}: ${__dependsrcs:@d@${exists($d):?$d:}@} +.endif + -@${MD_SED} ${__depfiles} > ${DEPENDFILE}.new 2> /dev/null && \ + test -s ${DEPENDFILE}.new && mv ${DEPENDFILE}.new ${DEPENDFILE}; \ + ${RM} -f ${DEPENDFILE}.new +.endif +.endif +.else +depend: beforedepend afterdepend _SUBDIRUSE +.endif + +.if !target(beforedepend) +beforedepend: +.endif +.if !target(afterdepend) +afterdepend: +.endif + +.endif diff --git a/devel/bmake/files/mk/compiler.mk b/devel/bmake/files/mk/compiler.mk new file mode 100644 index 00000000000..e165844f3a5 --- /dev/null +++ b/devel/bmake/files/mk/compiler.mk @@ -0,0 +1,43 @@ +# $Id: compiler.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 2019, 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 !target(__${.PARSEFILE}__) +__${.PARSEFILE}__: + +.if ${MACHINE} == "common" +COMPILER_TYPE = none +COMPILER_VERSION = 0 +.endif +.if empty(COMPILER_TYPE) || empty(COMPILER_VERSION) +# gcc does not always say gcc +_v != ${CC} --version 2> /dev/null | \ + egrep -i 'clang|cc|[1-9]\.[0-9]|Free Software Foundation' +.if empty(COMPILER_TYPE) +.if ${_v:Mclang} != "" +COMPILER_TYPE = clang +.elif ${_v:M[Gg][Cc][Cc]} != "" || ${_v:MFoundation*} != "" +COMPILER_TYPE = gcc +.endif +.endif +.if empty(COMPILER_VERSION) +COMPILER_VERSION != echo "${_v:M[1-9].[0-9]*}:[1]" | \ + awk -F. '{print $$1 * 10000 + $$2 * 100 + $$3;}' +.endif +.undef _v +.endif +# just in case we don't recognize compiler +COMPILER_TYPE ?= unknown +COMPILER_VERSION ?= 0 +.endif diff --git a/devel/bmake/files/mk/cython.mk b/devel/bmake/files/mk/cython.mk new file mode 100644 index 00000000000..320178c0fa5 --- /dev/null +++ b/devel/bmake/files/mk/cython.mk @@ -0,0 +1,101 @@ +# RCSid: +# $Id: cython.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 2014, 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 +# + +# pyprefix is where python bits are +# which may not be where we want to put ours (prefix) +.if exists(/usr/pkg/include) +pyprefix?= /usr/pkg +.endif +pyprefix?= /usr/local + +PYTHON_VERSION?= 2.7 +PYTHON_H?= ${pyprefix}/include/python${PYTHON_VERSION}/Python.h +PYVERSION:= ${PYTHON_VERSION:C,\..*,,} + +CFLAGS+= -I${PYTHON_H:H} + +# conf.host_target() is limited to uname -m rather than uname -p +_HOST_MACHINE!= uname -m +.if ${HOST_TARGET:M*${_HOST_MACHINE}} == "" +PY_HOST_TARGET:= ${HOST_TARGET:S,${_HOST_ARCH:U${uname -p:L:sh}}$,${_HOST_MACHINE},} +.endif + +COMPILE.c?= ${CC} -c ${CFLAGS} +PICO?= .pico + +.SUFFIXES: ${PICO} .c + +.c${PICO}: + ${COMPILE.c} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET} + +# this is what we build +.if !empty(CYTHON_MODULE_NAME) +CYTHON_MODULE = ${CYTHON_MODULE_NAME}${CYTHON_PYVERSION}.so + +CYTHON_SRCS?= ${CYTHON_MODULE_NAME}.pyx + +# this is where we save generated src +CYTHON_SAVEGENDIR?= ${.CURDIR}/gen + +# set this empty if you don't want to handle multiple versions +.if !defined(CYTHON_PYVERSION) +CYTHON_PYVERSION:= ${PYVERSION} +.endif + +CYTHON_GENSRCS= ${CYTHON_SRCS:R:S,$,${CYTHON_PYVERSION}.c,} +SRCS+= ${CYTHON_GENSRCS} + +.SUFFIXES: .pyx .c .So + +CYTHON?= ${pyprefix}/bin/cython + +# if we don't have cython we can use pre-generated srcs +.if ${type ${CYTHON} 2> /dev/null || echo:L:sh:M/*} == "" +.PATH: ${CYTHON_SAVEGENDIR} +.else + +.if !empty(CYTHON_PYVERSION) +.for c in ${CYTHON_SRCS} +${c:R}${CYTHON_PYVERSION}.${c:E}: $c + ln -sf ${.ALLSRC:M*pyx} ${.TARGET} +.endfor +.endif + +.pyx.c: + ${CYTHON} ${CYTHON_FLAGS} -${PYVERSION} -o ${.TARGET} ${.IMPSRC} + + +save-gen: ${CYTHON_GENSRCS} + mkdir -p ${CYTHON_SAVEGENDIR} + cp -p ${.ALLSRC} ${CYTHON_SAVEGENDIR} + +.endif + +${CYTHON_MODULE}: ${SRCS:S,.c,${PICO},} + ${CC} ${CC_SHARED:U-shared} -o ${.TARGET} ${.ALLSRC:M*${PICO}} ${LDADD} + +MODULE_BINDIR?= ${.CURDIR:H}/${PY_HOST_TARGET:U${HOST_TARGET}} + +build-cython-module: ${CYTHON_MODULE} + +install-cython-module: ${CYTHON_MODULE} + test -d ${DESTDIR}${MODULE_BINDIR} || \ + ${INSTALL} -d ${DESTDIR}${MODULE_BINDIR} + ${INSTALL} -m 755 ${.ALLSRC} ${DESTDIR}${MODULE_BINDIR} + +CLEANFILES+= *${PICO} ${CYTHON_MODULE} + +.endif diff --git a/devel/bmake/files/mk/dep.mk b/devel/bmake/files/mk/dep.mk new file mode 100644 index 00000000000..73c2fd860f7 --- /dev/null +++ b/devel/bmake/files/mk/dep.mk @@ -0,0 +1,127 @@ +# $Id: dep.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ + +.if !target(__${.PARSEFILE}__) +__${.PARSEFILE}__: + +# handle Proc*C as well... +.if defined(SRCS) +.if !empty(SRCS:M*.pc) +.include <proc.mk> +.endif + +# it would be nice to be able to query .SUFFIXES +OBJ_EXTENSIONS+= .o .po .lo .So + +# explicit dependencies help short-circuit .SUFFIX searches +SRCS_DEP_FILTER+= N*.[hly] +.for s in ${SRCS:${SRCS_DEP_FILTER:O:u:ts:}} +.for e in ${OBJ_EXTENSIONS:O:u} +.if !target(${s:T:R}$e) +${s:T:R}$e: $s +.endif +.endfor +.endfor +.endif + +.if exists(/usr/bin/mkdep) +MKDEP_CMD?= mkdep +.elif exists(/usr/local/share/bin/mkdeps.sh) +MKDEP_CMD?= /usr/local/share/bin/mkdeps.sh -N +.endif +MKDEP_CMD?= mkdep + +MKDEP ?= ${MKDEP_CMD} + +.NOPATH: .depend + +.if ${MKDEP_MK:Uno} == "auto.dep.mk" && make(depend) +# auto.dep.mk does not "do" depend +MK_AUTODEP= no +.endif + +.if ${MK_AUTODEP} == yes +MKDEP_MK ?= autodep.mk +.include <${MKDEP_MK}> +.else +MKDEP_ENV_VARS += CC CXX +.for v in ${MKDEP_ENV_VARS:O:u} +.if !empty($v) +MKDEP_ENV += $v='${$v}' +.endif +.endfor + +_MKDEP = ${MKDEP_ENV} ${MKDEP} + +# some of the rules involve .h sources, so remove them from mkdep line +.if !target(depend) +depend: beforedepend .depend _SUBDIRUSE afterdepend + +.if defined(SRCS) +# libs can have too many SRCS for a single command line +# so do them one at a time. +.depend: ${SRCS} ${.PARSEDIR}/${.PASEFILE} + @rm -f .depend +.ifdef LIB + @files="${.ALLSRC:M*.[sS]}"; \ + set -x; for f in $$files; do ${_MKDEP} -a ${MKDEPFLAGS} \ + ${CFLAGS:M-[ID]*} ${CPPFLAGS} ${AINC} $$f; done + @files="${.ALLSRC:M*.c} ${.ALLSRC:M*.pc:T:.pc=.c}"; \ + set -x; for f in $$files; do ${_MKDEP} -a ${MKDEPFLAGS} \ + ${CFLAGS:M-[ID]*} ${CPPFLAGS} $$f; done + @files="${.ALLSRC:M*.cc} ${.ALLSRC:M*.C} ${.ALLSRC:M*.cxx}"; \ + set -x; for f in $$files; do ${_MKDEP} -a ${MKDEPFLAGS} \ + ${CXXFLAGS:M-[ID]*} ${CPPFLAGS} $$f; done +.else + @files="${.ALLSRC:M*.[Ss]}"; \ + case "$$files" in *.[Ss]*) \ + echo ${_MKDEP} -a ${MKDEPFLAGS} \ + ${CFLAGS:M-[ID]*} ${CPPFLAGS} ${AINC} $$files; \ + ${_MKDEP} -a ${MKDEPFLAGS} \ + ${CFLAGS:M-[ID]*} ${CPPFLAGS} ${AINC} $$files;; \ + esac + @files="${.ALLSRC:M*.c} ${.ALLSRC:M*.pc:T:.pc=.c}"; \ + case "$$files" in *.c*) \ + echo ${_MKDEP} -a ${MKDEPFLAGS} \ + ${CFLAGS:M-[ID]*} ${CPPFLAGS} $$files; \ + ${_MKDEP} -a ${MKDEPFLAGS} \ + ${CFLAGS:M-[ID]*} ${CPPFLAGS} $$files;; \ + esac + @files="${.ALLSRC:M*.cc} ${.ALLSRC:M*.C} ${.ALLSRC:M*.cxx}"; \ + case "$$files" in *.[Cc]*) \ + echo ${_MKDEP} -a ${MKDEPFLAGS} \ + ${CXXFLAGS:M-[ID]*} ${CPPFLAGS} $$files; \ + ${_MKDEP} -a ${MKDEPFLAGS} \ + ${CXXFLAGS:M-[ID]*} ${CPPFLAGS} $$files;; \ + esac +.endif +.else +.depend: +.endif +.if !target(beforedepend) +beforedepend: +.endif +.if !target(afterdepend) +afterdepend: +.endif +.endif +.endif + +.if !target(tags) +.if defined(SRCS) +tags: ${SRCS} _SUBDIRUSE + -cd ${.CURDIR}; ctags -f /dev/stdout ${.ALLSRC:N*.h} | \ + sed "s;\${.CURDIR}/;;" > tags +.else +tags: +.endif +.endif + +.if defined(SRCS) +cleandir: cleandepend +.if !target(cleandepend) +cleandepend: + rm -f .depend ${.CURDIR}/tags +.endif +.endif + +.endif diff --git a/devel/bmake/files/mk/dirdeps-options.mk b/devel/bmake/files/mk/dirdeps-options.mk new file mode 100644 index 00000000000..c4933fc753f --- /dev/null +++ b/devel/bmake/files/mk/dirdeps-options.mk @@ -0,0 +1,73 @@ +# $Id: dirdeps-options.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 2018, 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 +# + +## +# +# This makefile is used to deal with optional DIRDEPS. +# +# It is to be included by Makefile.depend.options in a +# directory which has DIRDEPS affected by optional features. +# Makefile.depend.options should set DIRDEPS_OPTIONS and +# may also set specific DIRDEPS.* for those options. +# +# If a Makefile.depend.options file exists, it will be included by +# dirdeps.mk and meta.autodep.mk +# +# We include local.dirdeps-options.mk which may also define DIRDEPS.* +# for options. +# +# Thus a directory, that is affected by an option FOO would have +# a Makefile.depend.options that sets +# DIRDEPS_OPTIONS= FOO +# It can also set either/both of +# DIRDEPS.FOO.yes +# DIRDEPS.FOO.no +# to whatever applies for that dir, or it can rely on globals +# set in local.dirdeps-options.mk +# Either way, we will .undef DIRDEPS.* when done. + +# This should have been set by Makefile.depend.options +# before including us +DIRDEPS_OPTIONS ?= + +# pickup any DIRDEPS.* we need +.-include <local.dirdeps-options.mk> + +.if ${.MAKE.LEVEL} == 0 +# :U below avoids potential errors when we := +.for o in ${DIRDEPS_OPTIONS:tu} +DIRDEPS += ${DIRDEPS.$o.${MK_$o:U}:U} +.endfor +DIRDEPS := ${DIRDEPS:O:u} +# avoid cross contamination +.for o in ${DIRDEPS_OPTIONS:tu} +.undef DIRDEPS.$o.yes +.undef DIRDEPS.$o.no +.endfor +.else +# whether options are enabled or not, +# we want to filter out the relevant DIRDEPS.* +# we should only be included by meta.autodep.mk +# if dependencies are to be updated +.for o in ${DIRDEPS_OPTIONS:tu} +.for d in ${DIRDEPS.$o.yes} ${DIRDEPS.$o.no} +.if exists(${SRCTOP}/$d) +GENDIRDEPS_FILTER += N$d* +.elif exists(${SRCTOP}/${d:R}) +GENDIRDEPS_FILTER += N${d:R}* +.endif +.endfor +.endfor +.endif diff --git a/devel/bmake/files/mk/dirdeps-targets.mk b/devel/bmake/files/mk/dirdeps-targets.mk new file mode 100644 index 00000000000..2bdb9511b59 --- /dev/null +++ b/devel/bmake/files/mk/dirdeps-targets.mk @@ -0,0 +1,133 @@ +# RCSid: +# $Id: dirdeps-targets.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 2019 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 +# + +## +# This makefile is used to set initial DIRDEPS for top-level build +# targets. +# +# The basic idea is that we have a list of directories in +# DIRDEPS_TARGETS_DIRS which are relative to SRCTOP. +# When asked to make 'foo' we look for any directory named 'foo' +# under DIRDEPS_TARGETS_DIRS. +# We then search those dirs for any Makefile.depend* +# Finally we select any that match conditions like REQUESTED_MACHINE +# or TARGET_SPEC and initialize DIRDEPS accordingly. +# + +.if ${.MAKE.LEVEL} == 0 +# pickup customizations +.-include <local.dirdeps-targets.mk> + +# for DIRDEPS_BUILD this is how we prime the pump +DIRDEPS_TARGETS_DIRS ?= targets targets/pseudo +# these prefixes can modify how we behave +# they need to be stripped when looking for target dirs +DIRDEPS_TARGETS_PREFIX_LIST ?= pkg- build- + +# matching target dirs if any +tdirs := ${.TARGETS:Nall:${DIRDEPS_TARGETS_PREFIX_LIST:@p@S,^$p,,@:ts:}:@t@${DIRDEPS_TARGETS_DIRS:@d@$d/$t@}@:@d@${exists(${SRCTOP}/$d):?$d:}@} + +.if !empty(DEBUG_DIRDEPS_TARGETS) +.info tdirs=${tdirs} +.endif + +.if !empty(tdirs) +# some things we know we want to ignore +DIRDEPS_TARGETS_SKIP_LIST += \ + *~ \ + *.bak \ + *.inc \ + *.old \ + *.options \ + *.orig \ + *.rej \ + +# the list of MACHINEs we consider +DIRDEPS_TARGETS_MACHINE_LIST += \ + ${ALL_MACHINE_LIST:U} \ + ${PSEUDO_MACHINE_LIST:Ucommon host host32} \ + ${TARGET_MACHINE_LIST} + +DIRDEPS_TARGETS_MACHINE_LIST := ${DIRDEPS_TARGETS_MACHINE_LIST:O:u} + +# raw Makefile.depend* list +tdeps != 'cd' ${SRCTOP} && 'ls' -1 ${tdirs:O:u:@d@$d/${.MAKE.DEPENDFILE_PREFIX}*@} 2> /dev/null; echo +.if ${DEBUG_DIRDEPS_TARGETS:U:Mdep*} != "" +.info tdeps=${tdeps} +.endif +# remove things we know we don't want +tdeps := ${tdeps:${DIRDEPS_TARGETS_SKIP_LIST:${M_ListToSkip}}} +.if ${DEBUG_DIRDEPS_TARGETS:U:Mdep*} != "" +.info tdeps=${tdeps} +.endif + +# plain entries (no qualifiers) these apply to any TARGET_SPEC +ptdeps := ${tdeps:M*${.MAKE.DEPENDFILE_PREFIX}:S,/${.MAKE.DEPENDFILE_PREFIX},,} + +# MACHINE qualified entries +mqtdeps := ${DIRDEPS_TARGETS_MACHINE_LIST:@m@${tdeps:M*.$m}@:S,/${.MAKE.DEPENDFILE_PREFIX},,} + +tqtdeps = +.if ${TARGET_SPEC_VARS:[#]} > 1 +# TARGET_SPEC qualified entries +.if !empty(TARGET_SPEC_LIST) +# we have a list of valid TARGET_SPECS; use it +tqtdeps := ${TARGET_SPEC_LIST:U:O:u:@t@${tdeps:M*.$t}@:S,/${.MAKE.DEPENDFILE_PREFIX},,} +.else +# do we have a list of valid tuple members for at least +# the last tupple element? if so match on that +TARGET_SPEC_LAST_LIST ?= ${${TARGET_SPEC_VARS:[-1]}_LIST} +.if !empty(TARGET_SPEC_LAST_LIST) +tqtdeps := ${TARGET_SPEC_LAST_LIST:U:O:u:@t@${tdeps:M*,$t}@:S,/${.MAKE.DEPENDFILE_PREFIX},,} +.else +# this is sub-optimal match MACHINE, +tqtdeps := ${DIRDEPS_TARGETS_MACHINE_LIST:@m@${tdeps:M*.$m,*}@:S,/${.MAKE.DEPENDFILE_PREFIX},,} +.endif +.endif +.endif + +# now work out what we want in DIRDEPS +.if empty(REQUESTED_MACHINE) +# we want them all just as found +DIRDEPS = ${ptdeps} ${mqtdeps} ${tqtdeps} +.else +# we only want those that match REQUESTED_MACHINE/REQUESTED_TARGET_SPEC +# or REQUESTED_TARGET_SPEC (TARGET_SPEC) +DIRDEPS = \ + ${ptdeps:@d@$d.${REQUESTED_TARGET_SPEC:U${TARGET_SPEC:U${REQUESTED_MACHINE}}}@} \ + ${mqtdeps:M*.${REQUESTED_MACHINE}} \ + ${tqtdeps:M*.${REQUESTED_TARGET_SPEC:U${TARGET_SPEC}}} +.endif +# clean up +DIRDEPS := ${DIRDEPS:O:u} + +.if !empty(DEBUG_DIRDEPS_TARGETS) +.for x in tdeps ptdeps mqtdeps tqtdeps DIRDEPS +.info $x=${$x} +.endfor +.endif +.endif +# if we got DIRDEPS get to work +.if !empty(DIRDEPS) +.include <dirdeps.mk> + +DIRDEPS_TARGETS_SKIP += all clean* destroy* + +.for t in ${.TARGETS:${DIRDEPS_TARGETS_SKIP:${M_ListToSkip}}} +$t: dirdeps +.endfor +.endif +.endif diff --git a/devel/bmake/files/mk/dirdeps.mk b/devel/bmake/files/mk/dirdeps.mk new file mode 100644 index 00000000000..d352c5f55b7 --- /dev/null +++ b/devel/bmake/files/mk/dirdeps.mk @@ -0,0 +1,834 @@ +# $Id: dirdeps.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ + +# Copyright (c) 2010-2020, Simon J. Gerraty +# Copyright (c) 2010-2018, Juniper Networks, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# Much of the complexity here is for supporting cross-building. +# If a tree does not support that, simply using plain Makefile.depend +# should provide sufficient clue. +# Otherwise the recommendation is to use Makefile.depend.${MACHINE} +# as expected below. + +# Note: this file gets multiply included. +# This is what we do with DIRDEPS + +# DIRDEPS: +# This is a list of directories - relative to SRCTOP, it is +# normally only of interest to .MAKE.LEVEL 0. +# In some cases the entry may be qualified with a .<machine> +# or .<target_spec> suffix (see TARGET_SPEC_VARS below), +# for example to force building something for the pseudo +# machines "host" or "common" regardless of current ${MACHINE}. +# +# All unqualified entries end up being qualified with .${TARGET_SPEC} +# and partially qualified (if TARGET_SPEC_VARS has multiple +# entries) are also expanded to a full .<target_spec>. +# The _DIRDEP_USE target uses the suffix to set TARGET_SPEC +# correctly when visiting each entry. +# +# The fully qualified directory entries are used to construct a +# dependency graph that will drive the build later. +# +# Also, for each fully qualified directory target, we will search +# using ${.MAKE.DEPENDFILE_PREFERENCE} to find additional +# dependencies. We use Makefile.depend (default value for +# .MAKE.DEPENDFILE_PREFIX) to refer to these makefiles to +# distinguish them from others. +# +# Before each Makefile.depend file is read, we set +# DEP_RELDIR to be the RELDIR (path relative to SRCTOP) for +# its directory, and DEP_MACHINE etc according to the .<target_spec> +# represented by the suffix of the corresponding target. +# +# Since each Makefile.depend file includes dirdeps.mk, this +# processing is recursive and results in .MAKE.LEVEL 0 learning the +# dependencies of the tree wrt the initial directory (_DEP_RELDIR). +# +# BUILD_AT_LEVEL0 +# Indicates whether .MAKE.LEVEL 0 builds anything: +# if "no" sub-makes are used to build everything, +# if "yes" sub-makes are only used to build for other machines. +# It is best to use "no", but this can require fixing some +# makefiles to not do anything at .MAKE.LEVEL 0. +# +# TARGET_SPEC_VARS +# The default value is just MACHINE, and for most environments +# this is sufficient. The _DIRDEP_USE target actually sets +# both MACHINE and TARGET_SPEC to the suffix of the current +# target so that in the general case TARGET_SPEC can be ignored. +# +# If more than MACHINE is needed then sys.mk needs to decompose +# TARGET_SPEC and set the relevant variables accordingly. +# It is important that MACHINE be included in and actually be +# the first member of TARGET_SPEC_VARS. This allows other +# variables to be considered optional, and some of the treatment +# below relies on MACHINE being the first entry. +# Note: TARGET_SPEC cannot contain any '.'s so the target +# triple used by compiler folk won't work (directly anyway). +# +# For example: +# +# # Always list MACHINE first, +# # other variables might be optional. +# TARGET_SPEC_VARS = MACHINE TARGET_OS +# .if ${TARGET_SPEC:Uno:M*,*} != "" +# _tspec := ${TARGET_SPEC:S/,/ /g} +# MACHINE := ${_tspec:[1]} +# TARGET_OS := ${_tspec:[2]} +# # etc. +# # We need to stop that TARGET_SPEC affecting any submakes +# # and deal with MACHINE=${TARGET_SPEC} in the environment. +# TARGET_SPEC = +# # export but do not track +# .export-env TARGET_SPEC +# .export ${TARGET_SPEC_VARS} +# .for v in ${TARGET_SPEC_VARS:O:u} +# .if empty($v) +# .undef $v +# .endif +# .endfor +# .endif +# # make sure we know what TARGET_SPEC is +# # as we may need it to find Makefile.depend* +# TARGET_SPEC = ${TARGET_SPEC_VARS:@v@${$v:U}@:ts,} +# +# The following variables can influence the initial DIRDEPS +# computation with regard to the TARGET_SPECs that will be +# built. +# Most should also be considered by init.mk +# +# ONLY_TARGET_SPEC_LIST +# Defines a list of TARGET_SPECs for which the current +# directory can be built. +# If ALL_MACHINES is defined, we build for all the +# TARGET_SPECs listed. +# +# ONLY_MACHINE_LIST +# As for ONLY_TARGET_SPEC_LIST but only specifies +# MACHINEs. +# +# NOT_TARGET_SPEC_LIST +# A list of TARGET_SPECs for which the current +# directory should not be built. +# +# NOT_MACHINE_LIST +# A list of MACHINEs the current directory should not be +# built for. +# + +.if !target(bootstrap) && (make(bootstrap) || \ + make(bootstrap-this) || \ + make(bootstrap-recurse) || \ + make(bootstrap-empty)) +# disable most of below +.MAKE.LEVEL = 1 +.endif + +# touch this at your peril +_DIRDEP_USE_LEVEL?= 0 +.if ${.MAKE.LEVEL} == ${_DIRDEP_USE_LEVEL} +# only the first instance is interested in all this + +.if !target(_DIRDEP_USE) + +# do some setup we only need once +_CURDIR ?= ${.CURDIR} +_OBJDIR ?= ${.OBJDIR} + +now_utc = ${%s:L:gmtime} +.if !defined(start_utc) +start_utc := ${now_utc} +.endif + +.if ${MAKEFILE:T} == ${.PARSEFILE} && empty(DIRDEPS) && ${.TARGETS:Uall:M*/*} != "" +# This little trick let's us do +# +# mk -f dirdeps.mk some/dir.${TARGET_SPEC} +# +all: +${.TARGETS:Nall}: all +DIRDEPS := ${.TARGETS:M*[/.]*} +# so that -DNO_DIRDEPS works +DEP_RELDIR := ${DIRDEPS:[1]:R} +# this will become DEP_MACHINE below +TARGET_MACHINE := ${DIRDEPS:[1]:E:C/,.*//} +.if ${TARGET_MACHINE:N*/*} == "" +TARGET_MACHINE := ${MACHINE} +.endif +# disable DIRDEPS_CACHE as it does not like this trick +MK_DIRDEPS_CACHE = no +.endif + +# make sure we get the behavior we expect +.MAKE.SAVE_DOLLARS = no + +# make sure these are empty to start with +_DEP_TARGET_SPEC = + +# If TARGET_SPEC_VARS is other than just MACHINE +# it should be set by sys.mk or similar by now. +# TARGET_SPEC must not contain any '.'s. +TARGET_SPEC_VARS ?= MACHINE +# this is what we started with +TARGET_SPEC = ${TARGET_SPEC_VARS:@v@${$v:U}@:ts,} +# this is what we mostly use below +DEP_TARGET_SPEC = ${TARGET_SPEC_VARS:S,^,DEP_,:@v@${$v:U}@:ts,} +# make sure we have defaults +.for v in ${TARGET_SPEC_VARS} +DEP_$v ?= ${$v} +.endfor + +.if ${TARGET_SPEC_VARS:[#]} > 1 +# Ok, this gets more complex (putting it mildly). +# In order to stay sane, we need to ensure that all the build_dirs +# we compute below are fully qualified wrt DEP_TARGET_SPEC. +# The makefiles may only partially specify (eg. MACHINE only), +# so we need to construct a set of modifiers to fill in the gaps. +.if ${MAKE_VERSION} >= 20170130 +_tspec_x := ${TARGET_SPEC_VARS:range} +.elif ${TARGET_SPEC_VARS:[#]} > 10 +# seriously? better have jot(1) or equivalent to produce suitable sequence +_tspec_x := ${${JOT:Ujot} ${TARGET_SPEC_VARS:[#]}:L:sh} +.else +# we can provide the sequence ourselves +_tspec_x := ${1 2 3 4 5 6 7 8 9 10:L:[1..${TARGET_SPEC_VARS:[#]}]} +.endif +# this handles unqualified entries +M_dep_qual_fixes = C;(/[^/.,]+)$$;\1.$${DEP_TARGET_SPEC}; +# there needs to be at least one item missing for these to make sense +.for i in ${_tspec_x:[2..-1]} +_tspec_m$i := ${TARGET_SPEC_VARS:[2..$i]:@w@[^,]+@:ts,} +_tspec_a$i := ,${TARGET_SPEC_VARS:[$i..-1]:@v@$$$${DEP_$v}@:ts,} +M_dep_qual_fixes += C;(\.${_tspec_m$i})$$;\1${_tspec_a$i}; +.endfor +.else +# A harmless? default. +M_dep_qual_fixes = U +.endif + +.if !defined(.MAKE.DEPENDFILE_PREFERENCE) +# .MAKE.DEPENDFILE_PREFERENCE makes the logic below neater? +# you really want this set by sys.mk or similar +.MAKE.DEPENDFILE_PREFERENCE = ${_CURDIR}/${.MAKE.DEPENDFILE:T} +.if ${.MAKE.DEPENDFILE:E} == "${TARGET_SPEC}" +.if ${TARGET_SPEC} != ${MACHINE} +.MAKE.DEPENDFILE_PREFERENCE += ${_CURDIR}/${.MAKE.DEPENDFILE:T:R}.$${MACHINE} +.endif +.MAKE.DEPENDFILE_PREFERENCE += ${_CURDIR}/${.MAKE.DEPENDFILE:T:R} +.endif +.endif + +_default_dependfile := ${.MAKE.DEPENDFILE_PREFERENCE:[1]:T} +_machine_dependfiles := ${.MAKE.DEPENDFILE_PREFERENCE:T:M*${MACHINE}*} + +# for machine specific dependfiles we require ${MACHINE} to be at the end +# also for the sake of sanity we require a common prefix +.if !defined(.MAKE.DEPENDFILE_PREFIX) +# knowing .MAKE.DEPENDFILE_PREFIX helps +.if !empty(_machine_dependfiles) +.MAKE.DEPENDFILE_PREFIX := ${_machine_dependfiles:[1]:T:R} +.else +.MAKE.DEPENDFILE_PREFIX := ${_default_dependfile:T} +.endif +.endif + + +# this is how we identify non-machine specific dependfiles +N_notmachine := ${.MAKE.DEPENDFILE_PREFERENCE:E:N*${MACHINE}*:${M_ListToSkip}} + +.endif # !target(_DIRDEP_USE) + +# First off, we want to know what ${MACHINE} to build for. +# This can be complicated if we are using a mixture of ${MACHINE} specific +# and non-specific Makefile.depend* + +# if we were included recursively _DEP_TARGET_SPEC should be valid. +.if empty(_DEP_TARGET_SPEC) +# we may or may not have included a dependfile yet +.if defined(.INCLUDEDFROMFILE) +_last_dependfile := ${.INCLUDEDFROMFILE:M${.MAKE.DEPENDFILE_PREFIX}*} +.else +_last_dependfile := ${.MAKE.MAKEFILES:M*/${.MAKE.DEPENDFILE_PREFIX}*:[-1]} +.endif +.if ${_debug_reldir:U0} +.info ${DEP_RELDIR}.${DEP_TARGET_SPEC}: _last_dependfile='${_last_dependfile}' +.endif + +.if empty(_last_dependfile) || ${_last_dependfile:E:${N_notmachine}} == "" +# this is all we have to work with +DEP_MACHINE = ${TARGET_MACHINE:U${MACHINE}} +_DEP_TARGET_SPEC := ${DEP_TARGET_SPEC} +.else +_DEP_TARGET_SPEC = ${_last_dependfile:${M_dep_qual_fixes:ts:}:E} +.endif +.if !empty(_last_dependfile) +# record that we've read dependfile for this +_dirdeps_checked.${_CURDIR}.${TARGET_SPEC}: +.endif +.endif + +# by now _DEP_TARGET_SPEC should be set, parse it. +.if ${TARGET_SPEC_VARS:[#]} > 1 +# we need to parse DEP_MACHINE may or may not contain more info +_tspec := ${_DEP_TARGET_SPEC:S/,/ /g} +.for i in ${_tspec_x} +DEP_${TARGET_SPEC_VARS:[$i]} := ${_tspec:[$i]} +.endfor +.for v in ${TARGET_SPEC_VARS:O:u} +.if empty(DEP_$v) +.undef DEP_$v +.endif +.endfor +.else +DEP_MACHINE := ${_DEP_TARGET_SPEC} +.endif + +# reset each time through +_build_all_dirs = + +# the first time we are included the _DIRDEP_USE target will not be defined +# we can use this as a clue to do initialization and other one time things. +.if !target(_DIRDEP_USE) +# make sure this target exists +dirdeps: beforedirdeps .WAIT +beforedirdeps: + +# We normally expect to be included by Makefile.depend.* +# which sets the DEP_* macros below. +DEP_RELDIR ?= ${RELDIR} + +# this can cause lots of output! +# set to a set of glob expressions that might match RELDIR +DEBUG_DIRDEPS ?= no + +# remember the initial value of DEP_RELDIR - we test for it below. +_DEP_RELDIR := ${DEP_RELDIR} + +.endif + +# DIRDEPS_CACHE can be very handy for debugging. +# Also if repeatedly building the same target, +# we can avoid the overhead of re-computing the tree dependencies. +MK_DIRDEPS_CACHE ?= no +BUILD_DIRDEPS_CACHE ?= no +BUILD_DIRDEPS ?= yes + +.if ${MK_DIRDEPS_CACHE} == "yes" +# this is where we will cache all our work +DIRDEPS_CACHE ?= ${_OBJDIR:tA}/dirdeps.cache${.TARGETS:Nall:O:u:ts-:S,/,_,g:S,^,.,:N.} +.endif + +.if ${DEBUG_DIRDEPS:@x@${DEP_RELDIR:M$x}${${DEP_RELDIR}.${DEP_MACHINE}:L:M$x}@} != "" +_debug_reldir = 1 +.else +_debug_reldir = 0 +.endif +.if ${DEBUG_DIRDEPS:@x@${DEP_RELDIR:M$x}${${DEP_RELDIR}.depend:L:M$x}@} != "" +_debug_search = 1 +.else +_debug_search = 0 +.endif + +# pickup customizations +# as below you can use !target(_DIRDEP_USE) to protect things +# which should only be done once. +.-include <local.dirdeps.mk> + +.if !target(_DIRDEP_USE) +# things we skip for host tools +SKIP_HOSTDIR ?= + +NSkipHostDir = ${SKIP_HOSTDIR:N*.host*:S,$,.host*,:N.host*:S,^,${SRCTOP}/,:${M_ListToSkip}} + +# things we always skip +# SKIP_DIRDEPS allows for adding entries on command line. +SKIP_DIR += .host *.WAIT ${SKIP_DIRDEPS} +SKIP_DIR.host += ${SKIP_HOSTDIR} + +DEP_SKIP_DIR = ${SKIP_DIR} \ + ${SKIP_DIR.${DEP_TARGET_SPEC}:U} \ + ${TARGET_SPEC_VARS:@v@${SKIP_DIR.${DEP_$v}:U}@} \ + ${SKIP_DIRDEPS.${DEP_TARGET_SPEC}:U} \ + ${TARGET_SPEC_VARS:@v@${SKIP_DIRDEPS.${DEP_$v}:U}@} + + +NSkipDir = ${DEP_SKIP_DIR:${M_ListToSkip}} + +.if defined(NODIRDEPS) || defined(WITHOUT_DIRDEPS) +NO_DIRDEPS = +.elif defined(WITHOUT_DIRDEPS_BELOW) +NO_DIRDEPS_BELOW = +.endif + +.if defined(NO_DIRDEPS) +# confine ourselves to the original dir and below. +DIRDEPS_FILTER += M${_DEP_RELDIR}* +.elif defined(NO_DIRDEPS_BELOW) +DIRDEPS_FILTER += M${_DEP_RELDIR} +.endif + +# this is what we run below +DIRDEP_MAKE ?= ${.MAKE} +DIRDEP_DIR ?= ${.TARGET:R} + +# we suppress SUBDIR when visiting the leaves +# we assume sys.mk will set MACHINE_ARCH +# you can add extras to DIRDEP_USE_ENV +# if there is no makefile in the target directory, we skip it. +_DIRDEP_USE: .USE .MAKE + @for m in ${.MAKE.MAKEFILE_PREFERENCE}; do \ + test -s ${.TARGET:R}/$$m || continue; \ + echo "${TRACER}Checking ${.TARGET:R} for ${.TARGET:E} ..."; \ + ${DIRDEP_USE_PRELUDE} \ + MACHINE_ARCH= NO_SUBDIR=1 ${DIRDEP_USE_ENV} \ + TARGET_SPEC=${.TARGET:E} \ + MACHINE=${.TARGET:E} \ + ${DIRDEP_MAKE} -C ${DIRDEP_DIR} || exit 1; \ + break; \ + done + +.ifdef ALL_MACHINES +# this is how you limit it to only the machines we have been built for +# previously. +.if empty(ONLY_TARGET_SPEC_LIST) && empty(ONLY_MACHINE_LIST) +.if !empty(ALL_MACHINE_LIST) +# ALL_MACHINE_LIST is the list of all legal machines - ignore anything else +_machine_list != cd ${_CURDIR} && 'ls' -1 ${ALL_MACHINE_LIST:O:u:@m@${.MAKE.DEPENDFILE:T:R}.$m@} 2> /dev/null; echo +.else +_machine_list != 'ls' -1 ${_CURDIR}/${.MAKE.DEPENDFILE_PREFIX}.* 2> /dev/null; echo +.endif +_only_machines := ${_machine_list:${NIgnoreFiles:UN*.bak}:E:O:u} +.else +_only_machines := ${ONLY_TARGET_SPEC_LIST:U} ${ONLY_MACHINE_LIST:U} +.endif + +.if empty(_only_machines) +# we must be boot-strapping +_only_machines := ${TARGET_MACHINE:U${ALL_MACHINE_LIST:U${DEP_MACHINE}}} +.endif + +.else # ! ALL_MACHINES +# if ONLY_TARGET_SPEC_LIST or ONLY_MACHINE_LIST is set, we are limited to that. +# Note that ONLY_TARGET_SPEC_LIST should be fully qualified. +# if TARGET_MACHINE is set - it is really the same as ONLY_MACHINE_LIST +# otherwise DEP_MACHINE is it - so DEP_MACHINE will match. +_only_machines := ${ONLY_TARGET_SPEC_LIST:U:M${DEP_MACHINE},*} +.if empty(_only_machines) +_only_machines := ${ONLY_MACHINE_LIST:U${TARGET_MACHINE:U${DEP_MACHINE}}:M${DEP_MACHINE}} +.endif +.endif + +.if !empty(NOT_MACHINE_LIST) +_only_machines := ${_only_machines:${NOT_MACHINE_LIST:${M_ListToSkip}}} +.endif +.if !empty(NOT_TARGET_SPEC_LIST) +# we must first qualify +_dm := ${DEP_MACHINE} +_only_machines := ${_only_machines:M*,*} ${_only_machines:N*,*:@DEP_MACHINE@${DEP_TARGET_SPEC}@:S,^,.,:${M_dep_qual_fixes:ts:}:O:u:S,^.,,} +DEP_MACHINE := ${_dm} +_only_machines := ${_only_machines:${NOT_TARGET_SPEC_LIST:${M_ListToSkip}}} +.endif +# clean up +_only_machines := ${_only_machines:O:u} + +# make sure we have a starting place? +DIRDEPS ?= ${RELDIR} +.endif # target + +.if !defined(NO_DIRDEPS) && !defined(NO_DIRDEPS_BELOW) +.if ${MK_DIRDEPS_CACHE} == "yes" + +# just ensure this exists +build-dirdeps: + +M_oneperline = @x@\\${.newline} $$x@ + +.if ${BUILD_DIRDEPS_CACHE} == "no" +.if !target(dirdeps-cached) +# we do this via sub-make +BUILD_DIRDEPS = no + +# ignore anything but these +.MAKE.META.IGNORE_FILTER = M*/${.MAKE.DEPENDFILE_PREFIX}* + +dirdeps: dirdeps-cached +dirdeps-cached: ${DIRDEPS_CACHE} .MAKE + @echo "${TRACER}Using ${DIRDEPS_CACHE}" + @MAKELEVEL=${.MAKE.LEVEL} ${.MAKE} -C ${_CURDIR} -f ${DIRDEPS_CACHE} \ + dirdeps MK_DIRDEPS_CACHE=no BUILD_DIRDEPS=no + +# these should generally do +BUILD_DIRDEPS_MAKEFILE ?= ${MAKEFILE} +BUILD_DIRDEPS_TARGETS ?= ${.TARGETS} + +# we need the .meta file to ensure we update if +# any of the Makefile.depend* changed. +# We do not want to compare the command line though. +${DIRDEPS_CACHE}: .META .NOMETA_CMP + +@{ echo '# Autogenerated - do NOT edit!'; echo; \ + echo 'BUILD_DIRDEPS=no'; echo; \ + echo '.include <dirdeps.mk>'; echo; \ + } > ${.TARGET}.new + +@MAKELEVEL=${.MAKE.LEVEL} DIRDEPS_CACHE=${DIRDEPS_CACHE} \ + DIRDEPS="${DIRDEPS}" \ + TARGET_SPEC=${TARGET_SPEC} \ + MAKEFLAGS= ${.MAKE} -C ${_CURDIR} -f ${BUILD_DIRDEPS_MAKEFILE} \ + ${BUILD_DIRDEPS_TARGETS} BUILD_DIRDEPS_CACHE=yes \ + .MAKE.DEPENDFILE=.none \ + ${.MAKEFLAGS:tW:S,-D ,-D,g:tw:M*WITH*} \ + ${.MAKEFLAGS:tW:S,-d ,-d,g:tw:M-d*} \ + 3>&1 1>&2 | sed 's,${SRCTOP},$${SRCTOP},g' >> ${.TARGET}.new && \ + mv ${.TARGET}.new ${.TARGET} + +.endif +.elif !target(_count_dirdeps) +# we want to capture the dirdeps count in the cache +.END: _count_dirdeps +_count_dirdeps: .NOMETA + @echo '.info $${.newline}$${TRACER}Makefiles read: total=${.MAKE.MAKEFILES:[#]} depend=${.MAKE.MAKEFILES:M*depend*:[#]} dirdeps=${.ALLTARGETS:M${SRCTOP}*:O:u:[#]}' >&3 + +.endif +.elif !make(dirdeps) && !target(_count_dirdeps) +beforedirdeps: _count_dirdeps +_count_dirdeps: .NOMETA + @echo "${TRACER}Makefiles read: total=${.MAKE.MAKEFILES:[#]} depend=${.MAKE.MAKEFILES:M*depend*:[#]} dirdeps=${.ALLTARGETS:M${SRCTOP}*:O:u:[#]} seconds=`expr ${now_utc} - ${start_utc}`" + +.endif +.endif + +.if ${BUILD_DIRDEPS} == "yes" + +# the rest is done repeatedly for every Makefile.depend we read. +# if we are anything but the original dir we care only about the +# machine type we were included for.. + +.if ${DEP_RELDIR} == "." +_this_dir := ${SRCTOP} +.else +_this_dir := ${SRCTOP}/${DEP_RELDIR} +.endif + +# on rare occasions, there can be a need for extra help +_dep_hack := ${_this_dir}/${.MAKE.DEPENDFILE_PREFIX}.inc +.-include <${_dep_hack}> +.-include <${_dep_hack:R}.options> + +.if ${DEP_RELDIR} != ${_DEP_RELDIR} || ${DEP_TARGET_SPEC} != ${TARGET_SPEC} +# this should be all +_machines := ${DEP_MACHINE} +.else +# this is the machine list we actually use below +_machines := ${_only_machines} + +.if defined(HOSTPROG) || ${DEP_MACHINE:Nhost*} == "" +# we need to build this guy's dependencies for host as well. +.if ${DEP_MACHINE:Nhost*} == "" +_machines += ${DEP_MACHINE} +.else +_machines += host +.endif +.endif + +_machines := ${_machines:O:u} +.endif + +.if ${TARGET_SPEC_VARS:[#]} > 1 +# we need to tweak _machines +_dm := ${DEP_MACHINE} +# apply the same filtering that we do when qualifying DIRDEPS. +# M_dep_qual_fixes expects .${MACHINE}* so add (and remove) '.' +# Again we expect that any already qualified machines are fully qualified. +_machines := ${_machines:M*,*} ${_machines:N*,*:@DEP_MACHINE@${DEP_TARGET_SPEC}@:S,^,.,:${M_dep_qual_fixes:ts:}:O:u:S,^.,,} +DEP_MACHINE := ${_dm} +_machines := ${_machines:O:u} +.endif + +# reset each time through +_build_dirs = + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# pickup other machines for this dir if necessary +.if ${BUILD_AT_LEVEL0:Uyes} == "no" +_build_dirs += ${_machines:@m@${_CURDIR}.$m@} +.else +_build_dirs += ${_machines:N${DEP_TARGET_SPEC}:@m@${_CURDIR}.$m@} +.if ${DEP_TARGET_SPEC} == ${TARGET_SPEC} +# pickup local dependencies now +.if ${MAKE_VERSION} < 20160220 +.-include <.depend> +.else +.dinclude <.depend> +.endif +.endif +.endif +.endif + +.if ${_debug_reldir} +.info ${DEP_RELDIR}.${DEP_TARGET_SPEC}: DIRDEPS='${DIRDEPS}' +.info ${DEP_RELDIR}.${DEP_TARGET_SPEC}: _machines='${_machines}' +.endif + +.if !empty(DIRDEPS) +# these we reset each time through as they can depend on DEP_MACHINE +DEP_DIRDEPS_FILTER = \ + ${DIRDEPS_FILTER.${DEP_TARGET_SPEC}:U} \ + ${TARGET_SPEC_VARS:@v@${DIRDEPS_FILTER.${DEP_$v}:U}@} \ + ${DIRDEPS_FILTER:U} +.if empty(DEP_DIRDEPS_FILTER) +# something harmless +DEP_DIRDEPS_FILTER = U +.endif + +# this is what we start with +__depdirs := ${DIRDEPS:${NSkipDir}:${DEP_DIRDEPS_FILTER:ts:}:C,//+,/,g:O:u:@d@${SRCTOP}/$d@} + +# some entries may be qualified with .<machine> +# the :M*/*/*.* just tries to limit the dirs we check to likely ones. +# the ${d:E:M*/*} ensures we don't consider junos/usr.sbin/mgd +__qual_depdirs := ${__depdirs:M*/*/*.*:@d@${exists($d):?:${"${d:E:M*/*}":?:${exists(${d:R}):?$d:}}}@} +__unqual_depdirs := ${__depdirs:${__qual_depdirs:Uno:${M_ListToSkip}}} + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# if it was called out - we likely need it. +__hostdpadd := ${DPADD:U.:M${HOST_OBJTOP}/*:S,${HOST_OBJTOP}/,,:H:${NSkipDir}:${DIRDEPS_FILTER:ts:}:S,$,.host,:N.*:@d@${SRCTOP}/$d@} \ + ${DPADD:U.:M${HOST_OBJTOP32:Uno}/*:S,${HOST_OBJTOP32:Uno}/,,:H:${NSkipDir}:${DIRDEPS_FILTER:ts:}:S,$,.host32,:N.*:@d@${SRCTOP}/$d@} +__qual_depdirs += ${__hostdpadd} +.endif + +.if ${_debug_reldir} +.info depdirs=${__depdirs} +.info qualified=${__qual_depdirs} +.info unqualified=${__unqual_depdirs} +.endif + +# _build_dirs is what we will feed to _DIRDEP_USE +_build_dirs += \ + ${__qual_depdirs:M*.host:${NSkipHostDir}:N.host} \ + ${__qual_depdirs:N*.host} \ + ${_machines:Mhost*:@m@${__unqual_depdirs:@d@$d.$m@}@:${NSkipHostDir}:N.host} \ + ${_machines:Nhost*:@m@${__unqual_depdirs:@d@$d.$m@}@} + +# qualify everything now +_build_dirs := ${_build_dirs:${M_dep_qual_fixes:ts:}:O:u} + +.endif # empty DIRDEPS + +_build_all_dirs += ${_build_dirs} +_build_all_dirs := ${_build_all_dirs:O:u} + +# Normally if doing make -V something, +# we do not want to waste time chasing DIRDEPS +# but if we want to count the number of Makefile.depend* read, we do. +.if ${.MAKEFLAGS:M-V${_V_READ_DIRDEPS}} == "" +.if !empty(_build_all_dirs) +.if ${BUILD_DIRDEPS_CACHE} == "yes" +# guard against _build_all_dirs being too big for a single command line +# first get list of dirs that need _DIRDEP_USE +# then export that and _build_all_dirs +_new_dirdeps := ${_build_all_dirs:@x@${target($x):?:$x}@} +.export _new_dirdeps _build_all_dirs +x!= echo; { echo '\# ${DEP_RELDIR}.${DEP_TARGET_SPEC}'; \ + echo "dirdeps: \\"; \ + for x in $$_build_all_dirs; do echo " $$x \\"; done; echo; \ + for x in $$_new_dirdeps; do echo "$$x: _DIRDEP_USE"; done; echo; } >&3 +.if !empty(DEP_EXPORT_VARS) +# Discouraged, but there are always exceptions. +# Handle it here rather than explain how. +x!= { echo; ${DEP_EXPORT_VARS:@v@echo '$v=${$v}';@} echo '.export ${DEP_EXPORT_VARS}'; echo; } >&3; echo +.endif +.else +# this makes it all happen +dirdeps: ${_build_all_dirs} +.endif +${_build_all_dirs}: _DIRDEP_USE + +.if ${_debug_reldir} +.info ${DEP_RELDIR}.${DEP_TARGET_SPEC}: needs: ${_build_dirs} +.endif + +.if !empty(DEP_EXPORT_VARS) +.export ${DEP_EXPORT_VARS} +DEP_EXPORT_VARS= +.endif + +# this builds the dependency graph +.for m in ${_machines} +# it would be nice to do :N${.TARGET} +.if !empty(__qual_depdirs) +.for q in ${__qual_depdirs:${M_dep_qual_fixes:ts:}:E:O:u:N$m} +.if ${_debug_reldir} || ${DEBUG_DIRDEPS:@x@${${DEP_RELDIR}.$m:L:M$x}${${DEP_RELDIR}.$q:L:M$x}@} != "" +.info ${DEP_RELDIR}.$m: graph: ${_build_dirs:M*.$q} +.endif +.if ${BUILD_DIRDEPS_CACHE} == "yes" +_cache_deps := ${_build_dirs:M*.$q} +.export _cache_deps +x!= echo; { echo "${_this_dir}.$m: \\"; \ + for x in $$_cache_deps; do echo " $$x \\"; done; echo; } >&3 +.else +${_this_dir}.$m: ${_build_dirs:M*.$q} +.endif +.endfor +.endif +.if ${_debug_reldir} +.info ${DEP_RELDIR}.$m: graph: ${_build_dirs:M*.$m:N${_this_dir}.$m} +.endif +.if ${BUILD_DIRDEPS_CACHE} == "yes" +_cache_deps := ${_build_dirs:M*.$m:N${_this_dir}.$m} +.export _cache_deps +x!= echo; { echo "${_this_dir}.$m: \\"; \ + for x in $$_cache_deps; do echo " $$x \\"; done; echo; } >&3 +.else +${_this_dir}.$m: ${_build_dirs:M*.$m:N${_this_dir}.$m} +.endif +.endfor + +.endif + +# Now find more dependencies - and recurse. +.for d in ${_build_all_dirs} +.if !target(_dirdeps_checked.$d) +# once only +_dirdeps_checked.$d: +.if ${_debug_search} +.info checking $d +.endif +# Note: _build_all_dirs is fully qualifed so d:R is always the directory +.if exists(${d:R}) +# we pass _DEP_TARGET_SPEC to tell the next step what we want +_DEP_TARGET_SPEC := ${d:E} +# some makefiles may still look at this +_DEP_MACHINE := ${d:E:C/,.*//} +# set these too in case Makefile.depend* uses them +.if ${TARGET_SPEC_VARS:[#]} > 1 +_dtspec := ${_DEP_TARGET_SPEC:S/,/ /g} +.for i in ${_tspec_x} +DEP_${TARGET_SPEC_VARS:[$i]} := ${_dtspec:[$i]} +.endfor +.else +DEP_MACHINE := ${_DEP_MACHINE} +.endif +# Warning: there is an assumption here that MACHINE is always +# the first entry in TARGET_SPEC_VARS. +# If TARGET_SPEC and MACHINE are insufficient, you have a problem. +_m := ${.MAKE.DEPENDFILE_PREFERENCE:T:S;${TARGET_SPEC}$;${d:E};:S;${MACHINE};${d:E:C/,.*//};:@m@${exists(${d:R}/$m):?${d:R}/$m:}@:[1]} +.if !empty(_m) +# M_dep_qual_fixes isn't geared to Makefile.depend +_qm := ${_m:C;(\.depend)$;\1.${d:E};:${M_dep_qual_fixes:ts:}} +.if ${_debug_search} +.info Looking for ${_qm} +.endif +# set this "just in case" +# we can skip :tA since we computed the path above +DEP_RELDIR := ${_m:H:S,${SRCTOP}/,,} +# and reset this +DIRDEPS = +.if ${_debug_reldir} && ${_qm} != ${_m} +.info loading ${_m} for ${d:E} +.endif +.include <${_m}> +.else +.-include <local.dirdeps-missing.mk> +.endif +.endif +.endif +.endfor + +.endif # -V +.endif # BUILD_DIRDEPS + +.elif ${.MAKE.LEVEL} > 42 +.error You should have stopped recursing by now. +.else +# we are building something +DEP_RELDIR := ${RELDIR} +_DEP_RELDIR := ${RELDIR} +# Since we are/should be included by .MAKE.DEPENDFILE +# This is a final opportunity to add/hook global rules. +.-include <local.dirdeps-build.mk> + +# pickup local dependencies +.if ${MAKE_VERSION} < 20160220 +.-include <.depend> +.else +.dinclude <.depend> +.endif +.endif + +# bootstrapping new dependencies made easy? +.if !target(bootstrap) && (make(bootstrap) || \ + make(bootstrap-this) || \ + make(bootstrap-recurse) || \ + make(bootstrap-empty)) + +# if we are bootstrapping create the default +_want = ${.CURDIR}/${.MAKE.DEPENDFILE_DEFAULT:T} + +.if exists(${_want}) +# stop here +${.TARGETS:Mboot*}: +.elif !make(bootstrap-empty) +# find a Makefile.depend to use as _src +_src != cd ${.CURDIR} && for m in ${.MAKE.DEPENDFILE_PREFERENCE:T:S,${MACHINE},*,}; do test -s $$m || continue; echo $$m; break; done; echo +.if empty(_src) +.error cannot find any of ${.MAKE.DEPENDFILE_PREFERENCE:T}${.newline}Use: bootstrap-empty +.endif + +_src?= ${.MAKE.DEPENDFILE} + +.MAKE.DEPENDFILE_BOOTSTRAP_SED+= -e 's/${_src:E:C/,.*//}/${MACHINE}/g' + +# just create Makefile.depend* for this dir +bootstrap-this: .NOTMAIN + @echo Bootstrapping ${RELDIR}/${_want:T} from ${_src:T}; \ + echo You need to build ${RELDIR} to correctly populate it. +.if ${_src:T} != ${.MAKE.DEPENDFILE_PREFIX:T} + (cd ${.CURDIR} && sed ${.MAKE.DEPENDFILE_BOOTSTRAP_SED} ${_src} > ${_want:T}) +.else + cp ${.CURDIR}/${_src:T} ${_want} +.endif + +# create Makefile.depend* for this dir and its dependencies +bootstrap: bootstrap-recurse +bootstrap-recurse: bootstrap-this + +_mf := ${.PARSEFILE} +bootstrap-recurse: .NOTMAIN .MAKE + @cd ${SRCTOP} && \ + for d in `cd ${RELDIR} && ${.MAKE} -B -f ${"${.MAKEFLAGS:M-n}":?${_src}:${.MAKE.DEPENDFILE:T}} -V DIRDEPS`; do \ + test -d $$d || d=$${d%.*}; \ + test -d $$d || continue; \ + echo "Checking $$d for bootstrap ..."; \ + (cd $$d && ${.MAKE} -f ${_mf} bootstrap-recurse); \ + done + +.endif + +# create an empty Makefile.depend* to get the ball rolling. +bootstrap-empty: .NOTMAIN .NOMETA + @echo Creating empty ${RELDIR}/${_want:T}; \ + echo You need to build ${RELDIR} to correctly populate it. + @{ echo DIRDEPS=; echo ".include <dirdeps.mk>"; } > ${_want} + +.endif diff --git a/devel/bmake/files/mk/doc.mk b/devel/bmake/files/mk/doc.mk new file mode 100644 index 00000000000..6981beee748 --- /dev/null +++ b/devel/bmake/files/mk/doc.mk @@ -0,0 +1,64 @@ +# $Id: doc.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ + +.if !target(__${.PARSEFILE}__) +__${.PARSEFILE}__: + +.include <init.mk> + +BIB?= bib +EQN?= eqn +GREMLIN?= grn +GRIND?= vgrind -f +INDXBIB?= indxbib +PIC?= pic +REFER?= refer +ROFF?= groff -M/usr/share/tmac ${MACROS} ${PAGES} +SOELIM?= soelim +TBL?= tbl + +.PATH: ${.CURDIR} + +.if !defined(_SKIP_BUILD) +realbuild: paper.ps +.endif + +.if !target(paper.ps) +paper.ps: ${SRCS} + ${ROFF} ${SRCS} > ${.TARGET} +.endif + +.if !target(print) +print: paper.ps + lpr -P${PRINTER} paper.ps +.endif + +.if !target(manpages) +manpages: +.endif + +.if !target(obj) +obj: +.endif + +clean cleandir: + rm -f paper.* [eE]rrs mklog ${CLEANFILES} + +.if ${MK_DOC} == "no" +install: +.else +FILES?= ${SRCS} +install: + test -d ${DESTDIR}${DOCDIR}/${DIR} || \ + ${INSTALL} -d ${DOC_INSTALL_OWN} -m ${DIRMODE} ${DESTDIR}${DOCDIR}/${DIR} + ${INSTALL} ${COPY} ${DOC_INSTALL_OWN} -m ${DOCMODE} \ + Makefile ${FILES} ${EXTRA} ${DESTDIR}${DOCDIR}/${DIR} +.endif + +spell: ${SRCS} + spell ${SRCS} | sort | comm -23 - spell.ok > paper.spell + +.if !empty(DOCOWN) +DOC_INSTALL_OWN?= -o ${DOCOWN} -g ${DOCGRP} +.endif + +.endif diff --git a/devel/bmake/files/mk/dpadd.mk b/devel/bmake/files/mk/dpadd.mk new file mode 100644 index 00000000000..cb67bf1827f --- /dev/null +++ b/devel/bmake/files/mk/dpadd.mk @@ -0,0 +1,339 @@ +# $Id: dpadd.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 2004, 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 +# + +## +# DESCRIPTION: +# This makefile manages a number of variables that simplify +# dealing with libs in a build. +# +# Primary inputs are DPLIBS, DPADD and SRC_LIBS: +# +# DPLIBS +# List of LIB* that we will actually link with +# should be in correct link order. +# DPLIBS is a short-cut to ensure that DPADD and LDADD are +# kept in sync. +# +# DPADD List of LIB* that should already be built. +# +# SRC_LIBS +# List of LIB* that we want headers from, we do *not* +# require that such libs have been built. +# +# The above all get added to DPMAGIC_LIBS which is what we +# process. +# +# We expect LIB* to be set to absolute path of a library - +# suitable for putting in DPADD. +# eg. +# +# LIBC ?= ${OBJTOP}/lib/libc/libc.a +# +# From such a path we can derrive a number of other variables +# for which we can supply sensible default values. +# We name all these variables for the basename of the library +# (libc in our example above -- ${__lib:T:R} in below): +# +# LDADD_${__lib:T:R}: +# What should be added to LDADD (eg -lc) +# +# OBJ_${__lib:T:R}: +# This is trivial - just the dirname of the built library. +# +# SRC_${__lib:T:R}: +# Where the src for ${__lib} is, if LIB* is set as above +# we can simply substitute ${SRCTOP} for ${OBJTOP} in +# the dirname. +# +# INCLUDES_${__lib:T:R}: +# What should be added to CFLAGS +# +# If the directory ${SRC_${__lib:T:R}}/h exists we will +# only add -I${SRC_${__lib:T:R}}/h on the basis that +# this is where the public api is kept. +# +# Otherwise default will be -I${OBJ_${__lib:T:R}} +# -I${SRC_${__lib:T:R}} +# +# Note much of the above is skipped for staged libs +# eg. +# LIBC ?= ${STAGE_OBJTOP}/usr/lib/libc.a +# +# Since we can safely assume that -I${STAGE_OBJTOP}/usr/include +# and -L${STAGE_OBJTOP}/usr/lib are sufficient, and we should +# have no need of anything else. +# + +.if !target(__${.PARSEFILE}__) +__${.PARSEFILE}__: + +# sometimes we play games with .CURDIR etc +# _* hold the original values of .* +_OBJDIR?= ${.OBJDIR} +_CURDIR?= ${.CURDIR} + +.if ${_CURDIR} == ${SRCTOP} +RELDIR=. +RELTOP=. +.else +RELDIR?= ${_CURDIR:S,${SRCTOP}/,,} +.if ${RELDIR} == ${_CURDIR} +RELDIR?= ${_OBJDIR:S,${OBJTOP}/,,} +.endif +RELTOP?= ${RELDIR:C,[^/]+,..,g} +.endif +RELOBJTOP?= ${OBJTOP} +RELSRCTOP?= ${SRCTOP} + +# we get included just about everywhere so this is handy... +# C*DEBUG_XTRA are for defining on cmd line etc +# so do not use in makefiles. +.ifdef CFLAGS_DEBUG_XTRA +CFLAGS_LAST += ${CFLAGS_DEBUG_XTRA} +.endif +.ifdef CXXFLAGS_DEBUG_XTRA +CXXFLAGS_LAST += ${CXXFLAGS_DEBUG_XTRA} +.endif + +.-include <local.dpadd.mk> + +# DPLIBS helps us ensure we keep DPADD and LDADD in sync +DPLIBS+= ${DPLIBS_LAST} +DPADD+= ${DPLIBS:N-*} +.for __lib in ${DPLIBS} +.if "${__lib:M-*}" != "" +LDADD += ${__lib} +.else +LDADD += ${LDADD_${__lib:T:R}:U${__lib:T:R:S/lib/-l/:C/\.so.*//}} +.endif +.endfor + +# DPADD can contain things other than libs +__dpadd_libs := ${DPADD:M*/lib*} + +.if defined(PROG) && ${MK_PROG_LDORDER_MK:Uno} != "no" +# some libs have dependencies... +# DPLIBS_* allows bsd.libnames.mk to flag libs which must be included +# in DPADD for a given library. +# Gather all such dependencies into __ldadd_all_xtras +# dups will be dealt with later. +# Note: libfoo_pic uses DPLIBS_libfoo +__ldadd_all_xtras= +.for __lib in ${__dpadd_libs:@d@${DPLIBS_${d:T:R:S,_pic,,}}@} +__ldadd_all_xtras+= ${LDADD_${__lib}:U${__lib:T:R:S/lib/-l/:C/\.so.*//}} +.if "${DPADD:M${__lib}}" == "" +DPADD+= ${__lib} +.endif +.endfor +.endif +# Last of all... for libc and libgcc +DPADD+= ${DPADD_LAST} + +# de-dupuplicate __ldadd_all_xtras into __ldadd_xtras +# in reverse order so that libs end up listed after all that needed them. +__ldadd_xtras= +.for __lib in ${__ldadd_all_xtras:[-1..1]} +.if "${__ldadd_xtras:M${__lib}}" == "" || ${NEED_IMPLICIT_LDADD:tl:Uno} != "no" +__ldadd_xtras+= ${__lib} +.endif +.endfor + +.if !empty(__ldadd_xtras) +# now back to the original order +__ldadd_xtras:= ${__ldadd_xtras:[-1..1]} +LDADD+= ${__ldadd_xtras} +.endif + +# Convert DPADD into -I and -L options and add them to CPPFLAGS and LDADD +# For the -I's convert the path to a relative one. For separate objdirs +# the DPADD paths will be to the obj tree so we need to subst anyway. + +# update this +__dpadd_libs := ${DPADD:M*/lib*} + +# Order -L's to search ours first. +# Avoids picking up old versions already installed. +__dpadd_libdirs := ${__dpadd_libs:R:H:S/^/-L/g:O:u:N-L} +LDADD += ${__dpadd_libdirs:M-L${OBJTOP}/*} +LDADD += ${__dpadd_libdirs:N-L${OBJTOP}/*:N-L${HOST_LIBDIR:U/usr/lib}} +.if defined(HOST_LIBDIR) && ${HOST_LIBDIR} != "/usr/lib" +LDADD+= -L${HOST_LIBDIR} +.endif + +.if !make(dpadd) +.ifdef LIB +# Each lib is its own src_lib, we want to include it in SRC_LIBS +# so that the correct INCLUDES_* will be picked up automatically. +SRC_LIBS+= ${_OBJDIR}/lib${LIB}.a +.endif +.endif + +# +# This little bit of magic, assumes that SRC_libfoo will be +# set if it cannot be correctly derrived from ${LIBFOO} +# Note that SRC_libfoo and INCLUDES_libfoo should be named for the +# actual library name not the variable name that might refer to it. +# 99% of the time the two are the same, but the DPADD logic +# only has the library name available, so stick to that. +# + +SRC_LIBS?= +# magic_libs includes those we want to link with +# as well as those we might look at +__dpadd_magic_libs += ${__dpadd_libs} ${SRC_LIBS} +DPMAGIC_LIBS += ${__dpadd_magic_libs} \ + ${__dpadd_magic_libs:@d@${DPMAGIC_LIBS_${d:T:R}}@} + +# we skip this for staged libs +.for __lib in ${DPMAGIC_LIBS:O:u:N${STAGE_OBJTOP:Unot}*/lib/*} +# +# if SRC_libfoo is not set, then we assume that the srcdir corresponding +# to where we found the library is correct. +# +SRC_${__lib:T:R} ?= ${__lib:H:S,${OBJTOP},${RELSRCTOP},} +# +# This is a no-brainer but just to be complete... +# +OBJ_${__lib:T:R} ?= ${__lib:H:S,${OBJTOP},${RELOBJTOP},} +# +# If INCLUDES_libfoo is not set, then we'll use ${SRC_libfoo}/h if it exists, +# else just ${SRC_libfoo}. +# +INCLUDES_${__lib:T:R}?= -I${exists(${SRC_${__lib:T:R}}/h):?${SRC_${__lib:T:R}}/h:${SRC_${__lib:T:R}}} + +.endfor + +# even for staged libs we sometimes +# need to allow direct -I to avoid cicular dependencies +.for __lib in ${DPMAGIC_LIBS:O:u:T:R} +.if !empty(SRC_${__lib}) && empty(INCLUDES_${__lib}) +# must be a staged lib +.if exists(${SRC_${__lib}}/h) +INCLUDES_${__lib} = -I${SRC_${__lib}}/h +.else +INCLUDES_${__lib} = -I${SRC_${__lib}} +.endif +.endif +.endfor + +# when linking a shared lib, avoid non pic libs +SHLDADD+= ${LDADD:N-[lL]*} +.for __lib in ${__dpadd_libs:u} +.if defined(SHLIB_NAME) && ${LDADD:M-l${__lib:T:R:S,lib,,}} != "" +.if ${__lib:T:N*_pic.a:N*.so} == "" || exists(${__lib:R}.so) +SHLDADD+= -l${__lib:T:R:S,lib,,} +.elif exists(${__lib:R}_pic.a) +SHLDADD+= -l${__lib:T:R:S,lib,,}_pic +.else +.warning ${RELDIR}.${TARGET_SPEC} needs ${__lib:T:R}_pic.a +SHLDADD+= -l${__lib:T:R:S,lib,,} +.endif +SHLDADD+= -L${__lib:H} +.endif +.endfor + +# Now for the bits we actually need +__dpadd_incs= +.for __lib in ${__dpadd_libs:u} +.if (make(${PROG}_p) || defined(NEED_GPROF)) && exists(${__lib:R}_p.a) +__ldadd=-l${__lib:T:R:S,lib,,} +LDADD := ${LDADD:S,^${__ldadd}$,${__ldadd}_p,g} +.endif +.endfor + +# +# We take care of duplicate suppression later. +# don't apply :T:R too early +__dpadd_incs += ${__dpadd_magic_libs:u:@x@${INCLUDES_${x:T:R}}@} +__dpadd_incs += ${__dpadd_magic_libs:O:u:@s@${SRC_LIBS_${s:T:R}:U}@:@x@${INCLUDES_${x:T:R}}@} + +__dpadd_last_incs += ${__dpadd_magic_libs:u:@x@${INCLUDES_LAST_${x:T:R}}@} +__dpadd_last_incs += ${__dpadd_magic_libs:O:u:@s@${SRC_LIBS_${s:T:R}:U}@:@x@${INCLUDES_LAST_${x:T:R}}@} + +.if defined(HOSTPROG) || ${MACHINE:Nhost*} == "" +# we want any -I/usr/* last +__dpadd_last_incs := \ + ${__dpadd_last_incs:N-I/usr/*} \ + ${__dpadd_incs:M-I/usr/*} \ + ${__dpadd_last_incs:M-I/usr/*} +__dpadd_incs := ${__dpadd_incs:N-I/usr/*} +.endif + +# +# eliminate any duplicates - but don't mess with the order +# force evaluation now - to avoid giving make a headache +# +.for t in CFLAGS CXXFLAGS +# avoid duplicates +__$t_incs:=${$t:M-I*:O:u} +.for i in ${__dpadd_incs} +.if "${__$t_incs:M$i}" == "" +$t+= $i +__$t_incs+= $i +.endif +.endfor +.endfor + +.for t in CFLAGS_LAST CXXFLAGS_LAST +# avoid duplicates +__$t_incs:=${$t:M-I*:u} +.for i in ${__dpadd_last_incs} +.if "${__$t_incs:M$i}" == "" +$t+= $i +__$t_incs+= $i +.endif +.endfor +.endfor + +# This target is used to gather a list of +# dir: ${DPADD} +# entries +.if make(*dpadd*) +.if !target(dpadd) +dpadd: .NOTMAIN +.if defined(DPADD) && ${DPADD} != "" + @echo "${RELDIR}: ${DPADD:S,${OBJTOP}/,,}" +.endif +.endif +.endif + +.ifdef SRC_PATHADD +# We don't want to assume that we need to .PATH every element of +# SRC_LIBS, but the Makefile cannot do +# .PATH: ${SRC_libfoo} +# since the value of SRC_libfoo must be available at the time .PATH: +# is read - and we only just worked it out. +# Further, they can't wait until after include of {lib,prog}.mk as +# the .PATH is needed before then. +# So we let the Makefile do +# SRC_PATHADD+= ${SRC_libfoo} +# and we defer the .PATH: until now so that SRC_libfoo will be available. +.PATH: ${SRC_PATHADD} +.endif + +# after all that, if doing -n we don't care +.if ${.MAKEFLAGS:Ux:M-n} != "" +DPADD = +.elif ${.MAKE.MODE:Mmeta*} != "" && exists(${.MAKE.DEPENDFILE}) +DPADD_CLEAR_DPADD ?= yes +.if ${DPADD_CLEAR_DPADD} == "yes" +# save this +__dpadd_libs := ${__dpadd_libs} +# we have made what use of it we can of DPADD +DPADD = +.endif +.endif + +.endif diff --git a/devel/bmake/files/mk/files.mk b/devel/bmake/files/mk/files.mk new file mode 100644 index 00000000000..af86c7f10f5 --- /dev/null +++ b/devel/bmake/files/mk/files.mk @@ -0,0 +1,83 @@ +# $Id: files.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 2017, 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 +# + +.include <init.mk> + +FILES_INSTALL_OWN ?= -o ${SHAREOWN} -g ${SHAREGRP} +FILESMODE ?= ${SHAREMODE} +FILES_COPY ?= -C + +FILESGROUPS ?= FILES +FILESGROUPS := ${FILESGROUPS:O:u} + +.if !target(buildfiles) +.for group in ${FILESGROUPS} +buildfiles: ${${group}} +.endfor +.endif +buildfiles: +realbuild: buildfiles + +# there is no default FILESDIR so +# ignore group if ${group}DIR is not defined +.for group in ${FILESGROUPS} +.if !empty(${group}) && defined(${group}DIR) +.if ${group} != "FILES" +${group}_INSTALL_OWN ?= ${FILES_INSTALL_OWN} +.endif +# incase we are staging +STAGE_DIR.${group} ?= ${STAGE_OBJTOP}${${group}DIR} + +.for file in ${${group}:O:u} +${group}_INSTALL_OWN.${file:T} ?= ${${group}_INSTALL_OWN} +${group}DIR.${file:T} ?= ${${group}DIR} +file_mkdir_list += ${${group}DIR.${file:T}} + +.if defined(${group}NAME.${file:T}) +STAGE_AS_SETS += ${group} +STAGE_AS_${file} = ${${group}NAME.${file:T}} +stage_as.${group}: ${file} + +installfiles: installfiles.${group}.${file:T} +installfiles.${group}.${file:T}: ${file} file_mkdirs + ${INSTALL} ${FILES_COPY} ${${group}_INSTALL_OWN.${file:T}} \ + -m ${FILESMODE} ${.ALLSRC:Nfile_mkdirs} ${DESTDIR}${${group}DIR}/${${group}NAME.${file:T}} + +.else +STAGE_SETS += ${group} +stage_files.${group}: ${file} +installfiles.${group}: ${file} +installfiles: installfiles.${group} +.endif + +.endfor # file + +installfiles.${group}: file_mkdirs + ${INSTALL} ${FILES_COPY} ${${group}_INSTALL_OWN} -m ${FILESMODE} \ + ${.ALLSRC:Nfile_mkdirs:O:u} ${DESTDIR}${${group}DIR} + +.endif # !empty +.endfor # group + +file_mkdirs: + @for d in ${file_mkdir_list:O:u}; do \ + test -d ${DESTDIR}$$d || \ + ${INSTALL} -d ${FILES_INSTALL_OWN} -m 775 ${DESTDIR}$$d; \ + done + +beforeinstall: +installfiles: +realinstall: installfiles +.ORDER: beforeinstall installfiles diff --git a/devel/bmake/files/mk/final.mk b/devel/bmake/files/mk/final.mk new file mode 100644 index 00000000000..6180a94296f --- /dev/null +++ b/devel/bmake/files/mk/final.mk @@ -0,0 +1,22 @@ +# $Id: final.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ + +.if !target(__${.PARSEFILE}__) +__${.PARSEFILE}__: + +# provide a hook for folk who want to do scary stuff +.-include <${.CURDIR:H}/Makefile-final.inc> + +.-include <local.final.mk> + +.if ${MK_STAGING} == "yes" +.include <meta.stage.mk> +.elif !empty(STAGE) +.-include <stage.mk> +.endif + +.if empty(_SKIP_BUILD) +install: realinstall +.endif +realinstall: + +.endif diff --git a/devel/bmake/files/mk/gendirdeps.mk b/devel/bmake/files/mk/gendirdeps.mk new file mode 100644 index 00000000000..e028b2dca17 --- /dev/null +++ b/devel/bmake/files/mk/gendirdeps.mk @@ -0,0 +1,383 @@ +# $Id: gendirdeps.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ + +# Copyright (c) 2011-2020, Simon J. Gerraty +# Copyright (c) 2010-2018, Juniper Networks, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +# +# This makefile [re]generates ${.MAKE.DEPENDFILE} +# + +.include <install-new.mk> + +# Assumptions: +# RELDIR is the relative path from ${SRCTOP} to ${_CURDIR} +# (SRCTOP is ${SB}/src) +# _CURDIR is the absolute version of ${.CURDIR} +# _OBJDIR is the absolute version of ${.OBJDIR} +# _objroot is realpath of ${_OBJTOP} without ${MACHINE} +# this may be different from _OBJROOT if $SB/obj is a +# symlink to another filesystem. +# _objroot must be a prefix match for _objtop + +.MAIN: all + +# keep this simple +.MAKE.MODE = compat + +all: + +_CURDIR ?= ${.CURDIR} +_OBJDIR ?= ${.OBJDIR} +_OBJTOP ?= ${OBJTOP} +_OBJROOT ?= ${OBJROOT:U${_OBJTOP}} +.if ${_OBJROOT:M*/} +_slash=/ +.else +_slash= +.endif +_objroot ?= ${_OBJROOT:tA}${_slash} + +_this = ${.PARSEDIR}/${.PARSEFILE} + +# remember what to make +_DEPENDFILE := ${_CURDIR}/${.MAKE.DEPENDFILE:T} + +# We do _not_ want to read our own output! +.MAKE.DEPENDFILE = /dev/null + +# caller should have set this +META_FILES ?= ${.MAKE.META.FILES} + +.if !empty(META_FILES) + +.if ${.MAKE.LEVEL} > 0 && !empty(GENDIRDEPS_FILTER) +# so we can compare below +.-include <${_DEPENDFILE}> +# yes, I mean :U with no value +_DIRDEPS := ${DIRDEPS:U:O:u} +.endif + +META_FILES := ${META_FILES:T:O:u} + +# pickup customizations +.-include <local.gendirdeps.mk> + +# these are actually prefixes that we'll skip +# they should all be absolute paths +SKIP_GENDIRDEPS ?= +.if !empty(SKIP_GENDIRDEPS) +_skip_gendirdeps = egrep -v '^(${SKIP_GENDIRDEPS:O:u:ts|})' | +.else +_skip_gendirdeps = +.endif + +# Below we will turn _{VAR} into ${VAR} which keeps this simple +# GENDIRDEPS_FILTER_DIR_VARS is a list of dirs to be substiuted for. +# GENDIRDEPS_FILTER_VARS is more general. +# In each case order matters. +.if !empty(GENDIRDEPS_FILTER_DIR_VARS) +GENDIRDEPS_FILTER += ${GENDIRDEPS_FILTER_DIR_VARS:@v@S,${$v},_{${v}},@} +.endif +.if !empty(GENDIRDEPS_FILTER_VARS) +GENDIRDEPS_FILTER += ${GENDIRDEPS_FILTER_VARS:@v@S,/${$v}/,/_{${v}}/,@:NS,//,*:u} +.endif + +# this (*should* be set in meta.sys.mk) +# is the script that extracts what we want. +META2DEPS ?= ${.PARSEDIR}/meta2deps.sh +META2DEPS := ${META2DEPS} + +.if ${DEBUG_GENDIRDEPS:Uno:@x@${RELDIR:M$x}@} != "" && ${DEBUG_GENDIRDEPS:Uno:Mmeta2d*} != "" +_time = time +_sh_x = sh -x +_py_d = -ddd +.else +_time = +_sh_x = +_py_d = +.endif + +.if ${META2DEPS:E} == "py" +# we can afford to do this all the time. +DPDEPS ?= no +META2DEPS_CMD = ${_time} ${PYTHON} ${META2DEPS} ${_py_d} +.if ${DPDEPS:tl} != "no" +META2DEPS_CMD += -D ${DPDEPS} +.endif +META2DEPS_FILTER = sed 's,^src:,${SRCTOP}/,;s,^\([^/]\),${OBJTOP}/\1,' | +.elif ${META2DEPS:E} == "sh" +META2DEPS_CMD = ${_time} ${_sh_x} ${META2DEPS} OBJTOP=${_OBJTOP} +.else +META2DEPS_CMD ?= ${META2DEPS} +.endif + +.if ${TARGET_OBJ_SPEC:U${MACHINE}} != ${MACHINE} +META2DEPS_CMD += -T ${TARGET_OBJ_SPEC} +.endif +META2DEPS_CMD += \ + -R ${RELDIR} -H ${HOST_TARGET} \ + ${M2D_OBJROOTS:O:u:@o@-O $o@} \ + ${M2D_EXCLUDES:O:u:@o@-X $o@} \ + + +M2D_OBJROOTS += ${OBJTOP} ${_OBJROOT} ${_objroot} +.if defined(SB_OBJROOT) +M2D_OBJROOTS += ${SB_OBJROOT} +.endif +.if defined(STAGE_ROOT) +M2D_OBJROOTS += ${STAGE_ROOT} +.endif +.if ${.MAKE.DEPENDFILE_PREFERENCE:U${.MAKE.DEPENDFILE}:M*.${MACHINE}} == "" +# meta2deps.py only groks objroot +# so we need to give it what it expects +# and tell it not to add machine qualifiers +META2DEPS_ARGS += MACHINE=none +.endif +.if defined(SB_BACKING_SB) +META2DEPS_CMD += -S ${SB_BACKING_SB}/src +M2D_OBJROOTS += ${SB_BACKING_SB}/${SB_OBJPREFIX} +.endif + +GENDIRDEPS_SEDCMDS += \ + -e 's,//*$$,,;s,\.${HOST_TARGET:Uhost}$$,.host,' \ + -e 's,\.${HOST_TARGET32:Uhost32}$$,.host32,' \ + -e 's,\.${MACHINE}$$,,' \ + -e 's:\.${TARGET_SPEC:U${MACHINE}}$$::' + +# we are only interested in the dirs +# specifically those we read something from. +# we canonicalize them to keep things simple +# if we are using a split-fs sandbox, it gets a little messier. +_objtop := ${_OBJTOP:tA} + +# some people put *.meta in META_XTRAS to make sure we get here +_meta_files := ${META_FILES:N\*.meta:O:u} +# assume a big list +_meta_files_arg= @meta.list +.if empty(_meta_files) && ${META_FILES:M\*.meta} != "" +# XXX this should be considered a bad idea, +# since we cannot ignore stale .meta +x != cd ${_OBJDIR} && find . -name '*.meta' -print -o \( -type d ! -name . -prune \) | sed 's,^./,,' > meta.list; echo +.elif ${_meta_files:[#]} > 500 +.export _meta_files +x != echo; for m in $$_meta_files; do echo $$m; done > meta.list +# _meta_files is consuming a lot of env space +# that can impact command line length, +# and we do not need it any more +.undef _meta_files +.unexport _meta_files +.else +_meta_files_arg:= ${_meta_files} +.endif + +dir_list != cd ${_OBJDIR} && \ + ${META2DEPS_CMD} MACHINE=${MACHINE} \ + SRCTOP=${SRCTOP} RELDIR=${RELDIR} CURDIR=${_CURDIR} \ + ${META2DEPS_ARGS} \ + ${_meta_files_arg} | ${META2DEPS_FILTER} ${_skip_gendirdeps} \ + sed ${GENDIRDEPS_SEDCMDS} + +.if ${dir_list:M*ERROR\:*} != "" +.warning ${dir_list:tW:C,.*(ERROR),\1,} +.warning Skipping ${_DEPENDFILE:S,${SRCTOP}/,,} +# we are not going to update anything +.else +dpadd_dir_list= +.if !empty(DPADD) +_nonlibs := ${DPADD:T:Nlib*:N*include} +.if !empty(_nonlibs) +ddep_list = +.for f in ${_nonlibs:@x@${DPADD:M*/$x}@} +.if exists($f.dirdep) +ddep_list += $f.dirdep +.elif exists(${f:H}.dirdep) +ddep_list += ${f:H}.dirdep +.else +dir_list += ${f:H:tA} +dpadd_dir_list += ${f:H:tA} +.endif +.endfor +.if !empty(ddep_list) +ddeps != cat ${ddep_list:O:u} | ${META2DEPS_FILTER} ${_skip_gendirdeps} \ + sed ${GENDIRDEPS_SEDCMDS} + +.if ${DEBUG_GENDIRDEPS:Uno:@x@${RELDIR:M$x}@} != "" +.info ${RELDIR}: raw_dir_list='${dir_list}' +.info ${RELDIR}: ddeps='${ddeps}' +.endif +dir_list += ${ddeps} +.endif +.endif +.endif + +# DIRDEPS represent things that had to have been built first +# so they should all be undir OBJTOP. +# Note that ${_OBJTOP}/bsd/include/machine will get reported +# to us as $SRCTOP/bsd/sys/$MACHINE_ARCH/include meaning we +# will want to visit bsd/include +# so we add +# ${"${dir_list:M*bsd/sys/${MACHINE_ARCH}/include}":?bsd/include:} +# to GENDIRDEPS_DIR_LIST_XTRAS +_objtops = ${OBJTOP} ${_OBJTOP} ${_objtop} +_objtops := ${_objtops:O:u} +dirdep_list = \ + ${_objtops:@o@${dir_list:M$o*/*:C,$o[^/]*/,,}@} \ + ${GENDIRDEPS_DIR_LIST_XTRAS} + +# sort longest first +M2D_OBJROOTS := ${M2D_OBJROOTS:O:u:[-1..1]} + +# anything we use from an object dir other than ours +# needs to be qualified with its .<machine> suffix +# (we used the pseudo machine "host" for the HOST_TARGET). +skip_ql= ${SRCTOP}* ${_objtops:@o@$o*@} +.for o in ${M2D_OBJROOTS:${skip_ql:${M_ListToSkip}}} +# we need := so only skip_ql to this point applies +ql.$o := ${dir_list:${skip_ql:${M_ListToSkip}}:M$o*/*/*:C,$o([^/]+)/(.*),\2.\1,:S,.${HOST_TARGET},.host,} +qualdir_list += ${ql.$o} +.if ${DEBUG_GENDIRDEPS:Uno:@x@${RELDIR:M$x}@} != "" +.info ${RELDIR}: o=$o ${ql.$o qualdir_list:L:@v@$v=${$v}@} +.endif +skip_ql+= $o* +.endfor + +dirdep_list := ${dirdep_list:O:u} +qualdir_list := ${qualdir_list:N*.${MACHINE}:O:u} + +DIRDEPS = \ + ${dirdep_list:N${RELDIR}:N${RELDIR}/*} \ + ${qualdir_list:N${RELDIR}.*:N${RELDIR}/*} + +# We only consider things below $RELDIR/ if they have a makefile. +# This is the same test that _DIRDEP_USE applies. +# We have do a double test with dirdep_list as it _may_ contain +# qualified dirs - if we got anything from a stage dir. +# qualdir_list we know are all qualified. +# It would be nice do peform this check for all of DIRDEPS, +# but we cannot assume that all of the tree is present, +# in fact we can only assume that RELDIR is. +DIRDEPS += \ + ${dirdep_list:M${RELDIR}/*:@d@${.MAKE.MAKEFILE_PREFERENCE:@m@${exists(${SRCTOP}/$d/$m):?$d:${exists(${SRCTOP}/${d:R}/$m):?$d:}}@}@} \ + ${qualdir_list:M${RELDIR}/*:@d@${.MAKE.MAKEFILE_PREFERENCE:@m@${exists(${SRCTOP}/${d:R}/$m):?$d:}@}@} + +# what modifiers do we allow in GENDIRDEPS_FILTER +GENDIRDEPS_FILTER_MASK += @CMNS +DIRDEPS := ${DIRDEPS:${GENDIRDEPS_FILTER:UNno:M[${GENDIRDEPS_FILTER_MASK:O:u:ts}]*:ts:}:C,//+,/,g:O:u} + +.if ${DEBUG_GENDIRDEPS:Uno:@x@${RELDIR:M$x}@} != "" +.info ${RELDIR}: M2D_OBJROOTS=${M2D_OBJROOTS} +.info ${RELDIR}: M2D_EXCLUDES=${M2D_EXCLUDES} +.info ${RELDIR}: dir_list='${dir_list}' +.info ${RELDIR}: dpadd_dir_list='${dpadd_dir_list}' +.info ${RELDIR}: dirdep_list='${dirdep_list}' +.info ${RELDIR}: qualdir_list='${qualdir_list}' +.info ${RELDIR}: SKIP_GENDIRDEPS='${SKIP_GENDIRDEPS}' +.info ${RELDIR}: GENDIRDEPS_FILTER='${GENDIRDEPS_FILTER}' +.info ${RELDIR}: FORCE_DPADD='${DPADD}' +.info ${RELDIR}: DIRDEPS='${DIRDEPS}' +.endif + +# SRC_DIRDEPS is for checkout logic +src_dirdep_list = \ + ${dir_list:M${SRCTOP}/*:S,${SRCTOP}/,,} + +SRC_DIRDEPS = \ + ${src_dirdep_list:N${RELDIR}:N${RELDIR}/*:C,(/h)/.*,,} + +SRC_DIRDEPS := ${SRC_DIRDEPS:${GENDIRDEPS_SRC_FILTER:UN/*:ts:}:C,//+,/,g:O:u} + +# if you want to capture SRC_DIRDEPS in .MAKE.DEPENDFILE put +# SRC_DIRDEPS_FILE = ${_DEPENDFILE} +# in local.gendirdeps.mk +.if ${SRC_DIRDEPS_FILE:Uno:tl} != "no" +ECHO_SRC_DIRDEPS = echo 'SRC_DIRDEPS = \'; echo '${SRC_DIRDEPS:@d@ $d \\${.newline}@}'; echo; + +.if ${SRC_DIRDEPS_FILE:T} == ${_DEPENDFILE:T} +_include_src_dirdeps = ${ECHO_SRC_DIRDEPS} +.else +all: ${SRC_DIRDEPS_FILE} +.if !target(${SRC_DIRDEPS_FILE}) +${SRC_DIRDEPS_FILE}: ${META_FILES} ${_this} ${META2DEPS} + @(${ECHO_SRC_DIRDEPS}) > $@ +.endif +.endif +.endif +_include_src_dirdeps ?= + +all: ${_DEPENDFILE} + +# if this is going to exist it would be there by now +.if !exists(.depend) +CAT_DEPEND = /dev/null +.endif +CAT_DEPEND ?= .depend + +.if !empty(_DIRDEPS) && ${DIRDEPS} != ${_DIRDEPS} +# we may have changed a filter +.PHONY: ${_DEPENDFILE} +.endif + +# 'cat .depend' should suffice, but if we are mixing build modes +# .depend may contain things we don't want. +# The sed command at the end of the stream, allows for the filters +# to output _{VAR} tokens which we will turn into proper ${VAR} references. +${_DEPENDFILE}: .NOMETA ${CAT_DEPEND:M.depend} ${META_FILES:O:u:@m@${exists($m):?$m:}@} ${_this} ${META2DEPS} + @(${GENDIRDEPS_HEADER} echo '# Autogenerated - do NOT edit!'; echo; \ + echo 'DIRDEPS = \'; \ + echo '${DIRDEPS:@d@ $d \\${.newline}@}'; echo; \ + ${_include_src_dirdeps} \ + echo '.include <dirdeps.mk>'; \ + echo; \ + echo '.if $${DEP_RELDIR} == $${_DEP_RELDIR}'; \ + echo '# local dependencies - needed for -jN in clean tree'; \ + [ -s ${CAT_DEPEND} ] && { grep : ${CAT_DEPEND} | grep -v '[/\\]'; }; \ + echo '.endif' ) | sed 's,_\([{(]\),$$\1,g' > $@.new${.MAKE.PID} + @${InstallNew}; InstallNew -s $@.new${.MAKE.PID} + +.endif # meta2deps failed +.elif !empty(SUBDIR) + +DIRDEPS := ${SUBDIR:S,^,${RELDIR}/,:O:u} + +all: ${_DEPENDFILE} + +${_DEPENDFILE}: .NOMETA ${MAKEFILE} ${_this} + @(${GENDIRDEPS_HEADER} echo '# Autogenerated - do NOT edit!'; echo; \ + echo 'DIRDEPS = \'; \ + echo '${DIRDEPS:@d@ $d \\${.newline}@}'; echo; \ + echo '.include <dirdeps.mk>'; \ + echo ) | sed 's,_\([{(]\),$$\1,g' > $@.new + @${InstallNew}; InstallNew $@.new + +.else + +# nothing to do +all ${_DEPENDFILE}: + +.endif +${_DEPENDFILE}: .PRECIOUS + +# don't waste time looking for ways to make .meta files +.SUFFIXES: diff --git a/devel/bmake/files/mk/host-target.mk b/devel/bmake/files/mk/host-target.mk new file mode 100644 index 00000000000..aea8d0d8634 --- /dev/null +++ b/devel/bmake/files/mk/host-target.mk @@ -0,0 +1,44 @@ +# RCSid: +# $Id: host-target.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ + +# Host platform information; may be overridden +.if !defined(_HOST_OSNAME) +_HOST_OSNAME != uname -s +.export _HOST_OSNAME +.endif +.if !defined(_HOST_OSREL) +_HOST_OSREL != uname -r +.export _HOST_OSREL +.endif +.if !defined(_HOST_MACHINE) +_HOST_MACHINE != uname -m +.export _HOST_MACHINE +.endif +.if !defined(_HOST_ARCH) +# for NetBSD prefer $MACHINE (amd64 rather than x86_64) +.if ${_HOST_OSNAME:NNetBSD} == "" +_HOST_ARCH := ${_HOST_MACHINE} +.else +_HOST_ARCH != uname -p 2> /dev/null || uname -m +# uname -p may produce garbage on linux +.if ${_HOST_ARCH:[\#]} > 1 || ${_HOST_ARCH:Nunknown} == "" +_HOST_ARCH := ${_HOST_MACHINE} +.endif +.endif +.export _HOST_ARCH +.endif +.if !defined(HOST_MACHINE) +HOST_MACHINE := ${_HOST_MACHINE} +.export HOST_MACHINE +.endif + +HOST_OSMAJOR := ${_HOST_OSREL:C/[^0-9].*//} +HOST_OSTYPE := ${_HOST_OSNAME:S,/,,g}-${_HOST_OSREL:C/\([^\)]*\)//}-${_HOST_ARCH} +HOST_OS := ${_HOST_OSNAME} +host_os := ${_HOST_OSNAME:tl} +HOST_TARGET := ${host_os:S,/,,g}${HOST_OSMAJOR}-${_HOST_ARCH} + +# tr is insanely non-portable, accommodate the lowest common denominator +TR ?= tr +toLower = ${TR} 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' +toUpper = ${TR} 'abcdefghijklmnopqrstuvwxyz' 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' diff --git a/devel/bmake/files/mk/host.libnames.mk b/devel/bmake/files/mk/host.libnames.mk new file mode 100644 index 00000000000..a057d5e3590 --- /dev/null +++ b/devel/bmake/files/mk/host.libnames.mk @@ -0,0 +1,29 @@ +# $Id: host.libnames.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 2007-2009, 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 +# + + +DLIBEXT ?= .a +DSHLIBEXT ?= ${DLIBEXT} +HOST_LIBEXT ?= ${DSHLIBEXT} +HOST_LIBDIRS ?= /usr/lib /lib +HOST_LIBS ?= + +.for x in ${HOST_LIBS:O:u} +.for d in ${HOST_LIBDIRS} +.if exists($d/lib$x${HOST_LIBEXT}) +LIB${x:tu} ?= $d/lib$x${HOST_LIBEXT} +.endif +.endfor +.endfor diff --git a/devel/bmake/files/mk/inc.mk b/devel/bmake/files/mk/inc.mk new file mode 100644 index 00000000000..d03f9e8afcf --- /dev/null +++ b/devel/bmake/files/mk/inc.mk @@ -0,0 +1,89 @@ +# $Id: inc.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 2008, 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 +# + +.include <init.mk> + +.if !empty(LIBOWN) +INC_INSTALL_OWN ?= -o ${LIBOWN} -g ${LIBGRP} +.endif +INCMODE ?= 444 +INC_COPY ?= -C +INCSDIR ?= ${INCDIR} + +STAGE_INCSDIR?= ${STAGE_OBJTOP}${INCSDIR} + +# accommodate folk used to freebsd +INCGROUPS ?= ${INCSGROUPS:UINCS} +INCGROUPS := ${INCGROUPS:O:u} + +.if !target(buildincludes) +.for group in ${INCGROUPS} +buildincludes: ${${group}} +.endfor +.endif +buildincludes: +includes: buildincludes + +.if !target(incinstall) +.for group in ${INCGROUPS} +.if !empty(${group}) +.if ${group} != "INC" +${group}_INSTALL_OWN ?= ${INC_INSTALL_OWN} +${group}DIR ?= ${INCDIR} +.endif +# incase we are staging +STAGE_DIR.${group} ?= ${STAGE_OBJTOP}${${group}DIR} + +.for header in ${${group}:O:u} +${group}_INSTALL_OWN.${header:T} ?= ${${group}_INSTALL_OWN} +${group}DIR.${header:T} ?= ${${group}DIR} +inc_mkdir_list += ${${group}DIR.${header:T}} + +.if defined(${group}NAME.${header:T}) +STAGE_AS_SETS += ${group} +STAGE_AS_${header} = ${${group}NAME.${header:T}} +stage_as.${group}: ${header} + +incinstall: incinstall.${group}.${header:T} +incinstall.${group}.${header:T}: ${header} inc_mkdirs + ${INSTALL} ${INC_COPY} ${${group}_INSTALL_OWN.${header:T}} -m ${INCMODE} ${.ALLSRC:Ninc_mkdirs} ${DESTDIR}${${group}DIR}/${${group}NAME.${header:T}} + +.else +STAGE_SETS += ${group} +stage_files.${group}: ${header} +incinstall.${group}: ${header} +incinstall: incinstall.${group} +.endif + +.endfor # header + +incinstall.${group}: inc_mkdirs + ${INSTALL} ${INC_COPY} ${${group}_INSTALL_OWN} -m ${INCMODE} \ + ${.ALLSRC:Ninc_mkdirs:O:u} ${DESTDIR}${${group}DIR} + +.endif # !empty +.endfor # group + +inc_mkdirs: + @for d in ${inc_mkdir_list:O:u}; do \ + test -d ${DESTDIR}$$d || \ + ${INSTALL} -d ${INC_INSTALL_OWN} -m 775 ${DESTDIR}$$d; \ + done + +.endif # !target(incinstall) + +beforeinstall: +realinstall: incinstall +.ORDER: beforeinstall incinstall diff --git a/devel/bmake/files/mk/init.mk b/devel/bmake/files/mk/init.mk new file mode 100644 index 00000000000..dcf219e4588 --- /dev/null +++ b/devel/bmake/files/mk/init.mk @@ -0,0 +1,70 @@ +# $Id: init.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 2002, 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 !target(__${.PARSEFILE}__) +__${.PARSEFILE}__: + +.if ${MAKE_VERSION:U0} > 20100408 +_this_mk_dir := ${.PARSEDIR:tA} +.else +_this_mk_dir := ${.PARSEDIR} +.endif + +.-include <local.init.mk> +.-include <${.CURDIR:H}/Makefile.inc> +.include <own.mk> +.include <compiler.mk> + +.MAIN: all + +# should have been set by sys.mk +CXX_SUFFIXES?= .cc .cpp .cxx .C + +.if !empty(WARNINGS_SET) || !empty(WARNINGS_SET_${MACHINE_ARCH}) +.include <warnings.mk> +.endif + +.for x in COPTS CPPFLAGS CPUFLAGS LDFLAGS +$x += ${$x.${COMPILER_TYPE}:U} ${$x.${.IMPSRC:T}:U} +.endfor + +CC_PG?= -pg +CXX_PG?= ${CC_PG} +CC_PIC?= -DPIC +CXX_PIC?= ${CC_PIC} +PROFFLAGS?= -DGPROF -DPROF + +.if ${.MAKE.LEVEL:U1} == 0 && ${BUILD_AT_LEVEL0:Uyes:tl} == "no" +# this tells lib.mk and prog.mk to not actually build anything +_SKIP_BUILD = not building at level 0 +.endif + +.if !defined(.PARSEDIR) +# no-op is the best we can do if not bmake. +.WAIT: +.endif + +# define this once for consistency +.if empty(_SKIP_BUILD) +# beforebuild is a hook for things that must be done early +all: beforebuild .WAIT realbuild +.else +all: .PHONY +.warning ${_SKIP_BUILD} +.endif +beforebuild: +realbuild: + +.endif diff --git a/devel/bmake/files/mk/install-mk b/devel/bmake/files/mk/install-mk new file mode 100644 index 00000000000..42040758e41 --- /dev/null +++ b/devel/bmake/files/mk/install-mk @@ -0,0 +1,185 @@ +: +# NAME: +# install-mk - install mk files +# +# SYNOPSIS: +# install-mk [options] [var=val] [dest] +# +# DESCRIPTION: +# This tool installs mk files in a semi-intelligent manner into +# "dest". +# +# Options: +# +# -n just say what we want to do, but don't touch anything. +# +# -f use -f when copying sys,mk. +# +# -v be verbose +# +# -q be quiet +# +# -m "mode" +# Use "mode" for installed files (444). +# +# -o "owner" +# Use "owner" for installed files. +# +# -g "group" +# Use "group" for installed files. +# +# var=val +# Set "var" to "val". See below. +# +# All our *.mk files are copied to "dest" with appropriate +# ownership and permissions. +# +# By default if a sys.mk can be found in a standard location +# (that bmake will find) then no sys.mk will be put in "dest". +# +# SKIP_SYS_MK: +# If set, we will avoid installing our 'sys.mk' +# This is probably a bad idea. +# +# SKIP_BSD_MK: +# If set, we will skip making bsd.*.mk links to *.mk +# +# sys.mk: +# +# By default (and provided we are not installing to the system +# mk dir - '/usr/share/mk') we install our own 'sys.mk' which +# includes a sys specific file, or a generic one. +# +# +# AUTHOR: +# Simon J. Gerraty <sjg@crufty.net> + +# RCSid: +# $Id: install-mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 1994 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 +# + +MK_VERSION=20200515 +OWNER= +GROUP= +MODE=444 +BINMODE=555 +ECHO=: +SKIP= +cp_f=-f + +while : +do + case "$1" in + *=*) eval "$1"; shift;; + +f) cp_f=; shift;; + -f) cp_f=-f; shift;; + -m) MODE=$2; shift 2;; + -o) OWNER=$2; shift 2;; + -g) GROUP=$2; shift 2;; + -v) ECHO=echo; shift;; + -q) ECHO=:; shift;; + -n) ECHO=echo SKIP=:; shift;; + --) shift; break;; + *) break;; + esac +done + +case $# in +0) echo "$0 [options] <destination> [<os>]" + echo "eg." + echo "$0 -o bin -g bin -m 444 /usr/local/share/mk" + exit 1 + ;; +esac +dest=$1 +os=${2:-`uname`} +osrel=${3:-`uname -r`} + +Do() { + $ECHO "$@" + $SKIP "$@" +} + +Error() { + echo "ERROR: $@" >&2 + exit 1 +} + +Warning() { + echo "WARNING: $@" >&2 +} + +[ "$FORCE_SYS_MK" ] && Warning "ignoring: FORCE_{BSD,SYS}_MK (no longer supported)" + +SYS_MK_DIR=${SYS_MK_DIR:-/usr/share/mk} +SYS_MK=${SYS_MK:-$SYS_MK_DIR/sys.mk} + +realpath() { + [ -d $1 ] && cd $1 && 'pwd' && return + echo $1 +} + +if [ -s $SYS_MK -a -d $dest ]; then + # if this is a BSD system we don't want to touch $SYS_MK + dest=`realpath $dest` + sys_mk_dir=`realpath $SYS_MK_DIR` + if [ $dest = $sys_mk_dir ]; then + case "$os" in + *BSD*) SKIP_SYS_MK=: + SKIP_BSD_MK=: + ;; + *) # could be fake? + if [ ! -d $dest/sys -a ! -s $dest/Generic.sys.mk ]; then + SKIP_SYS_MK=: # play safe + SKIP_BSD_MK=: + fi + ;; + esac + fi +fi + +[ -d $dest/sys ] || Do mkdir -p $dest/sys +[ -d $dest/sys ] || Do mkdir $dest/sys || exit 1 +[ -z "$SKIP" ] && dest=`realpath $dest` + +cd `dirname $0` +mksrc=`'pwd'` +if [ $mksrc = $dest ]; then + SKIP_MKFILES=: +else + # we do not install the examples + mk_files=`grep '^[a-z].*\.mk' FILES | egrep -v '(examples/|^sys\.mk|sys/)'` + mk_scripts=`egrep '^[a-z].*\.(sh|py)' FILES | egrep -v '/'` + sys_mk_files=`grep 'sys/.*\.mk' FILES` + SKIP_MKFILES= + [ -z "$SKIP_SYS_MK" ] && mk_files="sys.mk $mk_files" +fi +$SKIP_MKFILES Do cp $cp_f $mk_files $dest +$SKIP_MKFILES Do cp $cp_f $sys_mk_files $dest/sys +$SKIP_MKFILES Do cp $cp_f $mk_scripts $dest +$SKIP cd $dest +$SKIP_MKFILES Do chmod $MODE $mk_files $sys_mk_files +$SKIP_MKFILES Do chmod $BINMODE $mk_scripts +[ "$GROUP" ] && $SKIP_MKFILES Do chgrp $GROUP $mk_files $sys_mk_files +[ "$OWNER" ] && $SKIP_MKFILES Do chown $OWNER $mk_files $sys_mk_files +# if this is a BSD system the bsd.*.mk should exist and be used. +if [ -z "$SKIP_BSD_MK" ]; then + for f in dep doc files inc init lib links man nls obj own prog subdir + do + b=bsd.$f.mk + [ -s $b ] || Do ln -s $f.mk $b + done +fi +exit 0 diff --git a/devel/bmake/files/mk/install-new.mk b/devel/bmake/files/mk/install-new.mk new file mode 100644 index 00000000000..dc3d4d9de8d --- /dev/null +++ b/devel/bmake/files/mk/install-new.mk @@ -0,0 +1,53 @@ +# $Id: install-new.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 2009, 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 !defined(InstallNew) + +# copy if src and target are different making a backup if desired +CmpCp= CmpCp() { \ + src=$$1 target=$$2 _bak=$$3; \ + if ! test -s $$target || ! cmp -s $$target $$src; then \ + trap "" 1 2 3 15; \ + if test -s $$target; then \ + if test "x$$_bak" != x; then \ + rm -f $$target$$_bak; \ + mv $$target $$target$$_bak; \ + else \ + rm -f $$target; \ + fi; \ + fi; \ + cp $$src $$target; \ + fi; } + +# If the .new file is different, we want it. +# Note: this function will work as is for *.new$RANDOM" +InstallNew= ${CmpCp}; InstallNew() { \ + _t=-e; _bak=; \ + while :; do \ + case "$$1" in \ + -?) _t=$$1; shift;; \ + --bak) _bak=$$2; shift 2;; \ + *) break;; \ + esac; \ + done; \ + for new in "$$@"; do \ + if test $$_t $$new; then \ + target=`expr $$new : '\(.*\).new'`; \ + CmpCp $$new $$target $$_bak; \ + fi; \ + rm -f $$new; \ + done; :; } + +.endif diff --git a/devel/bmake/files/mk/java.mk b/devel/bmake/files/mk/java.mk new file mode 100644 index 00000000000..1a705d3d588 --- /dev/null +++ b/devel/bmake/files/mk/java.mk @@ -0,0 +1,97 @@ +# +# RCSid: +# $Id: java.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ + +# @(#) Copyright (c) 1998-2001, 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 !target(__${.PARSEFILE}__) +__${.PARSEFILE}__: + +.include <init.mk> + +CLASSPATH?=. + +.if defined(PROG) +SRCS?= ${PROG:.class=.java} +.endif +.if !defined(SRCS) || empty(SRCS) +SRCS!=cd ${.CURDIR} && echo *.java +.endif +.SUFFIXES: .class .java + +CLEANFILES+= *.class + +JAVAC?= javac +JAVADOC?= javadoc + +.if !target(docs) +docs: + ${JAVADOC} ${JAVADOC_FLAGS} ${SRCS} +.endif + +.if defined(JAVADESTDIR) && !empty(JAVADESTDIR) +JAVASRCDIR?=${JAVADESTDIR:H}/src +__classdest:=${JAVADESTDIR}${.CURDIR:S,${JAVASRCDIR},,}/ +CLASSPATH:=${CLASSPATH}:${JAVADESTDIR} +JAVAC_FLAGS+= -d ${JAVADESTDIR} +.else +__classdest= +.endif + +JAVAC_FLAGS+= ${JAVAC_DBG} + +.if defined(MAKE_VERSION) && !defined(NO_CLASSES_COOKIE) +# java works best by compiling a bunch of classes at once. +# this lot does that but needs a recent netbsd make or +# or its portable cousin bmake. +.for __s in ${SRCS} +__c:= ${__classdest}${__s:.java=.class} +.if !target(${__c}) +# We need to do something to force __c's parent to be made. +${__c}: ${__s} + @rm -f ${.TARGET} +.endif +SRCS_${__c}=${__s} +__classes:= ${__classes} ${__c} +.endfor +__classes_cookie=${__classdest}.classes.done +CLEANFILES+= ${__classes} ${__classes_cookie} + +${__classes_cookie}: ${__classes} + CLASSPATH=${CLASSPATH} ${JAVAC} ${JAVAC_FLAGS} ${.OODATE:@c@${SRCS_$c}@} + @touch ${.TARGET} + +all: ${__classes_cookie} + +.else +# this will work with other BSD make's +.for __s in ${SRCS} +__c:= ${__classdest}${__s:.java=.class} +${__c}: ${__s} + CLASSPATH=${CLASSPATH} ${JAVAC} ${JAVAC_FLAGS} ${.OODATE} +.endfor + +all: ${SRCS:%.java=${__classdest}%.class} + +.endif + +.if !target(cleanjava) +cleanjava: + rm -f [Ee]rrs mklog core *.core ${PROG} ${CLEANFILES} + +clean: cleanjava +cleandir: cleanjava +.endif + +.endif diff --git a/devel/bmake/files/mk/ldorder.mk b/devel/bmake/files/mk/ldorder.mk new file mode 100644 index 00000000000..2f2bc930526 --- /dev/null +++ b/devel/bmake/files/mk/ldorder.mk @@ -0,0 +1,156 @@ +# $Id: ldorder.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 2015, 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 +# + +# Try to compute optimal link order. +# When using only shared libs link order does not much matter, +# but archive libs are a different matter. + +# We can construct a graph of .ldorder-lib${LIB*} dependencies +# and associate each with _LDORDER_USE to output the relevant +# ld flags. +# Due to the nature of make, the result will be in the reverse order +# that we want to feed to ld. +# So we need to reverse it before use. + +.if !target(_LDORDER_USE) +# does caller want to use ldorder? +# yes for prog, normally no for lib +.if ${.ALLTARGETS:Mldorder} != "" +_ldorder_use: +.endif + +# define this if we need a barrier between local and external libs +# see below +LDORDER_EXTERN_BARRIER ?= .ldorder-extern-barrier + +.-include <local.ldorder.mk> + +# convert /path/to/libfoo.a into _{LIBFOO} +LDORDER_INC_FILTER += S,+,PLUS,g S,.so$$,,g +LDORDER_LIBS_FILTER += O:u +LDORDER_INC ?= ldorder.inc +# for meta mode +REFERENCE_FILE ?= : + +_LDORDER_USE: .ldorder-rm .USE .NOTMAIN + @echo depends: ${.ALLSRC:M.ldorder-lib*} > /dev/null + @echo ${LDADD_${.TARGET:T:S,.ldorder-,,}:U${.TARGET:T:S/.ldorder-lib/-l/}} >> .ldorder + @${META_COOKIE_TOUCH} + +# we need to truncate our working file +.ldorder-rm: .NOTMAIN + @rm -f .ldorder ldorder-* + @${.ALLSRC:O:u:@f@${REFERENCE_FILE} < $f;@} + @${META_COOKIE_TOUCH} + +# make sure this exists +.ldorder: .NOTMAIN + +# and finally we need to reverse the order of content +ldorder: .ldorder .NOTMAIN + @{ test ! -s .ldorder || cat -n .ldorder | sort -rn | \ + sed '/ldorder-/d;s,^[[:space:]0-9]*,,'; } > ${.TARGET} + +# Initially we hook contents of DPLIBS and DPADD into our graph +LDORDER_LIBS ?= ${DPLIBS} ${DPADD:M*/lib*} ${__dpadd_libs} +# we need to remember this +_LDORDER_LIBS := ${LDORDER_LIBS:${LDORDER_LIBS_FILTER:ts:}} + +.if empty(_LDORDER_LIBS) +# don't use stale ldorder +LDADD_LDORDER = +.else +# this is how you use it +LDADD_LDORDER ?= `cat ldorder` +.endif + +# for debug below +_ldorder = ${RELDIR}.${TARGET_SPEC} + +# we make have some libs that exist outside of $SB +# and want to insert a barrier +.if target(${LDORDER_EXTERN_BARRIER}) +# eg. in local.ldorder.mk +# ${LDORDER_EXTERN_BARRIER}: +# @test -z "${extern_ldorders}" || \ +# echo -Wl,-Bdynamic >> .ldorder +# +# feel free to put more suitable version in local.ldorder.mk if needed +# we do *not* count host libs in extern_ldorders +extern_ldorders ?= ${__dpadd_libs:tA:N/lib*:N/usr/lib*:N${SB}/*:N${SB_OBJROOT:tA}*:T:${LDORDER_LIBS_FILTER:ts:}:R:C/\.so.*//:S,^,.ldorder-,:N.ldorder-} +sb_ldorders ?= ${.ALLTARGETS:M.ldorder-*:N${LDORDER_EXTERN_BARRIER}:N.ldorder-rm:${extern_ldorders:${M_ListToSkip}}:N.ldorder-} + +# finally in Makefile after include of *.mk put +# .ldorder ${sb_ldorders}: ${LDORDER_EXTERN_BARRIER} +# ${LDORDER_EXTERN_BARRIER}: ${extern_ldorders} +.endif + +.endif # !target(_LDORDER_USE) + +.if !empty(LDORDER_LIBS) && target(_ldorder_use) +# canonicalize - these are just tokens anyway +LDORDER_LIBS := ${LDORDER_LIBS:${LDORDER_LIBS_FILTER:ts:}:R:C/\.so.*//} +_ldorders := ${LDORDER_LIBS:T:Mlib*:S,^,.ldorder-,} + +.for t in ${_ldorders} +.if !target($t) +$t: _LDORDER_USE +.endif +.endfor + +# and this makes it all happen +.ldorder: ${_ldorders} + +# this is how we get the dependencies +.if ${.INCLUDEDFROMFILE:M*.${LDORDER_INC}} != "" +_ldorder := .ldorder-${.INCLUDEDFROMFILE:S/.${LDORDER_INC}//} +${_ldorder}: ${_ldorders} +.ldorder-rm: ${.INCLUDEDFROMDIR}/${.INCLUDEDFROMFILE} +.endif + +# set DEBUG_LDORDER to pattern[s] that match the dirs of interest +.if ${DEBUG_LDORDER:Uno:@x@${RELDIR:M$x}@} != "" +.info ${_ldorder}: ${_ldorders} +.endif + +# now try to find more ... +# each *.${LDORDER_INC} should set LDORDER_LIBS to what it needs +# it can also add to CFLAGS etc. +.for __inc in ${LDORDER_LIBS:S,$,.${LDORDER_INC},} +.if !target(__${__inc}__) +__${__inc}__: +# make sure this is reset +LDORDER_LIBS = +_ldorders = +.-include <${__inc}> +.endif +.endfor + +.endif # !empty(LDORDER_LIBS) + +.ifdef LIB +# you can make this depend on files (must match *ldorder*) +# to add extra content - like CFLAGS +libLDORDER_INC = lib${LIB}.${LDORDER_INC} +.if !commands(${libLDORDER_INC}) +.if target(ldorder-header) +${libLDORDER_INC}: ldorder-header +.endif +${libLDORDER_INC}: + @(cat /dev/null ${.ALLSRC:M*ldorder*}; \ + echo 'LDORDER_LIBS= ${_LDORDER_LIBS:T:R:${LDORDER_INC_FILTER:ts:}:tu:C,.*,_{&},:N_{}}'; \ + echo; echo '.include <ldorder.mk>' ) | sed 's,_{,$${,g' > ${.TARGET} +.endif +.endif diff --git a/devel/bmake/files/mk/lib.mk b/devel/bmake/files/mk/lib.mk new file mode 100644 index 00000000000..91aa410607e --- /dev/null +++ b/devel/bmake/files/mk/lib.mk @@ -0,0 +1,609 @@ +# $Id: lib.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ + +.if !target(__${.PARSEFILE}__) +__${.PARSEFILE}__: + +.include <init.mk> + +.if ${OBJECT_FMT} == "ELF" +NEED_SOLINKS?= yes +.endif + +SHLIB_VERSION_FILE?= ${.CURDIR}/shlib_version +.if !defined(SHLIB_MAJOR) && exists(${SHLIB_VERSION_FILE}) +SHLIB_MAJOR != . ${SHLIB_VERSION_FILE} ; echo $$major +SHLIB_MINOR != . ${SHLIB_VERSION_FILE} ; echo $$minor +SHLIB_TEENY != . ${SHLIB_VERSION_FILE} ; echo $$teeny +.endif + +.for x in major minor teeny +print-shlib-$x: +.if defined(SHLIB_${x:tu}) && ${MK_PIC} != "no" + @echo ${SHLIB_${x:tu}} +.else + @false +.endif +.endfor + +SHLIB_FULLVERSION ?= ${${SHLIB_MAJOR} ${SHLIB_MINOR} ${SHLIB_TEENY}:L:ts.} +SHLIB_FULLVERSION := ${SHLIB_FULLVERSION} + +# add additional suffixes not exported. +# .po is used for profiling object files. +# ${PICO} is used for PIC object files. +PICO?= .pico +.SUFFIXES: .out .a .ln ${PICO} .po .o .s .S .c .cc .C .m .F .f .r .y .l .cl .p .h +.SUFFIXES: .sh .m4 .m + +CFLAGS+= ${COPTS} + +META_NOECHO?= echo + +# Originally derrived from NetBSD-1.6 + +# Set PICFLAGS to cc flags for producing position-independent code, +# if not already set. Includes -DPIC, if required. + +# Data-driven table using make variables to control how shared libraries +# are built for different platforms and object formats. +# OBJECT_FMT: currently either "ELF" or "a.out", from <bsd.own.mk> +# SHLIB_SOVERSION: version number to be compiled into a shared library +# via -soname. Usually ${SHLIB_MAJOR} on ELF. +# NetBSD/pmax used to use ${SHLIB_MAJOR}[.${SHLIB_MINOR} +# [.${SHLIB_TEENY}]] +# SHLIB_SHFLAGS: Flags to tell ${LD} to emit shared library. +# with ELF, also set shared-lib version for ld.so. +# SHLIB_LDSTARTFILE: support .o file, call C++ file-level constructors +# SHLIB_LDENDFILE: support .o file, call C++ file-level destructors +# FPICFLAGS: flags for ${FC} to compile .[fF] files to ${PICO} objects. +# CPPICFLAGS: flags for ${CPP} to preprocess .[sS] files for ${AS} +# CPICFLAGS: flags for ${CC} to compile .[cC] files to ${PICO} objects. +# CAPICFLAGS flags for {$CC} to compiling .[Ss] files +# (usually just ${CPPPICFLAGS} ${CPICFLAGS}) +# APICFLAGS: flags for ${AS} to assemble .[sS] to ${PICO} objects. + +.if ${TARGET_OSNAME} == "NetBSD" +.if ${MACHINE_ARCH} == "alpha" + # Alpha-specific shared library flags +FPICFLAGS ?= -fPIC +CPICFLAGS ?= -fPIC -DPIC +CPPPICFLAGS?= -DPIC +CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS} +APICFLAGS ?= +.elif ${MACHINE_ARCH} == "mipsel" || ${MACHINE_ARCH} == "mipseb" + # mips-specific shared library flags + +# On mips, all libs are compiled with ABIcalls, not just sharedlibs. +MKPICLIB= no + +# so turn shlib PIC flags on for ${AS}. +AINC+=-DABICALLS +AFLAGS+= -fPIC +AS+= -KPIC + +.elif ${MACHINE_ARCH} == "vax" && ${OBJECT_FMT} == "ELF" +# On the VAX, all object are PIC by default, not just sharedlibs. +MKPICLIB= no + +.elif (${MACHINE_ARCH} == "sparc" || ${MACHINE_ARCH} == "sparc64") && \ + ${OBJECT_FMT} == "ELF" +# If you use -fPIC you need to define BIGPIC to turn on 32-bit +# relocations in asm code +FPICFLAGS ?= -fPIC +CPICFLAGS ?= -fPIC -DPIC +CPPPICFLAGS?= -DPIC -DBIGPIC +CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS} +APICFLAGS ?= -KPIC + +.else + +# Platform-independent flags for NetBSD a.out shared libraries +SHLIB_SOVERSION=${SHLIB_FULLVERSION} +SHLIB_SHFLAGS= +FPICFLAGS ?= -fPIC +CPICFLAGS?= -fPIC -DPIC +CPPPICFLAGS?= -DPIC +CAPICFLAGS?= ${CPPPICFLAGS} ${CPICFLAGS} +APICFLAGS?= -k + +.endif + +# Platform-independent linker flags for ELF shared libraries +.if ${OBJECT_FMT} == "ELF" +SHLIB_SOVERSION= ${SHLIB_MAJOR} +SHLIB_SHFLAGS= -soname lib${LIB}.so.${SHLIB_SOVERSION} +SHLIB_LDSTARTFILE?= /usr/lib/crtbeginS.o +SHLIB_LDENDFILE?= /usr/lib/crtendS.o +.endif + +# for compatibility with the following +CC_PIC?= ${CPICFLAGS} +LD_shared=${SHLIB_SHFLAGS} + +.endif # NetBSD + +.if ${TARGET_OSNAME} == "FreeBSD" +.if ${OBJECT_FMT} == "ELF" +SHLIB_SOVERSION= ${SHLIB_MAJOR} +SHLIB_SHFLAGS= -soname lib${LIB}.so.${SHLIB_SOVERSION} +.else +SHLIB_SHFLAGS= -assert pure-text +.endif +SHLIB_LDSTARTFILE= +SHLIB_LDENDFILE= +CC_PIC?= -fpic +LD_shared=${SHLIB_SHFLAGS} + +.endif # FreeBSD + +MKPICLIB?= yes + +# sys.mk can override these +LD_X?=-X +LD_x?=-x +LD_r?=-r + +# Non BSD machines will be using bmake. +.if ${TARGET_OSNAME} == "SunOS" +LD_shared=-assert pure-text +.if ${OBJECT_FMT} == "ELF" || ${MACHINE} == "solaris" +# Solaris +LD_shared=-h lib${LIB}.so.${SHLIB_MAJOR} -G +.endif +.elif ${TARGET_OSNAME} == "HP-UX" +LD_shared=-b +LD_so=sl +DLLIB= +# HPsUX lorder does not grok anything but .o +LD_sobjs=`${LORDER} ${OBJS} | ${TSORT} | sed 's,\.o,${PICO},'` +LD_pobjs=`${LORDER} ${OBJS} | ${TSORT} | sed 's,\.o,.po,'` +.elif ${TARGET_OSNAME} == "OSF1" +LD_shared= -msym -shared -expect_unresolved '*' +LD_solib= -all lib${LIB}_pic.a +DLLIB= +# lorder does not grok anything but .o +LD_sobjs=`${LORDER} ${OBJS} | ${TSORT} | sed 's,\.o,${PICO},'` +LD_pobjs=`${LORDER} ${OBJS} | ${TSORT} | sed 's,\.o,.po,'` +AR_cq= -cqs +.elif ${TARGET_OSNAME} == "FreeBSD" +LD_solib= lib${LIB}_pic.a +.elif ${TARGET_OSNAME} == "Linux" +SHLIB_LD = ${CC} +# this is ambiguous of course +LD_shared=-shared -Wl,"-soname lib${LIB}.so.${SHLIB_MAJOR}" +LD_solib= -Wl,--whole-archive lib${LIB}_pic.a -Wl,--no-whole-archive +.if ${COMPILER_TYPE} == "gcc" +# Linux uses GNU ld, which is a multi-pass linker +# so we don't need to use lorder or tsort +LD_objs = ${OBJS} +LD_pobjs = ${POBJS} +LD_sobjs = ${SOBJS} +.endif +.elif ${TARGET_OSNAME} == "Darwin" +SHLIB_LD = ${CC} +SHLIB_INSTALL_VERSION ?= ${SHLIB_MAJOR} +SHLIB_COMPATABILITY_VERSION ?= ${SHLIB_MAJOR}.${SHLIB_MINOR:U0} +SHLIB_COMPATABILITY ?= \ + -compatibility_version ${SHLIB_COMPATABILITY_VERSION} \ + -current_version ${SHLIB_FULLVERSION} +LD_shared = -dynamiclib \ + -flat_namespace -undefined suppress \ + -install_name ${LIBDIR}/lib${LIB}.${SHLIB_INSTALL_VERSION}.${LD_solink} \ + ${SHLIB_COMPATABILITY} +SHLIB_LINKS = +.for v in ${SHLIB_COMPATABILITY_VERSION} ${SHLIB_INSTALL_VERSION} +.if "$v" != "${SHLIB_FULLVERSION}" +SHLIB_LINKS += lib${LIB}.$v.${LD_solink} +.endif +.endfor +.if ${MK_LINKLIB} != "no" +SHLIB_LINKS += lib${LIB}.${LD_solink} +.endif + +LD_so = ${SHLIB_FULLVERSION}.dylib +LD_sobjs = ${SOBJS:O:u} +LD_solib = ${LD_sobjs} +SOLIB = ${LD_sobjs} +LD_solink = dylib +.if ${MACHINE_ARCH} == "i386" +PICFLAG ?= -fPIC +.else +PICFLAG ?= -fPIC -fno-common +.endif +RANLIB = : +.endif + +SHLIB_LD ?= ${LD} + +.if !empty(SHLIB_MAJOR) +.if ${NEED_SOLINKS} && empty(SHLIB_LINKS) +.if ${MK_LINKLIB} != "no" +SHLIB_LINKS = lib${LIB}.${LD_solink} +.endif +.if "${SHLIB_FULLVERSION}" != "${SHLIB_MAJOR}" +SHLIB_LINKS += lib${LIB}.${LD_solink}.${SHLIB_MAJOR} +.endif +.endif +.endif + +LIBTOOL?=libtool +LD_shared ?= -Bshareable -Bforcearchive +LD_so ?= so.${SHLIB_FULLVERSION} +LD_solink ?= so +.if empty(LORDER) +LD_objs ?= ${OBJS} +LD_pobjs ?= ${POBJS} +LD_sobjs ?= ${SOBJS} +.else +LD_objs ?= `${LORDER} ${OBJS} | ${TSORT}` +LD_sobjs ?= `${LORDER} ${SOBJS} | ${TSORT}` +LD_pobjs ?= `${LORDER} ${POBJS} | ${TSORT}` +.endif +LD_solib ?= ${LD_sobjs} +AR_cq ?= cq +.if exists(/netbsd) && exists(${DESTDIR}/usr/lib/libdl.so) +DLLIB ?= -ldl +.endif + +# some libs have lots of objects, and scanning all .o, .po and ${PICO} meta files +# is a waste of time, this tells meta.autodep.mk to just pick one +# (typically ${PICO}) +# yes, 42 is a random number. +.if ${MK_DIRDEPS_BUILD} == "yes" && ${SRCS:Uno:[\#]} > 42 +OPTIMIZE_OBJECT_META_FILES ?= yes +.endif + + +.if ${MK_LIBTOOL} == "yes" +# because libtool is so fascist about naming the object files, +# we cannot (yet) build profiled libs +MK_PROFILE=no +_LIBS=lib${LIB}.a +.if exists(${.CURDIR}/shlib_version) +SHLIB_AGE != . ${.CURDIR}/shlib_version ; echo $$age +.endif +.else +# for the normal .a we do not want to strip symbols +.c.o: + ${COMPILE.c} ${.IMPSRC} + +# for the normal .a we do not want to strip symbols +${CXX_SUFFIXES:%=%.o}: + ${COMPILE.cc} ${.IMPSRC} + +.S.o .s.o: + ${COMPILE.S} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} + +.if (${LD_X} == "") +.c.po: + ${COMPILE.c} ${CC_PG} ${PROFFLAGS} ${.IMPSRC} -o ${.TARGET} + +${CXX_SUFFIXES:%=%.po}: + ${COMPILE.cc} -pg ${.IMPSRC} -o ${.TARGET} + +.S${PICO} .s${PICO}: + ${COMPILE.S} ${PICFLAG} ${CC_PIC} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET} +.else +.c.po: + ${COMPILE.c} ${CC_PG} ${PROFFLAGS} ${.IMPSRC} -o ${.TARGET}.o + @${LD} ${LD_X} ${LD_r} ${.TARGET}.o -o ${.TARGET} + @rm -f ${.TARGET}.o + +${CXX_SUFFIXES:%=%.po}: + ${COMPILE.cc} ${CXX_PG} ${.IMPSRC} -o ${.TARGET}.o + ${LD} ${LD_X} ${LD_r} ${.TARGET}.o -o ${.TARGET} + @rm -f ${.TARGET}.o + +.S${PICO} .s${PICO}: + ${COMPILE.S} ${PICFLAG} ${CC_PIC} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o + ${LD} ${LD_x} ${LD_r} ${.TARGET}.o -o ${.TARGET} + @rm -f ${.TARGET}.o +.endif + +.if (${LD_x} == "") +.c${PICO}: + ${COMPILE.c} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET} + +${CXX_SUFFIXES:%=%${PICO}}: + ${COMPILE.cc} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET} + +.S.po .s.po: + ${COMPILE.S} ${PROFFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET} +.else + +.c${PICO}: + ${COMPILE.c} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}.o + ${LD} ${LD_x} ${LD_r} ${.TARGET}.o -o ${.TARGET} + @rm -f ${.TARGET}.o + +${CXX_SUFFIXES:%=%${PICO}}: + ${COMPILE.cc} ${PICFLAG} ${CC_PIC} ${.IMPSRC} -o ${.TARGET}.o + ${LD} ${LD_x} ${LD_r} ${.TARGET}.o -o ${.TARGET} + @rm -f ${.TARGET}.o + +.S.po .s.po: + ${COMPILE.S} ${PROFFLAGS} ${CFLAGS:M-[ID]*} ${AINC} ${.IMPSRC} -o ${.TARGET}.o + ${LD} ${LD_X} ${LD_r} ${.TARGET}.o -o ${.TARGET} + @rm -f ${.TARGET}.o + +.endif +.endif + +.c.ln: + ${LINT} ${LINTFLAGS} ${CFLAGS:M-[IDU]*} -i ${.IMPSRC} + +.if ${MK_LIBTOOL} != "yes" + +.if !defined(PICFLAG) +PICFLAG=-fpic +.endif + +_LIBS= + +.if ${MK_ARCHIVE} != "no" +_LIBS += lib${LIB}.a +.endif + +.if ${MK_PROFILE} != "no" +_LIBS+=lib${LIB}_p.a +POBJS+=${OBJS:.o=.po} +.endif + +.if ${MK_PIC} != "no" +.if ${MK_PICLIB} == "no" +SOLIB ?= lib${LIB}.a +.else +SOLIB=lib${LIB}_pic.a +_LIBS+=${SOLIB} +.endif +.if !empty(SHLIB_FULLVERSION) +_LIBS+=lib${LIB}.${LD_so} +.endif +.endif + +.if ${MK_LINT} != "no" +_LIBS+=llib-l${LIB}.ln +.endif + +# here is where you can define what LIB* are +.-include <libnames.mk> +.if ${MK_DPADD_MK} == "yes" +# lots of cool magic, but might not suit everyone. +.include <dpadd.mk> +.endif + +.if empty(LIB) +_LIBS= +.elif ${MK_LDORDER_MK} != "no" +# Record any libs that we need to be linked with +_LIBS+= ${libLDORDER_INC} + +.include <ldorder.mk> +.endif + +.if !defined(_SKIP_BUILD) +realbuild: ${_LIBS} +.endif + +all: _SUBDIRUSE + +.for s in ${SRCS:N*.h:M*/*} +${.o ${PICO} .po .lo:L:@o@${s:T:R}$o@}: $s +.endfor + +OBJS+= ${SRCS:T:N*.h:R:S/$/.o/g} +.NOPATH: ${OBJS} + +.if ${MK_LIBTOOL} == "yes" +.if ${MK_PIC} == "no" +LT_STATIC=-static +.else +LT_STATIC= +.endif +SHLIB_AGE?=0 + +# .lo's are created as a side effect +.s.o .S.o .c.o: + ${LIBTOOL} --mode=compile ${CC} ${LT_STATIC} ${CFLAGS} ${CPPFLAGS} ${IMPFLAGS} -c ${.IMPSRC} + +# can't really do profiled libs with libtool - its too fascist about +# naming the output... +lib${LIB}.a: ${OBJS} + @rm -f ${.TARGET} + ${LIBTOOL} --mode=link ${CC} ${LT_STATIC} -o ${.TARGET:.a=.la} ${OBJS:.o=.lo} -rpath ${SHLIBDIR}:/usr/lib -version-info ${SHLIB_MAJOR}:${SHLIB_MINOR}:${SHLIB_AGE} + @ln .libs/${.TARGET} . + +lib${LIB}.${LD_so}: lib${LIB}.a + @[ -s ${.TARGET}.${SHLIB_AGE} ] || { ln -s .libs/lib${LIB}.${LD_so}* . 2>/dev/null; : } + @[ -s ${.TARGET} ] || ln -s ${.TARGET}.${SHLIB_AGE} ${.TARGET} + +.else # MK_LIBTOOL=yes + +lib${LIB}.a: ${OBJS} + @${META_NOECHO} building standard ${LIB} library + @rm -f ${.TARGET} + @${AR} ${AR_cq} ${.TARGET} ${LD_objs} + ${RANLIB} ${.TARGET} + +POBJS+= ${OBJS:.o=.po} +.NOPATH: ${POBJS} +lib${LIB}_p.a: ${POBJS} + @${META_NOECHO} building profiled ${LIB} library + @rm -f ${.TARGET} + @${AR} ${AR_cq} ${.TARGET} ${LD_pobjs} + ${RANLIB} ${.TARGET} + +SOBJS+= ${OBJS:.o=${PICO}} +.NOPATH: ${SOBJS} +lib${LIB}_pic.a: ${SOBJS} + @${META_NOECHO} building shared object ${LIB} library + @rm -f ${.TARGET} + @${AR} ${AR_cq} ${.TARGET} ${LD_sobjs} + ${RANLIB} ${.TARGET} + +#SHLIB_LDADD?= ${LDADD} + +# bound to be non-portable... +# this is known to work for NetBSD 1.6 and FreeBSD 4.2 +lib${LIB}.${LD_so}: ${SOLIB} ${DPADD} + @${META_NOECHO} building shared ${LIB} library \(version ${SHLIB_FULLVERSION}\) + @rm -f ${.TARGET} +.if ${TARGET_OSNAME} == "NetBSD" || ${TARGET_OSNAME} == "FreeBSD" +.if ${OBJECT_FMT} == "ELF" + ${SHLIB_LD} -x -shared ${SHLIB_SHFLAGS} -o ${.TARGET} \ + ${SHLIB_LDSTARTFILE} \ + --whole-archive ${SOLIB} --no-whole-archive ${SHLIB_LDADD} \ + ${SHLIB_LDENDFILE} +.else + ${SHLIB_LD} ${LD_x} ${LD_shared} \ + -o ${.TARGET} ${SOLIB} ${SHLIB_LDADD} +.endif +.else + ${SHLIB_LD} -o ${.TARGET} ${LD_shared} ${LD_solib} ${DLLIB} ${SHLIB_LDADD} +.endif +.endif +.if !empty(SHLIB_LINKS) + rm -f ${SHLIB_LINKS}; ${SHLIB_LINKS:O:u:@x@ln -s ${.TARGET} $x;@} +.endif + +LOBJS+= ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln} +.NOPATH: ${LOBJS} +LLIBS?= -lc +llib-l${LIB}.ln: ${LOBJS} + @${META_NOECHO} building llib-l${LIB}.ln + @rm -f llib-l${LIB}.ln + @${LINT} -C${LIB} ${LOBJS} ${LLIBS} + +.if !target(clean) +cleanlib: .PHONY + rm -f a.out [Ee]rrs mklog core *.core ${CLEANFILES} + rm -f lib${LIB}.a ${OBJS} + rm -f lib${LIB}_p.a ${POBJS} + rm -f lib${LIB}_pic.a lib${LIB}.so.*.* ${SOBJS} + rm -f llib-l${LIB}.ln ${LOBJS} +.if !empty(SHLIB_LINKS) + rm -f ${SHLIB_LINKS} +.endif + +clean: _SUBDIRUSE cleanlib +cleandir: _SUBDIRUSE cleanlib +.else +cleandir: _SUBDIRUSE clean +.endif + +.if defined(SRCS) && (!defined(MKDEP) || ${MKDEP} != autodep) +afterdepend: .depend + @(TMP=/tmp/_depend$$$$; \ + sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.po \1${PICO} \1.ln:/' \ + < .depend > $$TMP; \ + mv $$TMP .depend) +.endif + +.if !target(install) +.if !target(beforeinstall) +beforeinstall: +.endif + +.if !empty(LIBOWN) +LIB_INSTALL_OWN ?= -o ${LIBOWN} -g ${LIBGRP} +.endif + +.include <links.mk> + +.if !target(libinstall) && !empty(LIB) +realinstall: libinstall +libinstall: + [ -d ${DESTDIR}/${LIBDIR} ] || \ + ${INSTALL} -d ${LIB_INSTALL_OWN} -m 775 ${DESTDIR}${LIBDIR} +.if ${MK_ARCHIVE} != "no" + ${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m 644 lib${LIB}.a \ + ${DESTDIR}${LIBDIR} + ${RANLIB} ${DESTDIR}${LIBDIR}/lib${LIB}.a + chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}.a +.endif +.if ${MK_PROFILE} != "no" + ${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m 644 \ + lib${LIB}_p.a ${DESTDIR}${LIBDIR} + ${RANLIB} ${DESTDIR}${LIBDIR}/lib${LIB}_p.a + chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_p.a +.endif +.if ${MK_LDORDER_MK} != "no" + ${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m 644 \ + lib${LIB}.ldorder.inc ${DESTDIR}${LIBDIR} +.endif +.if ${MK_PIC} != "no" +.if ${MK_PICLIB} != "no" + ${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m 644 \ + lib${LIB}_pic.a ${DESTDIR}${LIBDIR} + ${RANLIB} ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a + chmod ${LIBMODE} ${DESTDIR}${LIBDIR}/lib${LIB}_pic.a +.endif +.if !empty(SHLIB_MAJOR) + ${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m ${LIBMODE} \ + lib${LIB}.${LD_so} ${DESTDIR}${LIBDIR} +.if !empty(SHLIB_LINKS) + (cd ${DESTDIR}${LIBDIR} && { rm -f ${SHLIB_LINKS}; ${SHLIB_LINKS:O:u:@x@ln -s lib${LIB}.${LD_so} $x;@} }) +.endif +.endif +.endif +.if ${MK_LINT} != "no" && ${MK_LINKLIB} != "no" && !empty(LOBJS) + ${INSTALL} ${COPY} ${LIB_INSTALL_OWN} -m ${LIBMODE} \ + llib-l${LIB}.ln ${DESTDIR}${LINTLIBDIR} +.endif +.if defined(LINKS) && !empty(LINKS) + @set ${LINKS}; ${_LINKS_SCRIPT} +.endif +.endif + +.if ${MK_MAN} != "no" +install: maninstall _SUBDIRUSE +maninstall: afterinstall +.endif +afterinstall: realinstall +libinstall: beforeinstall +realinstall: beforeinstall +.endif + +.if defined(FILES) || defined(FILESGROUPS) +.include <files.mk> +.endif + +.if ${MK_MAN} != "no" +.include <man.mk> +.endif + +.if ${MK_NLS} != "no" +.include <nls.mk> +.endif + +.include <obj.mk> +.include <inc.mk> +.include <dep.mk> +.include <subdir.mk> +.endif + +# during building we usually need/want to install libs somewhere central +# note that we do NOT ch{own,grp} as that would likely fail at this point. +# otherwise it is the same as realinstall +# Note that we don't need this when using dpadd.mk +.libinstall: ${_LIBS} + test -d ${DESTDIR}${LIBDIR} || ${INSTALL} -d -m775 ${DESTDIR}${LIBDIR} +.for _lib in ${_LIBS:M*.a} + ${INSTALL} ${COPY} -m 644 ${_lib} ${DESTDIR}${LIBDIR} + ${RANLIB} ${DESTDIR}${LIBDIR}/${_lib} +.endfor +.for _lib in ${_LIBS:M*.${LD_solink}*:O:u} + ${INSTALL} ${COPY} -m ${LIBMODE} ${_lib} ${DESTDIR}${LIBDIR} +.if !empty(SHLIB_LINKS) + (cd ${DESTDIR}${LIBDIR} && { ${SHLIB_LINKS:O:u:@x@ln -sf ${_lib} $x;@}; }) +.endif +.endfor + @touch ${.TARGET} + +.if !empty(LIB) +STAGE_LIBDIR?= ${STAGE_OBJTOP}${LIBDIR} +stage_libs: ${_LIBS} +.endif + +.include <final.mk> +.endif diff --git a/devel/bmake/files/mk/libnames.mk b/devel/bmake/files/mk/libnames.mk new file mode 100644 index 00000000000..586b6df6747 --- /dev/null +++ b/devel/bmake/files/mk/libnames.mk @@ -0,0 +1,22 @@ +# $Id: libnames.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 2007-2009, 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 +# + +DLIBEXT ?= .a +DSHLIBEXT ?= .so + +.-include <local.libnames.mk> +.-include <sjg.libnames.mk> +.-include <fwall.libnames.mk> +.-include <host.libnames.mk> diff --git a/devel/bmake/files/mk/libs.mk b/devel/bmake/files/mk/libs.mk new file mode 100644 index 00000000000..5479d992c5b --- /dev/null +++ b/devel/bmake/files/mk/libs.mk @@ -0,0 +1,93 @@ +# $Id: libs.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 2006, 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 +# + +.MAIN: all + +.if defined(LIBS) + +# In meta mode, we can capture dependenices for _one_ of the progs. +# if makefile doesn't nominate one, we use the first. +.ifndef UPDATE_DEPENDFILE_LIB +UPDATE_DEPENDFILE_LIB = ${LIBS:[1]} +.export UPDATE_DEPENDFILE_LIB +.endif + +.ifndef LIB +# They may have asked us to build just one +.for t in ${LIBS:R:T:S,^lib,,} +.if make(lib$t) +LIB?= $t +lib$t: all +.endif +.endfor +.endif + +.if defined(LIB) +# just one of many +LIB_VARS += \ + LIBDIR \ + CFLAGS \ + COPTS \ + CPPFLAGS \ + CXXFLAGS \ + DPADD \ + DPLIBS \ + LDADD \ + LDFLAGS \ + MAN \ + SRCS + +.for v in ${LIB_VARS:O:u} +.if defined(${v}.${LIB}) || defined(${v}_${LIB}) +$v += ${${v}_${LIB}:U${${v}.${LIB}}} +.endif +.endfor + +# for meta mode, there can be only one! +.if ${LIB} == ${UPDATE_DEPENDFILE_LIB:Uno} +UPDATE_DEPENDFILE ?= yes +.endif +UPDATE_DEPENDFILE ?= NO + +# ensure that we don't clobber each other's dependencies +DEPENDFILE?= .depend.${LIB} +# lib.mk will do the rest +.else +all: ${LIBS:S,^lib,,:@t@lib$t.a@} .MAKE + +# We cannot capture dependencies for meta mode here +UPDATE_DEPENDFILE = NO +# nor can we safely run in parallel. +.NOTPARALLEL: +.endif +.endif + +# handle being called [bsd.]libs.mk +.include <${.PARSEFILE:S,libs,lib,}> + +.ifndef LIB +# tell libs.mk we might want to install things +LIBS_TARGETS+= cleandepend cleandir cleanobj depend install + +.for b in ${LIBS:R:T:S,^lib,,} +lib$b.a: ${SRCS} ${DPADD} ${SRCS_lib$b} ${DPADD_lib$b} + (cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} LIB=$b) + +.for t in ${LIBS_TARGETS:O:u} +$b.$t: .PHONY .MAKE + (cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} LIB=$b ${@:E}) +.endfor +.endfor +.endif diff --git a/devel/bmake/files/mk/links.mk b/devel/bmake/files/mk/links.mk new file mode 100644 index 00000000000..c776295ce7a --- /dev/null +++ b/devel/bmake/files/mk/links.mk @@ -0,0 +1,80 @@ +# $Id: links.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 2005, 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 +# + +# some platforms need something special +LN?= ln +ECHO?= echo + +LINKS?= +SYMLINKS?= + +__SYMLINK_SCRIPT= \ + ${ECHO} "$$t -> $$l"; \ + case `'ls' -l $$t 2> /dev/null` in \ + *"> $$l") ;; \ + *) \ + mkdir -p `dirname $$t`; \ + rm -f $$t; \ + ${LN} -s $$l $$t;; \ + esac + + +__LINK_SCRIPT= \ + ${ECHO} "$$t -> $$l"; \ + mkdir -p `dirname $$t`; \ + rm -f $$t; \ + ${LN} $$l $$t + +_SYMLINKS_SCRIPT= \ + while test $$\# -ge 2; do \ + l=$$1; shift; \ + t=${DESTDIR}$$1; shift; \ + ${__SYMLINK_SCRIPT}; \ + done; :; + +_LINKS_SCRIPT= \ + while test $$\# -ge 2; do \ + l=${DESTDIR}$$1; shift; \ + t=${DESTDIR}$$1; shift; \ + ${__LINK_SCRIPT}; \ + done; :; + +_SYMLINKS_USE: .USE + @set ${$@_SYMLINKS:U${SYMLINKS}}; ${_SYMLINKS_SCRIPT} + +_LINKS_USE: .USE + @set ${$@_LINKS:U${LINKS}}; ${_LINKS_SCRIPT} + + +# sometimes we want to ensure DESTDIR is ignored +_BUILD_SYMLINKS_SCRIPT= \ + while test $$\# -ge 2; do \ + l=$$1; shift; \ + t=$$1; shift; \ + ${__SYMLINK_SCRIPT}; \ + done; :; + +_BUILD_LINKS_SCRIPT= \ + while test $$\# -ge 2; do \ + l=$$1; shift; \ + t=$$1; shift; \ + ${__LINK_SCRIPT}; \ + done; :; + +_BUILD_SYMLINKS_USE: .USE + @set ${$@_SYMLINKS:U${SYMLINKS}}; ${_BUILD_SYMLINKS_SCRIPT} + +_BUILD_LINKS_USE: .USE + @set ${$@_LINKS:U${LINKS}}; ${_BUILD_LINKS_SCRIPT} diff --git a/devel/bmake/files/mk/man.mk b/devel/bmake/files/mk/man.mk new file mode 100644 index 00000000000..d1fa999c56c --- /dev/null +++ b/devel/bmake/files/mk/man.mk @@ -0,0 +1,137 @@ +# $Id: man.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ + +.if !target(__${.PARSEFILE}__) +__${.PARSEFILE}__: + +.include <init.mk> + +# unlike bsd.man.mk we handle 3 approaches +# 1. install unformated nroff (default) +# 2. install formatted pages +# 3. install formatted pages but with extension of .0 +# sadly we cannot rely on a shell that supports ${foo#...} and ${foo%...} +# so we have to use sed(1). + +# set MANTARGET=cat for formatted pages +MANTARGET?= man +# set this to .0 for same behavior as bsd.man.mk +MCATEXT?= + +NROFF?= nroff +MANDIR?= /usr/share/man +MANDOC?= man + +.SUFFIXES: .1 .2 .3 .4 .5 .6 .7 .8 .9 .cat1 .cat2 .cat3 .cat4 .cat5 .cat6 \ + .cat7 .cat8 .cat9 + +.9.cat9 .8.cat8 .7.cat7 .6.cat6 .5.cat5 .4.cat4 .3.cat3 .2.cat2 .1.cat1: + @echo "${NROFF} -${MANDOC} ${.IMPSRC} > ${.TARGET:T}" + @${NROFF} -${MANDOC} ${.IMPSRC} > ${.TARGET:T} || ( rm -f ${.TARGET:T} ; false ) + +.if defined(MAN) && !empty(MAN) + +# we use cmt2doc.pl to extract manpages from source +# this is triggered by the setting of EXTRACT_MAN or MAN being set but +# not existsing. + +.if !exists(${MAN:[1]}) && !target(${MAN:[1]}) +.if defined(EXTRACT_MAN) && ${EXTRACT_MAN} == "no" +MAN= +.else +.if exists(/usr/local/share/bin/cmt2doc.pl) +CMT2DOC?= cmt2doc.pl +CMT2DOC_OPTS?= ${CMT2DOC_ORGOPT} -pmS${.TARGET:E} +.endif +.ifdef CMT2DOC +.c.8 .c.5 .c.3 .c.4 .c.1 \ + .cc.8 .cc.5 .cc.3 .cc.4 .cc.1 \ + .h.8 .h.5 .h.3 .h.4 .h.1 \ + .sh.8 .sh.5 .sh.3 .sh.4 .sh.1 \ + .pl.8 .pl.5 .pl.3 .pl.4 .pl.1: + @echo "${CMT2DOC} ${.IMPSRC} > ${.TARGET:T}" + @${CMT2DOC} ${CMT2DOC_OPTS} ${.IMPSRC} > ${.TARGET:T} || ( rm -f ${.TARGET:T} ; false ) +.else +MAN= +.endif +.endif +.endif + +_mandir=${DESTDIR}${MANDIR}/${MANTARGET}`echo $$page | sed -e 's/.*\.cat/./' -e 's/.*\.//'` +.if ${MANTARGET} == "cat" +_mfromdir?=. +MANALL= ${MAN:S/.1$/.cat1/g:S/.2$/.cat2/g:S/.3$/.cat3/g:S/.4$/.cat4/g:S/.5$/.cat5/g:S/.6$/.cat6/g:S/.7$/.cat7/g:S/.8$/.cat8/g:S/.9$/.cat9/g} +.if ${MCATEXT} == "" +_minstpage=`echo $$page | sed 's/\.cat/./'` +.else +_minstpage=`echo $$page | sed 's/\.cat.*//'`${MCATEXT} +.endif +.endif +.if target(${MAN:[1]}) +_mfromdir?=. +.endif +_mfromdir?=${.CURDIR} +MANALL?= ${MAN} +_minstpage?=$${page} +.endif + +.if !empty(MANOWN) +MAN_INSTALL_OWN ?= -o ${MANOWN} -g ${MANGRP} +MAN_CHOWN ?= chown +.else +MAN_CHOWN = : +.endif + +MINSTALL= ${INSTALL} ${COPY} ${MAN_INSTALL_OWN} -m ${MANMODE} +.if defined(MANZ) +# chown and chmod are done afterward automatically +MCOMPRESS= gzip -cf +MCOMPRESSSUFFIX= .gz +.endif + +maninstall: +.if defined(MANALL) && !empty(MANALL) + @for page in ${MANALL:T}; do \ + test -s ${_mfromdir}/$$page || continue; \ + dir=${_mandir}; \ + test -d $$dir || ${INSTALL} -d ${MAN_INSTALL_OWN} -m 775 $$dir; \ + instpage=$${dir}${MANSUBDIR}/${_minstpage}${MCOMPRESSSUFFIX}; \ + if [ X"${MCOMPRESS}" = X ]; then \ + echo ${MINSTALL} ${_mfromdir}/$$page $$instpage; \ + ${MINSTALL} ${_mfromdir}/$$page $$instpage; \ + else \ + rm -f $$instpage; \ + echo ${MCOMPRESS} ${_mfromdir}/$$page \> $$instpage; \ + ${MCOMPRESS} ${_mfromdir}/$$page > $$instpage; \ + ${MAN_CHOWN} ${MANOWN}:${MANGRP} $$instpage; \ + chmod ${MANMODE} $$instpage; \ + fi \ + done +.if defined(MLINKS) && !empty(MLINKS) + @set ${MLINKS}; \ + while test $$# -ge 2; do \ + page=$$1; \ + shift; \ + dir=${_mandir}; \ + l=${_minstpage}${MCOMPRESSSUFFIX}; \ + page=$$1; \ + shift; \ + dir=${_mandir}; \ + t=$${dir}${MANSUBDIR}/${_minstpage}${MCOMPRESSSUFFIX}; \ + echo $$t -\> $$l; \ + rm -f $$t; \ + ln -s $$l $$t; \ + done +.endif +.endif + +.if defined(MANALL) && !empty(MANALL) +manall: ${MANALL} +all: manall +.endif + +.if defined(CLEANMAN) && !empty(CLEANMAN) +cleandir: cleanman +cleanman: + rm -f ${CLEANMAN} +.endif +.endif diff --git a/devel/bmake/files/mk/manifest.mk b/devel/bmake/files/mk/manifest.mk new file mode 100644 index 00000000000..535cf67e5a1 --- /dev/null +++ b/devel/bmake/files/mk/manifest.mk @@ -0,0 +1,66 @@ +# $Id: manifest.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 2014, 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 +# + +# generate mtree style manifest supported by makefs in FreeBSD + +# input looks like +# MANIFEST= my.mtree +# for each MANIFEST we have a list of dirs +# ${MANIFEST}.DIRS += bin sbin usr/bin ... +# for each dir we have a ${MANIFEST}.SRCS.$dir +# that provides the absolute path to the contents +# ${MANIFEST}.SRCS.bin += ${OBJTOP}/bin/sh/sh +# ${MANIFEST}.SYMLINKS is a list of src target pairs +# for each file/dir there are a number of attributes +# UID GID MODE FLAGS +# which can be set per dir, per file or we use defaults +# eg. +# MODE.sbin = 550 +# MODE.usr/sbin = 550 +# MODE.dirs = 555 +# means that sbin and usr/sbin get 550 all other dirs get 555 +# MODE.usr/bin/passwd = 4555 +# MODE.usr/bin.files = 555 +# MODE.usr/sbin.files = 500 +# means passwd gets 4555 other files in usr/bin get 555 and +# files in usr/sbin get 500 +# STORE defaults to basename of src and target directory +# but we can use +# ${MANIFEST}.SRCS.sbin += ${OBJTOP}/bin/sh-static/sh-static +# STORE.sbin/sh-static = sbin/sh +# +# the above is a little overkill but means we can easily adapt to +# different formats + +UID.dirs ?= 0 +GID.dirs ?= 0 +MODE.dirs ?= 775 +FLAGS.dirs ?= + +UID.files ?= 0 +GID.files ?= 0 +MODE.files ?= 555 + +# a is attribute name d is dirname +M_DIR_ATTR = L:@a@$${$$a.$$d:U$${$$a.dirs}}@ +# as above and s is set to the name we store f as +M_FILE_ATTR = L:@a@$${$$a.$$s:U$${$$a.$$d.files:U$${$$a.files}}}@ + +# this produces the body of the manifest +# there should typically be a header prefixed +_GEN_MTREE_MANIFEST_USE: .USE + @(${${.TARGET}.DIRS:O:u:@d@echo '$d type=dir uid=${UID:${M_DIR_ATTR}} gid=${GID:${M_DIR_ATTR}} mode=${MODE:${M_DIR_ATTR}} ${FLAGS:${M_DIR_ATTR}}';@} \ + ${${.TARGET}.DIRS:O:u:@d@${${.TARGET}.SRCS.$d:O:u:@f@echo '${s::=${STORE.$d/${f:T}:U$d/${f:T}}}$s contents="$f" type=file uid=${UID:${M_FILE_ATTR}} gid=${GID:${M_FILE_ATTR}} mode=${MODE:${M_FILE_ATTR}} ${FLAGS:${M_FILE_ATTR}}';@}@} \ + set ${${.TARGET}.SYMLINKS}; while test $$# -ge 2; do echo "$$2 type=link link=$$1"; shift 2; done) > ${.TARGET} diff --git a/devel/bmake/files/mk/meta.autodep.mk b/devel/bmake/files/mk/meta.autodep.mk new file mode 100644 index 00000000000..ea4a79bb536 --- /dev/null +++ b/devel/bmake/files/mk/meta.autodep.mk @@ -0,0 +1,320 @@ +# $Id: meta.autodep.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ + +# +# @(#) Copyright (c) 2010, 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 +# + +_this ?= ${.PARSEFILE} +.if !target(__${_this}__) +__${_this}__: .NOTMAIN + +.-include <local.autodep.mk> + +PICO?= .pico + +.if defined(SRCS) +# it would be nice to be able to query .SUFFIXES +OBJ_EXTENSIONS+= .o .po .lo ${PICO} + +# explicit dependencies help short-circuit .SUFFIX searches +SRCS_DEP_FILTER+= N*.[hly] +.for s in ${SRCS:${SRCS_DEP_FILTER:O:u:ts:}} +.for e in ${OBJ_EXTENSIONS:O:u} +.if !target(${s:T:R}$e) +${s:T:R}$e: $s +.endif +.endfor +.endfor +.endif + +.if make(gendirdeps) +# you are supposed to know what you are doing! +UPDATE_DEPENDFILE = yes +.elif !empty(.TARGETS) && !make(all) +# do not update the *depend* files +# unless we are building the entire directory or the default target. +# NO means don't update .depend - or Makefile.depend* +# no means update .depend but not Makefile.depend* +UPDATE_DEPENDFILE = NO +.elif ${.MAKEFLAGS:M-k} != "" +# it is a bad idea to update anything +UPDATE_DEPENDFILE = NO +.endif + +_CURDIR ?= ${.CURDIR} +_OBJDIR ?= ${.OBJDIR} +_OBJTOP ?= ${OBJTOP} +_OBJROOT ?= ${OBJROOT:U${_OBJTOP}} +_DEPENDFILE := ${_CURDIR}/${.MAKE.DEPENDFILE:T} + +.if ${.MAKE.LEVEL} > 0 || ${BUILD_AT_LEVEL0:Uyes:tl} == "yes" +# do not allow auto update if we ever built this dir without filemon +NO_FILEMON_COOKIE = .nofilemon +CLEANFILES += ${NO_FILEMON_COOKIE} +.if ${.MAKE.MODE:Uno:Mnofilemon} != "" +UPDATE_DEPENDFILE = NO +all: ${NO_FILEMON_COOKIE} +${NO_FILEMON_COOKIE}: .NOMETA + @echo UPDATE_DEPENDFILE=NO > ${.TARGET} +.elif exists(${NO_FILEMON_COOKIE}) +UPDATE_DEPENDFILE = NO +.warning ${RELDIR} built with nofilemon; UPDATE_DEPENDFILE=NO +.endif +.endif + +.if ${.MAKE.LEVEL} == 0 +.if ${BUILD_AT_LEVEL0:Uyes:tl} == "no" +UPDATE_DEPENDFILE = NO +.endif +.endif +.if !exists(${_DEPENDFILE}) +_bootstrap_dirdeps = yes +.endif +_bootstrap_dirdeps ?= no +UPDATE_DEPENDFILE ?= yes + +.if ${DEBUG_AUTODEP:Uno:@m@${RELDIR:M$m}@} != "" +.info ${_DEPENDFILE:S,${SRCTOP}/,,} update=${UPDATE_DEPENDFILE} +.endif + +.if !empty(XMAKE_META_FILE) +.if exists(${.OBJDIR}/${XMAKE_META_FILE}) +# we cannot get accurate dependencies from an update build +UPDATE_DEPENDFILE = NO +.else +META_XTRAS += ${XMAKE_META_FILE} +.endif +.endif + +.if ${_bootstrap_dirdeps} == "yes" || exists(${_DEPENDFILE}) +# if it isn't supposed to be touched by us the Makefile should have +# UPDATE_DEPENDFILE = no +WANT_UPDATE_DEPENDFILE ?= yes +.endif + +.if ${WANT_UPDATE_DEPENDFILE:Uno:tl} != "no" +.if ${.MAKE.MODE:Uno:Mmeta*} == "" || ${.MAKE.MODE:Uno:M*read*} != "" +UPDATE_DEPENDFILE = no +.endif + +.if ${DEBUG_AUTODEP:Uno:@m@${RELDIR:M$m}@} != "" +.info ${_DEPENDFILE:S,${SRCTOP}/,,} update=${UPDATE_DEPENDFILE} +.endif + +.if ${UPDATE_DEPENDFILE:tl} == "yes" +# sometimes we want .meta files generated to aid debugging/error detection +# but do not want to consider them for dependencies +# for example the result of running configure +# just make sure this is not empty +META_FILE_FILTER ?= N.meta +# never consider these +META_FILE_FILTER += Ndirdeps.cache* + +.if !empty(DPADD) +# if we have any non-libs in DPADD, +# they probably need to be paid attention to +.if !empty(DPLIBS) +FORCE_DPADD = ${DPADD:${DPLIBS:${M_ListToSkip}}:${DPADD_LAST:${M_ListToSkip}}} +.else +_nonlibs := ${DPADD:T:Nlib*:N*include} +.if !empty(_nonlibs) +FORCE_DPADD += ${_nonlibs:@x@${DPADD:M*/$x}@} +.endif +.endif +.endif + +.if !make(gendirdeps) +.END: gendirdeps +.endif + +# if we don't have OBJS, then .depend isn't useful +.if !target(.depend) && (!empty(OBJS) || ${.ALLTARGETS:M*.o} != "") +# some makefiles and/or targets contain +# circular dependencies if you dig too deep +# (as meta mode is apt to do) +# so we provide a means of suppressing them. +# the input to the loop below is target: dependency +# with just one dependency per line. +# Also some targets are not really local, or use random names. +# Use local.autodep.mk to provide local additions! +SUPPRESS_DEPEND += \ + ${SB:S,/,_,g}* \ + *:y.tab.c \ + *.c:*.c \ + *.h:*.h + +.NOPATH: .depend +# we use ${.MAKE.META.CREATED} to trigger an update but +# we process using ${.MAKE.META.FILES} +# the double $$ defers initial evaluation +# if necessary, we fake .po dependencies, just so the result +# in Makefile.depend* is stable +# The current objdir may be referred to in various ways +OBJDIR_REFS += ${.OBJDIR} ${.OBJDIR:tA} ${_OBJDIR} ${RELOBJTOP}/${RELDIR} +_depend = .depend +# it would be nice to be able to get .SUFFIXES as ${.SUFFIXES} +# we actually only care about the .SUFFIXES of files that might be +# generated by tools like yacc. +DEPEND_SUFFIXES += .c .h .cpp .hpp .cxx .hxx .cc .hh +.depend: .NOMETA $${.MAKE.META.CREATED} ${_this} + @echo "Updating $@: ${.OODATE:T:[1..8]}" + @egrep -i '^R .*\.(${DEPEND_SUFFIXES:tl:O:u:S,^.,,:ts|})$$' /dev/null ${.MAKE.META.FILES:T:O:u:${META_FILE_FILTER:ts:}:M*o.meta} | \ + sed -e 's, \./, ,${OBJDIR_REFS:O:u:@d@;s, $d/, ,@};/\//d' \ + -e 's,^\([^/][^/]*\).meta...[0-9]* ,\1: ,' | \ + sort -u | \ + while read t d; do \ + case "$$d:" in $$t) continue;; esac; \ + case "$$t$$d" in ${SUPPRESS_DEPEND:U.:O:u:ts|}) continue;; esac; \ + echo $$t $$d; \ + done > $@.${.MAKE.PID} + @case "${.MAKE.META.FILES:T:M*.po.*}" in \ + *.po.*) mv $@.${.MAKE.PID} $@;; \ + *) { cat $@.${.MAKE.PID}; \ + sed 's,\${PICO}:,.o:,;s,\.o:,.po:,' $@.${.MAKE.PID}; } | sort -u > $@; \ + rm -f $@.${.MAKE.PID};; \ + esac +.else +# make sure this exists +.depend: +# do _not_ assume that .depend is in any fit state for us to use +CAT_DEPEND = /dev/null +.if ${.MAKE.LEVEL} > 0 +.export CAT_DEPEND +.endif +_depend = +.endif + +.if ${DEBUG_AUTODEP:Uno:@m@${RELDIR:M$m}@} != "" +.info ${_DEPENDFILE:S,${SRCTOP}/,,} _depend=${_depend} +.endif + +.if ${UPDATE_DEPENDFILE} == "yes" +gendirdeps: ${_DEPENDFILE} +.endif + +.if !target(${_DEPENDFILE}) +.if ${_bootstrap_dirdeps} == "yes" +# We are boot-strapping a new directory +# Use DPADD to seed DIRDEPS +.if !empty(DPADD) +# anything which matches ${_OBJROOT}* but not ${_OBJTOP}* +# needs to be qualified in DIRDEPS +# The pseudo machine "host" is used for HOST_TARGET +DIRDEPS += \ + ${DPADD:M${_OBJTOP}*:H:C,${_OBJTOP}[^/]*/,,:N.:O:u} \ + ${DPADD:M${_OBJROOT}*:N${_OBJTOP}*:N${STAGE_ROOT:U${_OBJTOP}}/*:H:S,${_OBJROOT},,:C,^([^/]+)/(.*),\2.\1,:S,${HOST_TARGET}$,host,:N.*:O:u} + +.endif +.endif + +_gendirdeps_mutex = +.if defined(NEED_GENDIRDEPS_MUTEX) +# If a src dir gets built with multiple object dirs, +# we need a mutex. Obviously, this is best avoided. +# Note if .MAKE.DEPENDFILE is common for all ${MACHINE} +# you either need to mutex, or ensure only one machine builds at a time! +# lockf is an example of a suitable tool +LOCKF ?= /usr/bin/lockf +.if exists(${LOCKF}) +GENDIRDEPS_MUTEXER ?= ${LOCKF} -k +.endif +.if empty(GENDIRDEPS_MUTEXER) +.error NEED_GENDIRDEPS_MUTEX defined, but GENDIRDEPS_MUTEXER not set +.else +_gendirdeps_mutex = ${GENDIRDEPS_MUTEXER} ${GENDIRDEPS_MUTEX:U${_CURDIR}/Makefile} +.endif +.endif + +# If we have META_XTRAS we most likely did not create them +# but we need to behave as if we did. +# Avoid adding glob patterns to .MAKE.META.CREATED though. +.MAKE.META.CREATED += ${META_XTRAS:N*\**:O:u} + +.if make(gendirdeps) +META_FILES = *.meta +.elif ${OPTIMIZE_OBJECT_META_FILES:Uno:tl} == "no" +META_FILES = ${.MAKE.META.FILES:T:N.depend*:O:u} +.else +# if we have 1000's of .o.meta, ${PICO}.meta etc we need only look at one set +# it is left as an exercise for the reader to work out what this does +META_FILES = ${.MAKE.META.FILES:T:N.depend*:N*o.meta:O:u} \ + ${.MAKE.META.FILES:T:M*.${.MAKE.META.FILES:M*o.meta:R:E:O:u:[1]}.meta:O:u} +.endif + +.if ${DEBUG_AUTODEP:Uno:@m@${RELDIR:M$m}@} != "" +.info ${_DEPENDFILE:S,${SRCTOP}/,,}: ${_depend} ${.PARSEDIR}/gendirdeps.mk ${META2DEPS} xtras=${META_XTRAS} +.endif + +.if ${.MAKE.LEVEL} > 0 +.if ${UPDATE_DEPENDFILE} == "yes" +.-include <${.CURDIR}/${.MAKE.DEPENDFILE_PREFIX}.options> +.endif +.if !empty(GENDIRDEPS_FILTER) +.export GENDIRDEPS_FILTER +.endif +# export to avoid blowing command line limit +META_FILES := ${META_XTRAS:U:O:u} ${META_FILES:U:T:O:u:${META_FILE_FILTER:ts:}} +.export META_FILES +.endif + +# we might have .../ in MAKESYSPATH +_makesyspath:= ${_PARSEDIR} +${_DEPENDFILE}: ${_depend} ${.PARSEDIR}/gendirdeps.mk ${META2DEPS} $${.MAKE.META.CREATED} + @echo Checking $@: ${.OODATE:T:[1..8]} + @(cd . && ${GENDIRDEPS_ENV} \ + SKIP_GENDIRDEPS='${SKIP_GENDIRDEPS:O:u}' \ + DPADD='${FORCE_DPADD:O:u}' ${_gendirdeps_mutex} \ + MAKESYSPATH=${_makesyspath} \ + ${.MAKE} -f gendirdeps.mk RELDIR=${RELDIR} _DEPENDFILE=${_DEPENDFILE}) + @test -s $@ && touch $@; : +.endif + +.endif +.endif + +.if ${_bootstrap_dirdeps} == "yes" +.if ${BUILD_AT_LEVEL0:Uno} == "no" +DIRDEPS+= ${RELDIR}.${TARGET_SPEC:U${MACHINE}} +.endif +# make sure this is included at least once +.include <dirdeps.mk> +.else +${_DEPENDFILE}: .PRECIOUS +.endif + +CLEANFILES += *.meta filemon.* *.db + +# these make it easy to gather some stats +now_utc = ${%s:L:gmtime} +start_utc := ${now_utc} + +meta_stats= meta=${empty(.MAKE.META.FILES):?0:${.MAKE.META.FILES:[#]}} \ + created=${empty(.MAKE.META.CREATED):?0:${.MAKE.META.CREATED:[#]}} + +#.END: _reldir_finish +.if target(gendirdeps) +_reldir_finish: gendirdeps +.endif +_reldir_finish: .NOMETA + @echo "${TIME_STAMP} Finished ${RELDIR}.${TARGET_SPEC} seconds=$$(( ${now_utc} - ${start_utc} )) ${meta_stats}" + +#.ERROR: _reldir_failed +_reldir_failed: .NOMETA + @echo "${TIME_STAMP} Failed ${RELDIR}.${TARGET_SPEC} seconds=$$(( ${now_utc} - ${start_utc} )) ${meta_stats}" + +.if defined(WITH_META_STATS) && ${.MAKE.LEVEL} > 0 +.END: _reldir_finish +.ERROR: _reldir_failed +.endif + +.endif diff --git a/devel/bmake/files/mk/meta.stage.mk b/devel/bmake/files/mk/meta.stage.mk new file mode 100644 index 00000000000..427bbb878b0 --- /dev/null +++ b/devel/bmake/files/mk/meta.stage.mk @@ -0,0 +1,366 @@ +# $Id: meta.stage.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 2011-2017, 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 +# + +.ifndef NO_STAGING + +.if !target(__${.PARSEFILE}__) +# the guard target is defined later + +.-include <local.meta.stage.mk> + +.if ${.MAKE.DEPENDFILE_PREFERENCE:U${.MAKE.DEPENDFILE}:M*.${MACHINE}} != "" +# this is generally safer anyway +_dirdep ?= ${RELDIR}.${TARGET_SPEC:U${MACHINE}} +.else +_dirdep ?= ${RELDIR} +.endif + +CLEANFILES+= .dirdep + +# this allows us to trace dependencies back to their src dir +.dirdep: .NOPATH + @echo '${_dirdep}' > $@ + +.if defined(NO_POSIX_SHELL) || ${type printf:L:sh:Mbuiltin} == "" +_stage_file_basename = `basename $$f` +_stage_target_dirname = `dirname $$t` +.else +_stage_file_basename = $${f\#\#*/} +_stage_target_dirname = $${t%/*} +.endif + +_OBJROOT ?= ${OBJROOT:U${OBJTOP:H}} +.if ${_OBJROOT:M*/} != "" +_objroot ?= ${_OBJROOT:tA}/ +.else +_objroot ?= ${_OBJROOT:tA} +.endif + +# make sure this is global +_STAGED_DIRS ?= +.export _STAGED_DIRS +# add each dir we stage to to _STAGED_DIRS +# and make sure we have absolute paths so that bmake +# will match against .MAKE.META.BAILIWICK +STAGE_DIR_FILTER = tA:@d@$${_STAGED_DIRS::+=$$d}$$d@ +# convert _STAGED_DIRS into suitable filters +GENDIRDEPS_FILTER += Nnot-empty-is-important \ + ${_STAGED_DIRS:O:u:M${OBJTOP}*:S,${OBJTOP}/,N,} \ + ${_STAGED_DIRS:O:u:M${_objroot}*:N${OBJTOP}*:S,${_objroot},,:C,^([^/]+)/(.*),N\2.\1,:S,${HOST_TARGET},.host,} + +LN_CP_SCRIPT = LnCp() { \ + rm -f $$2 2> /dev/null; \ + { [ -z "$$mode" ] && ${LN:Uln} $$1 $$2 2> /dev/null; } || \ + cp -p $$1 $$2; } + +# a staging conflict should cause an error +# a warning is handy when bootstapping different options. +STAGE_CONFLICT?= ERROR +.if ${STAGE_CONFLICT:tl} == "error" +STAGE_CONFLICT_ACTION= exit 1 +.else +STAGE_CONFLICT_ACTION= +.endif + +# it is an error for more than one src dir to try and stage +# the same file +STAGE_DIRDEP_SCRIPT = ${LN_CP_SCRIPT}; StageDirdep() { \ + t=$$1; \ + if [ -s $$t.dirdep ]; then \ + cmp -s .dirdep $$t.dirdep && return; \ + x=`cat $$t.dirdep`; \ + case "${RELDIR}:${_dirdep}" in $${x%.*}:$${x}*) ;; \ + *) echo "${STAGE_CONFLICT}: $$t installed by $$x not ${_dirdep}" >&2; \ + ${STAGE_CONFLICT_ACTION} ;; esac; \ + fi; \ + LnCp .dirdep $$t.dirdep || exit 1; } + +# common logic for staging files +# this all relies on RELDIR being set to a subdir of SRCTOP +# we use ln(1) if we can, else cp(1) +STAGE_FILE_SCRIPT = ${STAGE_DIRDEP_SCRIPT}; StageFiles() { \ + case "$$1" in "") return;; -m) mode=$$2; shift 2;; *) mode=;; esac; \ + dest=$$1; shift; \ + mkdir -p $$dest; \ + [ -s .dirdep ] || echo '${_dirdep}' > .dirdep; \ + for f in "$$@"; do \ + case "$$f" in */*) t=$$dest/${_stage_file_basename};; *) t=$$dest/$$f;; esac; \ + StageDirdep $$t; \ + LnCp $$f $$t || exit 1; \ + [ -z "$$mode" ] || chmod $$mode $$t; \ + done; :; } + +STAGE_LINKS_SCRIPT = ${STAGE_DIRDEP_SCRIPT}; StageLinks() { \ + case "$$1" in "") return;; --) shift;; -*) ldest= lnf=$$1; shift;; /*) ldest=$$1/;; esac; \ + dest=$$1; shift; \ + mkdir -p $$dest; \ + [ -s .dirdep ] || echo '${_dirdep}' > .dirdep; \ + while test $$\# -ge 2; do \ + l=$$ldest$$1; shift; \ + t=$$dest/$$1; \ + case "$$1" in */*) mkdir -p ${_stage_target_dirname};; esac; \ + shift; \ + StageDirdep $$t; \ + rm -f $$t 2>/dev/null; \ + ln $$lnf $$l $$t || exit 1; \ + done; :; } + +STAGE_AS_SCRIPT = ${STAGE_DIRDEP_SCRIPT}; StageAs() { \ + case "$$1" in "") return;; -m) mode=$$2; shift 2;; *) mode=;; esac; \ + dest=$$1; shift; \ + mkdir -p $$dest; \ + [ -s .dirdep ] || echo '${_dirdep}' > .dirdep; \ + while test $$\# -ge 2; do \ + s=$$1; shift; \ + t=$$dest/$$1; \ + case "$$1" in */*) mkdir -p ${_stage_target_dirname};; esac; \ + shift; \ + StageDirdep $$t; \ + LnCp $$s $$t || exit 1; \ + [ -z "$$mode" ] || chmod $$mode $$t; \ + done; :; } + +# this is simple, a list of the "staged" files depends on this, +_STAGE_BASENAME_USE: .USE .dirdep ${.TARGET:T} + @${STAGE_FILE_SCRIPT}; StageFiles ${.TARGET:H:${STAGE_DIR_FILTER}} ${.TARGET:T} + +_STAGE_AS_BASENAME_USE: .USE .dirdep ${.TARGET:T} + @${STAGE_AS_SCRIPT}; StageAs ${.TARGET:H:${STAGE_DIR_FILTER}} ${.TARGET:T} ${STAGE_AS_${.TARGET:T}:U${.TARGET:T}} + + +.endif # first time + + +.if !empty(STAGE_INCSDIR) +.if !empty(STAGE_INCS) +stage_incs: ${STAGE_INCS:N*\**} +.endif +.if target(stage_incs) || !empty(.ALLTARGETS:Mstage_includes) +STAGE_TARGETS += stage_incs +STAGE_INCS ?= ${.ALLSRC:N.dirdep:Nstage_*} +stage_includes: stage_incs +stage_incs: .dirdep + @${STAGE_FILE_SCRIPT}; StageFiles ${STAGE_INCSDIR:${STAGE_DIR_FILTER}} ${STAGE_INCS} + @touch $@ + +.endif +.endif + +.if !empty(STAGE_LIBDIR) +.if !empty(STAGE_LIBS) +stage_libs: ${STAGE_LIBS:N*\**} +.endif +.if target(stage_libs) +STAGE_TARGETS += stage_libs +STAGE_LIBS ?= ${.ALLSRC:N.dirdep:Nstage_*} +stage_libs: .dirdep + @${STAGE_FILE_SCRIPT}; StageFiles ${STAGE_LIBDIR:${STAGE_DIR_FILTER}} ${STAGE_LIBS} +.if !defined(NO_SHLIB_LINKS) +.if !empty(SHLIB_LINKS) + @${STAGE_LINKS_SCRIPT}; StageLinks -s ${STAGE_LIBDIR:${STAGE_DIR_FILTER}} \ + ${SHLIB_LINKS:@t@${STAGE_LIBS:T:M$t.*} $t@} +.elif !empty(SHLIB_LINK) && !empty(SHLIB_NAME) + @${STAGE_LINKS_SCRIPT}; StageLinks -s ${STAGE_LIBDIR:${STAGE_DIR_FILTER}} ${SHLIB_NAME} ${SHLIB_LINK} +.endif +.endif + @touch $@ +.endif +.endif + +.if !empty(STAGE_DIR) +STAGE_SETS += _default +STAGE_DIR._default = ${STAGE_DIR} +STAGE_LINKS_DIR._default = ${STAGE_LINKS_DIR:U${STAGE_OBJTOP}} +STAGE_SYMLINKS_DIR._default = ${STAGE_SYMLINKS_DIR:U${STAGE_OBJTOP}} +STAGE_FILES._default = ${STAGE_FILES} +STAGE_LINKS._default = ${STAGE_LINKS} +STAGE_SYMLINKS._default = ${STAGE_SYMLINKS} +.endif + +.if !empty(STAGE_SETS) +CLEANFILES += ${STAGE_SETS:@s@stage*$s@} + +# some makefiles need to populate multiple directories +.for s in ${STAGE_SETS:O:u} +.if !empty(STAGE_FILES.$s) +stage_files.$s: ${STAGE_FILES.$s:N*\**} +.endif +.if target(stage_files.$s) || target(stage_files${s:S,^,.,:N._default}) +STAGE_TARGETS += stage_files +STAGE_FILES.$s ?= ${.ALLSRC:N.dirdep:Nstage_*} +.if !target(.stage_files.$s) +.stage_files.$s: +.if $s != "_default" +stage_files: stage_files.$s +stage_files.$s: .dirdep +.else +STAGE_FILES ?= ${.ALLSRC:N.dirdep:Nstage_*} +stage_files: .dirdep +.endif + @${STAGE_FILE_SCRIPT}; StageFiles ${FLAGS.$@} ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_FILES.$s:O} + @touch $@ +.endif +.endif + +.if !empty(STAGE_LINKS.$s) +stage_links.$s: +.endif +.if target(stage_links.$s) || target(stage_links${s:S,^,.,:N._default}) +STAGE_LINKS_DIR.$s ?= ${STAGE_OBJTOP} +STAGE_TARGETS += stage_links +.if !target(.stage_links.$s) +.stage_links.$s: +.if $s != "_default" +stage_links: stage_links.$s +stage_links.$s: .dirdep +.else +stage_links: .dirdep +.endif + @${STAGE_LINKS_SCRIPT}; StageLinks ${STAGE_LINKS_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_LINKS.$s} + @touch $@ +.endif +.endif + +.if !empty(STAGE_SYMLINKS.$s) +stage_symlinks.$s: +.endif +.if target(stage_symlinks.$s) || target(stage_symlinks${s:S,^,.,:N._default}) +STAGE_SYMLINKS_DIR.$s ?= ${STAGE_OBJTOP} +STAGE_TARGETS += stage_symlinks +.if !target(.stage_symlinks.$s) +.stage_symlinks.$s: +.if $s != "_default" +stage_symlinks: stage_symlinks.$s +stage_symlinks.$s: .dirdep +.else +stage_symlinks: .dirdep +.endif + @${STAGE_LINKS_SCRIPT}; StageLinks -s ${STAGE_SYMLINKS_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_SYMLINKS.$s} + @touch $@ +.endif +.endif + +.endfor +.endif + +.if !empty(STAGE_AS_SETS) +CLEANFILES += ${STAGE_AS_SETS:@s@stage*$s@} + +# sometimes things need to be renamed as they are staged +# each ${file} will be staged as ${STAGE_AS_${file:T}} +# one could achieve the same with SYMLINKS +# stage_as_and_symlink makes the original name a symlink to the new name +# it is the same as using stage_as and stage_symlinks but ensures +# both operations happen together +.for s in ${STAGE_AS_SETS:O:u} +.if !empty(STAGE_AS.$s) +stage_as.$s: ${STAGE_AS.$s:N*\**} +.endif +.if target(stage_as.$s) +STAGE_TARGETS += stage_as +STAGE_AS.$s ?= ${.ALLSRC:N.dirdep:Nstage_*} +.if !target(.stage_as.$s) +.stage_as.$s: +stage_as: stage_as.$s +stage_as.$s: .dirdep + @${STAGE_AS_SCRIPT}; StageAs ${FLAGS.$@} ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_AS.$s:O:@f@$f ${STAGE_AS_${f:tA}:U${STAGE_AS_${f:T}:U${f:T}}}@} + @touch $@ +.endif +.endif + +.if !empty(STAGE_AS_AND_SYMLINK.$s) +stage_as_and_symlink.$s: ${STAGE_AS_AND_SYMLINK.$s:N*\**} +.endif +.if target(stage_as_and_symlink.$s) +STAGE_TARGETS += stage_as_and_symlink +STAGE_AS_AND_SYMLINK.$s ?= ${.ALLSRC:N.dirdep:Nstage_*} +.if !target(.stage_as_and_symlink.$s) +.stage_as_and_symlink.$s: +stage_as_and_symlink: stage_as_and_symlink.$s +stage_as_and_symlink.$s: .dirdep + @${STAGE_AS_SCRIPT}; StageAs ${FLAGS.$@} ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_AS_AND_SYMLINK.$s:O:@f@$f ${STAGE_AS_${f:tA}:U${STAGE_AS_${f:T}:U${f:T}}}@} + @${STAGE_LINKS_SCRIPT}; StageLinks -s ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_AS_AND_SYMLINK.$s:O:@f@${STAGE_AS_${f:tA}:U${STAGE_AS_${f:T}:U${f:T}}} $f@} + @touch $@ +.endif +.endif + +.endfor +.endif + +CLEANFILES += ${STAGE_TARGETS} stage_incs stage_includes + +# this lot also only makes sense the first time... +.if !target(__${.PARSEFILE}__) +__${.PARSEFILE}__: + +# stage_*links usually needs to follow any others. +# for non-jobs mode the order here matters +staging: ${STAGE_TARGETS:N*_links} ${STAGE_TARGETS:M*_links} + +.if ${.MAKE.JOBS:U0} > 0 && ${STAGE_TARGETS:U:M*_links} != "" +# the above isn't sufficient +.for t in ${STAGE_TARGETS:N*links:O:u} +.ORDER: $t stage_links +.endfor +.endif + +# generally we want staging to wait until everything else is done +STAGING_WAIT ?= .WAIT + +.if ${.MAKE.LEVEL} > 0 +all: ${STAGING_WAIT} staging +.endif + +.if exists(${.PARSEDIR}/stage-install.sh) && !defined(STAGE_INSTALL) +# this will run install(1) and then followup with .dirdep files. +STAGE_INSTALL := sh ${.PARSEDIR:tA}/stage-install.sh INSTALL="${INSTALL}" OBJDIR=${.OBJDIR:tA} +.endif + +# if ${INSTALL} gets run during 'all' assume it is for staging? +.if ${.TARGETS:Nall} == "" && defined(STAGE_INSTALL) +INSTALL := ${STAGE_INSTALL} +.if target(beforeinstall) +beforeinstall: .dirdep +.endif +.endif +.NOPATH: ${STAGE_FILES} + +.if !empty(STAGE_TARGETS) +# for backwards compat make sure they exist +${STAGE_TARGETS}: + +.NOPATH: ${CLEANFILES} + +MK_STALE_STAGED?= no +.if ${MK_STALE_STAGED} == "yes" +all: stale_staged +# get a list of paths that we have just staged +# get a list of paths that we have previously staged to those same dirs +# anything in the 2nd list but not the first is stale - remove it. +stale_staged: staging .NOMETA + @egrep '^[WL] .*${STAGE_OBJTOP}' /dev/null ${.MAKE.META.FILES:M*stage_*} | \ + sed "/\.dirdep/d;s,.* '*\(${STAGE_OBJTOP}/[^ '][^ ']*\).*,\1," | \ + sort > ${.TARGET}.staged1 + @grep -l '${_dirdep}' /dev/null ${_STAGED_DIRS:M${STAGE_OBJTOP}*:O:u:@d@$d/*.dirdep@} | \ + sed 's,\.dirdep,,' | sort > ${.TARGET}.staged2 + @comm -13 ${.TARGET}.staged1 ${.TARGET}.staged2 > ${.TARGET}.stale + @test ! -s ${.TARGET}.stale || { \ + echo "Removing stale staged files..."; \ + sed 's,.*,& &.dirdep,' ${.TARGET}.stale | xargs rm -f; } + +.endif +.endif +.endif +.endif diff --git a/devel/bmake/files/mk/meta.subdir.mk b/devel/bmake/files/mk/meta.subdir.mk new file mode 100644 index 00000000000..58581d37299 --- /dev/null +++ b/devel/bmake/files/mk/meta.subdir.mk @@ -0,0 +1,79 @@ +# $Id: meta.subdir.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ + +# +# @(#) Copyright (c) 2010, 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 !defined(NO_SUBDIR) && !empty(SUBDIR) +.if make(destroy*) || make(clean*) +.MAKE.MODE = compat +.if !commands(destroy) +.-include <bsd.obj.mk> +.endif +.elif ${.MAKE.LEVEL} == 0 + +.MAIN: all + +.if !exists(${.CURDIR}/${.MAKE.DEPENDFILE:T}) || make(gendirdeps) +# start with this +DIRDEPS = ${SUBDIR:N.WAIT:O:u:@d@${RELDIR}/$d@} + +.if make(gendirdeps) +.include <meta.autodep.mk> +.else +# this is the cunning bit +# actually it is probably a bit risky +# since we may pickup subdirs which are not relevant +# the alternative is a walk through the tree though +# which is difficult without a sub-make. + +.if defined(BOOTSTRAP_DEPENDFILES) +_find_name = ${.MAKE.MAKEFILE_PREFERENCE:@m@-o -name $m@:S,^-o,,1} +DIRDEPS = ${_subdeps:H:O:u:@d@${RELDIR}/$d@} +.elif ${.MAKE.DEPENDFILE:E} == ${MACHINE} && defined(ALL_MACHINES) +# we want to find Makefile.depend.* ie for all machines +# and turn the dirs into dir.<machine> +_find_name = -name '${.MAKE.DEPENDFILE:T:R}*' +DIRDEPS = ${_subdeps:O:u:${NIgnoreFiles}:@d@${RELDIR}/${d:H}.${d:E}@:S,.${MACHINE}$,,:S,.depend$,,} +.else +# much simpler +_find_name = -name ${.MAKE.DEPENDFILE:T} +.if ${.MAKE.DEPENDFILE:E} == ${MACHINE} +_find_name += -o -name ${.MAKE.DEPENDFILE:T:R} +.endif +DIRDEPS = ${_subdeps:H:O:u:@d@${RELDIR}/$d@} +.endif + +_subdeps != cd ${.CURDIR} && \ + find ${SUBDIR:N.WAIT} -type f \( ${_find_name} \) -print -o \ + -name .svn -prune 2> /dev/null; echo + +.if empty(_subdeps) +DIRDEPS = +.else +# clean up if needed +DIRDEPS := ${DIRDEPS:S,^./,,:S,/./,/,g:${SUBDIRDEPS_FILTER:Uu}} +.endif +# we just dealt with it, if we leave it defined, +# dirdeps.mk will compute some interesting combinations. +.undef ALL_MACHINES + +DEP_RELDIR = ${RELDIR} +.include <dirdeps.mk> +.endif +.endif +.else +all: .PHONY +.endif + +.endif diff --git a/devel/bmake/files/mk/meta.sys.mk b/devel/bmake/files/mk/meta.sys.mk new file mode 100644 index 00000000000..0ff65765757 --- /dev/null +++ b/devel/bmake/files/mk/meta.sys.mk @@ -0,0 +1,173 @@ +# $Id: meta.sys.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ + +# +# @(#) Copyright (c) 2010-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 +# + +# include this if you want to enable meta mode +# for maximum benefit, requires filemon(4) driver. + +.if ${MAKE_VERSION:U0} > 20100901 +.if !target(.ERROR) + +.-include <local.meta.sys.mk> + +# absolute path to what we are reading. +_PARSEDIR = ${.PARSEDIR:tA} + +.if !defined(SYS_MK_DIR) +SYS_MK_DIR := ${_PARSEDIR} +.endif + +META_MODE += meta verbose +.MAKE.MODE ?= ${META_MODE} + +.if ${.MAKE.LEVEL} == 0 +_make_mode := ${.MAKE.MODE} ${META_MODE} +.if ${_make_mode:M*read*} != "" || ${_make_mode:M*nofilemon*} != "" +# tell everyone we are not updating Makefile.depend* +UPDATE_DEPENDFILE = NO +.export UPDATE_DEPENDFILE +.endif +.if ${UPDATE_DEPENDFILE:Uyes:tl} == "no" && !exists(/dev/filemon) +# we should not get upset +META_MODE += nofilemon +.export META_MODE +.endif +.endif + +.if !defined(NO_SILENT) +.if ${MAKE_VERSION} > 20110818 +# only be silent when we have a .meta file +META_MODE += silent=yes +.else +.SILENT: +.endif +.endif + +# we use the pseudo machine "host" for the build host. +# this should be taken care of before we get here +.if ${OBJTOP:Ua} == ${HOST_OBJTOP:Ub} +MACHINE = host +.endif + +.if !defined(MACHINE0) +# it can be handy to know which MACHINE kicked off the build +# for example, if using Makefild.depend for multiple machines, +# allowing only MACHINE0 to update can keep things simple. +MACHINE0 := ${MACHINE} +.export MACHINE0 +.endif + +.if !defined(META2DEPS) +.if defined(PYTHON) && exists(${PYTHON}) +# we prefer the python version of this - it is much faster +META2DEPS ?= ${.PARSEDIR}/meta2deps.py +.else +META2DEPS ?= ${.PARSEDIR}/meta2deps.sh +.endif +META2DEPS := ${META2DEPS} +.export META2DEPS +.endif + +MAKE_PRINT_VAR_ON_ERROR += \ + .ERROR_TARGET \ + .ERROR_META_FILE \ + .MAKE.LEVEL \ + MAKEFILE \ + .MAKE.MODE + +.if !defined(SB) && defined(SRCTOP) +SB = ${SRCTOP:H} +.endif +ERROR_LOGDIR ?= ${SB}/error +meta_error_log = ${ERROR_LOGDIR}/meta-${.MAKE.PID}.log + +# we are not interested in make telling us a failure happened elsewhere +.ERROR: _metaError +_metaError: .NOMETA .NOTMAIN + -@[ "${.ERROR_META_FILE}" ] && { \ + grep -q 'failure has been detected in another branch' ${.ERROR_META_FILE} && exit 0; \ + mkdir -p ${meta_error_log:H}; \ + cp ${.ERROR_META_FILE} ${meta_error_log}; \ + echo "ERROR: log ${meta_error_log}" >&2; }; : + +.endif + +# Are we, after all, in meta mode? +.if ${.MAKE.MODE:Uno:Mmeta*} != "" +MKDEP_MK = meta.autodep.mk + +.if ${.MAKE.MAKEFILES:M*sys.dependfile.mk} == "" +# this does all the smarts of setting .MAKE.DEPENDFILE +.-include <sys.dependfile.mk> +# check if we got anything sane +.if ${.MAKE.DEPENDFILE} == ".depend" +.undef .MAKE.DEPENDFILE +.endif +.MAKE.DEPENDFILE ?= Makefile.depend +.endif + +# we can afford to use cookies to prevent some targets +# re-running needlessly +META_COOKIE_TOUCH?= touch ${COOKIE.${.TARGET}:U${.OBJDIR}/${.TARGET:T}} +META_NOPHONY= +META_NOECHO= : + +# some targets involve old pre-built targets +# ignore mtime of shell +# and mtime of makefiles does not matter in meta mode +.MAKE.META.IGNORE_PATHS += \ + ${MAKEFILE} \ + ${MAKE_SHELL} \ + ${SHELL} \ + ${SYS_MK_DIR} \ + + +.if ${UPDATE_DEPENDFILE:Uyes:tl} != "no" +.if ${.MAKEFLAGS:Uno:M-k} != "" +# make this more obvious +.warning Setting UPDATE_DEPENDFILE=NO due to -k +UPDATE_DEPENDFILE= NO +.export UPDATE_DEPENDFILE +.elif !exists(/dev/filemon) +.error ${.newline}ERROR: The filemon module (/dev/filemon) is not loaded. +.endif +.endif + +.if ${.MAKE.LEVEL} == 0 +# make sure dirdeps target exists and do it first +all: dirdeps .WAIT +dirdeps: +.NOPATH: dirdeps + +.if defined(ALL_MACHINES) +# the first .MAIN: is what counts +# by default dirdeps is all we want at level0 +.MAIN: dirdeps +# tell dirdeps.mk what we want +BUILD_AT_LEVEL0 = no +.endif +.if ${.TARGETS:Nall} == "" +# it works best if we do everything via sub-makes +BUILD_AT_LEVEL0 ?= no +.endif + +.endif +.else +META_COOKIE_TOUCH= +# some targets need to be .PHONY in non-meta mode +META_NOPHONY= .PHONY +META_NOECHO= echo +.endif +.endif diff --git a/devel/bmake/files/mk/meta2deps.py b/devel/bmake/files/mk/meta2deps.py new file mode 100755 index 00000000000..5a5a2315abb --- /dev/null +++ b/devel/bmake/files/mk/meta2deps.py @@ -0,0 +1,755 @@ +#!/usr/bin/env python + +from __future__ import print_function + +""" +This script parses each "meta" file and extracts the +information needed to deduce build and src dependencies. + +It works much the same as the original shell script, but is +*much* more efficient. + +The parsing work is handled by the class MetaFile. +We only pay attention to a subset of the information in the +"meta" files. Specifically: + +'CWD' to initialize our notion. + +'C' to track chdir(2) on a per process basis + +'R' files read are what we really care about. + directories read, provide a clue to resolving + subsequent relative paths. That is if we cannot find + them relative to 'cwd', we check relative to the last + dir read. + +'W' files opened for write or read-write, + for filemon V3 and earlier. + +'E' files executed. + +'L' files linked + +'V' the filemon version, this record is used as a clue + that we have reached the interesting bit. + +""" + +""" +RCSid: + $Id: meta2deps.py,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ + + Copyright (c) 2011-2019, Simon J. Gerraty + Copyright (c) 2011-2017, Juniper Networks, Inc. + All rights reserved. + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +""" + +import os, re, sys + +def getv(dict, key, d=None): + """Lookup key in dict and return value or the supplied default.""" + if key in dict: + return dict[key] + return d + +def resolve(path, cwd, last_dir=None, debug=0, debug_out=sys.stderr): + """ + Return an absolute path, resolving via cwd or last_dir if needed. + """ + if path.endswith('/.'): + path = path[0:-2] + if len(path) > 0 and path[0] == '/': + return path + if path == '.': + return cwd + if path.startswith('./'): + return cwd + path[1:] + if last_dir == cwd: + last_dir = None + for d in [last_dir, cwd]: + if not d: + continue + if path == '..': + dw = d.split('/') + p = '/'.join(dw[:-1]) + if not p: + p = '/' + return p + p = '/'.join([d,path]) + if debug > 2: + print("looking for:", p, end=' ', file=debug_out) + if not os.path.exists(p): + if debug > 2: + print("nope", file=debug_out) + p = None + continue + if debug > 2: + print("found:", p, file=debug_out) + return p + return None + +def cleanpath(path): + """cleanup path without using realpath(3)""" + if path.startswith('/'): + r = '/' + else: + r = '' + p = [] + w = path.split('/') + for d in w: + if not d or d == '.': + continue + if d == '..': + try: + p.pop() + continue + except: + break + p.append(d) + + return r + '/'.join(p) + +def abspath(path, cwd, last_dir=None, debug=0, debug_out=sys.stderr): + """ + Return an absolute path, resolving via cwd or last_dir if needed. + this gets called a lot, so we try to avoid calling realpath. + """ + rpath = resolve(path, cwd, last_dir, debug, debug_out) + if rpath: + path = rpath + if (path.find('/') < 0 or + path.find('./') > 0 or + path.endswith('/..')): + path = cleanpath(path) + return path + +def sort_unique(list, cmp=None, key=None, reverse=False): + list.sort(cmp, key, reverse) + nl = [] + le = None + for e in list: + if e == le: + continue + le = e + nl.append(e) + return nl + +def add_trims(x): + return ['/' + x + '/', + '/' + x, + x + '/', + x] + +class MetaFile: + """class to parse meta files generated by bmake.""" + + conf = None + dirdep_re = None + host_target = None + srctops = [] + objroots = [] + excludes = [] + seen = {} + obj_deps = [] + src_deps = [] + file_deps = [] + + def __init__(self, name, conf={}): + """if name is set we will parse it now. + conf can have the follwing keys: + + SRCTOPS list of tops of the src tree(s). + + CURDIR the src directory 'bmake' was run from. + + RELDIR the relative path from SRCTOP to CURDIR + + MACHINE the machine we built for. + set to 'none' if we are not cross-building. + More specifically if machine cannot be deduced from objdirs. + + TARGET_SPEC + Sometimes MACHINE isn't enough. + + HOST_TARGET + when we build for the pseudo machine 'host' + the object tree uses HOST_TARGET rather than MACHINE. + + OBJROOTS a list of the common prefix for all obj dirs it might + end in '/' or '-'. + + DPDEPS names an optional file to which per file dependencies + will be appended. + For example if 'some/path/foo.h' is read from SRCTOP + then 'DPDEPS_some/path/foo.h +=' "RELDIR" is output. + This can allow 'bmake' to learn all the dirs within + the tree that depend on 'foo.h' + + EXCLUDES + A list of paths to ignore. + ccache(1) can otherwise be trouble. + + debug desired debug level + + debug_out open file to send debug output to (sys.stderr) + + """ + + self.name = name + self.debug = getv(conf, 'debug', 0) + self.debug_out = getv(conf, 'debug_out', sys.stderr) + + self.machine = getv(conf, 'MACHINE', '') + self.machine_arch = getv(conf, 'MACHINE_ARCH', '') + self.target_spec = getv(conf, 'TARGET_SPEC', '') + self.curdir = getv(conf, 'CURDIR') + self.reldir = getv(conf, 'RELDIR') + self.dpdeps = getv(conf, 'DPDEPS') + self.line = 0 + + if not self.conf: + # some of the steps below we want to do only once + self.conf = conf + self.host_target = getv(conf, 'HOST_TARGET') + for srctop in getv(conf, 'SRCTOPS', []): + if srctop[-1] != '/': + srctop += '/' + if not srctop in self.srctops: + self.srctops.append(srctop) + _srctop = os.path.realpath(srctop) + if _srctop[-1] != '/': + _srctop += '/' + if not _srctop in self.srctops: + self.srctops.append(_srctop) + + trim_list = add_trims(self.machine) + if self.machine == 'host': + trim_list += add_trims(self.host_target) + if self.target_spec: + trim_list += add_trims(self.target_spec) + + for objroot in getv(conf, 'OBJROOTS', []): + for e in trim_list: + if objroot.endswith(e): + # this is not what we want - fix it + objroot = objroot[0:-len(e)] + + if objroot[-1] != '/': + objroot += '/' + if not objroot in self.objroots: + self.objroots.append(objroot) + _objroot = os.path.realpath(objroot) + if objroot[-1] == '/': + _objroot += '/' + if not _objroot in self.objroots: + self.objroots.append(_objroot) + + # we want the longest match + self.srctops.sort(reverse=True) + self.objroots.sort(reverse=True) + + self.excludes = getv(conf, 'EXCLUDES', []) + + if self.debug: + print("host_target=", self.host_target, file=self.debug_out) + print("srctops=", self.srctops, file=self.debug_out) + print("objroots=", self.objroots, file=self.debug_out) + print("excludes=", self.excludes, file=self.debug_out) + + self.dirdep_re = re.compile(r'([^/]+)/(.+)') + + if self.dpdeps and not self.reldir: + if self.debug: + print("need reldir:", end=' ', file=self.debug_out) + if self.curdir: + srctop = self.find_top(self.curdir, self.srctops) + if srctop: + self.reldir = self.curdir.replace(srctop,'') + if self.debug: + print(self.reldir, file=self.debug_out) + if not self.reldir: + self.dpdeps = None # we cannot do it? + + self.cwd = os.getcwd() # make sure this is initialized + self.last_dir = self.cwd + + if name: + self.try_parse() + + def reset(self): + """reset state if we are being passed meta files from multiple directories.""" + self.seen = {} + self.obj_deps = [] + self.src_deps = [] + self.file_deps = [] + + def dirdeps(self, sep='\n'): + """return DIRDEPS""" + return sep.strip() + sep.join(self.obj_deps) + + def src_dirdeps(self, sep='\n'): + """return SRC_DIRDEPS""" + return sep.strip() + sep.join(self.src_deps) + + def file_depends(self, out=None): + """Append DPDEPS_${file} += ${RELDIR} + for each file we saw, to the output file.""" + if not self.reldir: + return None + for f in sort_unique(self.file_deps): + print('DPDEPS_%s += %s' % (f, self.reldir), file=out) + # these entries provide for reverse DIRDEPS lookup + for f in self.obj_deps: + print('DEPDIRS_%s += %s' % (f, self.reldir), file=out) + + def seenit(self, dir): + """rememer that we have seen dir.""" + self.seen[dir] = 1 + + def add(self, list, data, clue=''): + """add data to list if it isn't already there.""" + if data not in list: + list.append(data) + if self.debug: + print("%s: %sAdd: %s" % (self.name, clue, data), file=self.debug_out) + + def find_top(self, path, list): + """the logical tree may be split across multiple trees""" + for top in list: + if path.startswith(top): + if self.debug > 2: + print("found in", top, file=self.debug_out) + return top + return None + + def find_obj(self, objroot, dir, path, input): + """return path within objroot, taking care of .dirdep files""" + ddep = None + for ddepf in [path + '.dirdep', dir + '/.dirdep']: + if not ddep and os.path.exists(ddepf): + ddep = open(ddepf, 'r').readline().strip('# \n') + if self.debug > 1: + print("found %s: %s\n" % (ddepf, ddep), file=self.debug_out) + if ddep.endswith(self.machine): + ddep = ddep[0:-(1+len(self.machine))] + elif self.target_spec and ddep.endswith(self.target_spec): + ddep = ddep[0:-(1+len(self.target_spec))] + + if not ddep: + # no .dirdeps, so remember that we've seen the raw input + self.seenit(input) + self.seenit(dir) + if self.machine == 'none': + if dir.startswith(objroot): + return dir.replace(objroot,'') + return None + m = self.dirdep_re.match(dir.replace(objroot,'')) + if m: + ddep = m.group(2) + dmachine = m.group(1) + if dmachine != self.machine: + if not (self.machine == 'host' and + dmachine == self.host_target): + if self.debug > 2: + print("adding .%s to %s" % (dmachine, ddep), file=self.debug_out) + ddep += '.' + dmachine + + return ddep + + def try_parse(self, name=None, file=None): + """give file and line number causing exception""" + try: + self.parse(name, file) + except: + # give a useful clue + print('{}:{}: '.format(self.name, self.line), end=' ', file=sys.stderr) + raise + + def parse(self, name=None, file=None): + """A meta file looks like: + + # Meta data file "path" + CMD "command-line" + CWD "cwd" + TARGET "target" + -- command output -- + -- filemon acquired metadata -- + # buildmon version 3 + V 3 + C "pid" "cwd" + E "pid" "path" + F "pid" "child" + R "pid" "path" + W "pid" "path" + X "pid" "status" + D "pid" "path" + L "pid" "src" "target" + M "pid" "old" "new" + S "pid" "path" + # Bye bye + + We go to some effort to avoid processing a dependency more than once. + Of the above record types only C,E,F,L,R,V and W are of interest. + """ + + version = 0 # unknown + if name: + self.name = name; + if file: + f = file + cwd = self.last_dir = self.cwd + else: + f = open(self.name, 'r') + skip = True + pid_cwd = {} + pid_last_dir = {} + last_pid = 0 + + self.line = 0 + if self.curdir: + self.seenit(self.curdir) # we ignore this + + interesting = 'CEFLRV' + for line in f: + self.line += 1 + # ignore anything we don't care about + if not line[0] in interesting: + continue + if self.debug > 2: + print("input:", line, end=' ', file=self.debug_out) + w = line.split() + + if skip: + if w[0] == 'V': + skip = False + version = int(w[1]) + """ + if version < 4: + # we cannot ignore 'W' records + # as they may be 'rw' + interesting += 'W' + """ + elif w[0] == 'CWD': + self.cwd = cwd = self.last_dir = w[1] + self.seenit(cwd) # ignore this + if self.debug: + print("%s: CWD=%s" % (self.name, cwd), file=self.debug_out) + continue + + pid = int(w[1]) + if pid != last_pid: + if last_pid: + pid_last_dir[last_pid] = self.last_dir + cwd = getv(pid_cwd, pid, self.cwd) + self.last_dir = getv(pid_last_dir, pid, self.cwd) + last_pid = pid + + # process operations + if w[0] == 'F': + npid = int(w[2]) + pid_cwd[npid] = cwd + pid_last_dir[npid] = cwd + last_pid = npid + continue + elif w[0] == 'C': + cwd = abspath(w[2], cwd, None, self.debug, self.debug_out) + if cwd.endswith('/.'): + cwd = cwd[0:-2] + self.last_dir = pid_last_dir[pid] = cwd + pid_cwd[pid] = cwd + if self.debug > 1: + print("cwd=", cwd, file=self.debug_out) + continue + + if w[2] in self.seen: + if self.debug > 2: + print("seen:", w[2], file=self.debug_out) + continue + # file operations + if w[0] in 'ML': + # these are special, tread src as read and + # target as write + self.parse_path(w[1].strip("'"), cwd, 'R', w) + self.parse_path(w[2].strip("'"), cwd, 'W', w) + continue + elif w[0] in 'ERWS': + path = w[2] + self.parse_path(path, cwd, w[0], w) + + if not file: + f.close() + + def is_src(self, base, dir, rdir): + """is base in srctop""" + for dir in [dir,rdir]: + if not dir: + continue + path = '/'.join([dir,base]) + srctop = self.find_top(path, self.srctops) + if srctop: + if self.dpdeps: + self.add(self.file_deps, path.replace(srctop,''), 'file') + self.add(self.src_deps, dir.replace(srctop,''), 'src') + self.seenit(dir) + return True + return False + + def parse_path(self, path, cwd, op=None, w=[]): + """look at a path for the op specified""" + + if not op: + op = w[0] + + # we are never interested in .dirdep files as dependencies + if path.endswith('.dirdep'): + return + for p in self.excludes: + if p and path.startswith(p): + if self.debug > 2: + print("exclude:", p, path, file=self.debug_out) + return + # we don't want to resolve the last component if it is + # a symlink + path = resolve(path, cwd, self.last_dir, self.debug, self.debug_out) + if not path: + return + dir,base = os.path.split(path) + if dir in self.seen: + if self.debug > 2: + print("seen:", dir, file=self.debug_out) + return + # we can have a path in an objdir which is a link + # to the src dir, we may need to add dependencies for each + rdir = dir + dir = abspath(dir, cwd, self.last_dir, self.debug, self.debug_out) + rdir = os.path.realpath(dir) + if rdir == dir: + rdir = None + # now put path back together + path = '/'.join([dir,base]) + if self.debug > 1: + print("raw=%s rdir=%s dir=%s path=%s" % (w[2], rdir, dir, path), file=self.debug_out) + if op in 'RWS': + if path in [self.last_dir, cwd, self.cwd, self.curdir]: + if self.debug > 1: + print("skipping:", path, file=self.debug_out) + return + if os.path.isdir(path): + if op in 'RW': + self.last_dir = path; + if self.debug > 1: + print("ldir=", self.last_dir, file=self.debug_out) + return + + if op in 'ERW': + # finally, we get down to it + if dir == self.cwd or dir == self.curdir: + return + if self.is_src(base, dir, rdir): + self.seenit(w[2]) + if not rdir: + return + + objroot = None + for dir in [dir,rdir]: + if not dir: + continue + objroot = self.find_top(dir, self.objroots) + if objroot: + break + if objroot: + ddep = self.find_obj(objroot, dir, path, w[2]) + if ddep: + self.add(self.obj_deps, ddep, 'obj') + if self.dpdeps and objroot.endswith('/stage/'): + sp = '/'.join(path.replace(objroot,'').split('/')[1:]) + self.add(self.file_deps, sp, 'file') + else: + # don't waste time looking again + self.seenit(w[2]) + self.seenit(dir) + + +def main(argv, klass=MetaFile, xopts='', xoptf=None): + """Simple driver for class MetaFile. + + Usage: + script [options] [key=value ...] "meta" ... + + Options and key=value pairs contribute to the + dictionary passed to MetaFile. + + -S "SRCTOP" + add "SRCTOP" to the "SRCTOPS" list. + + -C "CURDIR" + + -O "OBJROOT" + add "OBJROOT" to the "OBJROOTS" list. + + -m "MACHINE" + + -a "MACHINE_ARCH" + + -H "HOST_TARGET" + + -D "DPDEPS" + + -d bumps debug level + + """ + import getopt + + # import Psyco if we can + # it can speed things up quite a bit + have_psyco = 0 + try: + import psyco + psyco.full() + have_psyco = 1 + except: + pass + + conf = { + 'SRCTOPS': [], + 'OBJROOTS': [], + 'EXCLUDES': [], + } + + try: + machine = os.environ['MACHINE'] + if machine: + conf['MACHINE'] = machine + machine_arch = os.environ['MACHINE_ARCH'] + if machine_arch: + conf['MACHINE_ARCH'] = machine_arch + srctop = os.environ['SB_SRC'] + if srctop: + conf['SRCTOPS'].append(srctop) + objroot = os.environ['SB_OBJROOT'] + if objroot: + conf['OBJROOTS'].append(objroot) + except: + pass + + debug = 0 + output = True + + opts, args = getopt.getopt(argv[1:], 'a:dS:C:O:R:m:D:H:qT:X:' + xopts) + for o, a in opts: + if o == '-a': + conf['MACHINE_ARCH'] = a + elif o == '-d': + debug += 1 + elif o == '-q': + output = False + elif o == '-H': + conf['HOST_TARGET'] = a + elif o == '-S': + if a not in conf['SRCTOPS']: + conf['SRCTOPS'].append(a) + elif o == '-C': + conf['CURDIR'] = a + elif o == '-O': + if a not in conf['OBJROOTS']: + conf['OBJROOTS'].append(a) + elif o == '-R': + conf['RELDIR'] = a + elif o == '-D': + conf['DPDEPS'] = a + elif o == '-m': + conf['MACHINE'] = a + elif o == '-T': + conf['TARGET_SPEC'] = a + elif o == '-X': + if a not in conf['EXCLUDES']: + conf['EXCLUDES'].append(a) + elif xoptf: + xoptf(o, a, conf) + + conf['debug'] = debug + + # get any var=val assignments + eaten = [] + for a in args: + if a.find('=') > 0: + k,v = a.split('=') + if k in ['SRCTOP','OBJROOT','SRCTOPS','OBJROOTS']: + if k == 'SRCTOP': + k = 'SRCTOPS' + elif k == 'OBJROOT': + k = 'OBJROOTS' + if v not in conf[k]: + conf[k].append(v) + else: + conf[k] = v + eaten.append(a) + continue + break + + for a in eaten: + args.remove(a) + + debug_out = getv(conf, 'debug_out', sys.stderr) + + if debug: + print("config:", file=debug_out) + print("psyco=", have_psyco, file=debug_out) + for k,v in list(conf.items()): + print("%s=%s" % (k,v), file=debug_out) + + m = None + for a in args: + if a.endswith('.meta'): + if not os.path.exists(a): + continue + m = klass(a, conf) + elif a.startswith('@'): + # there can actually multiple files per line + for line in open(a[1:]): + for f in line.strip().split(): + if not os.path.exists(f): + continue + m = klass(f, conf) + + if output and m: + print(m.dirdeps()) + + print(m.src_dirdeps('\nsrc:')) + + dpdeps = getv(conf, 'DPDEPS') + if dpdeps: + m.file_depends(open(dpdeps, 'wb')) + + return m + +if __name__ == '__main__': + try: + main(sys.argv) + except: + # yes, this goes to stdout + print("ERROR: ", sys.exc_info()[1]) + raise + diff --git a/devel/bmake/files/mk/meta2deps.sh b/devel/bmake/files/mk/meta2deps.sh new file mode 100755 index 00000000000..ff603f9f1a5 --- /dev/null +++ b/devel/bmake/files/mk/meta2deps.sh @@ -0,0 +1,405 @@ +#!/bin/sh + +# NAME: +# meta2deps.sh - extract useful info from .meta files +# +# SYNOPSIS: +# meta2deps.sh SB="SB" "meta" ... +# +# DESCRIPTION: +# This script looks each "meta" file and extracts the +# information needed to deduce build and src dependencies. +# +# To do this, we extract the 'CWD' record as well as all the +# syscall traces which describe 'R'ead, 'C'hdir and 'E'xec +# syscalls. +# +# The typical meta file looks like:: +#.nf +# +# # Meta data file "path" +# CMD "command-line" +# CWD "cwd" +# TARGET "target" +# -- command output -- +# -- filemon acquired metadata -- +# # buildmon version 2 +# V 2 +# E "pid" "path" +# R "pid" "path" +# C "pid" "cwd" +# R "pid" "path" +# X "pid" "status" +#.fi +# +# The fact that all the syscall entry lines start with a single +# character make these files quite easy to process using sed(1). +# +# To simplify the logic the 'CWD' line is made to look like a +# normal 'C'hdir entry, and "cwd" is remembered so that it can +# be prefixed to any "path" which is not absolute. +# +# If the "path" being read ends in '.srcrel' it is the content +# of (actually the first line of) that file that we are +# interested in. +# +# Any "path" which lies outside of the sandbox "SB" is generally +# not of interest and is ignored. +# +# The output, is a set of absolute paths with "SB" like: +#.nf +# +# $SB/obj-i386/bsd/gnu/lib/csu +# $SB/obj-i386/bsd/gnu/lib/libgcc +# $SB/obj-i386/bsd/include +# $SB/obj-i386/bsd/lib/csu/i386-elf +# $SB/obj-i386/bsd/lib/libc +# $SB/src/bsd/include +# $SB/src/bsd/sys/i386/include +# $SB/src/bsd/sys/sys +# $SB/src/pan-release/rtsock +# $SB/src/pfe-shared/include/jnx +#.fi +# +# Which can then be further processed by 'gendirdeps.mk' +# +# If we are passed 'DPDEPS='"dpdeps", then for each src file +# outside of "CURDIR" we read, we output a line like: +#.nf +# +# DPDEPS_$path += $RELDIR +#.fi +# +# with "$path" geting turned into reldir's, so that we can end +# up with a list of all the directories which depend on each src +# file in another directory. This can allow for efficient yet +# complete testing of changes. + + +# RCSid: +# $Id: meta2deps.sh,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ + +# Copyright (c) 2010-2013, Juniper Networks, Inc. +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +meta2src() { + cat /dev/null "$@" | + sed -n '/^R .*\.[chyl]$/s,^..[0-9]* ,,p' | + sort -u +} + +meta2dirs() { + cat /dev/null "$@" | + sed -n '/^R .*\/.*\.[a-z0-9][^\/]*$/s,^..[0-9]* \(.*\)/[^/]*$,\1,p' | + sort -u +} + +add_list() { + sep=' ' + suffix= + while : + do + case "$1" in + "|") sep="$1"; shift;; + -s) suffix="$2"; shift 2;; + *) break;; + esac + done + name=$1 + shift + eval list="\$$name" + for top in "$@" + do + case "$sep$list$sep" in + *"$sep$top$suffix$sep"*) continue;; + esac + list="${list:+$list$sep}$top$suffix" + done + eval "$name=\"$list\"" +} + +_excludes_f() { + egrep -v "$EXCLUDES" +} + +meta2deps() { + DPDEPS= + SRCTOPS=$SRCTOP + OBJROOTS= + EXCLUDES= + while : + do + case "$1" in + *=*) eval export "$1"; shift;; + -a) MACHINE_ARCH=$2; shift 2;; + -m) MACHINE=$2; shift 2;; + -C) CURDIR=$2; shift 2;; + -H) HOST_TARGET=$2; shift 2;; + -S) add_list SRCTOPS $2; shift 2;; + -O) add_list OBJROOTS $2; shift 2;; + -X) add_list EXCLUDES '|' $2; shift 2;; + -R) RELDIR=$2; shift 2;; + -T) TARGET_SPEC=$2; shift 2;; + *) break;; + esac + done + + _th= _o= + case "$MACHINE" in + host) _ht=$HOST_TARGET;; + esac + + for o in $OBJROOTS + do + case "$MACHINE,/$o/" in + host,*$HOST_TARGET*) ;; + *$MACHINE*|*${TARGET_SPEC:-$MACHINE}*) ;; + *) add_list _o $o; continue;; + esac + for x in $_ht $TARGET_SPEC $MACHINE + do + case "$o" in + "") continue;; + */$x/) add_list _o ${o%$x/}; o=;; + */$x) add_list _o ${o%$x}; o=;; + *$x/) add_list _o ${o%$x/}; o=;; + *$x) add_list _o ${o%$x}; o=;; + esac + done + done + OBJROOTS="$_o" + + case "$OBJTOP" in + "") + for o in $OBJROOTS + do + OBJTOP=$o${TARGET_SPEC:-$MACHINE} + break + done + ;; + esac + src_re= + obj_re= + add_list '|' -s '/*' src_re $SRCTOPS + add_list '|' -s '*' obj_re $OBJROOTS + + [ -z "$RELDIR" ] && unset DPDEPS + tf=/tmp/m2d$$-$USER + rm -f $tf.* + trap 'rm -f $tf.*; trap 0' 0 + + > $tf.dirdep + > $tf.qual + > $tf.srcdep + > $tf.srcrel + > $tf.dpdeps + + seenit= + seensrc= + lpid= + case "$EXCLUDES" in + "") _excludes=cat;; + *) _excludes=_excludes_f;; + esac + # handle @list files + case "$@" in + *@[!.]*) + for f in "$@" + do + case "$f" in + *.meta) cat $f;; + @*) xargs cat < ${f#@};; + *) cat $f;; + esac + done + ;; + *) cat /dev/null "$@";; + esac 2> /dev/null | + sed -e 's,^CWD,C C,;/^[CREFLM] /!d' -e "s,',,g" | + $_excludes | + while read op pid path junk + do + : op=$op pid=$pid path=$path + # we track cwd and ldir (of interest) per pid + # CWD is bmake's cwd + case "$lpid,$pid" in + ,C) CWD=$path cwd=$path ldir=$path + if [ -z "$SB" ]; then + SB=`echo $CWD | sed 's,/obj.*,,'` + fi + SRCTOP=${SRCTOP:-$SB/src} + continue + ;; + $pid,$pid) ;; + *) + case "$lpid" in + "") ;; + *) eval ldir_$lpid=$ldir;; + esac + eval ldir=\${ldir_$pid:-$CWD} cwd=\${cwd_$pid:-$CWD} + lpid=$pid + ;; + esac + + case "$op,$path" in + W,*srcrel|*.dirdep) continue;; + C,*) + case "$path" in + /*) cwd=$path;; + *) cwd=`cd $cwd/$path 2> /dev/null && /bin/pwd`;; + esac + # watch out for temp dirs that no longer exist + test -d ${cwd:-/dev/null/no/such} || cwd=$CWD + eval cwd_$pid=$cwd + continue + ;; + F,*) # $path is new pid + eval cwd_$path=$cwd ldir_$path=$ldir + continue + ;; + *) dir=${path%/*} + case "$path" in + $src_re|$obj_re) ;; + /*/stage/*) ;; + /*) continue;; + *) for path in $ldir/$path $cwd/$path + do + test -e $path && break + done + dir=${path%/*} + ;; + esac + ;; + esac + # avoid repeating ourselves... + case "$DPDEPS,$seensrc," in + ,*) + case ",$seenit," in + *,$dir,*) continue;; + esac + ;; + *,$path,*) continue;; + esac + # canonicalize if needed + case "/$dir/" in + */../*|*/./*) + rdir=$dir + dir=`cd $dir 2> /dev/null && /bin/pwd` + seen="$rdir,$dir" + ;; + *) seen=$dir;; + esac + case "$dir" in + ${CURDIR:-.}|"") continue;; + $src_re) + # avoid repeating ourselves... + case "$DPDEPS,$seensrc," in + ,*) + case ",$seenit," in + *,$dir,*) continue;; + esac + ;; + esac + ;; + *) + case ",$seenit," in + *,$dir,*) continue;; + esac + ;; + esac + if [ -d $path ]; then + case "$path" in + */..) ldir=${dir%/*};; + *) ldir=$path;; + esac + continue + fi + [ -f $path ] || continue + case "$dir" in + $CWD) continue;; # ignore + $src_re) + seenit="$seenit,$seen" + echo $dir >> $tf.srcdep + case "$DPDEPS,$reldir,$seensrc," in + ,*) ;; + *) seensrc="$seensrc,$path" + echo "DPDEPS_$dir/${path##*/} += $RELDIR" >> $tf.dpdeps + ;; + esac + continue + ;; + esac + # if there is a .dirdep we cannot skip + # just because we've seen the dir before. + if [ -s $path.dirdep ]; then + # this file contains: + # '# ${RELDIR}.<machine>' + echo $path.dirdep >> $tf.qual + continue + elif [ -s $dir.dirdep ]; then + echo $dir.dirdep >> $tf.qual + seenit="$seenit,$seen" + continue + fi + seenit="$seenit,$seen" + case "$dir" in + $obj_re) + echo $dir;; + esac + done > $tf.dirdep + _nl=echo + for f in $tf.dirdep $tf.qual $tf.srcdep + do + [ -s $f ] || continue + case $f in + *qual) # a list of .dirdep files + # we can prefix everything with $OBJTOP to + # tell gendirdeps.mk that these are + # DIRDEP entries, since they are already + # qualified with .<machine> as needed. + # We strip .$MACHINE though + xargs cat < $f | sort -u | + sed "s,^# ,,;s,^,$OBJTOP/,;s,\.${TARGET_SPEC:-$MACHINE}\$,,;s,\.$MACHINE\$,," + ;; + *) sort -u $f;; + esac + _nl=: + done + if [ -s $tf.dpdeps ]; then + case "$DPDEPS" in + */*) ;; + *) echo > $DPDEPS;; # the echo is needed! + esac + sort -u $tf.dpdeps | + sed "s,${SRCTOP}/,,;s,${SB_BACKING_SB:-$SB}/src/,," >> $DPDEPS + fi + # ensure we produce _something_ else egrep -v gets upset + $_nl +} + +case /$0 in +*/meta2dep*) meta2deps "$@";; +*/meta2dirs*) meta2dirs "$@";; +*/meta2src*) meta2src "$@";; +esac diff --git a/devel/bmake/files/mk/mk-files.txt b/devel/bmake/files/mk/mk-files.txt new file mode 100644 index 00000000000..3975ad6ace2 --- /dev/null +++ b/devel/bmake/files/mk/mk-files.txt @@ -0,0 +1,503 @@ +mk-files +******** + +The term ``mk-files`` refers to a collection of ``*.mk`` files. + +You need bmake_ or a *recent* NetBSD_ make. +If in doubt use bmake_. + +Introduction +============ + +Many years ago, when building large software projects, I used GNU make +(or my own patched version of it), and had developed a set of macros +to simplify developing complex build trees. + +Since the early 90's my main development machines, run BSD +(NetBSD_ to be precise), and the BSD source tree is good example of a +large software project. It quickly became clear that +``/usr/share/mk/*.mk`` were a great model, but were quite tightly +linked to building the BSD tree. + +Much as I liked using NetBSD, my customers were more likely to be +using SunOS, HP-UX etc, so I started on bmake_ and a portable collection +of mk-files (mk.tar.gz_). NetBSD provided much of the original structure. + +Since then I've added a lot of features to NetBSD's make and hence to +bmake which is kept closely in sync. The mk-files however have +diverged quite a bit, though ideas are still picked up from NetBSD +and FreeBSD. + +Basics +------ + +The BSD build model is very simple. A directory produces one +component, which is generally either a library or a program. +Library makefiles include ``lib.mk`` and programs include ``prog.mk`` +and they *do the right thing*. + +A simple library makefile might look like:: + + LIB = sig + + SRCS = \ + sigaction.c \ + sigcompat.c \ + sighdl.c + + .include <lib.mk> + +a simple program makefile:: + + PROG = cat + + SRCS = cat.c + + .include <prog.mk> + +in such cases even the ``SRCS`` line is unnecessary as ``prog.mk`` +will default it to ``${PROG}.c``. + +It is the sensible use of defaults and the plethora of macro modifiers +provided by bmake_ that allow simple makefiles such as the above +*just work* on many different systems. + + +mk-files +======== + +This section provides a brief description of some of the ``*.mk`` +files. + +sys.mk +------ + +When bmake starts, it looks for ``sys.mk`` and reads it before doing +anything else. Thus, this is the place to setup the environment for +everyone else. + +In this distribution, sys.mk avoids doing anything platform dependent. +It is quite short, and includes a number of other files (which may or +may not exists) + +sys.env.mk + If it exists, is expected to do things like conditioning the + environment. Since it will only be included by the initial + instance of bmake, it should ``.export`` anything that + sub-makes might need. + +examples/sys.clean-env.mk + An example of how to clean the environment. + See the file for all the details:: + + .if ${MAKE_VERSION} >= 20100606 && ${.MAKE.LEVEL} == 0 + # we save any env var that starts with these + MAKE_SAVE_ENV_PREFIX += SB MK MAKE MACHINE NEED_ CCACHE DISTCC USE_ SSH + MAKE_SAVE_ENV_VARS += \ + PATH HOME USER LOGNAME \ + SRCTOP OBJTOP OBJROOT \ + ${_env_vars} + + _env_vars != env | egrep '^(${MAKE_SAVE_ENV_PREFIX:ts|})' | sed 's,=.*,,'; echo + _export_list = + .for v in ${MAKE_SAVE_ENV_VARS:O:u} + .if !empty($v) + _export_list += $v + $v := ${$v} + .endif + .endfor + # now clobber the environment + .unexport-env + + # list of vars that we handle specially below + _tricky_env_vars = MAKEOBJDIR + # export our selection - sans tricky ones + .export ${_export_list:${_tricky_env_vars:${M_ListToSkip}}} + + # this next bit may need tweaking + .if defined(MAKEOBJDIR) + srctop := ${SRCTOP:U${SB_SRC:U${SB}/src}} + objroot := ${OBJROOT:U${SB_OBJROOT:U${SB}/${SB_OBJPREFIX}}} + # we'll take care of MACHINE below + objtop := ${OBJTOP:U${objroot}${MACHINE}} + .if !empty(objtop) + # we would normally want something like (/bin/sh): + # MAKEOBJDIR="\${.CURDIR:S,${SRCTOP},${OBJROOT}\${MACHINE},}" + # the $$ below is how we achieve the same result here. + # since everything saved from the environment above + # has run through := we need to compensate for ${MACHINE} + MAKEOBJDIR = $${.CURDIR:S,${srctop},${objtop:S,${MACHINE},\${MACHINE},},} + + # export these as-is, and do not track... + .export-env ${_tricky_env_vars} + # now evaluate for ourselves + .for v in ${_tricky_env_vars} + $v := ${$v} + .endfor + + .endif + .endif + .endif + + +host-target.mk + Is used to set macros like ``HOST_TARGET``, ``HOST_OS`` and + ``host_os`` which are used to find the next step. + +sys/\*.mk + Platform specific additions, such as ``Darwin.mk`` or ``SunOS.mk`` + set things like ``HOST_LIBEXT = .dylib`` for Darwin or + ``SHLIB_FULLVERSION = ${SHLIB_MAJOR}`` for SunOS 5. + If there is no OS specific file, ``sys/Generic.mk`` is used. + +local.sys.mk + Any ``local.*.mk`` file is not part of the distribution. + This provides a hook for sites to do extra setup without + having to edit the distributed files. + + +The above arrangement makes it easy for the mk files to be part of a +src tree on an NFS volume and to allow building on multiple platforms. + +lib.mk +------ + +This file is used to build a number of different libraries from the +same SRCS. + +lib${LIB}.a + An archive lib of ``.o`` files, this is the default + +lib${LIB}_p.a + A profiled lib of ``.po`` files. + Still an archive lib, but all the objects are built with + profiling in mind - hence the different extension. + It is skipped if ``MKPROFILE`` is "no". + +lib${LIB}_pic.a + An archive of ``.so`` objects compiled for relocation. + On NetBSD this is the input to ``lib${LIB}.${LD_so}``, it is + skipped if ``MKPICLIB`` is "no". + +lib${LIB}.${LD_so} + A shared library. The value of ``LD_so`` is very platform + specific. For example:: + + # SunOS 5 and most other ELF systems + libsslfd.so.1 + + # Darwin + libsslfd.1.dylib + + This library will only be built if ``SHLIB_MAJOR`` has + a value, and ``MKPIC`` is not set to "no". + +There is a lot of platform specific tweaking in ``lib.mk``, largely the +result of the original distributions trying to avoid interfering with +the system's ``sys.mk``. + +libnames.mk +----------- + +This is included by both ``prog.mk`` and ``lib.mk`` and tries to +include ``*.libnames.mk`` of which: + +local.libnames.mk + does not exist unless you create it. It is a handy way for you + to customize without touching the distributed files. + For example, on a test machine I needed to build openssl but + not install it, so put the following in ``local.libnames.mk``:: + + .if ${host_os} == "sunos" + LIBCRYPTO = ${OBJTOP}/openssl/lib/crypto/libcrypto${DLIBEXT} + LIBSSL = ${OBJTOP}/openssl/lib/ssl/libssl${DLIBEXT} + INCLUDES_libcrypto = -I${OBJ_libcrypto} + .endif + + The makefile created an openssl dir in ``${OBJ_libcrypto}`` to + gather all the headers. dpadd.mk_ did the rest. + +sjg.libnames.mk + not part of the mk-files distribution. + +host.libnames.mk + contains logic to find any libs named in ``HOST_LIBS`` in + ``HOST_LIBDIRS``. + +Each file above gets an opportunity to define things like:: + + LIBSSLFD ?= ${OBJTOP}/ssl/lib/sslfd/libsslfd${DLIBEXT} + INCLUDES_libsslfd = -I${SRC_libsslfd}/h -I${OBJ_libslfd} + +these are used by dpadd.mk_ and will be explained below. + +dpadd.mk +-------- + +This file looks like line noise, and is best considered read-only. +However it provides some very useful functionality, which simplifies the build. + +Makefiles can use the LIB* macros defined via libnames.mk_ or anywhere +else in various ways:: + + # indicate that we need to include headers from LIBCRYPTO + # this would result in ${INCLUDES_libcrypto} being added to CFLAGS. + SRC_LIBS += ${LIBCRYPTO} + + # indicate that libsslfd must be built already. + # it also has the same effect as SRC_LIBS + DPADD += ${LIBSSLFD} + + # indicate that not only must libsslfd be built, + # but that we need to link with it. + # this is almost exactly equivalent to + # DPADD += ${LIBSSLFD} + # LDADD += -L${LIBSSLFD:H} -lsslfd + # and mostly serves to ensure that DPADD and LDADD are in sync. + DPLIBS += ${LIBSSLFD} + +Any library (referenced by its full path) in any of the above, is +added to ``DPMAGIC_LIBS`` with the following results, for each lib *foo*. + +SRC_libfoo + Is set to indicate where the src for libfoo is. + By default it is derived from ``LIBFOO`` by replacing + ``${OBJTOP}`` with ``${SRCTOP}``. + +OBJ_libfoo + Not very exciting, is just the dir where libfoo lives. + +INCLUDES_libfoo + What to add to ``CFLAGS`` to find the public headers. + The default varies. If ``${SRC_libfoo}/h`` exists, it is assumed + to be the home of all public headers and thus the default is + ``-I${SRC_libfoo}/h`` + + Otherwise we make no assumptions and the default is + ``-I${SRC_libfoo} -I${OBJ_libfoo}`` + +LDADD_libfoo + This only applies to libs reference via ``DPLIBS``. + The default is ``-lfoo``, ``LDADD_*`` provides a hook to + instantiate other linker flags at the appropriate point + without losing the benfits of ``DPLIBS``. + +prog.mk +------- + +Compiles the specified SRCS and links them and the nominated libraries +into a program. Prog makefiles usually need to list the libraries +that need to be linked. We prefer use of ``DPLIBS`` but the more +traditional ``DPADD`` and ``LDADD`` work just as well. +That is:: + + DPLIBS += ${LIBCRYPTO} + +is equivalent to:: + + DPADD += ${LIBCRYPTO} + LDADD += -lcrypto + +obj.mk +------ + +One of the cool aspects of BSD make, is its support for separating +object files from the src tree. This is also the source of much +confusion to some. + +Traditionally one had to do a separate ``make obj`` pass through the +tree. If ``MKOBJDIRS`` is "auto", we include auto.obj.mk_. + +auto.obj.mk +----------- + +This leverages the ``.OBJDIR`` target introduced some years ago to +NetBSD make, to automatically create the desired object dir. + +subdir.mk +--------- + +This is the traditional means of walking the tree. A makefile sets +``SUBDIR`` to the list of sub-dirs to visit. + +If ``SUBDIR_MUST_EXIST`` is set, missing directories cause an error, +otherwise a warning is issued. If you don't even want the warning, +set ``MISSING_DIR=continue``. + +Traditionally, ``subdir.mk`` prints clue as it visits each subdir:: + + ===> ssl + ===> ssl/lib + ===> ssl/lib/sslfd + +you can suppress that - or enhance it by setting ``ECHO_DIR``:: + + # suppress subdir noise + ECHO_DIR=: + # print time stamps + ECHO_DIR=echo @ `date "+%s [%Y-%m-%d %T] "` + +links.mk +-------- + +Provides rules for processing lists of ``LINKS`` and ``SYMLINKS``. +Each is expected to be a list of ``link`` and ``target`` pairs +(``link`` -> ``target``). + +The logic is generally in a ``_*_SCRIPT`` which is referenced in a +``_*_USE`` (``.USE``) target. + +The ``_BUILD_*`` forms are identical, but do not use ``${DESTDIR}`` +and so are useful for creating symlinks during the build phase. +For example:: + + SYMLINKS += ${.CURDIR}/${MACHINE_ARCH}/include machine + header_links: _BUILD_SYMLINKS_USE + + md.o: header_links + +would create a symlink called ``machine`` in ``${.OBJDIR}`` pointing to +``${.CURDIR}/${MACHINE_ARCH}/include`` before compiling ``md.o`` + + +autoconf.mk +----------- + +Deals with running (or generating) GNU autoconf ``configure`` scripts. + +dep.mk +------ + +Deals with collecting dependencies. Another useful feature of BSD +make is the separation of this sort of information into a ``.depend`` +file. ``MKDEP`` needs to point to a suitable tool (like mkdeps.sh_) + +If ``USE_AUTODEP_MK`` is "yes" includes autodep.mk_ + +autodep.mk +---------- + +Leverages the ``-MD`` feature of recent GCC to collect dependency +information as a side effect of compilation. With this GCC puts +dependency info into a ``.d`` file. + +Unfortunately GCC bases the name of the ``.d`` file on the name of the +input rather than the output file, which causes problems when the same +source is compiled different ways. The latest GCC supports ``-MF`` to +name the ``.d`` file and ``-MT`` to control the name to put as the +dependent. + +Recent bmake allows dependencies for the ``.END`` target (run at the +end if everything was successful), and ``autodep.mk`` uses this to +post process the ``.d`` files into ``.depend``. + +auto.dep.mk +----------- + +A much simpler implementation than autodep.mk_ it uses +``-MF ${.TARGET:T}.d`` +to avoid possible conflicts during parallel builds. +This precludes the use of suffix rules to drive ``make depend``, so +dep.mk_ handles that if specifically requested. + +options.mk +---------- + +Inspired by FreeBSD's ``bsd.own.mk`` more flexible. +FreeBSD now have similar functionality in ``bsd.mkopt.mk``. + +It allows users to express their intent with respect to options +``MK_*`` by setting ``WITH_*`` or ``WITHOUT_*``. + +Note: ``WITHOUT_*`` wins if both are set, and makefiles can set +``NO_*`` to say they cannot handle that option, or even ``MK_*`` if +they really need to. + + +own.mk +------ + +Normally included by ``init.mk`` (included by ``lib.mk`` and +``prog.mk`` etc), sets macros for default ownership etc. + +It includes ``${MAKECONF}`` if it is defined and exists. + +ldorder.mk +---------- + +Leverages ``bmake`` to compute optimal link order for libraries. +This works nicely and makes refactoring a breeze - so long as you +have not (or few) cicular dependencies between libraries. + +man.mk +------ + +Deals with man pages. + +warnings.mk +----------- + +This provides a means of fine grained control over warnings on a per +``${MACHINE}`` or even file basis. + +A makefile sets ``WARNINGS_SET`` to name a list of warnings +and individual ``W_*`` macros can be used to tweak them. +For example:: + + WARNINGS_SET = HIGH + W_unused_sparc = -Wno-unused + +would add all the warnings in ``${HIGH_WARNINGS}`` to CFLAGS, but +on sparc, ``-Wno-unused`` would replace ``-Wunused``. + +You should never need to edit ``warnings.mk``, it will include +``warnings-sets.mk`` if it exists and you use that to make any local +customizations. + +rst2htm.mk +---------- + +Logic to simplify generating HTML (and PDF) documents from ReStructuredText. + +cython.mk +--------- + +Logic to build Python C interface modules using Cython_ + +.. _Cython: http://www.cython.org/ + +Meta mode +========= + +The 20110505 and later versions of ``mk-files`` include a number of +makefiles contributed by Juniper Networks, Inc. +These allow the latest version of bmake_ to run in `meta mode`_ +see `dirdeps.mk`_ + +.. _`dirdeps.mk`: /help/sjg/dirdeps.htm +.. _`meta mode`: bmake-meta-mode.htm + +Install +======= + +You can use the content of mk.tar.gz_ without installing at all. + +The script ``install-mk`` takes care of copying ``*.mk`` into a +destination directory, and unless told not to, create ``bsd.*.mk`` links +for ``lib.mk`` etc. + +If you just want to create the ``bsd.*.mk`` links in the directory +where you unpacked the tar file, you can:: + + ./mk/install-mk ./mk + +------ + +.. _bmake: bmake.htm +.. _NetBSD: http://www.netbsd.org/ +.. _mkdeps.sh: http://www.crufty.net/ftp/pub/sjg/mkdeps.sh +.. _mk.tar.gz: http://www.crufty.net/ftp/pub/sjg/mk.tar.gz + +:Author: sjg@crufty.net +:Revision: $Id: mk-files.txt,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +:Copyright: Crufty.NET diff --git a/devel/bmake/files/mk/mkopt.sh b/devel/bmake/files/mk/mkopt.sh new file mode 100644 index 00000000000..7df45662aa1 --- /dev/null +++ b/devel/bmake/files/mk/mkopt.sh @@ -0,0 +1,103 @@ +: +# $Id: mkopt.sh,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 2014, 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 +# + +# handle WITH[OUT]_* options in a manner compatible with +# options.mk and bsd.mkopt.mk in recent FreeBSD + +# no need to be included more than once +_MKOPT_SH=: +_MKOPT_PREFIX=${_MKOPT_PREFIX:-MK_} + +# +# _mk_opt default OPT +# +# Set MK_$OPT +# +# The semantics are simple, if MK_$OPT has no value +# WITHOUT_$OPT results in MK_$OPT=no +# otherwise WITH_$OPT results in MK_$OPT=yes. +# Note WITHOUT_$OPT overrides WITH_$OPT. +# +# For backwards compatability reasons we treat WITH_$OPT=no +# the same as WITHOUT_$OPT. +# +_mk_opt() { + _d=$1 + _mo=${_MKOPT_PREFIX}$2 _wo=WITHOUT_$2 _wi=WITH_$2 + eval "_mov=\$$_mo _wov=\$$_wo _wiv=\$$_wi" + + case "$_wiv" in + [Nn][Oo]) _wov=no;; + esac + _v=${_mov:-${_wov:+no}} + _v=${_v:-${_wiv:+yes}} + _v=${_v:-$_d} + _opt_list="$_opt_list $_mo" + case "$_v" in + yes|no) ;; # sane + 0|[NnFf]*) _v=no;; # they mean no + 1|[YyTt]*) _v=yes;; # they mean yes + *) _v=$_d;; # ignore bogus value + esac + eval "$_mo=$_v" +} + +# +# _mk_opts default opt ... [default [opt] ...] +# +# see _mk_opts_defaults for example +# +_mk_opts() { + _d=no + for _o in "$@" + do + case "$_o" in + */*) # option is dirname default comes from basename + eval "_d=\$${_MKOPT_PREFIX}${_o#*/}" + _o=${_o%/*} + ;; + yes|no) _d=$_o; continue;; + esac + _mk_opt $_d $_o + done +} + +# handle either options.mk style OPTIONS_DEFAULT_* +# or FreeBSD's new bsd.mkopt.mk style __DEFAULT_*_OPTIONS +_mk_opts_defaults() { + _mk_opts no $OPTIONS_DEFAULT_NO $__DEFAULT_NO_OPTIONS \ + yes $OPTIONS_DEFAULT_YES $__DEFAULT_YES_OPTIONS \ + $OPTIONS_DEFAULT_DEPENDENT $__DEFAULT_DEPENDENT_OPTIONS +} + +case "/$0" in +*/mkopt*) + _list=no + while : + do + case "$1" in + *=*) eval "$1"; shift;; + --no|no) _list="$_list no"; shift;; + --yes|yes) _list="$_list yes"; shift;; + -DWITH*) eval "${1#-D}=1"; shift;; + [A-Z]*) _list="$_list $1"; shift;; + *) break;; + esac + done + _mk_opts $_list + ;; +esac + diff --git a/devel/bmake/files/mk/nls.mk b/devel/bmake/files/mk/nls.mk new file mode 100644 index 00000000000..fefdeefc9ba --- /dev/null +++ b/devel/bmake/files/mk/nls.mk @@ -0,0 +1,47 @@ +# $NetBSD: nls.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ + +.if !target(.MAIN) +# init.mk not included +.-include <${.CURDIR:H}/Makefile.inc> + +.MAIN: all +.endif + +.SUFFIXES: .cat .msg + +.msg.cat: + @rm -f ${.TARGET} + gencat ${.TARGET} ${.IMPSRC} + +.if defined(NLS) && !empty(NLS) +NLSALL= ${NLS:.msg=.cat} +.NOPATH: ${NLSALL} +.endif + +.if !defined(NLSNAME) +.if defined(PROG) +NLSNAME=${PROG} +.else +NLSNAME=lib${LIB} +.endif +.endif + +nlsinstall: +.if defined(NLSALL) + @for msg in ${NLSALL}; do \ + NLSLANG=`basename $$msg .cat`; \ + dir=${DESTDIR}${NLSDIR}/$${NLSLANG}; \ + ${INSTALL} -d $$dir; \ + ${INSTALL} ${COPY} -o ${NLSOWN} -g ${NLSGRP} -m ${NLSMODE} $$msg $$dir/${NLSNAME}.cat; \ + done +.endif + +.if defined(NLSALL) +all: ${NLSALL} + +install: nlsinstall + +cleandir: cleannls +cleannls: + rm -f ${NLSALL} +.endif diff --git a/devel/bmake/files/mk/obj.mk b/devel/bmake/files/mk/obj.mk new file mode 100644 index 00000000000..dd346bee193 --- /dev/null +++ b/devel/bmake/files/mk/obj.mk @@ -0,0 +1,113 @@ +# $Id: obj.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 1999-2010, 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 !target(__${.PARSEFILE:S,bsd.,,}__) +__${.PARSEFILE:S,bsd.,,}__: + +.include <init.mk> + +ECHO_TRACE ?= echo + +.if ${MK_OBJDIRS} == "no" +obj: +objlink: +objwarn: +.else + +# this has to match how make behaves +.if defined(MAKEOBJDIRPREFIX) || defined(MAKEOBJDIR) +.if defined(MAKEOBJDIRPREFIX) +__objdir:= ${MAKEOBJDIRPREFIX}${.CURDIR} +.else +__objdir:= ${MAKEOBJDIR} +.endif +.else +__objdir= ${__objlink} +.endif + +.if defined(OBJMACHINE) +__objlink= obj.${MACHINE} +.else +__objlink= obj +.endif + +.if ${MK_AUTO_OBJ} == "yes" +.-include "auto.obj.mk" +.endif + +.NOPATH: ${__objdir} +.PHONY: obj + +obj: _SUBDIRUSE + @if test ! -d ${__objdir}/.; then \ + mkdir -p ${__objdir}; \ + if test ! -d ${__objdir}; then \ + mkdir ${__objdir}; exit 1; \ + fi; \ + ${ECHO_TRACE} "[Creating objdir ${__objdir}...]" >&2; \ + fi + +.if !target(_SUBDIRUSE) +# this just allows us to be included by ourselves +_SUBDIRUSE: +.endif + +# so we can interact with freebsd makefiles +.if !target(objwarn) +objwarn: +.if ${.OBJDIR} == ${.CURDIR} + @echo "Warning Object directory is ${.CURDIR}" +.elif ${.OBJDIR} != ${__objdir} + @echo "Warning Object directory is ${.OBJDIR} vs. ${__objdir}" +.endif +.endif + +.if !target(objlink) +objlink: +.if ${__objdir:T} != ${__objlink} + @if test -d ${__objdir}/.; then \ + ${RM} -f ${.CURDIR}/${__objlink}; \ + ${LN} -s ${__objdir} ${.CURDIR}/${__objlink}; \ + echo "${__objlink} -> ${__objdir}"; \ + else \ + echo "No ${__objdir} to link to - do a 'make obj'"; \ + fi +.endif +.endif +.endif + +_CURDIR?= ${.CURDIR} +_OBJDIR?= ${.OBJDIR} + +.if !target(print-objdir) +print-objdir: + @echo ${_OBJDIR} +.endif + +.if !target(whereobj) +whereobj: + @echo ${_OBJDIR} +.endif + +.if !target(destroy) +.if ${.CURDIR} != ${.OBJDIR} +destroy: + (cd ${_CURDIR} && rm -rf ${_OBJDIR}) +.else +destroy: clean +.endif +.endif + +.endif diff --git a/devel/bmake/files/mk/options.mk b/devel/bmake/files/mk/options.mk new file mode 100644 index 00000000000..1cc24d65cfc --- /dev/null +++ b/devel/bmake/files/mk/options.mk @@ -0,0 +1,80 @@ +# $Id: options.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 2012, 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 +# + +# Inspired by FreeBSD bsd.own.mk, but intentionally simpler and more flexible. + +# Options are normally listed in either OPTIONS_DEFAULT_{YES,NO} +# We convert these to ${OPTION}/{yes,no} in OPTIONS_DEFAULT_VALUES. +# We add the OPTIONS_DEFAULT_NO first so they take precedence. +# This allows override of an OPTIONS_DEFAULT_YES by adding it to +# OPTIONS_DEFAULT_NO or adding ${OPTION}/no to OPTIONS_DEFAULT_VALUES. +# An OPTIONS_DEFAULT_NO option can only be overridden by putting +# ${OPTION}/yes in OPTIONS_DEFAULT_VALUES. +# A makefile may set NO_* (or NO*) to indicate it cannot do something. +# User sets WITH_* and WITHOUT_* to indicate what they want. +# We set ${OPTION_PREFIX:UMK_}* which is then all we need care about. +OPTIONS_DEFAULT_VALUES += \ + ${OPTIONS_DEFAULT_NO:O:u:S,$,/no,} \ + ${OPTIONS_DEFAULT_YES:O:u:S,$,/yes,} + +OPTION_PREFIX ?= MK_ + +# NO_* takes precedence +# If both WITH_* and WITHOUT_* are defined, WITHOUT_ wins unless +# DOMINANT_* is set to "yes" +# Otherwise WITH_* and WITHOUT_* override the default. +.for o in ${OPTIONS_DEFAULT_VALUES:M*/*} +.if defined(NO_${o:H}) || defined(NO${o:H}) +# we cannot do it +${OPTION_PREFIX}${o:H} ?= no +.elif defined(WITH_${o:H}) && defined(WITHOUT_${o:H}) +# normally WITHOUT_ wins +DOMINANT_${o:H} ?= no +${OPTION_PREFIX}${o:H} ?= ${DOMINANT_${o:H}} +.elif ${o:T:tl} == "no" +.if defined(WITH_${o:H}) +${OPTION_PREFIX}${o:H} ?= yes +.else +${OPTION_PREFIX}${o:H} ?= no +.endif +.else +.if defined(WITHOUT_${o:H}) +${OPTION_PREFIX}${o:H} ?= no +.else +${OPTION_PREFIX}${o:H} ?= yes +.endif +.endif +.endfor + +# OPTIONS_DEFAULT_DEPENDENT += FOO_UTILS/FOO +# If neither WITH[OUT]_FOO_UTILS is set, (see rules above) +# use the value of ${OPTION_PREFIX}FOO +.for o in ${OPTIONS_DEFAULT_DEPENDENT:M*/*:O:u} +.if defined(NO_${o:H}) || defined(NO${o:H}) +# we cannot do it +${OPTION_PREFIX}${o:H} ?= no +.elif defined(WITH_${o:H}) && defined(WITHOUT_${o:H}) +# normally WITHOUT_ wins +DOMINANT_${o:H} ?= no +${OPTION_PREFIX}${o:H} ?= ${DOMINANT_${o:H}} +.elif defined(WITH_${o:H}) +${OPTION_PREFIX}${o:H} ?= yes +.elif defined(WITHOUT_${o:H}) +${OPTION_PREFIX}${o:H} ?= no +.else +${OPTION_PREFIX}${o:H} ?= ${${OPTION_PREFIX}${o:T}} +.endif +.endfor +.undef OPTIONS_DEFAULT_VALUES OPTIONS_DEFAULT_NO OPTIONS_DEFAULT_YES diff --git a/devel/bmake/files/mk/own.mk b/devel/bmake/files/mk/own.mk new file mode 100644 index 00000000000..bb7ee602174 --- /dev/null +++ b/devel/bmake/files/mk/own.mk @@ -0,0 +1,271 @@ +# $Id: own.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ + +.if !target(__${.PARSEFILE}__) +__${.PARSEFILE}__: + +.if !target(__init.mk__) +.include "init.mk" +.endif + +.if !defined(NOMAKECONF) && !defined(NO_MAKECONF) +MAKECONF?= /etc/mk.conf +.-include "${MAKECONF}" +.endif + +.include <host-target.mk> + +TARGET_OSNAME?= ${_HOST_OSNAME} +TARGET_OSREL?= ${_HOST_OSREL} +TARGET_OSTYPE?= ${HOST_OSTYPE} +TARGET_HOST?= ${HOST_TARGET} + +# these may or may not exist +.-include <${TARGET_HOST}.mk> +.-include <config.mk> + +RM?= rm +LN?= ln +INSTALL?= install + +prefix?= /usr +.if exists(${prefix}/lib) +libprefix?= ${prefix} +.else +libprefix?= /usr +.endif + +# FreeBSD at least does not set this +MACHINE_ARCH?= ${MACHINE} +# we need to make sure these are defined too in case sys.mk fails to. +COMPILE.s?= ${CC} ${AFLAGS} -c +LINK.s?= ${CC} ${AFLAGS} ${LDFLAGS} +COMPILE.S?= ${CC} ${AFLAGS} ${CPPFLAGS} -c -traditional-cpp +LINK.S?= ${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS} +COMPILE.c?= ${CC} ${CFLAGS} ${CPPFLAGS} -c +LINK.c?= ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} +CXXFLAGS?= ${CFLAGS} +COMPILE.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c +LINK.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS} +COMPILE.m?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} -c +LINK.m?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} ${LDFLAGS} +COMPILE.f?= ${FC} ${FFLAGS} -c +LINK.f?= ${FC} ${FFLAGS} ${LDFLAGS} +COMPILE.F?= ${FC} ${FFLAGS} ${CPPFLAGS} -c +LINK.F?= ${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS} +COMPILE.r?= ${FC} ${FFLAGS} ${RFLAGS} -c +LINK.r?= ${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS} +LEX.l?= ${LEX} ${LFLAGS} +COMPILE.p?= ${PC} ${PFLAGS} ${CPPFLAGS} -c +LINK.p?= ${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS} +YACC.y?= ${YACC} ${YFLAGS} + +# for suffix rules +IMPFLAGS?= ${COPTS.${.IMPSRC:T}} ${CPUFLAGS.${.IMPSRC:T}} ${CPPFLAGS.${.IMPSRC:T}} +.for s in .c .cc +COMPILE.$s += ${IMPFLAGS} +LINK.$s += ${IMPFLAGS} +.endfor + +PRINT.VAR.MAKE = MAKESYSPATH=${MAKESYSPATH:U${.PARSEDIR}} ${.MAKE} +.if empty(.MAKEFLAGS:M-V*) +.if defined(MAKEOBJDIRPREFIX) || defined(MAKEOBJDIR) +PRINTOBJDIR= ${PRINT.VAR.MAKE} -r -V .OBJDIR -f /dev/null xxx +.else +PRINTOBJDIR= ${PRINT.VAR.MAKE} -V .OBJDIR +.endif +.else +PRINTOBJDIR= echo # prevent infinite recursion +.endif + +# we really like to have SRCTOP and OBJTOP defined... +.if !defined(SRCTOP) || !defined(OBJTOP) +.-include <srctop.mk> +.endif + +.if !defined(SRCTOP) || !defined(OBJTOP) +# dpadd.mk is rather pointless without these +OPTIONS_DEFAULT_NO+= DPADD_MK +.endif + +# process options +OPTIONS_DEFAULT_NO+= \ + INSTALL_AS_USER \ + GPROF \ + PROG_LDORDER_MK \ + LIBTOOL \ + LINT \ + +OPTIONS_DEFAULT_YES+= \ + ARCHIVE \ + AUTODEP \ + CRYPTO \ + DOC \ + DPADD_MK \ + GDB \ + KERBEROS \ + LINKLIB \ + MAN \ + NLS \ + OBJ \ + PIC \ + SHARE \ + SKEY \ + YP \ + +OPTIONS_DEFAULT_DEPENDENT+= \ + CATPAGES/MAN \ + LDORDER_MK/PROG_LDORDER_MK \ + OBJDIRS/OBJ \ + PICINSTALL/LINKLIB \ + PICLIB/PIC \ + PROFILE/LINKLIB \ + STAGING_PROG/STAGING \ + +.include <options.mk> + +.if ${MK_INSTALL_AS_USER} == "yes" +# We ignore this if user is root. +_uid!= id -u +.if ${_uid} != 0 +.if !defined(USERGRP) +USERGRP!= id -g +.export USERGRP +.endif +.for x in BIN CONF DOC INC INFO FILES KMOD LIB MAN NLS PROG SHARE +$xOWN= ${USER} +$xGRP= ${USERGRP} +$x_INSTALL_OWN= +.endfor +.endif +.endif + +# override this in sys.mk +ROOT_GROUP?= wheel +BINGRP?= ${ROOT_GROUP} +BINOWN?= root +BINMODE?= 555 +NONBINMODE?= 444 +DIRMODE?= 755 + +INCLUDEDIR?= ${prefix}/include +INCDIR?= ${INCLUDEDIR} + +# Define MANZ to have the man pages compressed (gzip) +#MANZ= 1 + +MANTARGET?= cat +MANDIR?= ${prefix}/share/man/${MANTARGET} +MANGRP?= ${BINGRP} +MANOWN?= ${BINOWN} +MANMODE?= ${NONBINMODE} + +INCLUDEDIR?= ${libprefix}/include +LIBDIR?= ${libprefix}/lib +SHLIBDIR?= ${libprefix}/lib +.if ${USE_SHLIBDIR:Uno} == "yes" +_LIBSODIR?= ${SHLIBDIR} +.else +_LIBSODIR?= ${LIBDIR} +.endif +# this is where ld.*so lives +SHLINKDIR?= /usr/libexec +LINTLIBDIR?= ${libprefix}/libdata/lint +LIBGRP?= ${BINGRP} +LIBOWN?= ${BINOWN} +LIBMODE?= ${NONBINMODE} + +DOCDIR?= ${prefix}/share/doc +DOCGRP?= ${BINGRP} +DOCOWN?= ${BINOWN} +DOCMODE?= ${NONBINMODE} + +NLSDIR?= ${prefix}/share/nls +NLSGRP?= ${BINGRP} +NLSOWN?= ${BINOWN} +NLSMODE?= ${NONBINMODE} + +KMODDIR?= ${prefix}/lkm +KMODGRP?= ${BINGRP} +KMODOWN?= ${BINOWN} +KMODMODE?= ${NONBINMODE} + +SHAREGRP?= ${BINGRP} +SHAREOWN?= ${BINOWN} +SHAREMODE?= ${NONBINMODE} + +COPY?= -c +STRIP_FLAG?= -s + +.if ${TARGET_OSNAME} == "NetBSD" +.if exists(/usr/libexec/ld.elf_so) +OBJECT_FMT=ELF +.endif +OBJECT_FMT?=a.out +.endif +# sys.mk should set something appropriate if need be. +OBJECT_FMT?=ELF + +.if (${_HOST_OSNAME} == "FreeBSD") +CFLAGS+= ${CPPFLAGS} +.endif + +# allow for per target flags +# apply the :T:R first, so the more specific :T can override if needed +CPPFLAGS += ${CPPFLAGS_${.TARGET:T:R}} ${CPPFLAGS_${.TARGET:T}} +CFLAGS += ${CFLAGS_${.TARGET:T:R}} ${CFLAGS_${.TARGET:T}} + +# Define SYS_INCLUDE to indicate whether you want symbolic links to the system +# source (``symlinks''), or a separate copy (``copies''); (latter useful +# in environments where it's not possible to keep /sys publicly readable) +#SYS_INCLUDE= symlinks + +# don't try to generate PIC versions of libraries on machines +# which don't support PIC. +.if (${MACHINE_ARCH} == "vax") || \ + ((${MACHINE_ARCH} == "mips") && defined(STATIC_TOOLCHAIN)) || \ + ((${MACHINE_ARCH} == "alpha") && defined(ECOFF_TOOLCHAIN)) +MK_PIC=no +.endif + +# No lint, for now. +NOLINT= + + +.if ${MK_LINKLIB} == "no" +MK_PICINSTALL= no +MK_PROFILE= no +.endif + +.if ${MK_MAN} == "no" +MK_CATPAGES= no +.endif + +.if ${MK_OBJ} == "no" +MK_OBJDIRS= no +MK_AUTO_OBJ= no +.endif + +.if ${MK_SHARE} == "no" +MK_CATPAGES= no +MK_DOC= no +MK_INFO= no +MK_MAN= no +MK_NLS= no +.endif + +# :U incase not using our sys.mk +.if ${MK_META_MODE:Uno} == "yes" +# should all be set by sys.mk if not default +TARGET_SPEC_VARS ?= MACHINE +.if ${TARGET_SPEC_VARS:[#]} > 1 +TARGET_SPEC_VARS_REV := ${TARGET_SPEC_VARS:[-1..1]} +.else +TARGET_SPEC_VARS_REV = ${TARGET_SPEC_VARS} +.endif +.if ${MK_STAGING} == "yes" +STAGE_ROOT?= ${OBJROOT}/stage +STAGE_OBJTOP?= ${STAGE_ROOT}/${TARGET_SPEC_VARS_REV:ts/} +.endif +.endif + +.endif diff --git a/devel/bmake/files/mk/prlist.mk b/devel/bmake/files/mk/prlist.mk new file mode 100644 index 00000000000..d17cf5ceba0 --- /dev/null +++ b/devel/bmake/files/mk/prlist.mk @@ -0,0 +1,36 @@ +# $Id: prlist.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 2006, 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 !target(__${.PARSEFILE}__) +__${.PARSEFILE}__: + +# this needs to be included after all the lists it will process +# are defined - which is why it is a separate file. +# Usage looks like: +# MAKEFLAGS= ${.MAKE} -f ${MAKEFILE} prlist.SOMETHING_HUGE | xargs whatever +# +.if make(prlist.*) +.for t in ${.TARGETS:Mprlist.*:E} +.if empty($t) +prlist.$t: +.else +prlist.$t: ${$t:O:u:S,^,prlist-,} +${$t:O:u:S,^,prlist-,}: .PHONY + @echo "${.TARGET:S,prlist-,,}" +.endif +.endfor +.endif + +.endif diff --git a/devel/bmake/files/mk/prog.mk b/devel/bmake/files/mk/prog.mk new file mode 100644 index 00000000000..eeb0bac9694 --- /dev/null +++ b/devel/bmake/files/mk/prog.mk @@ -0,0 +1,251 @@ +# $Id: prog.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ + +.if !target(__${.PARSEFILE}__) +__${.PARSEFILE}__: + +.include <init.mk> + +# FreeBSD at least expects MAN8 etc. +.if defined(MAN) && !empty(MAN) +_sect:=${MAN:E} +MAN${_sect}=${MAN} +.endif + +.SUFFIXES: .out .o .c .cc .C .y .l .s .8 .7 .6 .5 .4 .3 .2 .1 .0 + +CFLAGS+= ${COPTS} + +.if ${TARGET_OSNAME} == "NetBSD" +.if ${MACHINE_ARCH} == "sparc64" +CFLAGS+= -mcmodel=medlow +.endif + +# ELF platforms depend on crtbegin.o and crtend.o +.if ${OBJECT_FMT} == "ELF" +.ifndef LIBCRTBEGIN +LIBCRTBEGIN= ${DESTDIR}/usr/lib/crtbegin.o +.MADE: ${LIBCRTBEGIN} +.endif +.ifndef LIBCRTEND +LIBCRTEND= ${DESTDIR}/usr/lib/crtend.o +.MADE: ${LIBCRTEND} +.endif +_SHLINKER= ${SHLINKDIR}/ld.elf_so +.else +LIBCRTBEGIN?= +LIBCRTEND?= +_SHLINKER= ${SHLINKDIR}/ld.so +.endif + +.ifndef LIBCRT0 +LIBCRT0= ${DESTDIR}/usr/lib/crt0.o +.MADE: ${LIBCRT0} +.endif +.endif # NetBSD + +# here is where you can define what LIB* are +.-include <libnames.mk> +.if ${MK_DPADD_MK} == "yes" +# lots of cool magic, but might not suit everyone. +.include <dpadd.mk> +.endif + +.if ${MK_GPROF} == "yes" +CFLAGS+= ${CC_PG} ${PROFFLAGS} +LDADD+= ${CC_PG} +.if ${MK_DPADD_MK} == "no" +LDADD_LIBC_P?= -lc_p +LDADD_LAST+= ${LDADD_LIBC_P} +.endif +.endif + +.if defined(SHAREDSTRINGS) +CLEANFILES+=strings +.c.o: + ${CC} -E ${CFLAGS} ${.IMPSRC} | xstr -c - + @${CC} ${CFLAGS} -c x.c -o ${.TARGET} + @rm -f x.c + +${CXX_SUFFIXES:%=%.o}: + ${CXX} -E ${CXXFLAGS} ${.IMPSRC} | xstr -c - + @mv -f x.c x.cc + @${CXX} ${CXXFLAGS} -c x.cc -o ${.TARGET} + @rm -f x.cc +.endif + + +.if defined(PROG) +BINDIR ?= ${prefix}/bin + +SRCS?= ${PROG}.c +.for s in ${SRCS:N*.h:N*.sh:M*/*} +${.o .po .lo:L:@o@${s:T:R}$o@}: $s +.endfor +.if !empty(SRCS:N*.h:N*.sh) +OBJS+= ${SRCS:T:N*.h:N*.sh:R:S/$/.o/g} +LOBJS+= ${LSRCS:.c=.ln} ${SRCS:M*.c:.c=.ln} +.endif + +.if defined(OBJS) && !empty(OBJS) +.NOPATH: ${OBJS} ${PROG} ${SRCS:M*.[ly]:C/\..$/.c/} ${YHEADER:D${SRCS:M*.y:.y=.h}} + +# this is known to work for NetBSD 1.6 and FreeBSD 4.2 +.if ${TARGET_OSNAME} == "NetBSD" || ${TARGET_OSNAME} == "FreeBSD" +_PROGLDOPTS= +.if ${SHLINKDIR} != "/usr/libexec" # XXX: change or remove if ld.so moves +_PROGLDOPTS+= -Wl,-dynamic-linker=${_SHLINKER} +.endif +.if defined(LIBDIR) && ${SHLIBDIR} != ${LIBDIR} +_PROGLDOPTS+= -Wl,-rpath-link,${DESTDIR}${SHLIBDIR}:${DESTDIR}/usr/lib \ + -L${DESTDIR}${SHLIBDIR} +.endif +_PROGLDOPTS+= -Wl,-rpath,${SHLIBDIR}:/usr/lib + +.if defined(PROG_CXX) +_CCLINK= ${CXX} +_SUPCXX= -lstdc++ -lm +.endif +.endif # NetBSD + +_CCLINK?= ${CC} + +.if ${MK_PROG_LDORDER_MK} != "no" +${PROG}: ldorder + +.include <ldorder.mk> +.endif + +.if defined(DESTDIR) && exists(${LIBCRT0}) && ${LIBCRT0} != "/dev/null" + +${PROG}: ${LIBCRT0} ${OBJS} ${LIBC} ${DPADD} + ${_CCLINK} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} -nostdlib ${_PROGLDOPTS} -L${DESTDIR}/usr/lib ${LIBCRT0} ${LIBCRTBEGIN} ${OBJS} ${LDADD_LDORDER} ${LDADD} -L${DESTDIR}/usr/lib ${_SUPCXX} -lgcc -lc -lgcc ${LIBCRTEND} + +.else + +${PROG}: ${LIBCRT0} ${OBJS} ${LIBC} ${DPADD} + ${_CCLINK} ${LDFLAGS} ${LDSTATIC} -o ${.TARGET} ${_PROGLDOPTS} ${OBJS} ${LDADD_LDORDER} ${LDADD} + +.endif # defined(DESTDIR) +.endif # defined(OBJS) && !empty(OBJS) + +.if !defined(MAN) +MAN= ${PROG}.1 +.endif # !defined(MAN) +.endif # defined(PROG) + +.if !defined(_SKIP_BUILD) +realbuild: ${PROG} +.endif + +all: _SUBDIRUSE + +.if !target(clean) +cleanprog: + rm -f a.out [Ee]rrs mklog core *.core \ + ${PROG} ${OBJS} ${LOBJS} ${CLEANFILES} + +clean: _SUBDIRUSE cleanprog +cleandir: _SUBDIRUSE cleanprog +.else +cleandir: _SUBDIRUSE clean +.endif + +.if defined(SRCS) && (!defined(MKDEP) || ${MKDEP} != autodep) +afterdepend: .depend + @(TMP=/tmp/_depend$$$$; \ + sed -e 's/^\([^\.]*\).o[ ]*:/\1.o \1.ln:/' \ + < .depend > $$TMP; \ + mv $$TMP .depend) +.endif + +.if !target(install) +.if !target(beforeinstall) +beforeinstall: +.endif +.if !target(afterinstall) +afterinstall: +.endif + +.if !empty(BINOWN) +PROG_INSTALL_OWN ?= -o ${BINOWN} -g ${BINGRP} +.endif + +.if !target(realinstall) +realinstall: proginstall +.endif +.if !target(proginstall) +proginstall: +.if defined(PROG) + [ -d ${DESTDIR}${BINDIR} ] || \ + ${INSTALL} -d ${PROG_INSTALL_OWN} -m 775 ${DESTDIR}${BINDIR} + ${INSTALL} ${COPY} ${STRIP_FLAG} ${PROG_INSTALL_OWN} -m ${BINMODE} \ + ${PROG} ${DESTDIR}${BINDIR}/${PROG_NAME} +.endif +.if defined(HIDEGAME) + (cd ${DESTDIR}/usr/games; rm -f ${PROG}; ln -s dm ${PROG}) +.endif +.endif + +.include <links.mk> + +install: maninstall install_links _SUBDIRUSE + +install_links: +.if !empty(SYMLINKS) + @set ${SYMLINKS}; ${_SYMLINKS_SCRIPT} +.endif +.if !empty(LINKS) + @set ${LINKS}; ${_LINKS_SCRIPT} +.endif + +maninstall: afterinstall +afterinstall: realinstall +install_links: realinstall +proginstall: beforeinstall +realinstall: beforeinstall +.endif + +.if !target(lint) +lint: ${LOBJS} +.if defined(LOBJS) && !empty(LOBJS) + @${LINT} ${LINTFLAGS} ${LDFLAGS:M-L*} ${LOBJS} ${LDADD} +.endif +.endif + +.NOPATH: ${PROG} +.if defined(OBJS) && !empty(OBJS) +.NOPATH: ${OBJS} +.endif + +.if defined(FILES) || defined(FILESGROUPS) +.include <files.mk> +.endif + +.if ${MK_MAN} != "no" +.include <man.mk> +.endif + +.if ${MK_NLS} != "no" +.include <nls.mk> +.endif + +.include <obj.mk> +.include <dep.mk> +.include <subdir.mk> + +.if !empty(PROG) && ${MK_STAGING_PROG} == "yes" +STAGE_BINDIR ?= ${STAGE_OBJTOP}${BINDIR} +STAGE_DIR.prog ?= ${STAGE_BINDIR} +.if ${PROG_NAME:U${PROG}} != ${PROG} +STAGE_AS_SETS += prog +STAGE_AS_${PROG} = ${PROG_NAME} +stage_as.prog: ${PROG} +.else +STAGE_SETS += prog +stage_files.prog: ${PROG} +.endif +.endif + +.include <final.mk> + +.endif diff --git a/devel/bmake/files/mk/progs.mk b/devel/bmake/files/mk/progs.mk new file mode 100644 index 00000000000..15a100e689a --- /dev/null +++ b/devel/bmake/files/mk/progs.mk @@ -0,0 +1,102 @@ +# $Id: progs.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 2006, 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 +# + +.MAIN: all + +.if defined(PROGS) + +# In meta mode, we can capture dependenices for _one_ of the progs. +# if makefile doesn't nominate one, we use the first. +.ifndef UPDATE_DEPENDFILE_PROG +UPDATE_DEPENDFILE_PROG = ${PROGS:[1]} +.export UPDATE_DEPENDFILE_PROG +.endif + +.ifndef PROG +# They may have asked us to build just one +.for t in ${PROGS} +.if make($t) +PROG ?= $t +.endif +.endfor +.endif + +.if defined(PROG) +# just one of many +PROG_VARS += \ + BINDIR \ + CFLAGS \ + COPTS \ + CPPFLAGS \ + CXXFLAGS \ + DPADD \ + DPLIBS \ + LDADD \ + LDFLAGS \ + MAN \ + SRCS + +.for v in ${PROG_VARS:O:u} +.if defined(${v}.${PROG}) || defined(${v}_${PROG}) +$v += ${${v}_${PROG}:U${${v}.${PROG}}} +.endif +.endfor + +# for meta mode, there can be only one! +.if ${PROG} == ${UPDATE_DEPENDFILE_PROG:Uno} +UPDATE_DEPENDFILE ?= yes +.endif +UPDATE_DEPENDFILE ?= NO + +# ensure that we don't clobber each other's dependencies +DEPENDFILE?= .depend.${PROG} +# prog.mk will do the rest +.else +all: ${PROGS} + +# We cannot capture dependencies for meta mode here +UPDATE_DEPENDFILE = NO +# nor can we safely run in parallel. +.NOTPARALLEL: +.endif +.endif + +# handle being called [bsd.]progs.mk +.include <${.PARSEFILE:S,progs,prog,}> + +.ifndef PROG +# tell progs.mk we might want to install things +PROGS_TARGETS+= cleandepend cleandir cleanobj depend install + +.for p in ${PROGS} +.if defined(PROGS_CXX) && !empty(PROGS_CXX:M$p) +# bsd.prog.mk may need to know this +x.$p= PROG_CXX=$p +.endif + +$p ${p}_p: .PHONY .MAKE + (cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} PROG=$p ${x.$p}) + +.for t in ${PROGS_TARGETS:O:u} +$p.$t: .PHONY .MAKE + (cd ${.CURDIR} && ${.MAKE} -f ${MAKEFILE} PROG=$p ${x.$p} ${@:E}) +.endfor +.endfor + +.for t in ${PROGS_TARGETS:O:u} +$t: ${PROGS:%=%.$t} +.endfor + +.endif diff --git a/devel/bmake/files/mk/rst2htm.mk b/devel/bmake/files/mk/rst2htm.mk new file mode 100644 index 00000000000..402a7ebc1ec --- /dev/null +++ b/devel/bmake/files/mk/rst2htm.mk @@ -0,0 +1,53 @@ +# $Id: rst2htm.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 2009, 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 +# + +# convert reStructuredText to HTML, using rst2html.py from +# docutils - http://docutils.sourceforge.net/ + +.if empty(TXTSRCS) +TXTSRCS != 'ls' -1t ${.CURDIR}/*.txt ${.CURDIR}/*.rst 2>/dev/null; echo +.endif +RSTSRCS ?= ${TXTSRCS} +HTMFILES ?= ${RSTSRCS:R:T:O:u:%=%.htm} +RST2HTML ?= rst2html.py +RST2PDF ?= rst2pdf +RST2S5 ?= rst2s5.py +# the following will run RST2S5 if the target name contains the word 'slides' +# otherwise it uses RST2HTML +RST2HTM = ${"${.TARGET:T:M*slides*}":?${RST2S5}:${RST2HTML}} +RST2HTM_SLIDES_FLAGS ?= ${RST2S5_FLAGS} +RST2HTM_DOC_FLAGS ?= ${RST2HTML_FLAGS} +RST2HTM_FLAGS ?= ${"${.TARGET:T:M*slides*}":?${RST2HTM_SLIDES_FLAGS}:${RST2HTM_DOC_FLAGS}} + +RST2PDF_FLAGS ?= ${"${.TARGET:T:M*slides*}":?${RST2PDF_SLIDES_FLAGS}:${RST2PDF_DOC_FLAGS}} + +RST_SUFFIXES ?= .rst .txt + +CLEANFILES += ${HTMFILES} + +html: ${HTMFILES} + +.SUFFIXES: ${RST_SUFFIXES} .htm .pdf + +${RST_SUFFIXES:@s@$s.htm@}: + ${RST2HTM} ${RST2HTM_FLAGS} ${FLAGS.${.TARGET}} ${.IMPSRC} ${.TARGET} + +${RST_SUFFIXES:@s@$s.pdf@}: + ${RST2PDF} ${RST2PDF_FLAGS} ${FLAGS.${.TARGET}} ${.IMPSRC} ${.TARGET} + +.for s in ${RSTSRCS:O:u} +${s:R:T}.htm: $s +${s:R:T}.pdf: $s +.endfor diff --git a/devel/bmake/files/mk/scripts.mk b/devel/bmake/files/mk/scripts.mk new file mode 100644 index 00000000000..c702b73da13 --- /dev/null +++ b/devel/bmake/files/mk/scripts.mk @@ -0,0 +1,91 @@ +# $Id: scripts.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 2006, 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 +# + +.include <init.mk> + +SCRIPTSGROUPS ?= SCRIPTS +SCRIPTSGROUPS := ${SCRIPTSGROUPS:O:u} + +SCRIPTSDIR?= ${BINDIR} +SCRIPTSOWN?= ${BINOWN} +SCRIPTSGRP?= ${BINGRP} +SCRIPTSMODE?= ${BINMODE} + +SCRIPTS_INSTALL_OWN?= -o ${SCRIPTSOWN} -g ${SCRIPTSGRP} +SCRIPTS_COPY ?= -C + +# how we get script name from src +SCRIPTSNAME_MOD?=T:R + +.if !target(buildfiles) +.for group in ${SCRIPTSGROUPS} +buildfiles: ${${group}} +.endfor +.endif +buildfiles: +realbuild: buildfiles + +.for group in ${SCRIPTSGROUPS} +.if !empty(${group}) && defined(${group}DIR) +.if ${group} != "SCRIPTS" +${group}_INSTALL_OWN ?= ${SCRIPTS_INSTALL_OWN} +.endif +# incase we are staging +STAGE_DIR.${group} ?= ${STAGE_OBJTOP}${${group}DIR} + +.for script in ${${group}:O:u} +${group}_INSTALL_OWN.${script:T} ?= ${${group}_INSTALL_OWN} +${group}DIR.${script:T} ?= ${${group}DIR_${script:T}:U${${group}DIR}} +script_mkdir_list += ${${group}DIR.${script:T}} + +${group}NAME.${script} ?= ${${group}NAME_${script:T}:U${script:${SCRIPTSNAME_MOD}}} +.if ${${group}NAME.${script}:T} != ${script:T} +STAGE_AS_SETS += ${group} +STAGE_AS_${script} = ${${group}NAME.${script:T}} +stage_as.${group}: ${script} + +installscripts: installscripts.${group}.${script:T} +installscripts.${group}.${script:T}: ${script} script_mkdirs + ${INSTALL} ${SCRIPTS_COPY} ${${group}_INSTALL_OWN.${script:T}} \ + -m ${SCRIPTSMODE} ${.ALLSRC:Nscript_mkdirs} ${DESTDIR}${${group}DIR}/${${group}NAME.${script:T}} + +.else +STAGE_SETS += ${group} +stage_files.${group}: ${script} +installscripts.${group}: ${script} +installscripts: installscripts.${group} +.endif + +.endfor # script + +installscripts.${group}: script_mkdirs + ${INSTALL} ${SCRIPTS_COPY} ${${group}_INSTALL_OWN} -m ${SCRIPTSMODE} \ + ${.ALLSRC:Nscript_mkdirs:O:u} ${DESTDIR}${${group}DIR} + +.endif # !empty +.endfor # group + +script_mkdirs: + @for d in ${script_mkdir_list:O:u}; do \ + test -d ${DESTDIR}$$d || \ + ${INSTALL} -d ${SCRIPTS_INSTALL_OWN} -m 775 ${DESTDIR}$$d; \ + done + + +beforeinstall: +installscripts: +realinstall: installscripts +.ORDER: beforeinstall installscripts + diff --git a/devel/bmake/files/mk/srctop.mk b/devel/bmake/files/mk/srctop.mk new file mode 100644 index 00000000000..411dabcef0e --- /dev/null +++ b/devel/bmake/files/mk/srctop.mk @@ -0,0 +1,66 @@ +# $Id: srctop.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 2012, 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 !defined(SRCTOP) +# if using mk(1) SB will be set. +.ifdef SB +.if ${.CURDIR:S,${SB},,} != ${.CURDIR} +# we are actually within SB +.ifdef SB_SRC +SRCTOP:= ${SB_SRC} +.elif exists(${SB}/src) +SRCTOP:= ${SB}/src +.else +SRCTOP:= ${SB} +.endif +.endif +.endif + +.if !defined(SRCTOP) +.for rd in share/mk build/mk mk +.if ${_this_mk_dir:M*${rd}} != "" +.if ${.CURDIR:S,${_this_mk_dir:${rd:C,[^/]+,H,g:S,/, ,g:ts:}},,} != ${.CURDIR} +SRCTOP:= ${_this_mk_dir:${rd:C,[^/]+,H,g:S,/, ,g:ts:}} +.endif +.endif +.endfor +.endif + +.if !defined(SRCTOP) +_SRCTOP_TEST_?= [ -f ../.sandbox-env -o -d share/mk ] +# Linux at least has a bug where attempting to check an automounter +# directory will hang. So avoid looking above /a/b +SRCTOP!= cd ${.CURDIR}; while :; do \ + here=`pwd`; \ + ${_SRCTOP_TEST_} && { echo $$here; break; }; \ + case $$here in /*/*/*) cd ..;; *) echo ""; break;; esac; \ + done +.endif +.if defined(SRCTOP) && exists(${SRCTOP}/.) +.export SRCTOP +.endif +.endif + +.if !defined(OBJTOP) && !empty(SRCTOP) +.if defined(MAKEOBJDIRPREFIX) && exists(${MAKEOBJDIRPREFIX}${SRCTOP}) +OBJTOP= ${MAKEOBJDIRPREFIX}${SRCTOP} +.elif (exists(${SRCTOP}/Makefile) || exists(${SRCTOP}/makefile)) +OBJTOP!= cd ${SRCTOP} && ${PRINTOBJDIR} +.endif +.if empty(OBJTOP) +OBJTOP= ${SRCTOP} +.endif +.export OBJTOP +.endif diff --git a/devel/bmake/files/mk/stage-install.sh b/devel/bmake/files/mk/stage-install.sh new file mode 100755 index 00000000000..f830738d018 --- /dev/null +++ b/devel/bmake/files/mk/stage-install.sh @@ -0,0 +1,98 @@ +#!/bin/sh + +# NAME: +# stage-install.sh - wrapper around install +# +# SYNOPSIS: +# stage-install.sh [variable="value"] "args" "dest" +# +# DESCRIPTION: +# This script is a wrapper around the normal install(1). +# Its role is to add '.dirdep' files to the destination. +# The variables we might use are: +# +# INSTALL +# Path to actual install(1), default is +# $REAL_INSTALL +# +# OBJDIR +# Path to the dir where '.dirdep' was generated, +# default is '.' +# +# _DIRDEP +# Path to actual '.dirdep' file, default is +# $OBJDIR/.dirdep +# +# The "args" and "dest" are passed as is to install(1), and if a +# '.dirdep' file exists it will be linked or copied to each +# "file".dirdep placed in "dest" or "dest".dirdep if it happed +# to be a file rather than a directory. +# +# SEE ALSO: +# meta.stage.mk +# + +# RCSid: +# $Id: stage-install.sh,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 2013, 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 +# + +INSTALL=${REAL_INSTALL:-install} +OBJDIR=. + +while : +do + case "$1" in + *=*) eval "$1"; shift;; + *) break;; + esac +done + +# if .dirdep doesn't exist, just run install and be done +_DIRDEP=${_DIRDEP:-$OBJDIR/.dirdep} +[ -s $_DIRDEP ] && EXEC= || EXEC=exec +$EXEC $INSTALL "$@" || exit 1 + +# from meta.stage.mk +LnCp() { + rm -f $2 2> /dev/null + ln $1 $2 2> /dev/null || cp -p $1 $2 +} + +StageDirdep() { + t=$1 + if [ -s $t.dirdep ]; then + cmp -s $_DIRDEP $t.dirdep && return + echo "ERROR: $t installed by `cat $t.dirdep` not `cat $_DIRDEP`" >&2 + exit 1 + fi + LnCp $_DIRDEP $t.dirdep || exit 1 +} + +args="$@" +while [ $# -gt 8 ] +do + shift 8 +done +eval dest=\$$# +if [ -f $dest ]; then + # a file, there can be only one .dirdep needed + StageDirdep $dest +elif [ -d $dest ]; then + for f in $args + do + test -f $f || continue + StageDirdep $dest/${f##*/} + done +fi diff --git a/devel/bmake/files/mk/subdir.mk b/devel/bmake/files/mk/subdir.mk new file mode 100644 index 00000000000..d2684f907dd --- /dev/null +++ b/devel/bmake/files/mk/subdir.mk @@ -0,0 +1,102 @@ +# $Id: subdir.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# skip missing directories... + +# $NetBSD: subdir.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# @(#)bsd.subdir.mk 5.9 (Berkeley) 2/1/91 + +.if ${.MAKE.LEVEL} == 0 && ${.MAKE.MODE:Uno:Mmeta*} != "" +.include <meta.subdir.mk> +# keep everyone happy +_SUBDIRUSE: +.elif !commands(_SUBDIRUSE) && !defined(NO_SUBDIR) && !defined(NOSUBDIR) +.-include <${.CURDIR}/Makefile.inc> +.if !target(.MAIN) +.MAIN: all +.endif + +ECHO_DIR ?= echo +.ifdef SUBDIR_MUST_EXIST +MISSING_DIR=echo "Missing ===> ${.CURDIR}/$${entry}"; exit 1 +.else +MISSING_DIR=echo "Skipping ===> ${.CURDIR}/$${entry}"; continue +.endif + +_SUBDIRUSE: .USE +.if defined(SUBDIR) + @Exists() { test -f $$1; }; \ + for entry in ${SUBDIR}; do \ + (set -e; \ + if Exists ${.CURDIR}/$${entry}.${MACHINE}/[mM]akefile; then \ + _newdir_="$${entry}.${MACHINE}"; \ + elif Exists ${.CURDIR}/$${entry}/[mM]akefile; then \ + _newdir_="$${entry}"; \ + else \ + ${MISSING_DIR}; \ + fi; \ + if test X"${_THISDIR_}" = X""; then \ + _nextdir_="$${_newdir_}"; \ + else \ + _nextdir_="$${_THISDIR_}/$${_newdir_}"; \ + fi; \ + ${ECHO_DIR} "===> $${_nextdir_}"; \ + cd ${.CURDIR}/$${_newdir_}; \ + ${.MAKE} _THISDIR_="$${_nextdir_}" \ + ${.TARGET:S/realinstall/install/:S/.depend/depend/}) || exit 1; \ + done + +${SUBDIR}:: + @set -e; _r=${.CURDIR}/; \ + if test -z "${.TARGET:M/*}"; then \ + if test -d ${.CURDIR}/${.TARGET}.${MACHINE}; then \ + _newdir_=${.TARGET}.${MACHINE}; \ + else \ + _newdir_=${.TARGET}; \ + fi; \ + else \ + _r= _newdir_=${.TARGET}; \ + fi; \ + ${ECHO_DIR} "===> $${_newdir_}"; \ + cd $${_r}$${_newdir_}; \ + ${.MAKE} _THISDIR_="$${_newdir_}" all +.endif + +.if !target(install) +.if !target(beforeinstall) +beforeinstall: +.endif +.if !target(afterinstall) +afterinstall: +.endif +install: maninstall +maninstall: afterinstall +afterinstall: realinstall +realinstall: beforeinstall _SUBDIRUSE +.endif + +.if defined(SRCS) +etags: ${SRCS} + -cd ${.CURDIR}; etags `echo ${.ALLSRC:N*.h} | sed 's;${.CURDIR}/;;'` +.endif + +SUBDIR_TARGETS += \ + all \ + clean \ + cleandir \ + includes \ + depend \ + lint \ + obj \ + tags \ + etags + +.for t in ${SUBDIR_TARGETS:O:u} +$t: _SUBDIRUSE +.endfor + +.include <own.mk> +.if make(destroy*) +.include <obj.mk> +.endif +.endif +# make sure this exists +all: diff --git a/devel/bmake/files/mk/sys.clean-env.mk b/devel/bmake/files/mk/sys.clean-env.mk new file mode 100644 index 00000000000..c22767fea14 --- /dev/null +++ b/devel/bmake/files/mk/sys.clean-env.mk @@ -0,0 +1,130 @@ +# $Id: sys.clean-env.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 2009, 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 +# + +# This makefile would normally be included by sys.env.mk + +# The variables used by this makefile include: +# +# MAKE_ENV_SAVE_VAR_LIST +# The actuall list of variables from the environment that will be +# preserved. +# MAKE_ENV_SAVE_PREFIX_LIST +# A list of prefixes to match against the environment - the results +# are added to MAKE_ENV_SAVE_VAR_LIST after being filtered by... +# MAKE_ENV_SAVE_EXCLUDE_LIST +# A list of words or patterns which is turned into a list of :N +# modifiers. + +.if ${.MAKE.LEVEL} == 0 && ${MAKE_VERSION} >= 20100606 +# We save any env var that starts with the words in MAKE_ENV_SAVE_PREFIX_LIST. +# This gets expanded to an egrep expression like '^(A|B|C...)' +# and added to MAKE_ENV_SAVE_VAR_LIST below. +# If any of these end up being too greedy, MAKE_ENV_SAVE_EXCLUDE_LIST +# can be used to filter. +MAKE_ENV_SAVE_PREFIX_LIST += \ + CCACHE \ + CVS \ + DEBUG \ + DISTCC \ + HOST \ + MACHINE \ + MAKE \ + MK \ + NEED_ \ + SB_ \ + SSH \ + SVN \ + USE_ \ + WITH_ \ + WITHOUT_ \ + + +# This could be a list of vars or patterns to explicitly exclude. +MAKE_ENV_SAVE_EXCLUDE_LIST ?= _ + +# This is the actual list that we will save +# HOME is probably something worth clobbering eg. +# HOME=/var/empty +MAKE_ENV_SAVE_VAR_LIST += \ + HOME \ + LOGNAME \ + OBJROOT \ + OBJTOP \ + PATH \ + SB \ + SRCTOP \ + USER \ + ${_env_vars:${MAKE_ENV_SAVE_EXCLUDE_LIST:${M_ListToSkip}}} + +_env_vars != env | egrep '^(${MAKE_ENV_SAVE_PREFIX_LIST:ts|})' | sed 's,=.*,,'; echo + +_export_list = +.for v in ${MAKE_ENV_SAVE_VAR_LIST:O:u} +.if defined($v) +_export_list += $v +# Save current value +$v := ${$v} +.endif +.endfor + +# Now, clobber the environment +.unexport-env + +# This is a list of vars that we handle specially below +_tricky_env_vars = MAKEOBJDIR OBJTOP +# Export our selection - sans tricky ones +.export ${_export_list:${_tricky_env_vars:${M_ListToSkip}}} + +# This next bit may need tweaking +# if you don't happen to like the way I set it. +.if defined(MAKEOBJDIR) +# We are going to set this to the equivalent of the shell's +# MAKEOBJDIR='${.CURDIR:S,${SRCTOP},${OBJTOP},}' +_srctop := ${SRCTOP:U${SB_SRC:U${SB}/src}} +_objroot := ${OBJROOT:U${SB_OBJROOT:U${SB}/${SB_OBJPREFIX}}} +.if ${MAKE_VERSION} < 20160218 +_objtop := ${OBJTOP:U${_objroot}${MACHINE}} +# Take care of ${MACHINE} +.if ${MACHINE:Nhost*} == "" || ${OBJTOP} == ${HOST_OBJTOP:Uno} +OBJTOP = ${_objtop:S,${HOST_TARGET}$,\${MACHINE},} +.else +OBJTOP = ${_objtop:S,${MACHINE}$,\${MACHINE},} +.endif +# Export like this +MAKEOBJDIR = $${.CURDIR:S,${_srctop},$${OBJTOP},} +#.info ${MAKE_SAVE_ENV_VARS _srctop _objroot _objtop OBJTOP MAKEOBJDIR:L:@v@${.newline}$v=${$v}@} + +# Export these as-is, and do not track... +# otherwise the environment will be ruined when we evaluate them below. +.export-env ${_tricky_env_vars} + +# Now evaluate for ourselves +.for v in ${_tricky_env_vars} +$v := ${$v} +.endfor +.else +# we cannot use the '$$' trick, anymore +# but we can export a literal (unexpanded) value +SRCTOP := ${_srctop} +OBJROOT := ${_objroot} +OBJTOP = ${OBJROOT}${MACHINE} +MAKEOBJDIR = ${.CURDIR:S,${SRCTOP},${OBJTOP},} +.export-literal SRCTOP OBJROOT ${_tricky_env_vars} +.endif +#.info ${_tricky_env_vars:@v@${.newline}$v=${$v}@} +#showenv: +# @env | egrep 'OBJ|SRC' +.endif # MAKEOBJDIR +.endif # level 0 diff --git a/devel/bmake/files/mk/sys.debug.mk b/devel/bmake/files/mk/sys.debug.mk new file mode 100644 index 00000000000..5e183093bfe --- /dev/null +++ b/devel/bmake/files/mk/sys.debug.mk @@ -0,0 +1,33 @@ +# $Id: sys.debug.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 2009, 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 +# + +# Sometimes we want to turn on debugging in just one or two places +# if .CURDIR is matched by any entry in DEBUG_MAKE_SYS_DIRS we +# will apply DEBUG_MAKE_FLAGS now. +# if an entry in DEBUG_MAKE_DIRS matches, we at the end of sys.mk +# eg. DEBUG_MAKE_FLAGS=-dv DEBUG_MAKE_SYS_DIRS="*lib/sjg" +# use DEBUG_MAKE_FLAGS0 to apply only to .MAKE.LEVEL 0 +# +.if ${.MAKE.LEVEL:U1} == 0 +# we use indirection, to simplify the tests below, and incase +# DEBUG_* were given on our command line. +_DEBUG_MAKE_FLAGS = ${DEBUG_MAKE_FLAGS0} +_DEBUG_MAKE_SYS_DIRS = ${DEBUG_MAKE_SYS_DIRS0:U${DEBUG_MAKE_SYS_DIRS}} +_DEBUG_MAKE_DIRS = ${DEBUG_MAKE_DIRS0:U${DEBUG_MAKE_DIRS}} +.else +_DEBUG_MAKE_FLAGS = ${DEBUG_MAKE_FLAGS} +_DEBUG_MAKE_SYS_DIRS = ${DEBUG_MAKE_SYS_DIRS} +_DEBUG_MAKE_DIRS = ${DEBUG_MAKE_DIRS} +.endif diff --git a/devel/bmake/files/mk/sys.dependfile.mk b/devel/bmake/files/mk/sys.dependfile.mk new file mode 100644 index 00000000000..984c921289f --- /dev/null +++ b/devel/bmake/files/mk/sys.dependfile.mk @@ -0,0 +1,59 @@ +# $Id: sys.dependfile.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 2012, 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 +# + +# This only makes sense in meta mode. +# This allows a mixture of auto generated as well as manually edited +# dependency files, which can be differentiated by their names. +# As per dirdeps.mk we only require: +# 1. a common prefix +# 2. that machine specific files end in .${MACHINE} +# +# The .MAKE.DEPENDFILE_PREFERENCE below is an example. + +# All depend file names should start with this +.MAKE.DEPENDFILE_PREFIX ?= Makefile.depend + +.if !empty(.MAKE.DEPENDFILE) && \ + ${.MAKE.DEPENDFILE:M${.MAKE.DEPENDFILE_PREFIX}*} == "" +# let us do our thing below... +.undef .MAKE.DEPENDFILE +.endif + +# The order of preference: we will use the first one of these we find. +# It usually makes sense to order from most specific to least. +.MAKE.DEPENDFILE_PREFERENCE ?= \ + ${.CURDIR}/${.MAKE.DEPENDFILE_PREFIX}.${MACHINE} \ + ${.CURDIR}/${.MAKE.DEPENDFILE_PREFIX} + +# Normally the 1st entry is our default choice +# Another useful default is ${.MAKE.DEPENDFILE_PREFIX} +.MAKE.DEPENDFILE_DEFAULT ?= ${.MAKE.DEPENDFILE_PREFERENCE:[1]} + +_e := ${.MAKE.DEPENDFILE_PREFERENCE:@m@${exists($m):?$m:}@} +.if !empty(_e) +.MAKE.DEPENDFILE := ${_e:[1]} +.elif ${.MAKE.DEPENDFILE_PREFERENCE:M*${MACHINE}} != "" && ${.MAKE.DEPENDFILE_DEFAULT:E} != ${MACHINE} +# MACHINE specific depend files are supported, but *not* default. +# If any already exist, we should follow suit. +_aml = ${ALL_MACHINE_LIST:Uarm amd64 i386 powerpc:N${MACHINE}} ${MACHINE} +# make sure we restore MACHINE +_m := ${MACHINE} +_e := ${_aml:@MACHINE@${.MAKE.DEPENDFILE_PREFERENCE:@m@${exists($m):?$m:}@}@} +MACHINE := ${_m} +.if !empty(_e) +.MAKE.DEPENDFILE ?= ${.MAKE.DEPENDFILE_PREFERENCE:M*${MACHINE}:[1]} +.endif +.endif +.MAKE.DEPENDFILE ?= ${.MAKE.DEPENDFILE_DEFAULT} diff --git a/devel/bmake/files/mk/sys.mk b/devel/bmake/files/mk/sys.mk new file mode 100644 index 00000000000..77dae89a228 --- /dev/null +++ b/devel/bmake/files/mk/sys.mk @@ -0,0 +1,155 @@ +# $Id: sys.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 2003-2009, 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 +# + +# Avoid putting anything platform specific in here. + +# _DEBUG_MAKE_FLAGS etc. +.include <sys.debug.mk> + +.if !empty(_DEBUG_MAKE_FLAGS) +.if ${_DEBUG_MAKE_SYS_DIRS:Uno:@x@${.CURDIR:M$x}@} != "" +.MAKEFLAGS: ${_DEBUG_MAKE_FLAGS} +.endif +.endif + +# useful modifiers +.include <sys.vars.mk> + +# we expect a recent bmake +.if !defined(_TARGETS) +# some things we do only once +_TARGETS := ${.TARGETS} +.-include <sys.env.mk> +.endif + +# we need HOST_TARGET etc below. +.include <host-target.mk> + +# early customizations +.-include <local.sys.env.mk> + +# Popular suffixes for C++ +CXX_SUFFIXES += .cc .cpp .cxx .C +CXX_SUFFIXES := ${CXX_SUFFIXES:O:u} + +# find the OS specifics +.if defined(SYS_OS_MK) +.include <${SYS_OS_MK}> +.else +_sys_mk = +.for x in ${HOST_OSTYPE} ${HOST_TARGET} ${HOST_OS} ${MACHINE} Generic +.if empty(_sys_mk) +.-include <sys/$x.mk> +_sys_mk := ${.MAKE.MAKEFILES:M*/$x.mk} +.if !empty(_sys_mk) +_sys_mk := sys/${_sys_mk:T} +.endif +.endif +.if empty(_sys_mk) +# might be an old style +.-include <$x.sys.mk> +_sys_mk := ${.MAKE.MAKEFILES:M*/$x.sys.mk:T} +.endif +.endfor + +SYS_OS_MK := ${_sys_mk} +.export SYS_OS_MK +.endif + +# some options we need to know early +OPTIONS_DEFAULT_NO += \ + DIRDEPS_BUILD \ + DIRDEPS_CACHE + +OPTIONS_DEFAULT_DEPENDENT += \ + AUTO_OBJ/DIRDEPS_BUILD \ + META_MODE/DIRDEPS_BUILD \ + STAGING/DIRDEPS_BUILD \ + +.-include <options.mk> + +.if ${MK_DIRDEPS_BUILD:Uno} == "yes" +MK_META_MODE = yes +.-include <meta.sys.mk> +.elif ${MK_META_MODE:Uno} == "yes" +.MAKE.MODE = meta verbose ${META_MODE} +.endif +# make sure we have a harmless value +.MAKE.MODE ?= normal + +# if you want objdirs make them automatic +# and do it early before we compute .PATH +.if ${MK_AUTO_OBJ:Uno} == "yes" || ${MKOBJDIRS:Uno} == "auto" +.include <auto.obj.mk> +.endif + +.if !empty(SRCTOP) +.if ${.CURDIR} == ${SRCTOP} +RELDIR = . +.elif ${.CURDIR:M${SRCTOP}/*} +RELDIR := ${.CURDIR:S,${SRCTOP}/,,} +.endif +.endif + +MACHINE_ARCH.host ?= ${_HOST_ARCH} +MACHINE_ARCH.${MACHINE} ?= ${MACHINE} +.if empty(MACHINE_ARCH) +MACHINE_ARCH = ${MACHINE_ARCH.${MACHINE}} +.endif + +.ifndef ROOT_GROUP +ROOT_GROUP != sed -n /:0:/s/:.*//p /etc/group +.export ROOT_GROUP +.endif + +unix ?= We run ${_HOST_OSNAME}. + +# We need a Bourne/POSIX shell +MAKE_SHELL ?= sh +SHELL ?= ${MAKE_SHELL} + +# A race condition in mkdir, means that it can bail if another +# process made a dir that mkdir expected to. +# We repeat the mkdir -p a number of times to try and work around this. +# We stop looping as soon as the dir exists. +# If we get to the end of the loop, a plain mkdir will issue an error. +Mkdirs= Mkdirs() { \ + for d in $$*; do \ + for i in 1 2 3 4 5 6; do \ + mkdir -p $$d; \ + test -d $$d && return 0; \ + done; \ + mkdir $$d || exit $$?; \ + done; } + +# this often helps with debugging +.SUFFIXES: .cpp-out + +.c.cpp-out: + @${COMPILE.c:N-c} -E ${.IMPSRC} | grep -v '^[ ]*$$' + +${CXX_SUFFIXES:%=%.cpp-out}: + @${COMPILE.cc:N-c} -E ${.IMPSRC} | grep -v '^[ ]*$$' + +# late customizations +.-include <local.sys.mk> + +# if .CURDIR is matched by any entry in DEBUG_MAKE_DIRS we +# will apply DEBUG_MAKE_FLAGS, now. +.if !empty(_DEBUG_MAKE_FLAGS) +.if ${_DEBUG_MAKE_DIRS:Uno:@x@${.CURDIR:M$x}@} != "" +.MAKEFLAGS: ${_DEBUG_MAKE_FLAGS} +.endif +.endif diff --git a/devel/bmake/files/mk/sys.vars.mk b/devel/bmake/files/mk/sys.vars.mk new file mode 100644 index 00000000000..797b1fc5e69 --- /dev/null +++ b/devel/bmake/files/mk/sys.vars.mk @@ -0,0 +1,85 @@ +# $Id: sys.vars.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 2003-2009, 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 +# + +# We use the following paradigm for preventing multiple inclusion. +# It relies on the fact that conditionals and dependencies are resolved +# at the time they are read. +# +# _this ?= ${.PARSEFILE} +# .if !target(__${_this}__) +# __${_this}__: +# +.if ${MAKE_VERSION:U0} > 20100408 +_this = ${.PARSEDIR:tA}/${.PARSEFILE} +.else +_this = ${.PARSEDIR}/${.PARSEFILE} +.endif + +# if this is an ancient version of bmake +MAKE_VERSION ?= 0 +.if ${MAKE_VERSION:M*make-*} +# turn it into what we want - just the date +MAKE_VERSION := ${MAKE_VERSION:[1]:C,.*-,,} +.endif + +# some useful modifiers + +# A useful trick for testing multiple :M's against something +# :L says to use the variable's name as its value - ie. literal +# got = ${clean* destroy:${M_ListToMatch:S,V,.TARGETS,}} +M_ListToMatch = L:@m@$${V:M$$m}@ +# match against our initial targets (see above) +M_L_TARGETS = ${M_ListToMatch:S,V,_TARGETS,} + +# turn a list into a set of :N modifiers +# NskipFoo = ${Foo:${M_ListToSkip}} +M_ListToSkip= O:u:S,^,N,:ts: + +# type should be a builtin in any sh since about 1980, +# but sadly there are exceptions! +.if ${.MAKE.OS:Unknown:NBSD/OS} == "" +_type_sh = which +.endif + +# AUTOCONF := ${autoconf:L:${M_whence}} +M_type = @x@(${_type_sh:Utype} $$x) 2> /dev/null; echo;@:sh:[0]:N* found*:[@]:C,[()],,g +M_whence = ${M_type}:M/*:[1] + +# convert a path to a valid shell variable +M_P2V = tu:C,[./-],_,g + +# convert path to absolute +.if ${MAKE_VERSION:U0} > 20100408 +M_tA = tA +.else +M_tA = C,.*,('cd' & \&\& 'pwd') 2> /dev/null || echo &,:sh +.endif + +.if ${MAKE_VERSION:U0} >= 20170130 +# M_cmpv allows comparing dotted versions like 3.1.2 +# ${3.1.2:L:${M_cmpv}} -> 3001002 +# we use big jumps to handle 3 digits per dot: +# ${123.456.789:L:${M_cmpv}} -> 123456789 +M_cmpv.units = 1 1000 1000000 +M_cmpv = S,., ,g:_:range:@i@+ $${_:[-$$i]} \* $${M_cmpv.units:[$$i]}@:S,^,expr 0 ,1:sh +.endif + +# absoulte path to what we are reading. +_PARSEDIR = ${.PARSEDIR:${M_tA}} + +# many projects use MAJOR MINOR PATCH versioning +# ${OPENSSL:${M_M.M.P_VERSION}} is equivalent to +# ${OPENSSL_MAJOR_VERSION}.${OPENSSL_MINOR_VERSION}.${OPENSSL_PATCH_VERSION} +M_M.M.P_VERSION = L:@v@$${MAJOR MINOR PATCH:L:@t@$${$$v_$$t_VERSION:U0}@}@:ts. diff --git a/devel/bmake/files/mk/sys/AIX.mk b/devel/bmake/files/mk/sys/AIX.mk new file mode 100644 index 00000000000..9fd4bf022a8 --- /dev/null +++ b/devel/bmake/files/mk/sys/AIX.mk @@ -0,0 +1,184 @@ +# $NetBSD: AIX.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# @(#)sys.mk 5.11 (Berkeley) 3/13/91 + +OS= AIX +unix= We run ${OS}. +ROOT_GROUP= system + +# This needs a lot of work yet... + +NOPIC=no # no shared libs? + +.SUFFIXES: .out .a .ln .o .c ${CXX_SUFFIXES} .F .f .r .y .l .s .S .cl .p .h .sh .m4 + +.LIBS: .a + +AR= ar +ARFLAGS= rl +RANLIB= ranlib + +AS= as +AFLAGS= +COMPILE.s= ${AS} ${AFLAGS} +LINK.s= ${CC} ${AFLAGS} ${LDFLAGS} +COMPILE.S= ${CC} ${AFLAGS} ${CPPFLAGS} -c +LINK.S= ${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS} +.if exists(/usr/local/bin/gcc) +CC= gcc +DBG= -O -g +STATIC?= -static +.else +CC= cc +DBG= -g +STATIC= +.endif +CFLAGS= ${DBG} +COMPILE.c= ${CC} ${CFLAGS} ${CPPFLAGS} -c +LINK.c= ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} + +CXX= g++ +CXXFLAGS= ${CFLAGS} +COMPILE.cc= ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c +LINK.cc= ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS} + +CPP= cpp +.if defined(DESTDIR) +CPPFLAGS+= -nostdinc -idirafter ${DESTDIR}/usr/include +.endif + +MK_DEP= mkdeps.sh -N +FC= f77 +FFLAGS= -O +RFLAGS= +COMPILE.f= ${FC} ${FFLAGS} -c +LINK.f= ${FC} ${FFLAGS} ${LDFLAGS} +COMPILE.F= ${FC} ${FFLAGS} ${CPPFLAGS} -c +LINK.F= ${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS} +COMPILE.r= ${FC} ${FFLAGS} ${RFLAGS} -c +LINK.r= ${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS} + +LEX= lex +LFLAGS= +LEX.l= ${LEX} ${LFLAGS} + +LD= ld +LDFLAGS= + +LINT= lint +LINTFLAGS= -chapbx + +PC= pc +PFLAGS= +COMPILE.p= ${PC} ${PFLAGS} ${CPPFLAGS} -c +LINK.p= ${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS} + +YACC= yacc +YFLAGS= -d +YACC.y= ${YACC} ${YFLAGS} + +# C +.c: + ${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.c.o: + ${COMPILE.c} ${.IMPSRC} +.c.a: + ${COMPILE.c} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# C++ +${CXX_SUFFIXES}: + ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +${CXX_SUFFIXES:%=%.o}: + ${COMPILE.cc} ${.IMPSRC} +${CXX_SUFFIXES:%=%.a}: + ${COMPILE.cc} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Fortran/Ratfor +.f: + ${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.f.o: + ${COMPILE.f} ${.IMPSRC} +.f.a: + ${COMPILE.f} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +.F: + ${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.F.o: + ${COMPILE.F} ${.IMPSRC} +.F.a: + ${COMPILE.F} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +.r: + ${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.r.o: + ${COMPILE.r} ${.IMPSRC} +.r.a: + ${COMPILE.r} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Pascal +.p: + ${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.p.o: + ${COMPILE.p} ${.IMPSRC} +.p.a: + ${COMPILE.p} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Assembly +.s: + ${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.s.o: + ${COMPILE.s} -o ${.TARGET} ${.IMPSRC} +.s.a: + ${COMPILE.s} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o +.S: + ${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.S.o: + ${COMPILE.S} ${.IMPSRC} +.S.a: + ${COMPILE.S} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Lex +.l: + ${LEX.l} ${.IMPSRC} + ${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll + rm -f lex.yy.c +.l.c: + ${LEX.l} ${.IMPSRC} + mv lex.yy.c ${.TARGET} +.l.o: + ${LEX.l} ${.IMPSRC} + ${COMPILE.c} -o ${.TARGET} lex.yy.c + rm -f lex.yy.c + +# Yacc +.y: + ${YACC.y} ${.IMPSRC} + ${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS} + rm -f y.tab.c +.y.c: + ${YACC.y} ${.IMPSRC} + mv y.tab.c ${.TARGET} +.y.o: + ${YACC.y} ${.IMPSRC} + ${COMPILE.c} -o ${.TARGET} y.tab.c + rm -f y.tab.c + +# Shell +.sh: + rm -f ${.TARGET} + cp ${.IMPSRC} ${.TARGET} diff --git a/devel/bmake/files/mk/sys/Darwin.mk b/devel/bmake/files/mk/sys/Darwin.mk new file mode 100644 index 00000000000..1568190e684 --- /dev/null +++ b/devel/bmake/files/mk/sys/Darwin.mk @@ -0,0 +1,222 @@ +# $NetBSD: Darwin.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# @(#)sys.mk 8.2 (Berkeley) 3/21/94 + +OS= Darwin +unix?= We run ${OS}. + +.SUFFIXES: .out .a .ln .o .s .S .c .m ${CXX_SUFFIXES} .F .f .r .y .l .cl .p .h +.SUFFIXES: .sh .m4 .dylib + +.LIBS: .a .dylib + +SHLIBEXT = .dylib +HOST_LIBEXT = .dylib +DSHLIBEXT = .dylib + +AR?= ar +ARFLAGS?= rl +RANLIB = + +AS?= as +AFLAGS?= +COMPILE.s?= ${AS} ${AFLAGS} +LINK.s?= ${CC} ${AFLAGS} ${LDFLAGS} +COMPILE.S?= ${CC} ${AFLAGS} ${CPPFLAGS} -c +LINK.S?= ${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS} + +PIPE?= -pipe + +.if exists(/usr/bin/clang) +CC?= cc ${PIPE} +CXX?= c++ +.elif exists(/usr/bin/gcc) +CC?= gcc ${PIPE} +.else +CC?= cc ${PIPE} +.endif +DBG?= -O2 +CFLAGS?= ${DBG} +COMPILE.c?= ${CC} ${CFLAGS} ${CPPFLAGS} -c +LINK.c?= ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} + +.if exists(/usr/bin/g++) +CXX?= g++ +.else +CXX?= c++ +.endif +CXXFLAGS?= ${CFLAGS} +COMPILE.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c +LINK.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS} + +OBJC?= ${CC} +OBJCFLAGS?= ${CFLAGS} +COMPILE.m?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} -c +LINK.m?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} ${LDFLAGS} + +CPP?= cpp +NOLINT= 1 +CPPFLAGS?= + +MK_DEP?= mkdep + +FC?= f77 +FFLAGS?= -O +RFLAGS?= +COMPILE.f?= ${FC} ${FFLAGS} -c +LINK.f?= ${FC} ${FFLAGS} ${LDFLAGS} +COMPILE.F?= ${FC} ${FFLAGS} ${CPPFLAGS} -c +LINK.F?= ${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS} +COMPILE.r?= ${FC} ${FFLAGS} ${RFLAGS} -c +LINK.r?= ${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS} + +INSTALL?= install + +LEX?= lex +LFLAGS?= +LEX.l?= ${LEX} ${LFLAGS} + +LD?= ld +LDFLAGS?= + +SHLIB_TEENY = 0 +SHLIB_MINOR = 0 + +MKPICLIB = no +LIBEXT = .dylib + +LINT?= lint +LINTFLAGS?= -chapbx + +LORDER?= lorder + +NM?= nm + +PC?= pc +PFLAGS?= +COMPILE.p?= ${PC} ${PFLAGS} ${CPPFLAGS} -c +LINK.p?= ${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS} + +SIZE?= size + +TSORT?= tsort -q + +YACC?= bison -y +YFLAGS?= -d +YACC.y?= ${YACC} ${YFLAGS} + +# C +.c: + ${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.c.o: + ${COMPILE.c} ${.IMPSRC} +.c.a: + ${COMPILE.c} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# C++ +${CXX_SUFFIXES}: + ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +${CXX_SUFFIXES:%=%.o}: + ${COMPILE.cc} ${.IMPSRC} +${CXX_SUFFIXES:%=%.a}: + ${COMPILE.cc} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Objective-C +.m: + ${LINK.m} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.m.o: + ${COMPILE.m} ${.IMPSRC} +.m.a: + ${COMPILE.m} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Fortran/Ratfor +.f: + ${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.f.o: + ${COMPILE.f} ${.IMPSRC} +.f.a: + ${COMPILE.f} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +.F: + ${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.F.o: + ${COMPILE.F} ${.IMPSRC} +.F.a: + ${COMPILE.F} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +.r: + ${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.r.o: + ${COMPILE.r} ${.IMPSRC} +.r.a: + ${COMPILE.r} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Pascal +.p: + ${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.p.o: + ${COMPILE.p} ${.IMPSRC} +.p.a: + ${COMPILE.p} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Assembly +.s: + ${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.s.o: + ${COMPILE.s} -o ${.TARGET} ${.IMPSRC} +.s.a: + ${COMPILE.s} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o +.S: + ${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.S.o: + ${COMPILE.S} ${.IMPSRC} +.S.a: + ${COMPILE.S} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Lex +.l: + ${LEX.l} ${.IMPSRC} + ${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll + rm -f lex.yy.c +.l.c: + ${LEX.l} ${.IMPSRC} + mv lex.yy.c ${.TARGET} +.l.o: + ${LEX.l} ${.IMPSRC} + ${COMPILE.c} -o ${.TARGET} lex.yy.c + rm -f lex.yy.c + +# Yacc +.y: + ${YACC.y} ${.IMPSRC} + ${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS} + rm -f y.tab.c +.y.c: + ${YACC.y} ${.IMPSRC} + mv y.tab.c ${.TARGET} +.y.o: + ${YACC.y} ${.IMPSRC} + ${COMPILE.c} -o ${.TARGET} y.tab.c + rm -f y.tab.c + +# Shell +.sh: + rm -f ${.TARGET} + cp ${.IMPSRC} ${.TARGET} diff --git a/devel/bmake/files/mk/sys/Generic.mk b/devel/bmake/files/mk/sys/Generic.mk new file mode 100644 index 00000000000..a9c565170a9 --- /dev/null +++ b/devel/bmake/files/mk/sys/Generic.mk @@ -0,0 +1,204 @@ +# $Id: Generic.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# + +# some reasonable defaults +.SUFFIXES: .out .a .ln .o .s .S .c ${CXX_SUFFIXES} .F .f .r .y .l .cl .p .h +.SUFFIXES: .sh .m4 + +.LIBS: .a + +tools = \ + ar \ + lorder \ + ranlib \ + tsort + +.for t in ${tools} +${t:tu} := ${t:${M_whence}} +.endfor + +# need to make sure this is set +MACHINE_ARCH.${MACHINE} ?= ${MACHINE} +.if empty(MACHINE_ARCH) +MACHINE_ARCH = ${MACHINE_ARCH.${MACHINE}} +.endif + +.if !empty(TSORT) +TSORT += -q +.endif + +ARFLAGS?= rl + +AS?= as +AFLAGS?= +.if ${MACHINE_ARCH} == "sparc64" +AFLAGS+= -Wa,-Av9a +.endif +COMPILE.s?= ${CC} ${AFLAGS} -c +LINK.s?= ${CC} ${AFLAGS} ${LDFLAGS} +COMPILE.S?= ${CC} ${AFLAGS} ${CPPFLAGS} -c -traditional-cpp +LINK.S?= ${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS} + +CC?= cc +DBG?= -O2 +CFLAGS?= ${DBG} +COMPILE.c?= ${CC} ${CFLAGS} ${CPPFLAGS} -c +LINK.c?= ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} + +CXX?= c++ +CXXFLAGS?= ${CFLAGS} +COMPILE.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c +LINK.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS} + +OBJC?= ${CC} +OBJCFLAGS?= ${CFLAGS} +COMPILE.m?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} -c +LINK.m?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} ${LDFLAGS} + +CPP?= cpp +CPPFLAGS?= + +FC?= f77 +FFLAGS?= -O +RFLAGS?= +COMPILE.f?= ${FC} ${FFLAGS} -c +LINK.f?= ${FC} ${FFLAGS} ${LDFLAGS} +COMPILE.F?= ${FC} ${FFLAGS} ${CPPFLAGS} -c +LINK.F?= ${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS} +COMPILE.r?= ${FC} ${FFLAGS} ${RFLAGS} -c +LINK.r?= ${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS} + +INSTALL?= install + +LEX?= lex +LFLAGS?= +LEX.l?= ${LEX} ${LFLAGS} + +LD?= ld +LDFLAGS?= + +LINT?= lint +LINTFLAGS?= -chapbxzF + +NM?= nm + +PC?= pc +PFLAGS?= +COMPILE.p?= ${PC} ${PFLAGS} ${CPPFLAGS} -c +LINK.p?= ${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS} + +SIZE?= size + +YACC?= yacc +YFLAGS?= +YACC.y?= ${YACC} ${YFLAGS} + +# C +.c: + ${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.c.o: + ${COMPILE.c} ${.IMPSRC} +.c.a: + ${COMPILE.c} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o +.c.ln: + ${LINT} ${LINTFLAGS} ${CPPFLAGS:M-[IDU]*} -i ${.IMPSRC} + +# C++ +${CXX_SUFFIXES}: + ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +${CXX_SUFFIXES:%=%.o}: + ${COMPILE.cc} ${.IMPSRC} +${CXX_SUFFIXES:%=%.a}: + ${COMPILE.cc} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Fortran/Ratfor +.f: + ${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.f.o: + ${COMPILE.f} ${.IMPSRC} +.f.a: + ${COMPILE.f} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +.F: + ${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.F.o: + ${COMPILE.F} ${.IMPSRC} +.F.a: + ${COMPILE.F} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +.r: + ${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.r.o: + ${COMPILE.r} ${.IMPSRC} +.r.a: + ${COMPILE.r} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Pascal +.p: + ${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.p.o: + ${COMPILE.p} ${.IMPSRC} +.p.a: + ${COMPILE.p} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Assembly +.s: + ${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.s.o: + ${COMPILE.s} ${.IMPSRC} +.s.a: + ${COMPILE.s} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o +.S: + ${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.S.o: + ${COMPILE.S} ${.IMPSRC} +.S.a: + ${COMPILE.S} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Lex +.l: + ${LEX.l} ${.IMPSRC} + ${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll + rm -f lex.yy.c +.l.c: + ${LEX.l} ${.IMPSRC} + mv lex.yy.c ${.TARGET} +.l.o: + ${LEX.l} ${.IMPSRC} + ${COMPILE.c} -o ${.TARGET} lex.yy.c + rm -f lex.yy.c + +# Yacc +.y: + ${YACC.y} ${.IMPSRC} + ${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS} + rm -f y.tab.c +.y.c: + ${YACC.y} ${.IMPSRC} + mv y.tab.c ${.TARGET} +.y.o: + ${YACC.y} ${.IMPSRC} + ${COMPILE.c} -o ${.TARGET} y.tab.c + rm -f y.tab.c + +# Shell +.sh: + rm -f ${.TARGET} + cp ${.IMPSRC} ${.TARGET} + diff --git a/devel/bmake/files/mk/sys/HP-UX.mk b/devel/bmake/files/mk/sys/HP-UX.mk new file mode 100644 index 00000000000..40a94a26637 --- /dev/null +++ b/devel/bmake/files/mk/sys/HP-UX.mk @@ -0,0 +1,226 @@ +# $Id: HP-UX.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# $NetBSD: HP-UX.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# @(#)sys.mk 5.11 (Berkeley) 3/13/91 + +OS= HP-UX +ROOT_GROUP= root +unix?= We run ${OS}. + +# HP-UX's cc does not provide any clues as to wether this is 9.x or 10.x +# nor does sys/param.h, so we'll use the existence of /hp-ux +.if exists("/hp-ux") +OSMAJOR?=9 +.endif +OSMAJOR?=10 +__HPUX_VERSION?=${OSMAJOR} + +.SUFFIXES: .out .a .ln .o .c ${CXX_SUFFIXES} .F .f .r .y .l .s .S .cl .p .h .sh .m4 + +LIBMODE= 755 +LIBCRT0= /lib/crt0.o + +.LIBS: .a + +# +b<path> is needed to stop the binaries from insisting on having +# the build tree available :-) +# +s tells the dynamic loader to use SHLIB_PATH if set +LD_bpath?=-Wl,+b/lib:/usr/lib:/usr/local/lib +LD_spath?=-Wl,+s +LDADD+= ${LD_bpath} ${LD_spath} + +.if exists(/usr/lib/end.o) +LDADD+= /usr/lib/end.o +.endif + +AR= ar +ARFLAGS= rl +RANLIB= : + +AFLAGS= +COMPILE.s= ${AS} ${AFLAGS} +LINK.s= ${CC} ${AFLAGS} ${LDFLAGS} +COMPILE.S= ${CC} ${AFLAGS} ${CPPFLAGS} -c +LINK.S= ${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS} +.if exists(/usr/local/bin/gcc) +PIPE?= -pipe +CC?= gcc ${PIPE} +AS= gas +DBG?= -O -g +STATIC?= -static +.if defined(DESTDIR) +CPPFLAGS+= -nostdinc -idirafter ${DESTDIR}/usr/include +.endif +.else +# HP's bundled compiler knows not -g or -O +AS= as +CC= cc +.if exists(/opt/ansic/bin/cc) +CCMODE?=-Ae +ESlit +PICFLAG?= +z +LD_x= +DBG?=-g -O +.endif +DBG?= +STATIC?= -Wl,-a,archive +.endif +.if (${__HPUX_VERSION} == "10") +CCSOURCE_FLAGS?= -D_HPUX_SOURCE +.else +CCSOURCE_FLAGS?= -D_HPUX_SOURCE -D_INCLUDE_POSIX_SOURCE -D_INCLUDE_XOPEN_SOURCE -D_INCLUDE_XOPEN_SOURCE_EXTENDED +.endif +CFLAGS= ${DBG} +CFLAGS+= ${CCMODE} -D__hpux__ -D__HPUX_VERSION=${__HPUX_VERSION} ${CCSOURCE_FLAGS} +COMPILE.c= ${CC} ${CFLAGS} ${CPPFLAGS} -c +LINK.c= ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} + +CXX= g++ +CXXFLAGS= ${CFLAGS} +COMPILE.cc= ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c +LINK.cc= ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS} + +CPP= cpp + +MK_DEP= mkdeps.sh -N +FC= f77 +FFLAGS= -O +RFLAGS= +COMPILE.f= ${FC} ${FFLAGS} -c +LINK.f= ${FC} ${FFLAGS} ${LDFLAGS} +COMPILE.F= ${FC} ${FFLAGS} ${CPPFLAGS} -c +LINK.F= ${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS} +COMPILE.r= ${FC} ${FFLAGS} ${RFLAGS} -c +LINK.r= ${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS} + +LEX= lex +LFLAGS= +LEX.l= ${LEX} ${LFLAGS} + +LD= ld +LDFLAGS= + +LINT= lint +LINTFLAGS= -chapbx + +PC= pc +PFLAGS= +COMPILE.p= ${PC} ${PFLAGS} ${CPPFLAGS} -c +LINK.p= ${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS} + +# HP's sh sucks +ENV= +MAKE_SHELL= /bin/ksh + +.if exists(/usr/local/bin/bison) +YACC= bison -y +.else +YACC= yacc +.endif +YFLAGS= -d +YACC.y= ${YACC} ${YFLAGS} + +# C +.c: + ${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.c.o: + ${COMPILE.c} ${.IMPSRC} +.c.a: + ${COMPILE.c} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# C++ +${CXX_SUFFIXES}: + ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +${CXX_SUFFIXES:%=%.o}: + ${COMPILE.cc} ${.IMPSRC} +${CXX_SUFFIXES:%=%.a}: + ${COMPILE.cc} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Fortran/Ratfor +.f: + ${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.f.o: + ${COMPILE.f} ${.IMPSRC} +.f.a: + ${COMPILE.f} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +.F: + ${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.F.o: + ${COMPILE.F} ${.IMPSRC} +.F.a: + ${COMPILE.F} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +.r: + ${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.r.o: + ${COMPILE.r} ${.IMPSRC} +.r.a: + ${COMPILE.r} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Pascal +.p: + ${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.p.o: + ${COMPILE.p} ${.IMPSRC} +.p.a: + ${COMPILE.p} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Assembly +.s: + ${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.s.o: + ${COMPILE.s} -o ${.TARGET} ${.IMPSRC} +.s.a: + ${COMPILE.s} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o +.S: + ${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.S.o: + ${COMPILE.S} ${.IMPSRC} +.S.a: + ${COMPILE.S} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Lex +.l: + ${LEX.l} ${.IMPSRC} + ${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll + rm -f lex.yy.c +.l.c: + ${LEX.l} ${.IMPSRC} + mv lex.yy.c ${.TARGET} +.l.o: + ${LEX.l} ${.IMPSRC} + ${COMPILE.c} -o ${.TARGET} lex.yy.c + rm -f lex.yy.c + +# Yacc +.y: + ${YACC.y} ${.IMPSRC} + ${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS} + rm -f y.tab.c +.y.c: + ${YACC.y} ${.IMPSRC} + mv y.tab.c ${.TARGET} +.y.o: + ${YACC.y} ${.IMPSRC} + ${COMPILE.c} -o ${.TARGET} y.tab.c + rm -f y.tab.c + +# Shell +.sh: + rm -f ${.TARGET} + cp ${.IMPSRC} ${.TARGET} diff --git a/devel/bmake/files/mk/sys/IRIX.mk b/devel/bmake/files/mk/sys/IRIX.mk new file mode 100644 index 00000000000..2d22756d87a --- /dev/null +++ b/devel/bmake/files/mk/sys/IRIX.mk @@ -0,0 +1,195 @@ +# $NetBSD: IRIX.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# @(#)sys.mk 8.2 (Berkeley) 3/21/94 + +.if ${.PARSEFILE} == "sys.mk" +.ifndef ROOT_GROUP +OS!= uname -s +ROOT_GROUP!= sed -n /:0:/s/:.*//p /etc/group +.MAKEOVERRIDES+= OS ROOT_GROUP +.endif +unix?= We run ${OS}. +.endif + +.SUFFIXES: .out .a .ln .o .s .S .c ${CXX_SUFFIXES} .F .f .r .y .l .cl .p .h +.SUFFIXES: .sh .m4 + +.LIBS: .a + +AR?= ar +ARFLAGS?= rl +RANLIB?= ranlib + +AS?= as +AFLAGS?= +COMPILE.s?= ${CC} ${AFLAGS} -c +LINK.s?= ${CC} ${AFLAGS} ${LDFLAGS} +COMPILE.S?= ${CC} ${AFLAGS} ${CPPFLAGS} -c -traditional-cpp +LINK.S?= ${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS} + +CC?= cc +NOGCCERROR?= # defined +DBG?= -O2 +CFLAGS?= ${DBG} +COMPILE.c?= ${CC} ${CFLAGS} ${CPPFLAGS} -c +LINK.c?= ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} + +CXX?= CC +CXXFLAGS?= ${CFLAGS} +COMPILE.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c +LINK.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS} + +OBJC?= ${CC} +OBJCFLAGS?= ${CFLAGS} +COMPILE.m?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} -c +LINK.m?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} ${LDFLAGS} + +CPP?= CC +CPPFLAGS?= + +FC?= f77 +FFLAGS?= -O +RFLAGS?= +COMPILE.f?= ${FC} ${FFLAGS} -c +LINK.f?= ${FC} ${FFLAGS} ${LDFLAGS} +COMPILE.F?= ${FC} ${FFLAGS} ${CPPFLAGS} -c +LINK.F?= ${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS} +COMPILE.r?= ${FC} ${FFLAGS} ${RFLAGS} -c +LINK.r?= ${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS} + +INSTALL?= ${PREFIX}/bin/install-sh + +LEX?= lex +LFLAGS?= +LEX.l?= ${LEX} ${LFLAGS} + +LD?= ld +LDFLAGS?= + +LINT?= lint +LINTFLAGS?= -chapbxzF + +LORDER?= lorder + +NM?= nm + +PC?= pc +PFLAGS?= +COMPILE.p?= ${PC} ${PFLAGS} ${CPPFLAGS} -c +LINK.p?= ${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS} + +SIZE?= size + +TSORT?= tsort -q + +YACC?= yacc +YFLAGS?= +YACC.y?= ${YACC} ${YFLAGS} + +# C +.c: + ${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.c.o: + ${COMPILE.c} ${.IMPSRC} +.c.a: + ${COMPILE.c} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o +.c.ln: + ${LINT} ${LINTFLAGS} ${CPPFLAGS:M-[IDU]*} -i ${.IMPSRC} + +# C++ +${CXX_SUFFIXES}: + ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +${CXX_SUFFIXES:%=%.o}: + ${COMPILE.cc} ${.IMPSRC} +${CXX_SUFFIXES:%=%.a}: + ${COMPILE.cc} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Fortran/Ratfor +.f: + ${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.f.o: + ${COMPILE.f} ${.IMPSRC} +.f.a: + ${COMPILE.f} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +.F: + ${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.F.o: + ${COMPILE.F} ${.IMPSRC} +.F.a: + ${COMPILE.F} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +.r: + ${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.r.o: + ${COMPILE.r} ${.IMPSRC} +.r.a: + ${COMPILE.r} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Pascal +.p: + ${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.p.o: + ${COMPILE.p} ${.IMPSRC} +.p.a: + ${COMPILE.p} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Assembly +.s: + ${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.s.o: + ${COMPILE.s} ${.IMPSRC} +.s.a: + ${COMPILE.s} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o +.S: + ${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.S.o: + ${COMPILE.S} ${.IMPSRC} +.S.a: + ${COMPILE.S} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Lex +.l: + ${LEX.l} ${.IMPSRC} + ${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll + rm -f lex.yy.c +.l.c: + ${LEX.l} ${.IMPSRC} + mv lex.yy.c ${.TARGET} +.l.o: + ${LEX.l} ${.IMPSRC} + ${COMPILE.c} -o ${.TARGET} lex.yy.c + rm -f lex.yy.c + +# Yacc +.y: + ${YACC.y} ${.IMPSRC} + ${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS} + rm -f y.tab.c +.y.c: + ${YACC.y} ${.IMPSRC} + mv y.tab.c ${.TARGET} +.y.o: + ${YACC.y} ${.IMPSRC} + ${COMPILE.c} -o ${.TARGET} y.tab.c + rm -f y.tab.c + +# Shell +.sh: + rm -f ${.TARGET} + cp ${.IMPSRC} ${.TARGET} diff --git a/devel/bmake/files/mk/sys/Linux.mk b/devel/bmake/files/mk/sys/Linux.mk new file mode 100644 index 00000000000..624db0b1228 --- /dev/null +++ b/devel/bmake/files/mk/sys/Linux.mk @@ -0,0 +1,187 @@ +# $Id: Linux.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# $NetBSD: Linux.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# @(#)sys.mk 5.11 (Berkeley) 3/13/91 + +OS?= Linux +unix?= We run ${OS}. + +ROOT_GROUP= root + +# would be better to work out where it is... +LIBCRT0= /dev/null + +NEED_SOLINKS=yes + +.SUFFIXES: .out .a .ln .o .c ${CXX_SUFFIXES} .F .f .r .y .l .s .S .cl .p .h .sh .m4 + +.LIBS: .a + +AR= ar +ARFLAGS= rl +RANLIB= ranlib + +AS= as +AFLAGS= +COMPILE.s= ${AS} ${AFLAGS} +LINK.s= ${CC} ${AFLAGS} ${LDFLAGS} +COMPILE.S= ${CC} ${AFLAGS} ${CPPFLAGS} -c +LINK.S= ${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS} +.if exists(/usr/local/bin/gcc) +CC= gcc -pipe +DBG= -O -g +STATIC?= -static +.else +CC= cc -pipe +DBG= -g +STATIC= -Bstatic +.endif +CFLAGS= ${DBG} +COMPILE.c= ${CC} ${CFLAGS} ${CPPFLAGS} -c +LINK.c= ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} + +CXX= g++ +CXXFLAGS= ${CFLAGS} +COMPILE.cc= ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c +LINK.cc= ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS} + +CPP= cpp +.if defined(DESTDIR) +CPPFLAGS+= -nostdinc -idirafter ${DESTDIR}/usr/include +.endif + +MK_DEP= mkdeps.sh -N +FC= f77 +FFLAGS= -O +RFLAGS= +COMPILE.f= ${FC} ${FFLAGS} -c +LINK.f= ${FC} ${FFLAGS} ${LDFLAGS} +COMPILE.F= ${FC} ${FFLAGS} ${CPPFLAGS} -c +LINK.F= ${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS} +COMPILE.r= ${FC} ${FFLAGS} ${RFLAGS} -c +LINK.r= ${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS} + +LEX= lex +LFLAGS= +LEX.l= ${LEX} ${LFLAGS} + +LD= ld +LDFLAGS= + +LINT= lint +LINTFLAGS= -chapbx + +PC= pc +PFLAGS= +COMPILE.p= ${PC} ${PFLAGS} ${CPPFLAGS} -c +LINK.p= ${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS} + +YACC= yacc +YFLAGS= -d +YACC.y= ${YACC} ${YFLAGS} + +# C +.c: + ${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.c.o: + ${COMPILE.c} ${.IMPSRC} +.c.a: + ${COMPILE.c} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# C++ +${CXX_SUFFIXES}: + ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +${CXX_SUFFIXES:%=%.o}: + ${COMPILE.cc} ${.IMPSRC} +${CXX_SUFFIXES:%=%.a}: + ${COMPILE.cc} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Fortran/Ratfor +.f: + ${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.f.o: + ${COMPILE.f} ${.IMPSRC} +.f.a: + ${COMPILE.f} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +.F: + ${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.F.o: + ${COMPILE.F} ${.IMPSRC} +.F.a: + ${COMPILE.F} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +.r: + ${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.r.o: + ${COMPILE.r} ${.IMPSRC} +.r.a: + ${COMPILE.r} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Pascal +.p: + ${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.p.o: + ${COMPILE.p} ${.IMPSRC} +.p.a: + ${COMPILE.p} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Assembly +.s: + ${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.s.o: + ${COMPILE.s} -o ${.TARGET} ${.IMPSRC} +.s.a: + ${COMPILE.s} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o +.S: + ${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.S.o: + ${COMPILE.S} ${.IMPSRC} +.S.a: + ${COMPILE.S} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Lex +.l: + ${LEX.l} ${.IMPSRC} + ${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll + rm -f lex.yy.c +.l.c: + ${LEX.l} ${.IMPSRC} + mv lex.yy.c ${.TARGET} +.l.o: + ${LEX.l} ${.IMPSRC} + ${COMPILE.c} -o ${.TARGET} lex.yy.c + rm -f lex.yy.c + +# Yacc +.y: + ${YACC.y} ${.IMPSRC} + ${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS} + rm -f y.tab.c +.y.c: + ${YACC.y} ${.IMPSRC} + mv y.tab.c ${.TARGET} +.y.o: + ${YACC.y} ${.IMPSRC} + ${COMPILE.c} -o ${.TARGET} y.tab.c + rm -f y.tab.c + +# Shell +.sh: + rm -f ${.TARGET} + cp ${.IMPSRC} ${.TARGET} diff --git a/devel/bmake/files/mk/sys/NetBSD.mk b/devel/bmake/files/mk/sys/NetBSD.mk new file mode 100644 index 00000000000..ccdcff370b5 --- /dev/null +++ b/devel/bmake/files/mk/sys/NetBSD.mk @@ -0,0 +1,230 @@ +# $NetBSD: NetBSD.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# @(#)sys.mk 8.2 (Berkeley) 3/21/94 + +OS= NetBSD +unix?= We run ${OS}. + +.if !defined(MAKE_VERSION) +# we are running native make +# which defined MAKE_VERSION between 20010609 and 20090324 +# so we can make a rough guess +.if defined(.MAKE.LEVEL) +MAKE_VERSION = 20090908 +.elif defined(.MAKE.MAKEFILES) +# introduced 20071008 +MAKE_VERSION = 20090324 +.else +# this just before when MAKE_VERSION was introduced +MAKE_VERSION = 20010606 +.endif +.endif + +.SUFFIXES: .out .a .ln .o .s .S .c ${CXX_SUFFIXES} .F .f .r .y .l .cl .p .h +.SUFFIXES: .sh .m4 + +.LIBS: .a + +AR?= ar +ARFLAGS?= rl +RANLIB?= ranlib + +AS?= as +AFLAGS?= +COMPILE.s?= ${CC} ${AFLAGS} -c +LINK.s?= ${CC} ${AFLAGS} ${LDFLAGS} +COMPILE.S?= ${CC} ${AFLAGS} ${CPPFLAGS} -c -traditional-cpp +LINK.S?= ${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS} + +CC?= cc + +# need to make sure this is set +MACHINE_ARCH.${MACHINE} ?= ${MACHINE} +.if empty(MACHINE_ARCH) +MACHINE_ARCH = ${MACHINE_ARCH.${MACHINE}} +.endif + +# +# CPU model, derived from MACHINE_ARCH +# +MACHINE_CPU= ${MACHINE_ARCH:C/mipse[bl]/mips/:C/mips64e[bl]/mips/:C/sh3e[bl]/sh3/:S/m68000/m68k/:S/armeb/arm/} + +.if ${MACHINE_CPU} == "alpha" || \ + ${MACHINE_CPU} == "arm" || \ + ${MACHINE_CPU} == "i386" || \ + ${MACHINE_CPU} == "m68k" || \ + ${MACHINE_CPU} == "mips" || \ + ${MACHINE_CPU} == "powerpc" || \ + ${MACHINE_CPU} == "sparc" || \ + ${MACHINE_CPU} == "vax" +DBG?= -O2 +.elif ${MACHINE_ARCH} == "x86_64" +DBG?= +.elif ${MACHINE_ARCH} == "sparc64" +DBG?= -O -ffixed-g4 #Hack for embedany memory model compatibility +.else +DBG?= -O +.endif +CFLAGS?= ${DBG} +COMPILE.c?= ${CC} ${CFLAGS} ${CPPFLAGS} -c +LINK.c?= ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} + +CXX?= c++ +CXXFLAGS?= ${CFLAGS} +COMPILE.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c +LINK.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS} + +OBJC?= ${CC} +OBJCFLAGS?= ${CFLAGS} +COMPILE.m?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} -c +LINK.m?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} ${LDFLAGS} + +CPP?= cpp +CPPFLAGS?= + +FC?= f77 +FFLAGS?= -O +RFLAGS?= +COMPILE.f?= ${FC} ${FFLAGS} -c +LINK.f?= ${FC} ${FFLAGS} ${LDFLAGS} +COMPILE.F?= ${FC} ${FFLAGS} ${CPPFLAGS} -c +LINK.F?= ${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS} +COMPILE.r?= ${FC} ${FFLAGS} ${RFLAGS} -c +LINK.r?= ${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS} + +INSTALL?= install + +LEX?= lex +LFLAGS?= +LEX.l?= ${LEX} ${LFLAGS} + +LD?= ld +LDFLAGS?= + +LINT?= lint +LINTFLAGS?= -chapbxzF + +LORDER?= lorder + +NM?= nm + +PC?= pc +PFLAGS?= +COMPILE.p?= ${PC} ${PFLAGS} ${CPPFLAGS} -c +LINK.p?= ${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS} + +SIZE?= size + +TSORT?= tsort -q + +YACC?= yacc +YFLAGS?= +YACC.y?= ${YACC} ${YFLAGS} + +# C +.c: + ${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.c.o: + ${COMPILE.c} ${.IMPSRC} +.c.a: + ${COMPILE.c} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o +.c.ln: + ${LINT} ${LINTFLAGS} ${CPPFLAGS:M-[IDU]*} -i ${.IMPSRC} + +# C++ +${CXX_SUFFIXES}: + ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +${CXX_SUFFIXES:%=%.o}: + ${COMPILE.cc} ${.IMPSRC} +${CXX_SUFFIXES:%=%.a}: + ${COMPILE.cc} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Fortran/Ratfor +.f: + ${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.f.o: + ${COMPILE.f} ${.IMPSRC} +.f.a: + ${COMPILE.f} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +.F: + ${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.F.o: + ${COMPILE.F} ${.IMPSRC} +.F.a: + ${COMPILE.F} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +.r: + ${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.r.o: + ${COMPILE.r} ${.IMPSRC} +.r.a: + ${COMPILE.r} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Pascal +.p: + ${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.p.o: + ${COMPILE.p} ${.IMPSRC} +.p.a: + ${COMPILE.p} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Assembly +.s: + ${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.s.o: + ${COMPILE.s} ${.IMPSRC} +.s.a: + ${COMPILE.s} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o +.S: + ${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.S.o: + ${COMPILE.S} ${.IMPSRC} +.S.a: + ${COMPILE.S} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Lex +.l: + ${LEX.l} ${.IMPSRC} + ${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll + rm -f lex.yy.c +.l.c: + ${LEX.l} ${.IMPSRC} + mv lex.yy.c ${.TARGET} +.l.o: + ${LEX.l} ${.IMPSRC} + ${COMPILE.c} -o ${.TARGET} lex.yy.c + rm -f lex.yy.c + +# Yacc +.y: + ${YACC.y} ${.IMPSRC} + ${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS} + rm -f y.tab.c +.y.c: + ${YACC.y} ${.IMPSRC} + mv y.tab.c ${.TARGET} +.y.o: + ${YACC.y} ${.IMPSRC} + ${COMPILE.c} -o ${.TARGET} y.tab.c + rm -f y.tab.c + +# Shell +.sh: + rm -f ${.TARGET} + cp ${.IMPSRC} ${.TARGET} diff --git a/devel/bmake/files/mk/sys/OSF1.mk b/devel/bmake/files/mk/sys/OSF1.mk new file mode 100644 index 00000000000..b4a78eee2e6 --- /dev/null +++ b/devel/bmake/files/mk/sys/OSF1.mk @@ -0,0 +1,198 @@ +# $Id: OSF1.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# $NetBSD: OSF1.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# @(#)sys.mk 5.11 (Berkeley) 3/13/91 + +OS?= OSF1 +unix?= We run ${OS}. +ROOT_GROUP= system + +# can't fine one anywhere, so just stop the dependency +LIBCRT0= /dev/null + +PATH=/usr/sbin:/usr/bin:/usr/ucb:/opt/gnu/bin:/usr/ccs/bin + +.SUFFIXES: .out .a .ln .o .c ${CXX_SUFFIXES} .F .f .r .y .l .s .S .cl .p .h .sh .m4 + +.LIBS: .a + +# no -X +LD_X= +LD_x= -x +LD_r= -r +AR= ar +ARFLAGS= rl +RANLIB= ranlib + +AS= as +AS_STDIN= - +AFLAGS= +COMPILE.s= ${AS} ${AFLAGS} +LINK.s= ${CC} ${AFLAGS} ${LDFLAGS} +COMPILE.S= ${CC} ${AFLAGS} ${CPPFLAGS} -c +LINK.S= ${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS} +.if exists(/opt/gnu/bin/gcc) || exists(/usr/local/bin/gcc) +CC?= gcc +.else +CC?= cc -std +.endif +.if (${CC:T} == "gcc") +DBG= -O -g +STATIC= -static +DBG= -g +STATIC= -non_shared +.endif + +CFLAGS= ${DBG} +COMPILE.c= ${CC} ${CFLAGS} ${CPPFLAGS} -c +LINK.c= ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} + +CXX= g++ +CXXFLAGS= ${CFLAGS} +COMPILE.cc= ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c +LINK.cc= ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS} + +CPP= /usr/ccs/lib/cpp +.if defined(DESTDIR) +CPPFLAGS+= -nostdinc -idirafter ${DESTDIR}/usr/include +.endif + +MK_DEP= mkdeps.sh -N +FC= f77 +FFLAGS= -O +RFLAGS= +COMPILE.f= ${FC} ${FFLAGS} -c +LINK.f= ${FC} ${FFLAGS} ${LDFLAGS} +COMPILE.F= ${FC} ${FFLAGS} ${CPPFLAGS} -c +LINK.F= ${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS} +COMPILE.r= ${FC} ${FFLAGS} ${RFLAGS} -c +LINK.r= ${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS} + +LEX= lex +LFLAGS= +LEX.l= ${LEX} ${LFLAGS} + +LD= ld +LDFLAGS= + +LINT= lint +LINTFLAGS= -chapbx + +PC= pc +PFLAGS= +COMPILE.p= ${PC} ${PFLAGS} ${CPPFLAGS} -c +LINK.p= ${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS} + +.if exists(/usr/local/bin/bison) || exists(/opt/gnu/bin/bison) +YACC= bison -y +.else +YACC= yacc +.endif +YFLAGS= -d +YACC.y= ${YACC} ${YFLAGS} + +# C +.c: + ${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.c.o: + ${COMPILE.c} ${.IMPSRC} +.c.a: + ${COMPILE.c} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# C++ +${CXX_SUFFIXES}: + ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +${CXX_SUFFIXES:%=%.o}: + ${COMPILE.cc} ${.IMPSRC} +${CXX_SUFFIXES:%=%.a}: + ${COMPILE.cc} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Fortran/Ratfor +.f: + ${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.f.o: + ${COMPILE.f} ${.IMPSRC} +.f.a: + ${COMPILE.f} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +.F: + ${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.F.o: + ${COMPILE.F} ${.IMPSRC} +.F.a: + ${COMPILE.F} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +.r: + ${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.r.o: + ${COMPILE.r} ${.IMPSRC} +.r.a: + ${COMPILE.r} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Pascal +.p: + ${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.p.o: + ${COMPILE.p} ${.IMPSRC} +.p.a: + ${COMPILE.p} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Assembly +.s: + ${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.s.o: + ${COMPILE.s} ${.IMPSRC} +.s.a: + ${COMPILE.s} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o +.S: + ${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.S.o: + ${COMPILE.S} ${.IMPSRC} +.S.a: + ${COMPILE.S} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Lex +.l: + ${LEX.l} ${.IMPSRC} + ${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll + rm -f lex.yy.c +.l.c: + ${LEX.l} ${.IMPSRC} + mv lex.yy.c ${.TARGET} +.l.o: + ${LEX.l} ${.IMPSRC} + ${COMPILE.c} -o ${.TARGET} lex.yy.c + rm -f lex.yy.c + +# Yacc +.y: + ${YACC.y} ${.IMPSRC} + ${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS} + rm -f y.tab.c +.y.c: + ${YACC.y} ${.IMPSRC} + mv y.tab.c ${.TARGET} +.y.o: + ${YACC.y} ${.IMPSRC} + ${COMPILE.c} -o ${.TARGET} y.tab.c + rm -f y.tab.c + +# Shell +.sh: + rm -f ${.TARGET} + cp ${.IMPSRC} ${.TARGET} diff --git a/devel/bmake/files/mk/sys/OpenBSD.mk b/devel/bmake/files/mk/sys/OpenBSD.mk new file mode 100644 index 00000000000..0fba205f733 --- /dev/null +++ b/devel/bmake/files/mk/sys/OpenBSD.mk @@ -0,0 +1,205 @@ +# $NetBSD: OpenBSD.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# @(#)sys.mk 8.2 (Berkeley) 3/21/94 + +OS= OpenBSD +unix?= We run ${OS}. + +.SUFFIXES: .out .a .ln .o .s .S .c ${CXX_SUFFIXES} .F .f .r .y .l .cl .p .h +.SUFFIXES: .sh .m4 + +.LIBS: .a + +# need to make sure this is set +MACHINE_ARCH.${MACHINE} ?= ${MACHINE} +.if empty(MACHINE_ARCH) +MACHINE_ARCH = ${MACHINE_ARCH.${MACHINE}} +.endif + +AR?= ar +ARFLAGS?= rl +RANLIB?= ranlib + +AS?= as +AFLAGS?= +.if ${MACHINE_ARCH} == "sparc64" +AFLAGS+= -Wa,-Av9a +.endif +COMPILE.s?= ${CC} ${AFLAGS} -c +LINK.s?= ${CC} ${AFLAGS} ${LDFLAGS} +COMPILE.S?= ${CC} ${AFLAGS} ${CPPFLAGS} -c -traditional-cpp +LINK.S?= ${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS} + +CC?= cc +.if ${MACHINE_ARCH} == "alpha" || \ + ${MACHINE_ARCH} == "i386" || \ + ${MACHINE_ARCH} == "m68k" || \ + ${MACHINE_ARCH} == "sparc" || \ + ${MACHINE_ARCH} == "vax" +DBG?= -O2 +.else +DBG?= -O +.endif +CFLAGS?= ${DBG} +COMPILE.c?= ${CC} ${CFLAGS} ${CPPFLAGS} -c +LINK.c?= ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} + +CXX?= c++ +CXXFLAGS?= ${CFLAGS} +COMPILE.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c +LINK.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS} + +OBJC?= ${CC} +OBJCFLAGS?= ${CFLAGS} +COMPILE.m?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} -c +LINK.m?= ${OBJC} ${OBJCFLAGS} ${CPPFLAGS} ${LDFLAGS} + +CPP?= cpp +CPPFLAGS?= + +FC?= f77 +FFLAGS?= -O +RFLAGS?= +COMPILE.f?= ${FC} ${FFLAGS} -c +LINK.f?= ${FC} ${FFLAGS} ${LDFLAGS} +COMPILE.F?= ${FC} ${FFLAGS} ${CPPFLAGS} -c +LINK.F?= ${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS} +COMPILE.r?= ${FC} ${FFLAGS} ${RFLAGS} -c +LINK.r?= ${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS} + +INSTALL?= install + +LEX?= lex +LFLAGS?= +LEX.l?= ${LEX} ${LFLAGS} + +LD?= ld +LDFLAGS?= + +LINT?= lint +LINTFLAGS?= -chapbxzF + +LORDER?= lorder + +NM?= nm + +PC?= pc +PFLAGS?= +COMPILE.p?= ${PC} ${PFLAGS} ${CPPFLAGS} -c +LINK.p?= ${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS} + +SIZE?= size + +TSORT?= tsort -q + +YACC?= yacc +YFLAGS?= +YACC.y?= ${YACC} ${YFLAGS} + +# C +.c: + ${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.c.o: + ${COMPILE.c} ${.IMPSRC} +.c.a: + ${COMPILE.c} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o +.c.ln: + ${LINT} ${LINTFLAGS} ${CPPFLAGS:M-[IDU]*} -i ${.IMPSRC} + +# C++ +${CXX_SUFFIXES}: + ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +${CXX_SUFFIXES:%=%.o}: + ${COMPILE.cc} ${.IMPSRC} +${CXX_SUFFIXES:%=%.a}: + ${COMPILE.cc} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Fortran/Ratfor +.f: + ${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.f.o: + ${COMPILE.f} ${.IMPSRC} +.f.a: + ${COMPILE.f} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +.F: + ${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.F.o: + ${COMPILE.F} ${.IMPSRC} +.F.a: + ${COMPILE.F} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +.r: + ${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.r.o: + ${COMPILE.r} ${.IMPSRC} +.r.a: + ${COMPILE.r} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Pascal +.p: + ${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.p.o: + ${COMPILE.p} ${.IMPSRC} +.p.a: + ${COMPILE.p} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Assembly +.s: + ${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.s.o: + ${COMPILE.s} ${.IMPSRC} +.s.a: + ${COMPILE.s} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o +.S: + ${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.S.o: + ${COMPILE.S} ${.IMPSRC} +.S.a: + ${COMPILE.S} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Lex +.l: + ${LEX.l} ${.IMPSRC} + ${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll + rm -f lex.yy.c +.l.c: + ${LEX.l} ${.IMPSRC} + mv lex.yy.c ${.TARGET} +.l.o: + ${LEX.l} ${.IMPSRC} + ${COMPILE.c} -o ${.TARGET} lex.yy.c + rm -f lex.yy.c + +# Yacc +.y: + ${YACC.y} ${.IMPSRC} + ${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS} + rm -f y.tab.c +.y.c: + ${YACC.y} ${.IMPSRC} + mv y.tab.c ${.TARGET} +.y.o: + ${YACC.y} ${.IMPSRC} + ${COMPILE.c} -o ${.TARGET} y.tab.c + rm -f y.tab.c + +# Shell +.sh: + rm -f ${.TARGET} + cp ${.IMPSRC} ${.TARGET} diff --git a/devel/bmake/files/mk/sys/SunOS.mk b/devel/bmake/files/mk/sys/SunOS.mk new file mode 100644 index 00000000000..73eab18f8fd --- /dev/null +++ b/devel/bmake/files/mk/sys/SunOS.mk @@ -0,0 +1,219 @@ +# $Id: SunOS.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ + +.if ${.PARSEFILE} == "sys.mk" +.include <host-target.mk> + +OS?= SunOS.${HOST_OSMAJOR} +unix?= We run ${OS}. +.endif + +.if ${HOST_OSMAJOR} > 4 +ROOT_GROUP= root + +SHLIB_FULLVERSION = ${SHLIB_MAJOR} + +# suppress the dependency +LIBCRT0= /dev/null + +.ifndef CC +# the PATH below may find an ancient gcc +CC := ${gcc:L:${M_whence}} +.export CC +.endif + +# the stuff in /usr/xpg4/bin is usually more sane. +PATH=/usr/xpg4/bin:/usr/sbin:/usr/bin:/usr/ucb:/usr/sfw/bin:/opt/gnu/bin:/usr/ccs/bin:/usr/local/bin +.export PATH + +DSHLIBEXT = .so +HOST_LIBDIRS = /usr/lib /lib /usr/sfw/lib + +# no -X +LD_X= +LD_x= +RANLIB= : +CPP= /usr/ccs/lib/cpp +.else +ROOT_GROUP= wheel +RANLIB= ranlib +CPP= cpp +.endif + +# the rest is common + +.SUFFIXES: .out .a .ln .o .c ${CXX_SUFFIXES} .F .f .r .y .l .s .S .cl .p .h .sh .m4 + +.LIBS: .a + +AR= ar +ARFLAGS= rl + +AS= as +AS_STDIN= - +AFLAGS= +COMPILE.s= ${AS} ${AFLAGS} +LINK.s= ${CC} ${AFLAGS} ${LDFLAGS} +COMPILE.S= ${CC} ${AFLAGS} ${CPPFLAGS} -c +LINK.S= ${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS} +.if exists(/opt/gnu/bin/gcc) || exists(/usr/local/bin/gcc) +CC ?= gcc -pipe +DBG= -O -g +STATIC= -static +.else +CC ?= cc +DBG= -g +STATIC= -Bstatic +.endif +CFLAGS= ${DBG} +COMPILE.c= ${CC} ${CFLAGS} ${CPPFLAGS} -c +LINK.c= ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} + +CXX= g++ +CXXFLAGS= ${CFLAGS} +COMPILE.cc= ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c +LINK.cc= ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS} + +.if defined(DESTDIR) +CPPFLAGS+= -nostdinc -idirafter ${DESTDIR}/usr/include +.endif + +MK_DEP= mkdeps.sh -N +FC= f77 +FFLAGS= -O +RFLAGS= +COMPILE.f= ${FC} ${FFLAGS} -c +LINK.f= ${FC} ${FFLAGS} ${LDFLAGS} +COMPILE.F= ${FC} ${FFLAGS} ${CPPFLAGS} -c +LINK.F= ${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS} +COMPILE.r= ${FC} ${FFLAGS} ${RFLAGS} -c +LINK.r= ${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS} + +LEX= lex +LFLAGS= +LEX.l= ${LEX} ${LFLAGS} + +LD= ld +LDFLAGS= + +LINT= lint +LINTFLAGS= -chapbx + +PC= pc +PFLAGS= +COMPILE.p= ${PC} ${PFLAGS} ${CPPFLAGS} -c +LINK.p= ${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS} + +.if exists(/usr/local/bin/bison) || exists(/opt/gnu/bin/bison) +YACC= bison -y +.else +YACC= yacc +.endif +YFLAGS= -d +YACC.y= ${YACC} ${YFLAGS} + +# C +.c: + ${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.c.o: + ${COMPILE.c} ${.IMPSRC} +.c.a: + ${COMPILE.c} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# C++ +${CXX_SUFFIXES}: + ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +${CXX_SUFFIXES:%=%.o}: + ${COMPILE.cc} ${.IMPSRC} +${CXX_SUFFIXES:%=%.a}: + ${COMPILE.cc} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Fortran/Ratfor +.f: + ${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.f.o: + ${COMPILE.f} ${.IMPSRC} +.f.a: + ${COMPILE.f} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +.F: + ${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.F.o: + ${COMPILE.F} ${.IMPSRC} +.F.a: + ${COMPILE.F} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +.r: + ${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.r.o: + ${COMPILE.r} ${.IMPSRC} +.r.a: + ${COMPILE.r} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Pascal +.p: + ${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.p.o: + ${COMPILE.p} ${.IMPSRC} +.p.a: + ${COMPILE.p} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Assembly +.s: + ${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.s.o: + ${COMPILE.s} ${.IMPSRC} +.s.a: + ${COMPILE.s} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o +.S: + ${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.S.o: + ${COMPILE.S} ${.IMPSRC} +.S.a: + ${COMPILE.S} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Lex +.l: + ${LEX.l} ${.IMPSRC} + ${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll + rm -f lex.yy.c +.l.c: + ${LEX.l} ${.IMPSRC} + mv lex.yy.c ${.TARGET} +.l.o: + ${LEX.l} ${.IMPSRC} + ${COMPILE.c} -o ${.TARGET} lex.yy.c + rm -f lex.yy.c + +# Yacc +.y: + ${YACC.y} ${.IMPSRC} + ${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS} + rm -f y.tab.c +.y.c: + ${YACC.y} ${.IMPSRC} + mv y.tab.c ${.TARGET} +.y.o: + ${YACC.y} ${.IMPSRC} + ${COMPILE.c} -o ${.TARGET} y.tab.c + rm -f y.tab.c + +# Shell +.sh: + rm -f ${.TARGET} + cp ${.IMPSRC} ${.TARGET} diff --git a/devel/bmake/files/mk/sys/UnixWare.mk b/devel/bmake/files/mk/sys/UnixWare.mk new file mode 100644 index 00000000000..83e8264cd18 --- /dev/null +++ b/devel/bmake/files/mk/sys/UnixWare.mk @@ -0,0 +1,241 @@ +# $Id: UnixWare.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# based on "Id: SunOS.5.sys.mk,v 1.6 2003/09/30 16:42:23 sjg Exp " +# $NetBSD: UnixWare.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# @(#)sys.mk 5.11 (Berkeley) 3/13/91 + +OS?= UnixWare +unix?= We run ${OS}. +ROOT_GROUP= root + +# can't fine one anywhere, so just stop the dependency +LIBCRT0= /dev/null + +PATH=/usr/sbin:/usr/bin:/usr/ccs/bin:/usr/ccs/lib:/usr/ucb:/usr/local/bin + +.SUFFIXES: .out .a .ln .o .c ${CXX_SUFFIXES} .F .f .r .y .l .s .S .cl .p .h .sh .m4 + +.LIBS: .a + +# no -X +LD_X= +LD_x= +AR?= ar +ARFLAGS?= rl +RANLIB?= : + +AS?= as +AS_STDIN?= - +AFLAGS?= +COMPILE.s?= ${AS} ${AFLAGS} +LINK.s?= ${CC} ${AFLAGS} ${LDFLAGS} +COMPILE.S?= ${CC} ${AFLAGS} ${CPPFLAGS} -c +LINK.S?= ${CC} ${AFLAGS} ${CPPFLAGS} ${LDFLAGS} + +# at least gcc 2.95 on UnixWare has no internal macro to identify the system +.if exists(/usr/local/bin/gcc) +CC?= gcc -pipe -DUNIXWARE +DBG?= -O -g +STATIC?= -static +.else +CC?= cc +DBG?= -g +STATIC?= -Bstatic # XXX: don't know about UDK compilers +.endif +CFLAGS?= ${DBG} +COMPILE.c?= ${CC} ${CFLAGS} ${CPPFLAGS} -c +LINK.c?= ${CC} ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} + +.if exists(/usr/local/bin/g++) +CXX?= g++ -DUNIXWARE +.else +CXX?= c++ # XXX: don't know about UDK compilers +.endif +CXXFLAGS?= ${CFLAGS} +COMPILE.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} -c +LINK.cc?= ${CXX} ${CXXFLAGS} ${CPPFLAGS} ${LDFLAGS} + +CPP?= /usr/ccs/lib/cpp +.if defined(DESTDIR) +CPPFLAGS+= -nostdinc -idirafter ${DESTDIR}/usr/include +.endif + +MK_DEP?= mkdeps.sh -N +.if exists(/usr/local/bin/g77) +FC?= g77 +.else +FC?= f77 # XXX: don't know about UDK compilers +.endif +FFLAGS?= -O +RFLAGS?= +COMPILE.f?= ${FC} ${FFLAGS} -c +LINK.f?= ${FC} ${FFLAGS} ${LDFLAGS} +COMPILE.F?= ${FC} ${FFLAGS} ${CPPFLAGS} -c +LINK.F?= ${FC} ${FFLAGS} ${CPPFLAGS} ${LDFLAGS} +COMPILE.r?= ${FC} ${FFLAGS} ${RFLAGS} -c +LINK.r?= ${FC} ${FFLAGS} ${RFLAGS} ${LDFLAGS} + +INSTALL?= /usr/ucb/install # BSD install + +LEX?= lex +LFLAGS?= +LEX.l?= ${LEX} ${LFLAGS} + +LD?= ld +LDFLAGS?= + +LIBC?= ${DESTDIR}/usr/ccs/lib/libc.a +LIBCOMPAT?= +LIBCRYPT?= ${DESTDIR}/usr/lib/libcrypt.a +LIBCURSES?= ${DESTDIR}/usr/ccs/lib/libcurses.a +LIBDBM?= +LIBDES?= +LIBEDIT?= +LIBGCC?= +LIBKDB?= +LIBKRB?= +LIBKVM?= +LIBL?= ${DESTDIR}/usr/ccs/lib/libl.a +LIBM?= ${DESTDIR}/usr/ccs/lib/libm.a +LIBMP?= +LIBPC?= +LIBPCAP?= +LIBPLOT?= +LIBRESOLV?= +LIBRPCSVC?= ${DESTDIR}/usr/lib/librpcsvc.a +LIBSKEY?= ${DESTDIR}/usr/lib/libskey.a +LIBTERMCAP?= ${DESTDIR}/usr/ccs/lib/libtermcap.a +LIBUTIL?= +LIBWRAP?= +LIBY?= ${DESTDIR}/usr/ccs/lib/liby.a +LIBZ?= + +LINT?= lint +LINTFLAGS?= -pF + +LORDER?= lorder + +NM?= nm + +PC?= pc # XXX: UDK probably does not have pc +PFLAGS?= +COMPILE.p?= ${PC} ${PFLAGS} ${CPPFLAGS} -c +LINK.p?= ${PC} ${PFLAGS} ${CPPFLAGS} ${LDFLAGS} + +SIZE?= size + +TSORT?= tsort + +.if exists(/usr/local/bin/bison) +YACC?= bison -y +.else +YACC?= yacc +.endif +YFLAGS?= -d +YACC.y?= ${YACC} ${YFLAGS} + +# C +.c: + ${LINK.c} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.c.o: + ${COMPILE.c} ${.IMPSRC} +.c.a: + ${COMPILE.c} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# C++ +${CXX_SUFFIXES}: + ${LINK.cc} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +${CXX_SUFFIXES:%=%.o}: + ${COMPILE.cc} ${.IMPSRC} +${CXX_SUFFIXES:%=%.a}: + ${COMPILE.cc} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Fortran/Ratfor +.f: + ${LINK.f} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.f.o: + ${COMPILE.f} ${.IMPSRC} +.f.a: + ${COMPILE.f} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +.F: + ${LINK.F} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.F.o: + ${COMPILE.F} ${.IMPSRC} +.F.a: + ${COMPILE.F} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +.r: + ${LINK.r} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.r.o: + ${COMPILE.r} ${.IMPSRC} +.r.a: + ${COMPILE.r} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Pascal +.p: + ${LINK.p} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.p.o: + ${COMPILE.p} ${.IMPSRC} +.p.a: + ${COMPILE.p} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Assembly +.s: + ${LINK.s} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.s.o: + ${COMPILE.s} ${.IMPSRC} +.s.a: + ${COMPILE.s} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o +.S: + ${LINK.S} -o ${.TARGET} ${.IMPSRC} ${LDLIBS} +.S.o: + ${COMPILE.S} ${.IMPSRC} +.S.a: + ${COMPILE.S} ${.IMPSRC} + ${AR} ${ARFLAGS} $@ $*.o + rm -f $*.o + +# Lex +.l: + ${LEX.l} ${.IMPSRC} + ${LINK.c} -o ${.TARGET} lex.yy.c ${LDLIBS} -ll + rm -f lex.yy.c +.l.c: + ${LEX.l} ${.IMPSRC} + mv lex.yy.c ${.TARGET} +.l.o: + ${LEX.l} ${.IMPSRC} + ${COMPILE.c} -o ${.TARGET} lex.yy.c + rm -f lex.yy.c + +# Yacc +.y: + ${YACC.y} ${.IMPSRC} + ${LINK.c} -o ${.TARGET} y.tab.c ${LDLIBS} + rm -f y.tab.c +.y.c: + ${YACC.y} ${.IMPSRC} + mv y.tab.c ${.TARGET} +.y.o: + ${YACC.y} ${.IMPSRC} + ${COMPILE.c} -o ${.TARGET} y.tab.c + rm -f y.tab.c + +# Shell +.sh: + rm -f ${.TARGET} + cp ${.IMPSRC} ${.TARGET} diff --git a/devel/bmake/files/mk/target-flags.mk b/devel/bmake/files/mk/target-flags.mk new file mode 100644 index 00000000000..8d1d26a0cb3 --- /dev/null +++ b/devel/bmake/files/mk/target-flags.mk @@ -0,0 +1,62 @@ +# NAME: +# target-flags.mk - target specific flags +# +# DESCRIPTION: +# Include this macro file after all others in a makefile and +# follow it with any target specific flag settings. +# For each such variable v in TARGET_FLAG_VARS we set: +#.nf +# +# _$v := ${$v} +# $v = ${${v}_${.TARGET:T}:U${_$v}} +#.fi +# +# This allows one to do things like: +#.nf +# +# TARGET_FLAG_VARS= CFLAGS +# .include <target-flags.mk> +# CFLAGS_fu.o = ${_CFLAGS:N-Wall} +#.fi +# +# To turn off -Wall for just the target fu.o +# Actually CFLAGS is the default value for TARGET_FLAG_VARS. +# +# BUGS: +# One must be careful to avoid creating circular references in +# variables. The original version of this macro file did +# elaborate things with CFLAGS. The current, simpler +# implementation is ultimately more flexible. +# +# It is important that target-flags.mk is included after other +# macro files and that target specific flags that may reference +# _$v are set after that. +# +# Only works with a make(1) that does nested evaluation correctly. + + + +# RCSid: +# $Id: target-flags.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 1998-2002, 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 +# + +TARGET_FLAG_VARS?= CFLAGS +.for v in ${TARGET_FLAG_VARS} +.ifndef _$v +_$v := ${$v} +$v = ${${v}_${.TARGET:T}:U${_$v}} +.endif +.endfor + diff --git a/devel/bmake/files/mk/warnings.mk b/devel/bmake/files/mk/warnings.mk new file mode 100644 index 00000000000..680bfcb8797 --- /dev/null +++ b/devel/bmake/files/mk/warnings.mk @@ -0,0 +1,139 @@ +# RCSid: +# $Id: warnings.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# @(#) Copyright (c) 2002, 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 +# + +.ifndef _w_cflags +# make sure we get the behavior we expect +.MAKE.SAVE_DOLLARS = no + +# Any number of warnings sets can be added. +.-include <warnings-sets.mk> + +# Modest defaults - put more elaborate sets in warnings-sets.mk +# -Wunused etc are here so you can set +# W_unused=-Wno-unused etc. +MIN_WARNINGS?= -Wall \ + -Wformat \ + -Wimplicit \ + -Wunused \ + -Wuninitialized + +LOW_WARNINGS?= ${MIN_WARNINGS} -W -Wstrict-prototypes -Wmissing-prototypes + +MEDIUM_WARNINGS?= ${LOW_WARNINGS} -Werror + +HIGH_WARNINGS?= ${MEDIUM_WARNINGS} \ + -Wcast-align \ + -Wcast-qual \ + -Wparentheses \ + -Wpointer-arith \ + -Wmissing-declarations \ + -Wreturn-type \ + -Wswitch \ + -Wwrite-strings + +EXTRA_WARNINGS?= ${HIGH_WARNINGS} -Wextra + +# The two step default makes it easier to test build with different defaults. +DEFAULT_WARNINGS_SET?= MIN +WARNINGS_SET?= ${DEFAULT_WARNINGS_SET} + +# There is always someone who wants more... +.if !empty(WARNINGS_XTRAS) +${WARNINGS_SET}_WARNINGS += ${WARNINGS_XTRAS} +.endif + +# If you add sets, besure to list them (you don't have to touch this list). +ALL_WARNINGS_SETS+= MIN LOW MEDIUM HIGH EXTRA + +.if !empty(WARNINGS_SET) +.for ws in ${WARNINGS_SET} +.if empty(${ws}_WARNINGS) +.if ${MAKE_VERSION:[1]:C/.*-//} >= 20050530 +.BEGIN: _empty_warnings +_empty_warnings: .PHONY +.else +.BEGIN: +.endif + @echo "ERROR: Invalid: WARNINGS_SET=${ws}" + @echo "ERROR: Try one of: ${ALL_WARNINGS_SETS:O:u}"; exit 1 + +.endif +.endfor +.endif + +# Without -O or if we've set -O0 somewhere - to make debugging more effective, +# we need to turn off -Wuninitialized as otherwise we get a warning that +# -Werror turns into an error. To be safe, set W_uninitialized blank. +_w_cflags= ${CFLAGS} ${CFLAGS_LAST} ${CPPFLAGS} +.if ${_w_cflags:M-O*} == "" || ${_w_cflags:M-O0} != "" +W_uninitialized= +.endif + + +# .for loops have the [dis]advantage of being evaluated when read, +# so adding to WARNINGS_SET[_${MACHINE_ARCH}] after this file is +# read has no effect. +# Replacing the above .for loops with the WARNINGS+= below solves that +# but tiggers a double free bug in bmake-20040118 and earlier. +# Don't try and read this too fast! +# +# The first :@ "loop" handles multiple sets in WARNINGS_SET +# +# In the second :@ "loop", the ::?= noise sets W_foo?=-Wfoo etc +# which makes it easy to turn off override individual flags +# (see W_uninitialized above). +# +# The last bit expands to ${W_foo_${.TARGET:T}:U${W_foo}} +# which is the bit we ultimately want. It allows W_* to be set on a +# per target basis. +# +# NOTE: that we force the target extension to be .o +# + +# define this once, we use it a couple of times below (hence the doubled $$). +M_warnings_list = @s@$${$$s_WARNINGS}@:O:u:@w@$${$${w:C/-(.)/\1_/}::?=$$w} $${$${w:C/-(.)/\1_/}_${MACHINE_ARCH}_${.TARGET:T:R}.o:U$${$${w:C/-(.)/\1_/}_${.TARGET:T:R}.o:U$${$${w:C/-(.)/\1_/}_${MACHINE_ARCH}:U$${$${w:C/-(.)/\1_/}}}}}@ + +# first a list of warnings from the chosen set +_warnings = ${WARNINGS_SET_${MACHINE_ARCH}:U${WARNINGS_SET}:${M_warnings_list}} +# now a list of all -Wno-* overrides not just those defined by WARNINGS_SET +# since things like -Wall imply lots of others. +# this should be a super-set of the -Wno-* in _warnings, but +# just in case... +_no_warnings = ${_warnings:M-Wno-*} ${ALL_WARNINGS_SETS:${M_warnings_list}:M-Wno-*} +# -Wno-* must follow any others +WARNINGS += ${_warnings:N-Wno-*} ${_no_warnings:O:u} + +.ifndef NO_CFLAGS_WARNINGS +# Just ${WARNINGS} should do, but this is more flexible? +CFLAGS+= ${WARNINGS_${.TARGET:T:R}.o:U${WARNINGS}} +.endif + +# it is rather silly that g++ blows up on some warning flags +NO_CXX_WARNINGS+= \ + implicit \ + missing-declarations \ + missing-prototypes \ + nested-externs \ + shadow \ + strict-prototypes + +.for s in ${SRCS:M*.c*:N*.c:N*h} +.for w in ${NO_CXX_WARNINGS} +W_$w_${s:T:R}.o= +.endfor +.endfor + +.endif # _w_cflags diff --git a/devel/bmake/files/mk/whats.mk b/devel/bmake/files/mk/whats.mk new file mode 100644 index 00000000000..9d94ed67baa --- /dev/null +++ b/devel/bmake/files/mk/whats.mk @@ -0,0 +1,69 @@ +# $Id: whats.mk,v 1.1.1.1 2020/05/24 05:35:53 nia 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 diff --git a/devel/bmake/files/mk/yacc.mk b/devel/bmake/files/mk/yacc.mk new file mode 100644 index 00000000000..6872f4a4a7e --- /dev/null +++ b/devel/bmake/files/mk/yacc.mk @@ -0,0 +1,57 @@ +# $Id: yacc.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ + +# +# @(#) Copyright (c) 1999-2011, 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 +# + +# this file contains rules to DTRT when SRCS contains foo.y or foo.c +# when only a foo.y exists. + +YACC?= yacc +YFLAGS?= -v -t +RM?= rm + +YACC.y?= ${YACC} ${YFLAGS} + +.if ${YACC.y:M-d} == "" || defined(NO_RENAME_Y_TAB_H) + +.y.c: + ${YACC.y} ${.IMPSRC} + [ ! -s y.tab.c ] || mv y.tab.c ${.TARGET} + ${RM} -f y.tab.[!h] + +.else + +# the touch of the .c is to ensure it is newer than .h (paranoia) +.y.h: + ${YACC.y} ${.IMPSRC} + [ ! -s y.tab.c ] || mv y.tab.c ${.TARGET:T:R}.c + [ ! -s y.tab.h ] || cmp -s y.tab.h ${.TARGET:T:R}.h \ + || mv y.tab.h ${.TARGET:T:R}.h + touch ${.TARGET:T:R}.c + ${RM} -f y.tab.* + +# Normally the .y.h rule does the work - to avoid races. +# If for any reason the .c is lost but the .h remains, +# regenerate the .c +.y.c: ${.TARGET:T:R}.h + [ -s ${.TARGET} ] || { \ + ${YACC.y} ${.IMPSRC} && \ + { [ ! -s y.tab.c ] || mv y.tab.c ${.TARGET}; \ + ${RM} y.tab.*; }; } +.endif + +beforedepend: ${SRCS:T:M*.y:S/.y/.c/g} + +CLEANFILES+= ${SRCS:T:M*.y:S/.y/.[ch]/g} +CLEANFILES+= y.tab.[ch] diff --git a/devel/bmake/files/nonints.h b/devel/bmake/files/nonints.h index 8511af43876..360fc271e90 100644 --- a/devel/bmake/files/nonints.h +++ b/devel/bmake/files/nonints.h @@ -1,4 +1,4 @@ -/* $NetBSD: nonints.h,v 1.1.1.9 2015/05/19 21:36:44 joerg Exp $ */ +/* $NetBSD: nonints.h,v 1.1.1.10 2020/05/24 05:35:52 nia Exp $ */ /*- * Copyright (c) 1988, 1989, 1990, 1993 @@ -109,7 +109,6 @@ void JobReapChild(pid_t, WAIT_T, Boolean); /* main.c */ void Main_ParseArgLine(const char *); void MakeMode(const char *); -int main(int, char **); char *Cmd_Exec(const char *, const char **); void Error(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2); void Fatal(const char *, ...) MAKE_ATTR_PRINTFLIKE(1, 2) MAKE_ATTR_DEAD; @@ -120,7 +119,9 @@ void Finish(int) MAKE_ATTR_DEAD; int eunlink(const char *); void execError(const char *, const char *); char *getTmpdir(void); +Boolean s2Boolean(const char *, Boolean); Boolean getBoolean(const char *, Boolean); +char *cached_realpath(const char *, char *); /* parse.c */ void Parse_Error(int, const char *, ...) MAKE_ATTR_PRINTFLIKE(2, 3); @@ -139,8 +140,13 @@ char *str_concat(const char *, const char *, int); char **brk_string(const char *, int *, Boolean, char **); char *Str_FindSubstring(const char *, const char *); int Str_Match(const char *, const char *); -char *Str_SYSVMatch(const char *, const char *, int *len); -void Str_SYSVSubst(Buffer *, char *, char *, int); +char *Str_SYSVMatch(const char *, const char *, size_t *, Boolean *); +void Str_SYSVSubst(Buffer *, char *, char *, size_t, Boolean); + +#ifndef HAVE_STRLCPY +/* strlcpy.c */ +size_t strlcpy(char *, const char *, size_t); +#endif /* suff.c */ void Suff_ClearSuffixes(void); @@ -184,8 +190,8 @@ void Var_Set(const char *, const char *, GNode *, int); void Var_Append(const char *, const char *, GNode *); Boolean Var_Exists(const char *, GNode *); char *Var_Value(const char *, GNode *, char **); -char *Var_Parse(const char *, GNode *, Boolean, int *, void **); -char *Var_Subst(const char *, const char *, GNode *, Boolean); +char *Var_Parse(const char *, GNode *, int, int *, void **); +char *Var_Subst(const char *, const char *, GNode *, int); char *Var_GetTail(const char *); char *Var_GetHead(const char *); void Var_Init(void); diff --git a/devel/bmake/files/os.sh b/devel/bmake/files/os.sh index 1aeabdd8381..15c02104b85 100644 --- a/devel/bmake/files/os.sh +++ b/devel/bmake/files/os.sh @@ -17,7 +17,7 @@ # Simon J. Gerraty <sjg@crufty.net> # RCSid: -# $Id: os.sh,v 1.1.1.7 2015/05/19 21:36:44 joerg Exp $ +# $Id: os.sh,v 1.1.1.8 2020/05/24 05:35:52 nia Exp $ # # @(#) Copyright (c) 1994 Simon J. Gerraty # @@ -44,7 +44,7 @@ MACHINE_ARCH=`uname -p 2>/dev/null || echo $MACHINE` # there is at least one case of `uname -p` outputting # a bunch of usless drivel case "$MACHINE_ARCH" in -*[!A-Za-z0-9_-]*) MACHINE_ARCH="$MACHINE";; +unknown|*[!A-Za-z0-9_-]*) MACHINE_ARCH="$MACHINE";; esac # we need this here, and it is not always available... @@ -56,10 +56,10 @@ Which() { case "$1" in /*) test $t $1 && echo $1;; *) - # some shells cannot correctly handle `IFS` - # in conjunction with the for loop. - _dirs=`IFS=:; echo ${2:-$PATH}` - for d in $_dirs + # some shells cannot correctly handle `IFS` + # in conjunction with the for loop. + _dirs=`IFS=:; echo ${2:-$PATH}` + for d in $_dirs do test $t $d/$1 && { echo $d/$1; break; } done @@ -70,11 +70,11 @@ Which() { # tr is insanely non-portable wrt char classes, so we need to # spell out the alphabet. sed y/// would work too. toUpper() { - ${TR:-tr} abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ + ${TR:-tr} abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ } toLower() { - ${TR:-tr} ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz + ${TR:-tr} ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz } K= @@ -91,7 +91,7 @@ SunOS) export CHOWN # Great! Solaris keeps moving arch(1) - # should just bite the bullet and use uname -p + # should just bite the bullet and use uname -p arch=`Which arch /usr/bin:/usr/ucb` MAILER=/usr/ucb/Mail @@ -105,8 +105,8 @@ SunOS) MACHINE=$MACHINE_ARCH ;; 4*) - MACHINE_ARCH=`arch` - ;; + MACHINE_ARCH=`arch` + ;; 5*) K=-k LOCAL_FS=ufs @@ -116,8 +116,8 @@ SunOS) # overwriting an existing file!!!!! We want one that works! test -x /usr/xpg4/bin/ln && LN=${LN:-/usr/xpg4/bin/ln} # wonderful, 5.8's tr again require's []'s - # but /usr/xpg4/bin/tr causes problems if LC_COLLATE is set! - # use toUpper/toLower instead. + # but /usr/xpg4/bin/tr causes problems if LC_COLLATE is set! + # use toUpper/toLower instead. ;; esac case "$OS/$MACHINE_ARCH" in @@ -137,11 +137,15 @@ SunOS) # NetBSD at least has good backward compatibility # so NetBSD/i386 is good enough case $OS in - NetBSD) SHARE_ARCH=$OS/${MACHINE_ARCH:-$MACHINE};; + NetBSD) + LOCALBASE=/usr/pkg + HOST_ARCH=$MACHINE + SHARE_ARCH=$OS/$HOST_ARCH + ;; OpenBSD) - arch=`Which arch /usr/bin:/usr/ucb:$PATH` - MACHINE_ARCH=`$arch -s` - ;; + arch=`Which arch /usr/bin:/usr/ucb:$PATH` + MACHINE_ARCH=`$arch -s` + ;; esac NAWK=awk export NAWK @@ -193,6 +197,7 @@ Haiku) esac ;; esac +LOCALBASE=${LOCALBASE:-/usr/local} HOSTNAME=${HOSTNAME:-`( hostname ) 2>/dev/null`} HOSTNAME=${HOSTNAME:-`( uname -n ) 2>/dev/null`} @@ -203,28 +208,48 @@ esac TMP_DIRS=${TMP_DIRS:-"/tmp /var/tmp"} MACHINE_ARCH=${MACHINE_ARCH:-$MACHINE} +case "$MACHINE_ARCH" in +x86*64|amd64) MACHINE32_ARCH=i386;; +*64) MACHINE32_ARCH=`echo $MACHINE_ARCH | sed 's,64,32,'`;; +*) MACHINE32_ARCH=$MACHINE_ARCH;; +esac +HOST_ARCH=${HOST_ARCH:-$MACHINE_ARCH} +HOST_ARCH32=${HOST_ARCH32:-$MACHINE32_ARCH} # we mount server:/share/arch/$SHARE_ARCH as /usr/local -SHARE_ARCH=${SHARE_ARCH:-$OS/$OSMAJOR.X/$MACHINE_ARCH} +SHARE_ARCH_DEFAULT=$OS/$OSMAJOR.X/$HOST_ARCH +SHARE_ARCH=${SHARE_ARCH:-$SHARE_ARCH_DEFAULT} LN=${LN:-ln} TR=${TR:-tr} # Some people like have /share/$HOST_TARGET/bin etc. -HOST_TARGET=`echo ${OS}${OSMAJOR}-${MACHINE_ARCH} | toLower` -export HOST_TARGET +HOST_TARGET=`echo ${OS}${OSMAJOR}-$HOST_ARCH | tr -d / | toLower` +HOST_TARGET32=`echo ${OS}${OSMAJOR}-$HOST_ARCH32 | tr -d / | toLower` +export HOST_TARGET HOST_TARGET32 case `echo -n .` in -n*) N=; C="\c";; *) N=-n; C=;; esac -export HOSTNAME HOST +Echo() { + case "$1" in + -n) _n=$N _c=$C; shift;; + *) _n= _c=;; + esac + echo $_n "$@" $_c +} + +export HOSTNAME HOST export OS MACHINE MACHINE_ARCH OSREL OSMAJOR LOCAL_FS TMP_DIRS MAILER N C K PS_AXC export LN SHARE_ARCH TR +export LOCALBASE case /$0 in */os.sh) - for v in $* + for v in $* do - eval vv=\$$v - echo "$v='$vv'" + eval vv=\$$v + echo "$v='$vv'" done - ;; + ;; +*/host_target32) echo $HOST_TARGET32;; +*/host_target) echo $HOST_TARGET;; esac diff --git a/devel/bmake/files/parse.c b/devel/bmake/files/parse.c index a7c3b44af00..24fd69600a2 100644 --- a/devel/bmake/files/parse.c +++ b/devel/bmake/files/parse.c @@ -1,4 +1,4 @@ -/* $NetBSD: parse.c,v 1.1.1.10 2015/05/19 21:36:44 joerg Exp $ */ +/* $NetBSD: parse.c,v 1.1.1.11 2020/05/24 05:35:53 nia Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: parse.c,v 1.1.1.10 2015/05/19 21:36:44 joerg Exp $"; +static char rcsid[] = "$NetBSD: parse.c,v 1.1.1.11 2020/05/24 05:35:53 nia Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)parse.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: parse.c,v 1.1.1.10 2015/05/19 21:36:44 joerg Exp $"); +__RCSID("$NetBSD: parse.c,v 1.1.1.11 2020/05/24 05:35:53 nia Exp $"); #endif #endif /* not lint */ #endif @@ -128,7 +128,6 @@ __RCSID("$NetBSD: parse.c,v 1.1.1.10 2015/05/19 21:36:44 joerg Exp $"); #include <assert.h> #include <ctype.h> #include <errno.h> -#include <fcntl.h> #include <stdarg.h> #include <stdio.h> @@ -139,6 +138,10 @@ __RCSID("$NetBSD: parse.c,v 1.1.1.10 2015/05/19 21:36:44 joerg Exp $"); #include "buf.h" #include "pathnames.h" +#ifdef HAVE_STDINT_H +#include <stdint.h> +#endif + #ifdef HAVE_MMAP #include <sys/mman.h> @@ -161,6 +164,7 @@ typedef struct IFile { int lineno; /* current line number in file */ int first_lineno; /* line number of start of text */ int cond_depth; /* 'if' nesting when file opened */ + Boolean depending; /* state of doing_depend on EOF */ char *P_str; /* point to base of string buffer */ char *P_ptr; /* point to next char of string buffer */ char *P_end; /* point to the end of string buffer */ @@ -184,6 +188,7 @@ typedef struct IFile { typedef enum { Begin, /* .BEGIN */ Default, /* .DEFAULT */ + DeleteOnError, /* .DELETE_ON_ERROR */ End, /* .END */ dotError, /* .ERROR */ Ignore, /* .IGNORE */ @@ -301,6 +306,7 @@ static const struct { } parseKeywords[] = { { ".BEGIN", Begin, 0 }, { ".DEFAULT", Default, 0 }, +{ ".DELETE_ON_ERROR", DeleteOnError, 0 }, { ".END", End, 0 }, { ".ERROR", dotError, 0 }, { ".EXEC", Attribute, OP_EXEC }, @@ -365,9 +371,6 @@ static void ParseHasCommands(void *); static void ParseDoInclude(char *); static void ParseSetParseFile(const char *); static void ParseSetIncludedFile(void); -#ifdef SYSVINCLUDE -static void ParseTraditionalInclude(char *); -#endif #ifdef GMAKEEXPORT static void ParseGmakeExport(char *); #endif @@ -484,7 +487,7 @@ loadfile(const char *path, int fd) { struct loadedfile *lf; #ifdef HAVE_MMAP - long pagesize; + static long pagesize = 0; #endif ssize_t result; size_t bufpos; @@ -508,7 +511,10 @@ loadfile(const char *path, int fd) #ifdef HAVE_MMAP if (load_getsize(fd, &lf->len) == SUCCESS) { /* found a size, try mmap */ - pagesize = sysconf(_SC_PAGESIZE); +#ifdef _SC_PAGESIZE + if (pagesize == 0) + pagesize = sysconf(_SC_PAGESIZE); +#endif if (pagesize <= 0) { pagesize = 0x1000; } @@ -533,7 +539,7 @@ loadfile(const char *path, int fd) if (lf->buf != MAP_FAILED) { /* succeeded */ if (lf->len == lf->maplen && lf->buf[lf->len - 1] != '\n') { - char *b = malloc(lf->len + 1); + char *b = bmake_malloc(lf->len + 1); b[lf->len] = '\n'; memcpy(b, lf->buf, lf->len++); munmap(lf->buf, lf->maplen); @@ -554,9 +560,15 @@ loadfile(const char *path, int fd) while (1) { assert(bufpos <= lf->len); if (bufpos == lf->len) { + if (lf->len > SIZE_MAX/2) { + errno = EFBIG; + Error("%s: file too large", path); + exit(1); + } lf->len *= 2; lf->buf = bmake_realloc(lf->buf, lf->len); } + assert(bufpos < lf->len); result = read(fd, lf->buf + bufpos, lf->len - bufpos); if (result < 0) { Error("%s: read error: %s", path, strerror(errno)); @@ -572,7 +584,11 @@ loadfile(const char *path, int fd) /* truncate malloc region to actual length (maybe not useful) */ if (lf->len > 0) { + /* as for mmap case, ensure trailing \n */ + if (lf->buf[lf->len - 1] != '\n') + lf->len++; lf->buf = bmake_realloc(lf->buf, lf->len); + lf->buf[lf->len - 1] = '\n'; } #ifdef HAVE_MMAP @@ -669,27 +685,37 @@ ParseVErrorInternal(FILE *f, const char *cfname, size_t clineno, int type, const char *fmt, va_list ap) { static Boolean fatal_warning_error_printed = FALSE; + char dirbuf[MAXPATHLEN+1]; (void)fprintf(f, "%s: ", progname); if (cfname != NULL) { (void)fprintf(f, "\""); if (*cfname != '/' && strcmp(cfname, "(stdin)") != 0) { - char *cp; - const char *dir; + char *cp, *cp2; + const char *dir, *fname; /* * Nothing is more annoying than not knowing - * which Makefile is the culprit. + * which Makefile is the culprit; we try ${.PARSEDIR} + * and apply realpath(3) if not absolute. */ dir = Var_Value(".PARSEDIR", VAR_GLOBAL, &cp); - if (dir == NULL || *dir == '\0' || - (*dir == '.' && dir[1] == '\0')) - dir = Var_Value(".CURDIR", VAR_GLOBAL, &cp); if (dir == NULL) dir = "."; - - (void)fprintf(f, "%s/%s", dir, cfname); + if (*dir != '/') { + dir = realpath(dir, dirbuf); + } + fname = Var_Value(".PARSEFILE", VAR_GLOBAL, &cp2); + if (fname == NULL) { + if ((fname = strrchr(cfname, '/'))) + fname++; + else + fname = cfname; + } + (void)fprintf(f, "%s/%s", dir, fname); + free(cp2); + free(cp); } else (void)fprintf(f, "%s", cfname); @@ -700,6 +726,8 @@ ParseVErrorInternal(FILE *f, const char *cfname, size_t clineno, int type, (void)vfprintf(f, fmt, ap); (void)fprintf(f, "\n"); (void)fflush(f); + if (type == PARSE_INFO) + return; if (type == PARSE_FATAL || parseWarnFatal) fatals += 1; if (parseWarnFatal && !fatal_warning_error_printed) { @@ -792,7 +820,7 @@ ParseMessage(char *line) switch(*line) { case 'i': - mtype = 0; + mtype = PARSE_INFO; break; case 'w': mtype = PARSE_WARNING; @@ -805,14 +833,14 @@ ParseMessage(char *line) return FALSE; } - while (isalpha((u_char)*line)) + while (isalpha((unsigned char)*line)) line++; - if (!isspace((u_char)*line)) + if (!isspace((unsigned char)*line)) return FALSE; /* not for us */ - while (isspace((u_char)*line)) + while (isspace((unsigned char)*line)) line++; - line = Var_Subst(NULL, line, VAR_CMD, 0); + line = Var_Subst(NULL, line, VAR_CMD, VARF_WANTRES); Parse_Error(mtype, "%s", line); free(line); @@ -1089,15 +1117,15 @@ ParseDoSrc(int tOp, const char *src) *----------------------------------------------------------------------- */ static int -ParseFindMain(void *gnp, void *dummy) +ParseFindMain(void *gnp, void *dummy MAKE_ATTR_UNUSED) { GNode *gn = (GNode *)gnp; if ((gn->type & OP_NOTARGET) == 0) { mainNode = gn; Targ_SetMain(gn); - return (dummy ? 1 : 1); + return 1; } else { - return (dummy ? 0 : 0); + return 0; } } @@ -1135,10 +1163,10 @@ ParseAddDir(void *path, void *name) *----------------------------------------------------------------------- */ static int -ParseClearPath(void *path, void *dummy) +ParseClearPath(void *path, void *dummy MAKE_ATTR_UNUSED) { Dir_ClearPath((Lst) path); - return(dummy ? 0 : 0); + return 0; } /*- @@ -1229,9 +1257,9 @@ ParseDoDependency(char *line) int length; void *freeIt; - (void)Var_Parse(cp, VAR_CMD, TRUE, &length, &freeIt); - if (freeIt) - free(freeIt); + (void)Var_Parse(cp, VAR_CMD, VARF_UNDEFERR|VARF_WANTRES, + &length, &freeIt); + free(freeIt); cp += length-1; } } @@ -1257,6 +1285,7 @@ ParseDoDependency(char *line) goto out; } else { /* Done with this word; on to the next. */ + cp = line; continue; } } @@ -1329,6 +1358,7 @@ ParseDoDependency(char *line) * .BEGIN * .END * .ERROR + * .DELETE_ON_ERROR * .INTERRUPT Are not to be considered the * main target. * .NOTPARALLEL Make only one target at a time. @@ -1364,6 +1394,9 @@ ParseDoDependency(char *line) (void)Lst_AtEnd(targets, gn); DEFAULT = gn; break; + case DeleteOnError: + deleteOnError = TRUE; + break; case NotParallel: maxJobs = 1; break; @@ -1592,7 +1625,8 @@ ParseDoDependency(char *line) goto out; } *line = '\0'; - } else if ((specType == NotParallel) || (specType == SingleShell)) { + } else if ((specType == NotParallel) || (specType == SingleShell) || + (specType == DeleteOnError)) { *line = '\0'; } @@ -1653,7 +1687,7 @@ ParseDoDependency(char *line) Suff_SetNull(line); break; case ExObjdir: - Main_SetObjdir(line); + Main_SetObjdir("%s", line); break; default: break; @@ -1669,10 +1703,12 @@ ParseDoDependency(char *line) } if (paths) { Lst_Destroy(paths, NULL); + paths = NULL; } if (specType == ExPath) Dir_SetPATH(); } else { + assert(paths == NULL); while (*line) { /* * The targets take real sources, so we must beware of archive @@ -1731,6 +1767,8 @@ ParseDoDependency(char *line) } out: + if (paths) + Lst_Destroy(paths, NULL); if (curTargs) Lst_Destroy(curTargs, NULL); } @@ -1853,7 +1891,7 @@ Parse_DoVar(char *line, GNode *ctxt) * XXX Rather than counting () and {} we should look for $ and * then expand the variable. */ - for (depth = 0, cp = line + 1; depth != 0 || *cp != '='; cp++) { + for (depth = 0, cp = line + 1; depth > 0 || *cp != '='; cp++) { if (*cp == '(' || *cp == '{') { depth++; continue; @@ -1944,7 +1982,7 @@ Parse_DoVar(char *line, GNode *ctxt) if (!Var_Exists(line, ctxt)) Var_Set(line, "", ctxt, 0); - cp = Var_Subst(NULL, cp, ctxt, FALSE); + cp = Var_Subst(NULL, cp, ctxt, VARF_WANTRES|VARF_ASSIGN); oldVars = oldOldVars; freeCp = TRUE; @@ -1959,7 +1997,7 @@ Parse_DoVar(char *line, GNode *ctxt) * expansion on the whole thing. The resulting string will need * freeing when we're done, so set freeCmd to TRUE. */ - cp = Var_Subst(NULL, cp, VAR_CMD, TRUE); + cp = Var_Subst(NULL, cp, VAR_CMD, VARF_UNDEFERR|VARF_WANTRES); freeCp = TRUE; } @@ -2151,7 +2189,7 @@ Parse_AddIncludeDir(char *dir) */ static void -Parse_include_file(char *file, Boolean isSystem, int silent) +Parse_include_file(char *file, Boolean isSystem, Boolean depinc, int silent) { struct loadedfile *lf; char *fullname; /* full pathname of file */ @@ -2251,6 +2289,8 @@ Parse_include_file(char *file, Boolean isSystem, int silent) /* Start reading from this file next */ Parse_SetInput(fullname, 0, -1, loadedfile_nextbuf, lf); curFile->lf = lf; + if (depinc) + doing_depend = depinc; /* only turn it on */ } static void @@ -2298,9 +2338,9 @@ ParseDoInclude(char *line) * Substitute for any variables in the file name before trying to * find the thing. */ - file = Var_Subst(NULL, file, VAR_CMD, FALSE); + file = Var_Subst(NULL, file, VAR_CMD, VARF_WANTRES); - Parse_include_file(file, endc == '>', silent); + Parse_include_file(file, endc == '>', (*line == 'd'), silent); free(file); } @@ -2335,10 +2375,8 @@ ParseSetIncludedFile(void) fprintf(debug_file, "%s: ${.INCLUDEDFROMDIR} = `%s' " "${.INCLUDEDFROMFILE} = `%s'\n", __func__, pd, pf); - if (fp) - free(fp); - if (dp) - free(dp); + free(fp); + free(dp); } /*- *--------------------------------------------------------------------- @@ -2390,15 +2428,19 @@ static void ParseTrackInput(const char *name) { char *old; + char *ep; char *fp = NULL; size_t name_len = strlen(name); old = Var_Value(MAKE_MAKEFILES, VAR_GLOBAL, &fp); if (old) { + ep = old + strlen(old) - name_len; /* does it contain name? */ for (; old != NULL; old = strchr(old, ' ')) { if (*old == ' ') old++; + if (old >= ep) + break; /* cannot contain name */ if (memcmp(old, name, name_len) == 0 && (old[name_len] == 0 || old[name_len] == ' ')) goto cleanup; @@ -2464,6 +2506,7 @@ Parse_SetInput(const char *name, int line, int fd, curFile->nextbuf = nextbuf; curFile->nextbuf_arg = arg; curFile->lf = NULL; + curFile->depending = doing_depend; /* restore this on EOF */ assert(nextbuf != NULL); @@ -2484,8 +2527,73 @@ Parse_SetInput(const char *name, int line, int fd, ParseSetParseFile(name); } +/*- + *----------------------------------------------------------------------- + * IsInclude -- + * Check if the line is an include directive + * + * Results: + * TRUE if it is. + * + * Side Effects: + * None + * + *----------------------------------------------------------------------- + */ +static Boolean +IsInclude(const char *line, Boolean sysv) +{ + static const char inc[] = "include"; + static const size_t inclen = sizeof(inc) - 1; + + // 'd' is not valid for sysv + int o = strchr(&("ds-"[sysv]), *line) != NULL; + + if (strncmp(line + o, inc, inclen) != 0) + return FALSE; + + // Space is not mandatory for BSD .include + return !sysv || isspace((unsigned char)line[inclen + o]); +} + + #ifdef SYSVINCLUDE /*- + *----------------------------------------------------------------------- + * IsSysVInclude -- + * Check if the line is a SYSV include directive + * + * Results: + * TRUE if it is. + * + * Side Effects: + * None + * + *----------------------------------------------------------------------- + */ +static Boolean +IsSysVInclude(const char *line) +{ + const char *p; + + if (!IsInclude(line, TRUE)) + return FALSE; + + /* Avoid interpeting a dependency line as an include */ + for (p = line; (p = strchr(p, ':')) != NULL;) { + if (*++p == '\0') { + /* end of line -> dependency */ + return FALSE; + } + if (*p == ':' || isspace((unsigned char)*p)) { + /* :: operator or ': ' -> dependency */ + return FALSE; + } + } + return TRUE; +} + +/*- *--------------------------------------------------------------------- * ParseTraditionalInclude -- * Push to another file. @@ -2524,12 +2632,12 @@ ParseTraditionalInclude(char *line) * Substitute for any variables in the file name before trying to * find the thing. */ - all_files = Var_Subst(NULL, file, VAR_CMD, FALSE); + all_files = Var_Subst(NULL, file, VAR_CMD, VARF_WANTRES); if (*file == '\0') { Parse_Error(PARSE_FATAL, "Filename missing from \"include\""); - return; + goto out; } for (file = all_files; !done; file = cp + 1) { @@ -2542,8 +2650,9 @@ ParseTraditionalInclude(char *line) else done = 1; - Parse_include_file(file, FALSE, silent); + Parse_include_file(file, FALSE, FALSE, silent); } +out: free(all_files); } #endif @@ -2592,8 +2701,9 @@ ParseGmakeExport(char *line) /* * Expand the value before putting it in the environment. */ - value = Var_Subst(NULL, value, VAR_CMD, FALSE); + value = Var_Subst(NULL, value, VAR_CMD, VARF_WANTRES); setenv(variable, value, 1); + free(value); } #endif @@ -2620,6 +2730,7 @@ ParseEOF(void) assert(curFile->nextbuf != NULL); + doing_depend = curFile->depending; /* restore this */ /* get next input buffer, if any */ ptr = curFile->nextbuf(curFile->nextbuf_arg, &len); curFile->P_ptr = ptr; @@ -2981,9 +3092,7 @@ Parse_File(const char *name, int fd) for (cp = line + 1; isspace((unsigned char)*cp); cp++) { continue; } - if (strncmp(cp, "include", 7) == 0 || - ((cp[0] == 's' || cp[0] == '-') && - strncmp(&cp[1], "include", 7) == 0)) { + if (IsInclude(cp, FALSE)) { ParseDoInclude(cp); continue; } @@ -3045,12 +3154,7 @@ Parse_File(const char *name, int fd) } #ifdef SYSVINCLUDE - if (((strncmp(line, "include", 7) == 0 && - isspace((unsigned char) line[7])) || - ((line[0] == 's' || line[0] == '-') && - strncmp(&line[1], "include", 7) == 0 && - isspace((unsigned char) line[8]))) && - strchr(line, ':') == NULL) { + if (IsSysVInclude(line)) { /* * It's an S3/S5-style "include". */ @@ -3141,7 +3245,7 @@ Parse_File(const char *name, int fd) * variables expanded before being parsed. Tell the variable * module to complain if some variable is undefined... */ - line = Var_Subst(NULL, line, VAR_CMD, TRUE); + line = Var_Subst(NULL, line, VAR_CMD, VARF_UNDEFERR|VARF_WANTRES); /* * Need a non-circular list for the target nodes diff --git a/devel/bmake/files/sprite.h b/devel/bmake/files/sprite.h index 14f955d2b10..bbfa31b53f8 100644 --- a/devel/bmake/files/sprite.h +++ b/devel/bmake/files/sprite.h @@ -1,4 +1,4 @@ -/* $NetBSD: sprite.h,v 1.1.1.3 2009/09/18 20:55:31 joerg Exp $ */ +/* $NetBSD: sprite.h,v 1.1.1.4 2020/05/24 05:35:53 nia Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -78,8 +78,8 @@ * Common constants and type declarations for Sprite. */ -#ifndef _SPRITE -#define _SPRITE +#ifndef MAKE_SPRITE_H +#define MAKE_SPRITE_H /* @@ -113,4 +113,4 @@ typedef int ReturnStatus; #define SUCCESS 0x00000000 #define FAILURE 0x00000001 -#endif /* _SPRITE */ +#endif /* MAKE_SPRITE_H */ diff --git a/devel/bmake/files/str.c b/devel/bmake/files/str.c index 2f521979e8c..408c2b175c5 100644 --- a/devel/bmake/files/str.c +++ b/devel/bmake/files/str.c @@ -1,4 +1,4 @@ -/* $NetBSD: str.c,v 1.1.1.6 2015/05/19 21:36:44 joerg Exp $ */ +/* $NetBSD: str.c,v 1.1.1.7 2020/05/24 05:35:53 nia Exp $ */ /*- * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: str.c,v 1.1.1.6 2015/05/19 21:36:44 joerg Exp $"; +static char rcsid[] = "$NetBSD: str.c,v 1.1.1.7 2020/05/24 05:35:53 nia Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)str.c 5.8 (Berkeley) 6/1/90"; #else -__RCSID("$NetBSD: str.c,v 1.1.1.6 2015/05/19 21:36:44 joerg Exp $"); +__RCSID("$NetBSD: str.c,v 1.1.1.7 2020/05/24 05:35:53 nia Exp $"); #endif #endif /* not lint */ #endif @@ -102,7 +102,7 @@ str_concat(const char *s1, const char *s2, int flags) len2 = strlen(s2); /* allocate length plus separator plus EOS */ - result = bmake_malloc((u_int)(len1 + len2 + 2)); + result = bmake_malloc((unsigned int)(len1 + len2 + 2)); /* copy first string into place */ memcpy(result, s1, len1); @@ -133,42 +133,43 @@ str_concat(const char *s1, const char *s2, int flags) * * returns -- * Pointer to the array of pointers to the words. - * Memory containing the actual words in *buffer. + * Memory containing the actual words in *store_words_buf. * Both of these must be free'd by the caller. - * Number of words in *store_argc. + * Number of words in *store_words_len. */ char ** -brk_string(const char *str, int *store_argc, Boolean expand, char **buffer) +brk_string(const char *str, int *store_words_len, Boolean expand, + char **store_words_buf) { - int argc, ch; - char inquote, *start, *t; - const char *p; - int len; - int argmax = 50, curlen = 0; - char **argv; + char inquote; + const char *str_p; + size_t str_len; + char **words; + int words_len; + int words_cap = 50; + char *words_buf, *word_start, *word_end; /* skip leading space chars. */ for (; *str == ' ' || *str == '\t'; ++str) continue; - /* allocate room for a copy of the string */ - if ((len = strlen(str) + 1) > curlen) - *buffer = bmake_malloc(curlen = len); + /* words_buf holds the words, separated by '\0'. */ + str_len = strlen(str); + words_buf = bmake_malloc(strlen(str) + 1); - /* - * initial argmax based on len - */ - argmax = MAX((len / 5), 50); - argv = bmake_malloc((argmax + 1) * sizeof(char *)); + words_cap = MAX((str_len / 5), 50); + words = bmake_malloc((words_cap + 1) * sizeof(char *)); /* * copy the string; at the same time, parse backslashes, - * quotes and build the argument list. + * quotes and build the word list. */ - argc = 0; + words_len = 0; inquote = '\0'; - for (p = str, start = t = *buffer;; ++p) { - switch(ch = *p) { + word_start = word_end = words_buf; + for (str_p = str;; ++str_p) { + char ch = *str_p; + switch(ch) { case '"': case '\'': if (inquote) { @@ -180,21 +181,21 @@ brk_string(const char *str, int *store_argc, Boolean expand, char **buffer) else { inquote = (char) ch; /* Don't miss "" or '' */ - if (start == NULL && p[1] == inquote) { + if (word_start == NULL && str_p[1] == inquote) { if (!expand) { - start = t; - *t++ = ch; + word_start = word_end; + *word_end++ = ch; } else - start = t + 1; - p++; + word_start = word_end + 1; + str_p++; inquote = '\0'; break; } } if (!expand) { - if (!start) - start = t; - *t++ = ch; + if (word_start == NULL) + word_start = word_end; + *word_end++ = ch; } continue; case ' ': @@ -202,30 +203,30 @@ brk_string(const char *str, int *store_argc, Boolean expand, char **buffer) case '\n': if (inquote) break; - if (!start) + if (word_start == NULL) continue; /* FALLTHROUGH */ case '\0': /* - * end of a token -- make sure there's enough argv + * end of a token -- make sure there's enough words * space and save off a pointer. */ - if (!start) + if (word_start == NULL) goto done; - *t++ = '\0'; - if (argc == argmax) { - argmax *= 2; /* ramp up fast */ - argv = (char **)bmake_realloc(argv, - (argmax + 1) * sizeof(char *)); + *word_end++ = '\0'; + if (words_len == words_cap) { + words_cap *= 2; /* ramp up fast */ + words = (char **)bmake_realloc(words, + (words_cap + 1) * sizeof(char *)); } - argv[argc++] = start; - start = NULL; + words[words_len++] = word_start; + word_start = NULL; if (ch == '\n' || ch == '\0') { if (expand && inquote) { - free(argv); - free(*buffer); - *buffer = NULL; + free(words); + free(words_buf); + *store_words_buf = NULL; return NULL; } goto done; @@ -233,21 +234,22 @@ brk_string(const char *str, int *store_argc, Boolean expand, char **buffer) continue; case '\\': if (!expand) { - if (!start) - start = t; - *t++ = '\\'; - if (*(p+1) == '\0') /* catch '\' at end of line */ + if (word_start == NULL) + word_start = word_end; + *word_end++ = '\\'; + /* catch '\' at end of line */ + if (str_p[1] == '\0') continue; - ch = *++p; + ch = *++str_p; break; } - switch (ch = *++p) { + switch (ch = *++str_p) { case '\0': case '\n': /* hmmm; fix it up as best we can */ ch = '\\'; - --p; + --str_p; break; case 'b': ch = '\b'; @@ -267,13 +269,14 @@ brk_string(const char *str, int *store_argc, Boolean expand, char **buffer) } break; } - if (!start) - start = t; - *t++ = (char) ch; + if (word_start == NULL) + word_start = word_end; + *word_end++ = ch; } -done: argv[argc] = NULL; - *store_argc = argc; - return(argv); +done: words[words_len] = NULL; + *store_words_len = words_len; + *store_words_buf = words_buf; + return words; } /* @@ -373,16 +376,26 @@ Str_Match(const char *string, const char *pattern) * by a range (two characters separated by "-"). */ if (*pattern == '[') { + int nomatch; + ++pattern; + if (*pattern == '^') { + ++pattern; + nomatch = 1; + } else + nomatch = 0; for (;;) { - if ((*pattern == ']') || (*pattern == 0)) + if ((*pattern == ']') || (*pattern == 0)) { + if (nomatch) + break; return(0); + } if (*pattern == *string) break; if (pattern[1] == '-') { c2 = pattern[2]; if (c2 == 0) - return(0); + return(nomatch); if ((*pattern <= *string) && (c2 >= *string)) break; @@ -393,8 +406,12 @@ Str_Match(const char *string, const char *pattern) } ++pattern; } + if (nomatch && (*pattern != ']') && (*pattern != 0)) + return 0; while ((*pattern != ']') && (*pattern != 0)) ++pattern; + if (*pattern == 0) + --pattern; goto thisCharOK; } /* @@ -438,12 +455,14 @@ thisCharOK: ++pattern; *----------------------------------------------------------------------- */ char * -Str_SYSVMatch(const char *word, const char *pattern, int *len) +Str_SYSVMatch(const char *word, const char *pattern, size_t *len, + Boolean *hasPercent) { const char *p = pattern; const char *w = word; const char *m; + *hasPercent = FALSE; if (*p == '\0') { /* Null pattern is the whole string */ *len = strlen(w); @@ -451,6 +470,11 @@ Str_SYSVMatch(const char *word, const char *pattern, int *len) } if ((m = strchr(p, '%')) != NULL) { + *hasPercent = TRUE; + if (*w == '\0') { + /* empty word does not match pattern */ + return NULL; + } /* check that the prefix matches */ for (; p != m && *w && *w == *p; w++, p++) continue; @@ -495,19 +519,21 @@ Str_SYSVMatch(const char *word, const char *pattern, int *len) *----------------------------------------------------------------------- */ void -Str_SYSVSubst(Buffer *buf, char *pat, char *src, int len) +Str_SYSVSubst(Buffer *buf, char *pat, char *src, size_t len, + Boolean lhsHasPercent) { char *m; - if ((m = strchr(pat, '%')) != NULL) { + if ((m = strchr(pat, '%')) != NULL && lhsHasPercent) { /* Copy the prefix */ Buf_AddBytes(buf, m - pat, pat); /* skip the % */ pat = m + 1; } - - /* Copy the pattern */ - Buf_AddBytes(buf, len, src); + if (m != NULL || !lhsHasPercent) { + /* Copy the pattern */ + Buf_AddBytes(buf, len, src); + } /* append the rest */ Buf_AddBytes(buf, strlen(pat), pat); diff --git a/devel/bmake/files/stresep.c b/devel/bmake/files/stresep.c index 42ad8d08a6c..b36b55aa876 100644 --- a/devel/bmake/files/stresep.c +++ b/devel/bmake/files/stresep.c @@ -1,4 +1,4 @@ -/* $NetBSD: stresep.c,v 1.1.1.1 2011/06/18 22:18:07 bsiegert Exp $ */ +/* $NetBSD: stresep.c,v 1.1.1.2 2020/05/24 05:35:53 nia Exp $ */ /*- * Copyright (c) 1990, 1993 @@ -59,6 +59,7 @@ stresep(char **stringp, const char *delim, int esc) char *s; const char *spanp; int c, sc; + size_t l; char *tok; if (stringp == NULL || delim == NULL) @@ -66,23 +67,26 @@ stresep(char **stringp, const char *delim, int esc) if ((s = *stringp) == NULL) return NULL; + l = strlen(s) + 1; for (tok = s;;) { c = *s++; + l--; while (esc != '\0' && c == esc) { - (void)strcpy(s - 1, s); + memmove(s - 1, s, l); c = *s++; + l--; } spanp = delim; do { if ((sc = *spanp++) == c) { - if (c == 0) + if (c == '\0') s = NULL; else - s[-1] = 0; + s[-1] = '\0'; *stringp = s; return tok; } - } while (sc != 0); + } while (sc != '\0'); } } #endif diff --git a/devel/bmake/files/suff.c b/devel/bmake/files/suff.c index 9cb14875509..88b5e6c330f 100644 --- a/devel/bmake/files/suff.c +++ b/devel/bmake/files/suff.c @@ -1,4 +1,4 @@ -/* $NetBSD: suff.c,v 1.1.1.6 2015/05/19 21:36:44 joerg Exp $ */ +/* $NetBSD: suff.c,v 1.1.1.7 2020/05/24 05:35:53 nia Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: suff.c,v 1.1.1.6 2015/05/19 21:36:44 joerg Exp $"; +static char rcsid[] = "$NetBSD: suff.c,v 1.1.1.7 2020/05/24 05:35:53 nia Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)suff.c 8.4 (Berkeley) 3/21/94"; #else -__RCSID("$NetBSD: suff.c,v 1.1.1.6 2015/05/19 21:36:44 joerg Exp $"); +__RCSID("$NetBSD: suff.c,v 1.1.1.7 2020/05/24 05:35:53 nia Exp $"); #endif #endif /* not lint */ #endif @@ -135,6 +135,7 @@ __RCSID("$NetBSD: suff.c,v 1.1.1.6 2015/05/19 21:36:44 joerg Exp $"); * order to find the node. */ +#include <assert.h> #include <stdio.h> #include "make.h" #include "hash.h" @@ -553,7 +554,20 @@ Suff_ClearSuffixes(void) #endif sufflist = Lst_Init(FALSE); sNum = 0; - suffNull = emptySuff; + if (suffNull) + SuffFree(suffNull); + emptySuff = suffNull = bmake_malloc(sizeof(Suff)); + + suffNull->name = bmake_strdup(""); + suffNull->nameLen = 0; + suffNull->searchPath = Lst_Init(FALSE); + Dir_Concat(suffNull->searchPath, dirSearchPath); + suffNull->children = Lst_Init(FALSE); + suffNull->parents = Lst_Init(FALSE); + suffNull->ref = Lst_Init(FALSE); + suffNull->sNum = sNum++; + suffNull->flags = SUFF_NULL; + suffNull->refCount = 1; } /*- @@ -749,7 +763,7 @@ Suff_AddTransform(char *line) *----------------------------------------------------------------------- */ int -Suff_EndTransform(void *gnp, void *dummy) +Suff_EndTransform(void *gnp, void *dummy MAKE_ATTR_UNUSED) { GNode *gn = (GNode *)gnp; @@ -796,7 +810,7 @@ Suff_EndTransform(void *gnp, void *dummy) fprintf(debug_file, "transformation %s complete\n", gn->name); } - return(dummy ? 0 : 0); + return 0; } /*- @@ -1202,7 +1216,7 @@ SuffAddSrc(void *sp, void *lsp) #ifdef DEBUG_SRC s2->cp = Lst_Init(FALSE); Lst_AtEnd(targ->cp, s2); - fprintf(debug_file, "1 add %x %x to %x:", targ, s2, ls->l); + fprintf(debug_file, "1 add %p %p to %p:", targ, s2, ls->l); Lst_ForEach(ls->l, PrintAddr, NULL); fprintf(debug_file, "\n"); #endif @@ -1220,7 +1234,7 @@ SuffAddSrc(void *sp, void *lsp) #ifdef DEBUG_SRC s2->cp = Lst_Init(FALSE); Lst_AtEnd(targ->cp, s2); - fprintf(debug_file, "2 add %x %x to %x:", targ, s2, ls->l); + fprintf(debug_file, "2 add %p %p to %p:", targ, s2, ls->l); Lst_ForEach(ls->l, PrintAddr, NULL); fprintf(debug_file, "\n"); #endif @@ -1292,14 +1306,14 @@ SuffRemoveSrc(Lst l) free(s->pref); else { #ifdef DEBUG_SRC - LstNode ln = Lst_Member(s->parent->cp, s); - if (ln != NULL) - Lst_Remove(s->parent->cp, ln); + LstNode ln2 = Lst_Member(s->parent->cp, s); + if (ln2 != NULL) + Lst_Remove(s->parent->cp, ln2); #endif --s->parent->children; } #ifdef DEBUG_SRC - fprintf(debug_file, "free: [l=%x] p=%x %d\n", l, s, s->children); + fprintf(debug_file, "free: [l=%p] p=%p %d\n", l, s, s->children); Lst_Destroy(s->cp, NULL); #endif Lst_Remove(l, ln); @@ -1310,7 +1324,7 @@ SuffRemoveSrc(Lst l) } #ifdef DEBUG_SRC else { - fprintf(debug_file, "keep: [l=%x] p=%x %d: ", l, s, s->children); + fprintf(debug_file, "keep: [l=%p] p=%p %d: ", l, s, s->children); Lst_ForEach(s->cp, PrintAddr, NULL); fprintf(debug_file, "\n"); } @@ -1359,7 +1373,7 @@ SuffFindThem(Lst srcs, Lst slst) */ if (Targ_FindNode(s->file, TARG_NOCREATE) != NULL) { #ifdef DEBUG_SRC - fprintf(debug_file, "remove %x from %x\n", s, srcs); + fprintf(debug_file, "remove %p from %p\n", s, srcs); #endif rs = s; break; @@ -1368,7 +1382,7 @@ SuffFindThem(Lst srcs, Lst slst) if ((ptr = Dir_FindFile(s->file, s->suff->searchPath)) != NULL) { rs = s; #ifdef DEBUG_SRC - fprintf(debug_file, "remove %x from %x\n", s, srcs); + fprintf(debug_file, "remove %p from %p\n", s, srcs); #endif free(ptr); break; @@ -1484,7 +1498,7 @@ SuffFindCmds(Src *targ, Lst slst) targ->children += 1; #ifdef DEBUG_SRC ret->cp = Lst_Init(FALSE); - fprintf(debug_file, "3 add %x %x\n", targ, ret); + fprintf(debug_file, "3 add %p %p\n", targ, ret); Lst_AtEnd(targ->cp, ret); #endif Lst_AtEnd(slst, ret); @@ -1543,7 +1557,7 @@ SuffExpandChildren(LstNode cln, GNode *pgn) if (DEBUG(SUFF)) { fprintf(debug_file, "Expanding \"%s\"...", cgn->name); } - cp = Var_Subst(NULL, cgn->name, pgn, TRUE); + cp = Var_Subst(NULL, cgn->name, pgn, VARF_UNDEFERR|VARF_WANTRES); if (cp != NULL) { Lst members = Lst_Init(FALSE); @@ -1596,14 +1610,14 @@ SuffExpandChildren(LstNode cln, GNode *pgn) int len; void *freeIt; - junk = Var_Parse(cp, pgn, TRUE, &len, &freeIt); + junk = Var_Parse(cp, pgn, VARF_UNDEFERR|VARF_WANTRES, + &len, &freeIt); if (junk != var_Error) { cp += len - 1; } - if (freeIt) - free(freeIt); - } else if (*cp == '\\' && *cp != '\0') { + free(freeIt); + } else if (*cp == '\\' && cp[1] != '\0') { /* * Escaped something -- skip over it */ @@ -1881,6 +1895,7 @@ SuffFindArchiveDeps(GNode *gn, Lst slst) TARGET, /* Must be first */ PREFIX, /* Must be second */ }; + LstNode ln, nln; /* Next suffix node to check */ int i; /* Index into copy and vals */ Suff *ms; /* Suffix descriptor for member */ char *name; /* Start of member's name */ @@ -1892,6 +1907,13 @@ SuffFindArchiveDeps(GNode *gn, Lst slst) eoarch = strchr(gn->name, '('); eoname = strchr(eoarch, ')'); + /* + * Caller guarantees the format `libname(member)', via + * Arch_ParseArchive. + */ + assert(eoarch != NULL); + assert(eoname != NULL); + *eoname = '\0'; /* Nuke parentheses during suffix search */ *eoarch = '\0'; /* So a suffix can be found */ @@ -1920,8 +1942,7 @@ SuffFindArchiveDeps(GNode *gn, Lst slst) for (i = (sizeof(copy)/sizeof(copy[0]))-1; i >= 0; i--) { char *p1; Var_Set(copy[i], Var_Value(copy[i], mem, &p1), gn, 0); - if (p1) - free(p1); + free(p1); } @@ -1943,6 +1964,20 @@ SuffFindArchiveDeps(GNode *gn, Lst slst) Var_Set(MEMBER, name, gn, 0); Var_Set(ARCHIVE, gn->name, gn, 0); + /* + * Set $@ for compatibility with other makes + */ + Var_Set(TARGET, gn->name, gn, 0); + + /* + * Now we've got the important local variables set, expand any sources + * that still contain variables or wildcards in their names. + */ + for (ln = Lst_First(gn->children); ln != NULL; ln = nln) { + nln = Lst_Succ(ln); + SuffExpandChildren(ln, gn); + } + if (ms != NULL) { /* * Member has a known suffix, so look for a transformation rule from @@ -1950,7 +1985,6 @@ SuffFindArchiveDeps(GNode *gn, Lst slst) * through the entire list, we just look at suffixes to which the * member's suffix may be transformed... */ - LstNode ln; SuffixCmpData sd; /* Search string data */ /* @@ -1990,9 +2024,10 @@ SuffFindArchiveDeps(GNode *gn, Lst slst) /* * Flag the member as such so we remember to look in the archive for - * its modification time. + * its modification time. The OP_JOIN | OP_MADE is needed because this + * target should never get made. */ - mem->type |= OP_MEMBER; + mem->type |= OP_MEMBER | OP_JOIN | OP_MADE; } /*- @@ -2524,32 +2559,18 @@ Suff_SetNull(char *name) void Suff_Init(void) { - sufflist = Lst_Init(FALSE); #ifdef CLEANUP suffClean = Lst_Init(FALSE); #endif srclist = Lst_Init(FALSE); transforms = Lst_Init(FALSE); - sNum = 0; /* * Create null suffix for single-suffix rules (POSIX). The thing doesn't * actually go on the suffix list or everyone will think that's its * suffix. */ - emptySuff = suffNull = bmake_malloc(sizeof(Suff)); - - suffNull->name = bmake_strdup(""); - suffNull->nameLen = 0; - suffNull->searchPath = Lst_Init(FALSE); - Dir_Concat(suffNull->searchPath, dirSearchPath); - suffNull->children = Lst_Init(FALSE); - suffNull->parents = Lst_Init(FALSE); - suffNull->ref = Lst_Init(FALSE); - suffNull->sNum = sNum++; - suffNull->flags = SUFF_NULL; - suffNull->refCount = 1; - + Suff_ClearSuffixes(); } @@ -2582,14 +2603,15 @@ Suff_End(void) /********************* DEBUGGING FUNCTIONS **********************/ -static int SuffPrintName(void *s, void *dummy) +static int SuffPrintName(void *s, void *dummy MAKE_ATTR_UNUSED) { + fprintf(debug_file, "%s ", ((Suff *)s)->name); - return (dummy ? 0 : 0); + return 0; } static int -SuffPrintSuff(void *sp, void *dummy) +SuffPrintSuff(void *sp, void *dummy MAKE_ATTR_UNUSED) { Suff *s = (Suff *)sp; int flags; @@ -2627,11 +2649,11 @@ SuffPrintSuff(void *sp, void *dummy) fprintf(debug_file, "#\tSearch Path: "); Dir_PrintPath(s->searchPath); fputc('\n', debug_file); - return (dummy ? 0 : 0); + return 0; } static int -SuffPrintTrans(void *tp, void *dummy) +SuffPrintTrans(void *tp, void *dummy MAKE_ATTR_UNUSED) { GNode *t = (GNode *)tp; @@ -2640,7 +2662,7 @@ SuffPrintTrans(void *tp, void *dummy) fputc('\n', debug_file); Lst_ForEach(t->commands, Targ_PrintCmd, NULL); fputc('\n', debug_file); - return(dummy ? 0 : 0); + return 0; } void diff --git a/devel/bmake/files/targ.c b/devel/bmake/files/targ.c index e08ce1607bf..bbe2405519b 100644 --- a/devel/bmake/files/targ.c +++ b/devel/bmake/files/targ.c @@ -1,4 +1,4 @@ -/* $NetBSD: targ.c,v 1.1.1.7 2015/05/19 21:36:44 joerg Exp $ */ +/* $NetBSD: targ.c,v 1.1.1.8 2020/05/24 05:35:53 nia Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: targ.c,v 1.1.1.7 2015/05/19 21:36:44 joerg Exp $"; +static char rcsid[] = "$NetBSD: targ.c,v 1.1.1.8 2020/05/24 05:35:53 nia Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)targ.c 8.2 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: targ.c,v 1.1.1.7 2015/05/19 21:36:44 joerg Exp $"); +__RCSID("$NetBSD: targ.c,v 1.1.1.8 2020/05/24 05:35:53 nia Exp $"); #endif #endif /* not lint */ #endif @@ -292,10 +292,8 @@ TargFreeGN(void *gnp) free(gn->name); - if (gn->uname) - free(gn->uname); - if (gn->path) - free(gn->path); + free(gn->uname); + free(gn->path); /* gn->fname points to name allocated when file was opened, don't free */ Lst_Destroy(gn->iParents, NULL); @@ -523,10 +521,10 @@ TargPrintName(void *gnp, void *pflags MAKE_ATTR_UNUSED) int -Targ_PrintCmd(void *cmd, void *dummy) +Targ_PrintCmd(void *cmd, void *dummy MAKE_ATTR_UNUSED) { fprintf(debug_file, "\t%s\n", (char *)cmd); - return (dummy ? 0 : 0); + return 0; } /*- diff --git a/devel/bmake/files/unit-tests/Makefile b/devel/bmake/files/unit-tests/Makefile new file mode 100644 index 00000000000..4c91e6697c8 --- /dev/null +++ b/devel/bmake/files/unit-tests/Makefile @@ -0,0 +1,155 @@ +# $Id: Makefile,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# $NetBSD: Makefile,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# Unit tests for make(1) +# The main targets are: +# +# all: run all the tests +# test: run 'all', and compare to expected results +# accept: move generated output to expected results +# +# Adding a test case. +# Each feature should get its own set of tests in its own suitably +# named makefile (*.mk), with its own set of expected results (*.exp), +# and it should be added to the TESTNAMES list. +# + +.MAIN: all + +.-include "Makefile.config" + +UNIT_TESTS:= ${.PARSEDIR} +.PATH: ${UNIT_TESTS} + +# Each test is in a sub-makefile. +# Keep the list sorted. +TESTNAMES= \ + comment \ + cond-late \ + cond1 \ + cond2 \ + dollar \ + doterror \ + dotwait \ + error \ + export \ + export-all \ + export-env \ + forloop \ + forsubst \ + hash \ + include-main \ + misc \ + moderrs \ + modmatch \ + modmisc \ + modorder \ + modts \ + modword \ + order \ + posix \ + qequals \ + sunshcmd \ + sysv \ + ternary \ + unexport \ + unexport-env \ + varcmd \ + varmisc \ + varmod-edge \ + varquote \ + varshell + +# these tests were broken by referting POSIX chanegs +STRICT_POSIX_TESTS = \ + escape \ + impsrc \ + phony-end \ + posix1 \ + suffixes + +# Override make flags for certain tests +flags.doterror= +flags.order=-j1 + +OUTFILES= ${TESTNAMES:S/$/.out/} + +all: ${OUTFILES} + +CLEANFILES += *.rawout *.out *.status *.tmp *.core *.tmp +CLEANFILES += obj*.[och] lib*.a # posix1.mk +CLEANFILES += issue* .[ab]* # suffixes.mk +CLEANRECURSIVE += dir dummy # posix1.mk + +clean: + rm -f ${CLEANFILES} +.if !empty(CLEANRECURSIVE) + rm -rf ${CLEANRECURSIVE} +.endif + +TEST_MAKE?= ${.MAKE} +TOOL_SED?= sed +TOOL_TR?= tr +TOOL_DIFF?= diff + +.if defined(.PARSEDIR) +# ensure consistent results from sort(1) +LC_ALL= C +LANG= C +.export LANG LC_ALL +.endif + +# some tests need extra post-processing +SED_CMDS.varshell = -e 's,^[a-z]*sh: ,,' \ + -e '/command/s,No such.*,not found,' + +# the tests are actually done with sub-makes. +.SUFFIXES: .mk .rawout .out +.mk.rawout: + @echo ${TEST_MAKE} ${flags.${.TARGET:R}:U-k} -f ${.IMPSRC} + -@cd ${.OBJDIR} && \ + { ${TEST_MAKE} ${flags.${.TARGET:R}:U-k} -f ${.IMPSRC} \ + 2>&1 ; echo $$? >${.TARGET:R}.status ; } > ${.TARGET}.tmp + @mv ${.TARGET}.tmp ${.TARGET} + +# We always pretend .MAKE was called 'make' +# and strip ${.CURDIR}/ from the output +# and replace anything after 'stopped in' with unit-tests +# so the results can be compared. +.rawout.out: + @echo postprocess ${.TARGET} + @${TOOL_SED} -e 's,^${TEST_MAKE:T:C/\./\\\./g}[][0-9]*:,make:,' \ + -e 's,${TEST_MAKE:C/\./\\\./g},make,' \ + -e '/stopped/s, /.*, unit-tests,' \ + -e 's,${.CURDIR:C/\./\\\./g}/,,g' \ + -e 's,${UNIT_TESTS:C/\./\\\./g}/,,g' ${SED_CMDS.${.TARGET:T:R}} \ + < ${.IMPSRC} > ${.TARGET}.tmp + @echo "exit status `cat ${.TARGET:R}.status`" >> ${.TARGET}.tmp + @mv ${.TARGET}.tmp ${.TARGET} + +# Compare all output files +test: ${OUTFILES} .PHONY + @failed= ; \ + for test in ${TESTNAMES}; do \ + ${TOOL_DIFF} ${DIFF_FLAGS} ${UNIT_TESTS}/$${test}.exp $${test}.out \ + || failed="$${failed}$${failed:+ }$${test}" ; \ + done ; \ + if [ -n "$${failed}" ]; then \ + echo "Failed tests: $${failed}" ; false ; \ + else \ + echo "All tests passed" ; \ + fi + +accept: + @for test in ${TESTNAMES}; do \ + cmp -s ${UNIT_TESTS}/$${test}.exp $${test}.out \ + || { echo "Replacing $${test}.exp" ; \ + cp $${test}.out ${UNIT_TESTS}/$${test}.exp ; } \ + done + +.if exists(${TEST_MAKE}) +${TESTNAMES:S/$/.rawout/}: ${TEST_MAKE} +.endif + +.-include <obj.mk> diff --git a/devel/bmake/files/unit-tests/Makefile.config.in b/devel/bmake/files/unit-tests/Makefile.config.in new file mode 100644 index 00000000000..0993ab0a224 --- /dev/null +++ b/devel/bmake/files/unit-tests/Makefile.config.in @@ -0,0 +1,4 @@ +# $Id: Makefile.config.in,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ + +srcdir= @srcdir@ +DIFF_FLAGS?= @diff_u@ diff --git a/devel/bmake/files/unit-tests/cond-late.exp b/devel/bmake/files/unit-tests/cond-late.exp new file mode 100644 index 00000000000..3717b088c64 --- /dev/null +++ b/devel/bmake/files/unit-tests/cond-late.exp @@ -0,0 +1,3 @@ +yes +no +exit status 0 diff --git a/devel/bmake/files/unit-tests/cond-late.mk b/devel/bmake/files/unit-tests/cond-late.mk new file mode 100644 index 00000000000..efc6f829133 --- /dev/null +++ b/devel/bmake/files/unit-tests/cond-late.mk @@ -0,0 +1,23 @@ +# $NetBSD: cond-late.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# Using the :? modifier, variable expressions can contain conditional +# expressions that are evaluated late. Any variables appearing in these +# conditions are expanded before parsing the condition. This is +# different from many other places. +# +# Because of this, variables that are used in these lazy conditions +# should not contain double-quotes, or the parser will probably fail. +# +# They should also not contain operators like == or <, since these are +# actually interpreted as these operators. This is demonstrated below. +# +# If the order of evaluation were to change to first parse the condition +# and then expand the variables, the output would change from the +# current "yes no" to "yes yes", since both variables are non-empty. + +COND.true= "yes" == "yes" +COND.false= "yes" != "yes" + +all: + @echo ${ ${COND.true} :?yes:no} + @echo ${ ${COND.false} :?yes:no} diff --git a/devel/bmake/files/unit-tests/cond2.mk b/devel/bmake/files/unit-tests/cond2.mk index e396fc308e7..1d6125af4a0 100644 --- a/devel/bmake/files/unit-tests/cond2.mk +++ b/devel/bmake/files/unit-tests/cond2.mk @@ -1,4 +1,4 @@ -# $Id: cond2.mk,v 1.1.1.1 2015/05/19 21:36:45 joerg Exp $ +# $Id: cond2.mk,v 1.1.1.2 2020/05/24 05:35:53 nia Exp $ TEST_UNAME_S= NetBSD @@ -21,5 +21,9 @@ Y!= echo TEST_NOT_SET is empty or not defined >&2; echo Y= oops .endif +.if defined(.NDEF) && ${.NDEF} > 0 +Z= yes +.endif + all: @echo $@ diff --git a/devel/bmake/files/unit-tests/dollar.exp b/devel/bmake/files/unit-tests/dollar.exp new file mode 100644 index 00000000000..496adc02f15 --- /dev/null +++ b/devel/bmake/files/unit-tests/dollar.exp @@ -0,0 +1,51 @@ + +Printing dollar from literals and variables + +To survive the parser, a dollar character must be doubled. + 1 dollar literal => <single-quote-var-value> + 1 dollar literal eol => <> + 2 dollar literal => <$> + 4 dollar literal => <$$> +Some hungry part of make eats all the dollars after a :U modifier. + 1 dollar default => <> + 2 dollar default => <> + 4 dollar default => <> +This works as expected. + 1 dollar variable => <> + 2 dollar variable => <$> + 4 dollar variable => <$$> +Some hungry part of make eats all the dollars after a :U modifier. + 1 dollar var-default => <> + 2 dollar var-default => <$> + 4 dollar var-default => <$$> + +Dollar in :S pattern + + S,$,word, => <$XYword> + S,$X,word, => <$XY> + S,$$X,word, => <$XY> + S,$$$X,word, => <$XY> + S,$X,replaced, => <replaced> + S,$$X,replaced, => <replaced> + S,$$$X,replaced, => <replaced> + +Dollar in :C character class + +The A is replaced because the $$ is reduced to a single $, +which is then resolved to the variable X with the value VAR_X. +The effective character class becomes [VAR_XY]. + C,[$$XY],<&>,g => <$<A><X><Y>> + +Dollar in :C pattern + +For some reason, multiple dollars are folded into one. + C,$,dollar,g => <> + C,$$,dollar,g => <> + +Dollar in :S replacement + +For some reason, multiple dollars are folded into one. + S,word,a$Xo, => <aVAR_Xo> + S,word,a$$Xo, => <aVAR_Xo> + S,word,a$$$Xo, => <aVAR_Xo> +exit status 0 diff --git a/devel/bmake/files/unit-tests/dollar.mk b/devel/bmake/files/unit-tests/dollar.mk new file mode 100644 index 00000000000..faa8e622802 --- /dev/null +++ b/devel/bmake/files/unit-tests/dollar.mk @@ -0,0 +1,81 @@ +# $NetBSD: dollar.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# Test the various places where a dollar character can appear and +# see what happens. There are lots of surprises here. +# + +LIST= plain 'single' "double" 'mix'"ed" back\ slashed +WORD= word + +DOLLAR1= $ +DOLLAR2= $$ +DOLLAR4= $$$$ + +X= VAR_X +DOLLAR_XY= $$XY +DOLLAR_AXY= $$AXY + +H= @header() { printf '\n%s\n\n' "$$*"; }; header +T= @testcase() { printf '%23s => <%s>\n' "$$@"; }; testcase +C= @comment() { printf '%s\n' "$$*"; }; comment + +# These variable values are not accessed. +# The trailing dollar in the '1 dollar literal eol' test case accesses +# the empty variable instead, which is always guaranteed to be empty. +${:U }= space-var-value +${:U${.newline}}= newline-var-value +# But this one is accessed. +${:U'}= single-quote-var-value' + +all: + $H 'Printing dollar from literals and variables' + + $C 'To survive the parser, a dollar character must be doubled.' + $T '1 dollar literal' '$' + $T '1 dollar literal eol' ''$ + $T '2 dollar literal' '$$' + $T '4 dollar literal' '$$$$' + + $C 'Some hungry part of make eats all the dollars after a :U modifier.' + $T '1 dollar default' ''${:U$:Q} + $T '2 dollar default' ''${:U$$:Q} + $T '4 dollar default' ''${:U$$$$:Q} + + $C 'This works as expected.' + $T '1 dollar variable' ''${DOLLAR1:Q} + $T '2 dollar variable' ''${DOLLAR2:Q} + $T '4 dollar variable' ''${DOLLAR4:Q} + + $C 'Some hungry part of make eats all the dollars after a :U modifier.' + $T '1 dollar var-default' ''${:U${DOLLAR1}:Q} + $T '2 dollar var-default' ''${:U${DOLLAR2}:Q} + $T '4 dollar var-default' ''${:U${DOLLAR4}:Q} + + $H 'Dollar in :S pattern' + + $T 'S,$$,word,' ''${DOLLAR_XY:S,$,word,:Q} + $T 'S,$$X,word,' ''${DOLLAR_XY:S,$X,word,:Q} + $T 'S,$$$$X,word,' ''${DOLLAR_XY:S,$$X,word,:Q} + $T 'S,$$$$$$X,word,' ''${DOLLAR_XY:S,$$$X,word,:Q} + + $T 'S,$$X,replaced,' ''${X:S,$X,replaced,:Q} + $T 'S,$$$$X,replaced,' ''${X:S,$$X,replaced,:Q} + $T 'S,$$$$$$X,replaced,' ''${X:S,$$$X,replaced,:Q} + + $H 'Dollar in :C character class' + + $C 'The A is replaced because the $$$$ is reduced to a single $$,' + $C 'which is then resolved to the variable X with the value VAR_X.' + $C 'The effective character class becomes [VAR_XY].' + $T 'C,[$$$$XY],<&>,g' ''${DOLLAR_AXY:C,[$$XY],<&>,g:Q} + + $H 'Dollar in :C pattern' + $C 'For some reason, multiple dollars are folded into one.' + $T 'C,$$,dollar,g' ''${DOLLAR:C,$,dollar,g:Q} + $T 'C,$$$$,dollar,g' ''${DOLLAR:C,$$,dollar,g:Q} + + $H 'Dollar in :S replacement' + $C 'For some reason, multiple dollars are folded into one.' + $T 'S,word,a$$Xo,' ''${WORD:S,word,a$Xo,:Q} + $T 'S,word,a$$$$Xo,' ''${WORD:S,word,a$$Xo,:Q} + $T 'S,word,a$$$$$$Xo,' ''${WORD:S,word,a$$$Xo,:Q} diff --git a/devel/bmake/files/unit-tests/doterror.exp b/devel/bmake/files/unit-tests/doterror.exp index 0447a519344..5655644c32e 100644 --- a/devel/bmake/files/unit-tests/doterror.exp +++ b/devel/bmake/files/unit-tests/doterror.exp @@ -1,9 +1,9 @@ At first, I am happy and now: sad -.ERROR: Looks like 'sad' is upset. *** Error code 1 Stop. make: stopped in unit-tests +.ERROR: Looks like 'sad' is upset. exit status 1 diff --git a/devel/bmake/files/unit-tests/dotwait.exp b/devel/bmake/files/unit-tests/dotwait.exp index 6bf96e301c1..bdc0a0eb150 100644 --- a/devel/bmake/files/unit-tests/dotwait.exp +++ b/devel/bmake/files/unit-tests/dotwait.exp @@ -22,9 +22,9 @@ shared.2.1 shared.2.1 shared.2.99 shared.2.99 +cycle.1.99 +cycle.1.99 make: Graph cycles through `cycle.2.99' make: Graph cycles through `cycle.2.98' make: Graph cycles through `cycle.2.97' -cycle.1.99 -cycle.1.99 exit status 0 diff --git a/devel/bmake/files/unit-tests/dotwait.mk b/devel/bmake/files/unit-tests/dotwait.mk index b6cde7d31de..463d30625f8 100644 --- a/devel/bmake/files/unit-tests/dotwait.mk +++ b/devel/bmake/files/unit-tests/dotwait.mk @@ -1,4 +1,4 @@ -# $NetBSD: dotwait.mk,v 1.1.1.1 2015/05/19 21:36:45 joerg Exp $ +# $NetBSD: dotwait.mk,v 1.1.1.2 2020/05/24 05:35:53 nia Exp $ THISMAKEFILE:= ${.PARSEDIR}/${.PARSEFILE} @@ -11,7 +11,7 @@ PAUSE= sleep 1 # Ignore "--- target ---" lines printed by parallel make. all: .for t in ${TESTS} - @${.MAKE} -f ${THISMAKEFILE} -j4 $t | grep -v "^--- " + @${.MAKE} -f ${THISMAKEFILE} -j4 $t 2>&1 | grep -v "^--- " .endfor # diff --git a/devel/bmake/files/unit-tests/escape.mk b/devel/bmake/files/unit-tests/escape.mk index ede9d9e7254..a48ea29f8be 100644 --- a/devel/bmake/files/unit-tests/escape.mk +++ b/devel/bmake/files/unit-tests/escape.mk @@ -1,4 +1,4 @@ -# $Id: escape.mk,v 1.1.1.1 2015/05/19 21:36:45 joerg Exp $ +# $Id: escape.mk,v 1.1.1.2 2020/05/24 05:35:53 nia Exp $ # # Test backslash escaping. @@ -35,8 +35,8 @@ # Also, our practice is that an even number of backslashes before a # newline in a variable assignment simply stores the backslashes as part # of the value, and treats the newline as though it was not escaped. -# Similarly, ann even number of backslashes before a newline in a -# command simply uses the backslashes as part of the command test, but +# Similarly, an even number of backslashes before a newline in a +# command simply uses the backslashes as part of the command, but # does not escape the newline. This is compatible with GNU make. all: .PHONY diff --git a/devel/bmake/files/unit-tests/export-env.exp b/devel/bmake/files/unit-tests/export-env.exp index 6221232a2a1..8a779e6aff0 100644 --- a/devel/bmake/files/unit-tests/export-env.exp +++ b/devel/bmake/files/unit-tests/export-env.exp @@ -2,8 +2,10 @@ make: UT_TEST=export-env.mk UT_ENV=not-exported UT_EXP=not-exported +UT_LIT=literal export-env.mk env: UT_TEST=export-env.mk UT_ENV=exported UT_EXP=exported +UT_LIT=literal ${UT_TEST} exit status 0 diff --git a/devel/bmake/files/unit-tests/export-env.mk b/devel/bmake/files/unit-tests/export-env.mk index 3832e2a2e27..aedcc7b38a3 100644 --- a/devel/bmake/files/unit-tests/export-env.mk +++ b/devel/bmake/files/unit-tests/export-env.mk @@ -1,4 +1,4 @@ -# $Id: export-env.mk,v 1.1.1.1 2015/05/19 21:36:45 joerg Exp $ +# $Id: export-env.mk,v 1.1.1.2 2020/05/24 05:35:53 nia Exp $ # our normal .export, subsequent changes affect the environment UT_TEST=this @@ -15,9 +15,12 @@ UT_EXP=before-export export UT_EXP=exported UT_EXP=not-exported +UT_LIT= literal ${UT_TEST} +.export-literal UT_LIT + all: - @echo make:; ${UT_TEST UT_ENV UT_EXP:L:@v@echo $v=${$v};@} - @echo env:; ${UT_TEST UT_ENV UT_EXP:L:@v@echo $v=$${$v};@} + @echo make:; ${UT_TEST UT_ENV UT_EXP UT_LIT:L:@v@echo $v=${$v};@} + @echo env:; ${UT_TEST UT_ENV UT_EXP UT_LIT:L:@v@echo $v=$${$v};@} diff --git a/devel/bmake/files/unit-tests/forloop.exp b/devel/bmake/files/unit-tests/forloop.exp index df14b751224..99845619073 100644 --- a/devel/bmake/files/unit-tests/forloop.exp +++ b/devel/bmake/files/unit-tests/forloop.exp @@ -7,12 +7,13 @@ x=-I"This or that" x=-Ithat x="-DTHIS=\"this and that\"" cfl=-I/this -I"This or that" -Ithat "-DTHIS=\"this and that\"" +newline-item=(a) a=one b="two and three" a=four b="five" a=ONE b="TWO AND THREE" a=FOUR b="FIVE" We expect an error next: -make: "forloop.mk" line 38: Wrong number of words (9) in .for substitution list with 2 vars +make: "forloop.mk" line 46: Wrong number of words (9) in .for substitution list with 2 vars make: Fatal errors encountered -- cannot continue make: stopped in unit-tests OK diff --git a/devel/bmake/files/unit-tests/forloop.mk b/devel/bmake/files/unit-tests/forloop.mk index ae693438b94..985ccaf964b 100644 --- a/devel/bmake/files/unit-tests/forloop.mk +++ b/devel/bmake/files/unit-tests/forloop.mk @@ -1,4 +1,4 @@ -# $Id: forloop.mk,v 1.1.1.1 2015/05/19 21:36:45 joerg Exp $ +# $Id: forloop.mk,v 1.1.1.2 2020/05/24 05:35:53 nia Exp $ all: for-loop @@ -33,7 +33,15 @@ X!= echo 'cfl=${cfl}' >&2; echo .for a b in ${EMPTY} X!= echo 'a=$a b=$b' >&2; echo .endfor -.endif + +# Since at least 1993, iteration stops at the first newline. +# Back then, the .newline variable didn't exist, therefore it was unlikely +# that a newline ever occured. +.for var in a${.newline}b${.newline}c +X!= echo 'newline-item=('${var:Q}')' 1>&2; echo +.endfor + +.endif # for-fail .for a b in ${LIST} ${LIST:tu} ${XTRA_LIST} X!= echo 'a=$a b=$b' >&2; echo diff --git a/devel/bmake/files/unit-tests/include-main.exp b/devel/bmake/files/unit-tests/include-main.exp new file mode 100644 index 00000000000..7a55c6e97dc --- /dev/null +++ b/devel/bmake/files/unit-tests/include-main.exp @@ -0,0 +1,6 @@ +main-before-ok +sub-before-ok +subsub-ok +sub-after-fail(include-sub.mk) +main-after-fail(include-sub.mk) +exit status 0 diff --git a/devel/bmake/files/unit-tests/include-main.mk b/devel/bmake/files/unit-tests/include-main.mk new file mode 100644 index 00000000000..cb333ef5211 --- /dev/null +++ b/devel/bmake/files/unit-tests/include-main.mk @@ -0,0 +1,30 @@ +# $NetBSD: include-main.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# Demonstrates that the .INCLUDEDFROMFILE magic variable does not behave +# as described in the manual page. +# +# The manual page says that it is the "filename of the file this Makefile +# was included from", while in reality it is the "filename in which the +# latest .include happened". +# + +.if !defined(.INCLUDEDFROMFILE) +LOG+= main-before-ok +.else +. for f in ${.INCLUDEDFROMFILE} +LOG+= main-before-fail\(${f:Q}\) +. endfor +.endif + +.include "include-sub.mk" + +.if !defined(.INCLUDEDFROMFILE) +LOG+= main-after-ok +.else +. for f in ${.INCLUDEDFROMFILE} +LOG+= main-after-fail\(${f:Q}\) +. endfor +.endif + +all: + @printf '%s\n' ${LOG} diff --git a/devel/bmake/files/unit-tests/include-sub.mk b/devel/bmake/files/unit-tests/include-sub.mk new file mode 100644 index 00000000000..2bed3465966 --- /dev/null +++ b/devel/bmake/files/unit-tests/include-sub.mk @@ -0,0 +1,17 @@ +# $NetBSD: include-sub.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ + +.if ${.INCLUDEDFROMFILE} == "include-main.mk" +LOG+= sub-before-ok +.else +LOG+= sub-before-fail +.endif + +.include "include-subsub.mk" + +.if ${.INCLUDEDFROMFILE} == "include-main.mk" +LOG+= sub-after-ok +.else +. for f in ${.INCLUDEDFROMFILE} +LOG+= sub-after-fail\(${f:Q}\) +. endfor +.endif diff --git a/devel/bmake/files/unit-tests/include-subsub.mk b/devel/bmake/files/unit-tests/include-subsub.mk new file mode 100644 index 00000000000..87d3e371366 --- /dev/null +++ b/devel/bmake/files/unit-tests/include-subsub.mk @@ -0,0 +1,7 @@ +# $NetBSD: include-subsub.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ + +.if ${.INCLUDEDFROMFILE:T} == "include-sub.mk" +LOG+= subsub-ok +.else +LOG+= subsub-fail +.endif diff --git a/devel/bmake/files/unit-tests/modmatch.exp b/devel/bmake/files/unit-tests/modmatch.exp index fcaf6c02ed6..a7bf8b748f5 100644 --- a/devel/bmake/files/unit-tests/modmatch.exp +++ b/devel/bmake/files/unit-tests/modmatch.exp @@ -14,4 +14,7 @@ LIB=e X_LIBS:M${LIB${LIB:tu}} is "/tmp/libe.a" LIB=e X_LIBS:M*/lib${LIB}.a is "/tmp/libe.a" LIB=e X_LIBS:M*/lib${LIB}.a:tu is "/TMP/LIBE.A" Mscanner=OK +Upper=One Two Three Four +Lower=five six seven +nose=One Three five exit status 0 diff --git a/devel/bmake/files/unit-tests/modmatch.mk b/devel/bmake/files/unit-tests/modmatch.mk index 48a1befb58b..45199287acd 100644 --- a/devel/bmake/files/unit-tests/modmatch.mk +++ b/devel/bmake/files/unit-tests/modmatch.mk @@ -15,7 +15,9 @@ res = no res = OK .endif -all: +all: show-libs check-cclass + +show-libs: @for x in $X; do ${.MAKE} -f ${MAKEFILE} show LIB=$$x; done @echo "Mscanner=${res}" @@ -23,3 +25,10 @@ show: @echo 'LIB=${LIB} X_LIBS:M$${LIB$${LIB:tu}} is "${X_LIBS:M${LIB${LIB:tu}}}"' @echo 'LIB=${LIB} X_LIBS:M*/lib$${LIB}.a is "${X_LIBS:M*/lib${LIB}.a}"' @echo 'LIB=${LIB} X_LIBS:M*/lib$${LIB}.a:tu is "${X_LIBS:M*/lib${LIB}.a:tu}"' + +LIST= One Two Three Four five six seven + +check-cclass: + @echo Upper=${LIST:M[A-Z]*} + @echo Lower=${LIST:M[^A-Z]*} + @echo nose=${LIST:M[^s]*[ex]} diff --git a/devel/bmake/files/unit-tests/modorder.mk b/devel/bmake/files/unit-tests/modorder.mk index 441a3da5ad2..3070d340e1a 100644 --- a/devel/bmake/files/unit-tests/modorder.mk +++ b/devel/bmake/files/unit-tests/modorder.mk @@ -1,4 +1,4 @@ -# $NetBSD: modorder.mk,v 1.1.1.1 2015/05/19 21:36:45 joerg Exp $ +# $NetBSD: modorder.mk,v 1.1.1.2 2020/05/24 05:35:53 nia Exp $ LIST= one two three four five six seven eight nine ten LISTX= ${LIST:Ox} @@ -12,8 +12,9 @@ all: @echo "LIST:O = ${LIST:O}" # Note that 1 in every 10! trials two independently generated # randomized orderings will be the same. The test framework doesn't - # support checking probabilistic output, so we accept that the test - # will incorrectly fail with probability 2.8E-7. + # support checking probabilistic output, so we accept that each of the + # 3 :Ox tests will incorrectly fail with probability 2.756E-7, which + # lets the whole test fail once in 1.209.600 runs, on average. @echo "LIST:Ox = `test '${LIST:Ox}' != '${LIST:Ox}' ${TEST_RESULT}`" @echo "LIST:O:Ox = `test '${LIST:O:Ox}' != '${LIST:O:Ox}' ${TEST_RESULT}`" @echo "LISTX = `test '${LISTX}' != '${LISTX}' ${TEST_RESULT}`" diff --git a/devel/bmake/files/unit-tests/modts.exp b/devel/bmake/files/unit-tests/modts.exp index cf3c91d43c0..338964963a8 100644 --- a/devel/bmake/files/unit-tests/modts.exp +++ b/devel/bmake/files/unit-tests/modts.exp @@ -23,10 +23,16 @@ THREE FOUR FIVE SIX" +LIST:ts/xa:tu="ONE +TWO +THREE +FOUR +FIVE +SIX" make: Bad modifier `:tx' for LIST LIST:tx="}" -make: Bad modifier `:ts\x' for LIST -LIST:ts/x:tu="\x:tu}" +make: Bad modifier `:ts\X' for LIST +LIST:ts/x:tu="\X:tu}" FU_mod-ts="a/b/cool" FU_mod-ts:ts:T="cool" == cool? B.${AAA:ts}="Baaa" == Baaa? diff --git a/devel/bmake/files/unit-tests/modts.mk b/devel/bmake/files/unit-tests/modts.mk index 616bd8944f2..e66dc25a2a0 100644 --- a/devel/bmake/files/unit-tests/modts.mk +++ b/devel/bmake/files/unit-tests/modts.mk @@ -12,9 +12,9 @@ all: mod-ts # Use print or printf iff they are builtin. # XXX note that this causes problems, when make decides # there is no need to use a shell, so avoid where possible. -.if ${type print 2> /dev/null || echo:L:sh:Mbuiltin} != "" +.if ${(type print) 2> /dev/null || echo:L:sh:Mbuiltin} != "" PRINT= print -r -- -.elif ${type printf 2> /dev/null || echo:L:sh:Mbuiltin} != "" +.elif ${(type printf) 2> /dev/null || echo:L:sh:Mbuiltin} != "" PRINT= printf '%s\n' .else PRINT= echo @@ -36,8 +36,9 @@ mod-ts: @${PRINT} 'LIST:ts/n="${LIST:ts\n}"' @${PRINT} 'LIST:ts/t="${LIST:ts\t}"' @${PRINT} 'LIST:ts/012:tu="${LIST:ts\012:tu}"' + @${PRINT} 'LIST:ts/xa:tu="${LIST:ts\xa:tu}"' @${PRINT} 'LIST:tx="${LIST:tx}"' - @${PRINT} 'LIST:ts/x:tu="${LIST:ts\x:tu}"' + @${PRINT} 'LIST:ts/x:tu="${LIST:ts\X:tu}"' @${PRINT} 'FU_$@="${FU_${@:ts}:ts}"' @${PRINT} 'FU_$@:ts:T="${FU_${@:ts}:ts:T}" == cool?' @${PRINT} 'B.$${AAA:ts}="${B.${AAA:ts}}" == Baaa?' diff --git a/devel/bmake/files/unit-tests/sysv.exp b/devel/bmake/files/unit-tests/sysv.exp index 4cce2de3191..610f97c39e8 100644 --- a/devel/bmake/files/unit-tests/sysv.exp +++ b/devel/bmake/files/unit-tests/sysv.exp @@ -4,4 +4,12 @@ fun fun fun In the Sun +acme +aam.d +sam.c +a%.c +asam.c.c +asam.c +a.c.c + exit status 0 diff --git a/devel/bmake/files/unit-tests/sysv.mk b/devel/bmake/files/unit-tests/sysv.mk index 0eb780f91e9..99a9f4a3bc9 100644 --- a/devel/bmake/files/unit-tests/sysv.mk +++ b/devel/bmake/files/unit-tests/sysv.mk @@ -1,4 +1,4 @@ -# $Id: sysv.mk,v 1.1.1.1 2015/05/19 21:36:45 joerg Exp $ +# $Id: sysv.mk,v 1.1.1.2 2020/05/24 05:35:53 nia Exp $ FOO ?= FOOBAR = ${FOO:=bar} @@ -11,7 +11,7 @@ FUN = ${B}${S}fun SUN = the Sun # we expect nothing when FOO is empty -all: foo fun +all: foo fun sam bla foo: @echo FOOBAR = ${FOOBAR} @@ -24,3 +24,20 @@ fun: @echo ${FUN:${B}${S}fun=fun} @echo ${FUN:${B}${S}%=%} @echo ${In:L:%=% ${SUN}} + + +SAM=sam.c + +sam: + @echo ${SAM:s%.c=acme} + @echo ${SAM:s%.c=a%.d} + @echo ${SAM:s.c=a%.d} + @echo ${SAM:sam.c=a%.c} + @echo ${SAM:%=a%.c} + @echo ${SAM:%.c=a%.c} + @echo ${SAM:sam%=a%.c} + +BLA= + +bla: + @echo $(BLA:%=foo/%x) diff --git a/devel/bmake/files/unit-tests/varcmd.exp b/devel/bmake/files/unit-tests/varcmd.exp index 34dd637f93e..7803c2b4299 100644 --- a/devel/bmake/files/unit-tests/varcmd.exp +++ b/devel/bmake/files/unit-tests/varcmd.exp @@ -1,5 +1,7 @@ default FU=<v>fu</v> FOO=<v>foo</v> VAR=<v></v> two FU=<v>bar</v> FOO=<v>goo</v> VAR=<v></v> +immutable FU='bar' +immutable FOO='goo' three FU=<v>bar</v> FOO=<v>goo</v> VAR=<v></v> four FU=<v>bar</v> FOO=<v>goo</v> VAR=<v>Internal</v> five FU=<v>bar</v> FOO=<v>goo</v> VAR=<v>Internal</v> diff --git a/devel/bmake/files/unit-tests/varcmd.mk b/devel/bmake/files/unit-tests/varcmd.mk index b107a7ccec8..1d6e75c7fb2 100644 --- a/devel/bmake/files/unit-tests/varcmd.mk +++ b/devel/bmake/files/unit-tests/varcmd.mk @@ -1,4 +1,4 @@ -# $Id: varcmd.mk,v 1.1.1.1 2015/05/19 21:36:45 joerg Exp $ +# $Id: varcmd.mk,v 1.1.1.2 2020/05/24 05:35:53 nia Exp $ # # Test behaviour of recursive make and vars set on command line. @@ -15,7 +15,7 @@ show: @echo "${TAG} FU=<v>${FU}</v> FOO=<v>${FOO}</v> VAR=<v>${VAR}</v>" one: show - @${.MAKE} -f ${MAKEFILE} FU=bar FOO=goo two + @${.MAKE} -f ${MAKEFILE} FU=bar FOO+=goo two two: show @${.MAKE} -f ${MAKEFILE} three @@ -24,6 +24,17 @@ three: show @${.MAKE} -f ${MAKEFILE} four +.ifmake two +# this should not work +FU+= oops +FOO+= oops +_FU:= ${FU} +_FOO:= ${FOO} +two: immutable +immutable: + @echo "$@ FU='${_FU}'" + @echo "$@ FOO='${_FOO}'" +.endif .ifmake four VAR=Internal .MAKEOVERRIDES+= VAR diff --git a/devel/bmake/files/unit-tests/varmisc.exp b/devel/bmake/files/unit-tests/varmisc.exp index 1636aafc11e..ffe8f8b867c 100644 --- a/devel/bmake/files/unit-tests/varmisc.exp +++ b/devel/bmake/files/unit-tests/varmisc.exp @@ -1,2 +1,25 @@ +:D expanded when var set +true +TRUE +:U expanded when var undef +true +TRUE +:D skipped if var undef + +:U skipped when var set +is set +:? only lhs when value true +true +TRUE +:? only rhs when value false +false +FALSE +do not evaluate or expand :? if discarding +is set +year=2016 month=04 day=01 +date=20160401 +Version=123.456.789 == 123456789 +Literal=3.4.5 == 3004005 +We have target specific vars exit status 0 diff --git a/devel/bmake/files/unit-tests/varmisc.mk b/devel/bmake/files/unit-tests/varmisc.mk index 47da97329ad..8f23dfec588 100644 --- a/devel/bmake/files/unit-tests/varmisc.mk +++ b/devel/bmake/files/unit-tests/varmisc.mk @@ -1,8 +1,62 @@ -# $Id: varmisc.mk,v 1.1.1.1 2015/05/19 21:36:45 joerg Exp $ +# $Id: varmisc.mk,v 1.1.1.2 2020/05/24 05:35:53 nia Exp $ # # Miscellaneous variable tests. -all: unmatched_var_paren +all: unmatched_var_paren D_true U_true D_false U_false Q_lhs Q_rhs NQ_none \ + strftime cmpv unmatched_var_paren: @echo ${foo::=foo-text} + +True = ${echo true >&2:L:sh}TRUE +False= ${echo false >&2:L:sh}FALSE + +VSET= is set +.undef UNDEF + +U_false: + @echo :U skipped when var set + @echo ${VSET:U${False}} + +D_false: + @echo :D skipped if var undef + @echo ${UNDEF:D${False}} + +U_true: + @echo :U expanded when var undef + @echo ${UNDEF:U${True}} + +D_true: + @echo :D expanded when var set + @echo ${VSET:D${True}} + +Q_lhs: + @echo :? only lhs when value true + @echo ${1:L:?${True}:${False}} + +Q_rhs: + @echo :? only rhs when value false + @echo ${0:L:?${True}:${False}} + +NQ_none: + @echo do not evaluate or expand :? if discarding + @echo ${VSET:U${1:L:?${True}:${False}}} + +April1= 1459494000 + +# slightly contorted syntax to use utc via variable +strftime: + @echo ${year=%Y month=%m day=%d:L:gmtime=1459494000} + @echo date=${%Y%m%d:L:${gmtime=${April1}:L}} + +# big jumps to handle 3 digits per step +M_cmpv.units = 1 1000 1000000 +M_cmpv = S,., ,g:_:range:@i@+ $${_:[-$$i]} \* $${M_cmpv.units:[$$i]}@:S,^,expr 0 ,1:sh + +Version = 123.456.789 +cmpv.only = target specific vars + +cmpv: + @echo Version=${Version} == ${Version:${M_cmpv}} + @echo Literal=3.4.5 == ${3.4.5:L:${M_cmpv}} + @echo We have ${${.TARGET:T}.only} diff --git a/devel/bmake/files/unit-tests/varmod-edge.exp b/devel/bmake/files/unit-tests/varmod-edge.exp new file mode 100644 index 00000000000..b3b2e3a92f9 --- /dev/null +++ b/devel/bmake/files/unit-tests/varmod-edge.exp @@ -0,0 +1,17 @@ +make: Unclosed variable specification (expecting '}') for "" (value "*)") modifier U +make: Unclosed substitution for INP.eq-esc (= missing) +ok M-paren +ok M-mixed +ok M-unescape +ok M-nest-mix +ok M-nest-brk +ok M-pat-err +ok M-bsbs +ok M-bs1-par +ok M-bs2-par +ok M-128 +ok eq-ext +ok eq-q +ok eq-bs +ok eq-esc +exit status 0 diff --git a/devel/bmake/files/unit-tests/varmod-edge.mk b/devel/bmake/files/unit-tests/varmod-edge.mk new file mode 100644 index 00000000000..587f5bd6d94 --- /dev/null +++ b/devel/bmake/files/unit-tests/varmod-edge.mk @@ -0,0 +1,162 @@ +# $NetBSD: varmod-edge.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# Tests for edge cases in variable modifiers. +# +# These tests demonstrate the current implementation in small examples. +# They may contain surprising behavior. +# +# Each test consists of: +# - INP, the input to the test +# - MOD, the expression for testing the modifier +# - EXP, the expected output + +TESTS+= M-paren +INP.M-paren= (parentheses) {braces} (opening closing) () +MOD.M-paren= ${INP.M-paren:M(*)} +EXP.M-paren= (parentheses) () + +# The first closing brace matches the opening parenthesis. +# The second closing brace actually ends the variable expression. +# +# XXX: This is unexpected but rarely occurs in practice. +TESTS+= M-mixed +INP.M-mixed= (paren-brace} ( +MOD.M-mixed= ${INP.M-mixed:M(*}} +EXP.M-mixed= (paren-brace} + +# After the :M modifier has parsed the pattern, only the closing brace +# and the colon are unescaped. The other characters are left as-is. +# To actually see this effect, the backslashes in the :M modifier need +# to be doubled since single backslashes would simply be unescaped by +# Str_Match. +# +# XXX: This is unexpected. The opening brace should also be unescaped. +TESTS+= M-unescape +INP.M-unescape= ({}): \(\{\}\)\: \(\{}\): +MOD.M-unescape= ${INP.M-unescape:M\\(\\{\\}\\)\\:} +EXP.M-unescape= \(\{}\): + +# When the :M and :N modifiers are parsed, the pattern finishes as soon +# as open_parens + open_braces == closing_parens + closing_braces. This +# means that ( and } form a matching pair. +# +# Nested variable expressions are not parsed as such. Instead, only the +# parentheses and braces are counted. This leads to a parse error since +# the nested expression is not "${:U*)}" but only "${:U*)", which is +# missing the closing brace. The expression is evaluated anyway. +# The final brace in the output comes from the end of M.nest-mix. +# +# XXX: This is unexpected but rarely occurs in practice. +TESTS+= M-nest-mix +INP.M-nest-mix= (parentheses) +MOD.M-nest-mix= ${INP.M-nest-mix:M${:U*)}} +EXP.M-nest-mix= (parentheses)} +# make: Unclosed variable specification (expecting '}') for "" (value "*)") modifier U + +# In contrast to parentheses and braces, the brackets are not counted +# when the :M modifier is parsed since Makefile variables only take the +# ${VAR} or $(VAR) forms, but not $[VAR]. +# +# The final ] in the pattern is needed to close the character class. +TESTS+= M-nest-brk +INP.M-nest-brk= [ [[ [[[ +MOD.M-nest-brk= ${INP.M-nest-brk:M${:U[[[[[]}} +EXP.M-nest-brk= [ + +# The pattern in the nested variable has an unclosed character class. +# No error is reported though, and the pattern is closed implicitly. +# +# XXX: It is unexpected that no error is reported. +# See str.c, function Str_Match. +# +# Before 2019-12-02, this test case triggered an out-of-bounds read +# in Str_Match. +TESTS+= M-pat-err +INP.M-pat-err= [ [[ [[[ +MOD.M-pat-err= ${INP.M-pat-err:M${:U[[}} +EXP.M-pat-err= [ + +# The first backslash does not escape the second backslash. +# Therefore, the second backslash escapes the parenthesis. +# This means that the pattern ends there. +# The final } in the output comes from the end of MOD.M-bsbs. +# +# If the first backslash were to escape the second backslash, the first +# closing brace would match the opening parenthesis (see M-mixed), and +# the second closing brace would be needed to close the variable. +# After that, the remaining backslash would escape the parenthesis in +# the pattern, therefore (} would match. +TESTS+= M-bsbs +INP.M-bsbs= (} \( \(} +MOD.M-bsbs= ${INP.M-bsbs:M\\(}} +EXP.M-bsbs= \(} +#EXP.M-bsbs= (} # If the first backslash were to escape ... + +# The backslash in \( does not escape the parenthesis, therefore it +# counts for the nesting level and matches with the first closing brace. +# The second closing brace closes the variable, and the third is copied +# literally. +# +# The second :M in the pattern is nested between ( and }, therefore it +# does not start a new modifier. +TESTS+= M-bs1-par +INP.M-bs1-par= ( (:M (:M} \( \(:M \(:M} +MOD.M-bs1-par= ${INP.M-bs1-par:M\(:M*}}} +EXP.M-bs1-par= (:M}} + +# The double backslash is passed verbatim to the pattern matcher. +# The Str_Match pattern is \\(:M*}, and there the backslash is unescaped. +# Again, the ( takes place in the nesting level, and there is no way to +# prevent this, no matter how many backslashes are used. +TESTS+= M-bs2-par +INP.M-bs2-par= ( (:M (:M} \( \(:M \(:M} +MOD.M-bs2-par= ${INP.M-bs2-par:M\\(:M*}}} +EXP.M-bs2-par= \(:M}} + +# Str_Match uses a recursive algorithm for matching the * patterns. +# Make sure that it survives patterns with 128 asterisks. +# That should be enough for all practical purposes. +# To produce a stack overflow, just add more :Qs below. +TESTS+= M-128 +INP.M-128= ${:U\\:Q:Q:Q:Q:Q:Q:Q:S,\\,x,g} +PAT.M-128= ${:U\\:Q:Q:Q:Q:Q:Q:Q:S,\\,*,g} +MOD.M-128= ${INP.M-128:M${PAT.M-128}} +EXP.M-128= ${INP.M-128} + +# This is the normal SysV substitution. Nothing surprising here. +TESTS+= eq-ext +INP.eq-ext= file.c file.cc +MOD.eq-ext= ${INP.eq-ext:%.c=%.o} +EXP.eq-ext= file.o file.cc + +# The SysV := modifier is greedy and consumes all the modifier text +# up until the closing brace or parenthesis. The :Q may look like a +# modifier, but it really isn't, that's why it appears in the output. +TESTS+= eq-q +INP.eq-q= file.c file.cc +MOD.eq-q= ${INP.eq-q:%.c=%.o:Q} +EXP.eq-q= file.o:Q file.cc + +# The = in the := modifier can be escaped. +TESTS+= eq-bs +INP.eq-bs= file.c file.c=%.o +MOD.eq-bs= ${INP.eq-bs:%.c\=%.o=%.ext} +EXP.eq-bs= file.c file.ext + +# Having only an escaped = results in a parse error. +# The call to "pattern.lhs = VarGetPattern" fails. +TESTS+= eq-esc +INP.eq-esc= file.c file... +MOD.eq-esc= ${INP.eq-esc:a\=b} +EXP.eq-esc= # empty +# make: Unclosed substitution for INP.eq-esc (= missing) + +all: +.for test in ${TESTS} +. if ${MOD.${test}} == ${EXP.${test}} + @printf 'ok %s\n' ${test:Q}'' +. else + @printf 'error in %s: expected %s, got %s\n' \ + ${test:Q}'' ${EXP.${test}:Q}'' ${MOD.${test}:Q}'' +. endif +.endfor diff --git a/devel/bmake/files/unit-tests/varquote.exp b/devel/bmake/files/unit-tests/varquote.exp new file mode 100644 index 00000000000..63107bfd34f --- /dev/null +++ b/devel/bmake/files/unit-tests/varquote.exp @@ -0,0 +1,3 @@ +-fdebug-prefix-map=$NETBSDSRCDIR=/usr/src -fdebug-regex-map=/usr/src/(.*)/obj$=/usr/obj/\1 +-fdebug-prefix-map=$NETBSDSRCDIR=/usr/src -fdebug-regex-map=/usr/src/(.*)/obj$=/usr/obj/\1 +exit status 0 diff --git a/devel/bmake/files/unit-tests/varquote.mk b/devel/bmake/files/unit-tests/varquote.mk new file mode 100644 index 00000000000..45fc119c831 --- /dev/null +++ b/devel/bmake/files/unit-tests/varquote.mk @@ -0,0 +1,14 @@ +# $NetBSD: varquote.mk,v 1.1.1.1 2020/05/24 05:35:53 nia Exp $ +# +# Test VAR:q modifier + +.if !defined(REPROFLAGS) +REPROFLAGS+= -fdebug-prefix-map=\$$NETBSDSRCDIR=/usr/src +REPROFLAGS+= -fdebug-regex-map='/usr/src/(.*)/obj$$=/usr/obj/\1' +all: + @${MAKE} -f ${MAKEFILE} REPROFLAGS=${REPROFLAGS:S/\$/&&/g:Q} + @${MAKE} -f ${MAKEFILE} REPROFLAGS=${REPROFLAGS:q} +.else +all: + @printf "%s %s\n" ${REPROFLAGS} +.endif diff --git a/devel/bmake/files/util.c b/devel/bmake/files/util.c index 30b813ef084..ca562de9dc0 100644 --- a/devel/bmake/files/util.c +++ b/devel/bmake/files/util.c @@ -1,9 +1,9 @@ -/* $NetBSD: util.c,v 1.1.1.10 2015/05/19 21:36:44 joerg Exp $ */ +/* $NetBSD: util.c,v 1.1.1.11 2020/05/24 05:35:53 nia Exp $ */ /* * Missing stuff from OS's * - * $Id: util.c,v 1.1.1.10 2015/05/19 21:36:44 joerg Exp $ + * $Id: util.c,v 1.1.1.11 2020/05/24 05:35:53 nia Exp $ */ #if defined(__MINT__) || defined(__linux__) #include <signal.h> @@ -12,10 +12,10 @@ #include "make.h" #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: util.c,v 1.1.1.10 2015/05/19 21:36:44 joerg Exp $"; +static char rcsid[] = "$NetBSD: util.c,v 1.1.1.11 2020/05/24 05:35:53 nia Exp $"; #else #ifndef lint -__RCSID("$NetBSD: util.c,v 1.1.1.10 2015/05/19 21:36:44 joerg Exp $"); +__RCSID("$NetBSD: util.c,v 1.1.1.11 2020/05/24 05:35:53 nia Exp $"); #endif #endif @@ -229,32 +229,6 @@ killpg(int pid, int sig) return kill(-pid, sig); } -#if !defined(__hpux__) && !defined(__hpux) -void -srandom(long seed) -{ - srand48(seed); -} - -long -random(void) -{ - return lrand48(); -} -#endif - -#if !defined(__hpux__) && !defined(__hpux) -int -utimes(char *file, struct timeval tvp[2]) -{ - struct utimbuf t; - - t.actime = tvp[0].tv_sec; - t.modtime = tvp[1].tv_sec; - return(utime(file, &t)); -} -#endif - #if !defined(BSD) && !defined(d_fileno) # define d_fileno d_ino #endif diff --git a/devel/bmake/files/var.c b/devel/bmake/files/var.c index 946a235f310..bf32217f870 100644 --- a/devel/bmake/files/var.c +++ b/devel/bmake/files/var.c @@ -1,4 +1,4 @@ -/* $NetBSD: var.c,v 1.1.1.10 2015/05/19 21:36:44 joerg Exp $ */ +/* $NetBSD: var.c,v 1.1.1.11 2020/05/24 05:35:53 nia Exp $ */ /* * Copyright (c) 1988, 1989, 1990, 1993 @@ -69,14 +69,14 @@ */ #ifndef MAKE_NATIVE -static char rcsid[] = "$NetBSD: var.c,v 1.1.1.10 2015/05/19 21:36:44 joerg Exp $"; +static char rcsid[] = "$NetBSD: var.c,v 1.1.1.11 2020/05/24 05:35:53 nia Exp $"; #else #include <sys/cdefs.h> #ifndef lint #if 0 static char sccsid[] = "@(#)var.c 8.3 (Berkeley) 3/19/94"; #else -__RCSID("$NetBSD: var.c,v 1.1.1.10 2015/05/19 21:36:44 joerg Exp $"); +__RCSID("$NetBSD: var.c,v 1.1.1.11 2020/05/24 05:35:53 nia Exp $"); #endif #endif /* not lint */ #endif @@ -129,7 +129,6 @@ __RCSID("$NetBSD: var.c,v 1.1.1.10 2015/05/19 21:36:44 joerg Exp $"); #include <regex.h> #endif #include <ctype.h> -#include <inttypes.h> #include <stdlib.h> #include <limits.h> #include <time.h> @@ -138,6 +137,7 @@ __RCSID("$NetBSD: var.c,v 1.1.1.10 2015/05/19 21:36:44 joerg Exp $"); #include "buf.h" #include "dir.h" #include "job.h" +#include "metachar.h" extern int makelevel; /* @@ -154,13 +154,23 @@ char **savedEnv = NULL; char var_Error[] = ""; /* - * Similar to var_Error, but returned when the 'errnum' flag for Var_Parse is - * set false. Why not just use a constant? Well, gcc likes to condense - * identical string instances... + * Similar to var_Error, but returned when the 'VARF_UNDEFERR' flag for + * Var_Parse is not set. Why not just use a constant? Well, gcc likes + * to condense identical string instances... */ static char varNoError[] = ""; /* + * Traditionally we consume $$ during := like any other expansion. + * Other make's do not. + * This knob allows controlling the behavior. + * FALSE for old behavior. + * TRUE for new compatible. + */ +#define SAVE_DOLLARS ".MAKE.SAVE_DOLLARS" +static Boolean save_dollars = FALSE; + +/* * Internally, variables are contained in four different contexts. * 1) the environment. They may not be changed. If an environment * variable is appended-to, the result is placed in the global @@ -216,7 +226,11 @@ static int var_exportedVars = VAR_EXPORTED_NONE; * We pass this to Var_Export when doing the initial export * or after updating an exported var. */ -#define VAR_EXPORT_PARENT 1 +#define VAR_EXPORT_PARENT 1 +/* + * We pass this to Var_Export1 to tell it to leave the value alone. + */ +#define VAR_EXPORT_LITERAL 2 /* Var*Pattern flags */ #define VAR_SUB_GLOBAL 0x01 /* Apply substitution globally */ @@ -310,7 +324,7 @@ static Boolean VarLoopExpand(GNode *, Var_Parse_State *, static char *VarGetPattern(GNode *, Var_Parse_State *, int, const char **, int, int *, int *, VarPattern *); -static char *VarQuote(char *); +static char *VarQuote(char *, Boolean); static char *VarHash(char *); static char *VarModify(GNode *, Var_Parse_State *, const char *, @@ -516,7 +530,7 @@ VarAdd(const char *name, const char *val, GNode *ctxt) h = Hash_CreateEntry(&ctxt->context, name, NULL); Hash_SetValue(h, v); v->name = h->name; - if (DEBUG(VAR)) { + if (DEBUG(VAR) && (ctxt->flags & INTERNAL) == 0) { fprintf(debug_file, "%s:%s = %s\n", ctxt->name, name, val); } } @@ -541,7 +555,7 @@ Var_Delete(const char *name, GNode *ctxt) char *cp; if (strchr(name, '$')) { - cp = Var_Subst(NULL, name, VAR_GLOBAL, 0); + cp = Var_Subst(NULL, name, VAR_GLOBAL, VARF_WANTRES); } else { cp = (char *)name; } @@ -580,12 +594,13 @@ Var_Delete(const char *name, GNode *ctxt) * We only manipulate flags of vars if 'parent' is set. */ static int -Var_Export1(const char *name, int parent) +Var_Export1(const char *name, int flags) { char tmp[BUFSIZ]; Var *v; char *val = NULL; int n; + int parent = (flags & VAR_EXPORT_PARENT); if (*name == '.') return 0; /* skip internals */ @@ -613,7 +628,7 @@ Var_Export1(const char *name, int parent) return 0; /* nothing to do */ } val = Buf_GetAll(&v->val, NULL); - if (strchr(val, '$')) { + if ((flags & VAR_EXPORT_LITERAL) == 0 && strchr(val, '$')) { if (parent) { /* * Flag this as something we need to re-export. @@ -632,7 +647,7 @@ Var_Export1(const char *name, int parent) } n = snprintf(tmp, sizeof(tmp), "${%s}", name); if (n < (int)sizeof(tmp)) { - val = Var_Subst(NULL, tmp, VAR_GLOBAL, 0); + val = Var_Subst(NULL, tmp, VAR_GLOBAL, VARF_WANTRES); setenv(name, val, 1); free(val); } @@ -700,14 +715,16 @@ Var_ExportVars(void) int ac; int i; - val = Var_Subst(NULL, tmp, VAR_GLOBAL, 0); - av = brk_string(val, &ac, FALSE, &as); - for (i = 0; i < ac; i++) { - Var_Export1(av[i], 0); + val = Var_Subst(NULL, tmp, VAR_GLOBAL, VARF_WANTRES); + if (*val) { + av = brk_string(val, &ac, FALSE, &as); + for (i = 0; i < ac; i++) { + Var_Export1(av[i], 0); + } + free(as); + free(av); } free(val); - free(as); - free(av); } } @@ -723,7 +740,7 @@ Var_Export(char *str, int isExport) char *val; char **av; char *as; - int track; + int flags; int ac; int i; @@ -732,42 +749,47 @@ Var_Export(char *str, int isExport) return; } + flags = 0; if (strncmp(str, "-env", 4) == 0) { - track = 0; str += 4; + } else if (strncmp(str, "-literal", 8) == 0) { + str += 8; + flags |= VAR_EXPORT_LITERAL; } else { - track = VAR_EXPORT_PARENT; + flags |= VAR_EXPORT_PARENT; } - val = Var_Subst(NULL, str, VAR_GLOBAL, 0); - av = brk_string(val, &ac, FALSE, &as); - for (i = 0; i < ac; i++) { - name = av[i]; - if (!name[1]) { - /* - * A single char. - * If it is one of the vars that should only appear in - * local context, skip it, else we can get Var_Subst - * into a loop. - */ - switch (name[0]) { - case '@': - case '%': - case '*': - case '!': - continue; + val = Var_Subst(NULL, str, VAR_GLOBAL, VARF_WANTRES); + if (*val) { + av = brk_string(val, &ac, FALSE, &as); + for (i = 0; i < ac; i++) { + name = av[i]; + if (!name[1]) { + /* + * A single char. + * If it is one of the vars that should only appear in + * local context, skip it, else we can get Var_Subst + * into a loop. + */ + switch (name[0]) { + case '@': + case '%': + case '*': + case '!': + continue; + } } - } - if (Var_Export1(name, track)) { - if (VAR_EXPORTED_ALL != var_exportedVars) - var_exportedVars = VAR_EXPORTED_YES; - if (isExport && track) { - Var_Append(MAKE_EXPORTED, name, VAR_GLOBAL); + if (Var_Export1(name, flags)) { + if (VAR_EXPORTED_ALL != var_exportedVars) + var_exportedVars = VAR_EXPORTED_YES; + if (isExport && (flags & VAR_EXPORT_PARENT)) { + Var_Append(MAKE_EXPORTED, name, VAR_GLOBAL); + } } } + free(as); + free(av); } free(val); - free(as); - free(av); } @@ -813,7 +835,8 @@ Var_UnExport(char *str) environ = savedEnv = newenv; newenv[0] = NULL; newenv[1] = NULL; - setenv(MAKE_LEVEL_ENV, cp, 1); + if (cp && *cp) + setenv(MAKE_LEVEL_ENV, cp, 1); } else { for (; *str != '\n' && isspace((unsigned char) *str); str++) continue; @@ -826,7 +849,7 @@ Var_UnExport(char *str) /* Using .MAKE.EXPORTED */ n = snprintf(tmp, sizeof(tmp), "${" MAKE_EXPORTED ":O:u}"); if (n < (int)sizeof(tmp)) { - vlist = Var_Subst(NULL, tmp, VAR_GLOBAL, 0); + vlist = Var_Subst(NULL, tmp, VAR_GLOBAL, VARF_WANTRES); } } if (vlist) { @@ -856,7 +879,7 @@ Var_UnExport(char *str) n = snprintf(tmp, sizeof(tmp), "${" MAKE_EXPORTED ":N%s}", v->name); if (n < (int)sizeof(tmp)) { - cp = Var_Subst(NULL, tmp, VAR_GLOBAL, 0); + cp = Var_Subst(NULL, tmp, VAR_GLOBAL, VARF_WANTRES); Var_Set(MAKE_EXPORTED, cp, VAR_GLOBAL, 0); free(cp); } @@ -911,7 +934,7 @@ Var_Set(const char *name, const char *val, GNode *ctxt, int flags) * point in searching them all just to save a bit of memory... */ if (strchr(name, '$') != NULL) { - expanded_name = Var_Subst(NULL, name, ctxt, 0); + expanded_name = Var_Subst(NULL, name, ctxt, VARF_WANTRES); if (expanded_name[0] == 0) { if (DEBUG(VAR)) { fprintf(debug_file, "Var_Set(\"%s\", \"%s\", ...) " @@ -948,7 +971,8 @@ Var_Set(const char *name, const char *val, GNode *ctxt, int flags) VarAdd(name, val, ctxt); } else { Buf_Empty(&v->val); - Buf_AddBytes(&v->val, strlen(val), val); + if (val) + Buf_AddBytes(&v->val, strlen(val), val); if (DEBUG(VAR)) { fprintf(debug_file, "%s:%s = %s\n", ctxt->name, name, val); @@ -975,14 +999,17 @@ Var_Set(const char *name, const char *val, GNode *ctxt, int flags) * Makefile settings. */ if (varNoExportEnv != TRUE) - setenv(name, val, 1); + setenv(name, val ? val : "", 1); Var_Append(MAKEOVERRIDES, name, VAR_GLOBAL); } - + if (*name == '.') { + if (strcmp(name, SAVE_DOLLARS) == 0) + save_dollars = s2Boolean(val, save_dollars); + } + out: - if (expanded_name != NULL) - free(expanded_name); + free(expanded_name); if (v != NULL) VarFreeEnv(v, TRUE); } @@ -1022,7 +1049,7 @@ Var_Append(const char *name, const char *val, GNode *ctxt) char *expanded_name = NULL; if (strchr(name, '$') != NULL) { - expanded_name = Var_Subst(NULL, name, ctxt, 0); + expanded_name = Var_Subst(NULL, name, ctxt, VARF_WANTRES); if (expanded_name[0] == 0) { if (DEBUG(VAR)) { fprintf(debug_file, "Var_Append(\"%s\", \"%s\", ...) " @@ -1035,11 +1062,11 @@ Var_Append(const char *name, const char *val, GNode *ctxt) name = expanded_name; } - v = VarFind(name, ctxt, (ctxt == VAR_GLOBAL) ? FIND_ENV : 0); + v = VarFind(name, ctxt, (ctxt == VAR_GLOBAL) ? (FIND_CMD|FIND_ENV) : 0); if (v == NULL) { - VarAdd(name, val, ctxt); - } else { + Var_Set(name, val, ctxt, 0); + } else if (ctxt == VAR_CMD || !(v->flags & VAR_FROM_CMD)) { Buf_AddByte(&v->val, ' '); Buf_AddBytes(&v->val, strlen(val), val); @@ -1060,8 +1087,7 @@ Var_Append(const char *name, const char *val, GNode *ctxt) Hash_SetValue(h, v); } } - if (expanded_name != NULL) - free(expanded_name); + free(expanded_name); } /*- @@ -1088,12 +1114,10 @@ Var_Exists(const char *name, GNode *ctxt) char *cp; if ((cp = strchr(name, '$')) != NULL) { - cp = Var_Subst(NULL, name, ctxt, FALSE); + cp = Var_Subst(NULL, name, ctxt, VARF_WANTRES); } v = VarFind(cp ? cp : name, ctxt, FIND_CMD|FIND_GLOBAL|FIND_ENV); - if (cp != NULL) { - free(cp); - } + free(cp); if (v == NULL) { return(FALSE); } else { @@ -1159,7 +1183,7 @@ Var_Value(const char *name, GNode *ctxt, char **frp) static Boolean VarHead(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate, char *word, Boolean addSpace, Buffer *buf, - void *dummy) + void *dummy MAKE_ATTR_UNUSED) { char *slash; @@ -1180,7 +1204,7 @@ VarHead(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate, Buf_AddByte(buf, vpstate->varSpace); Buf_AddByte(buf, '.'); } - return(dummy ? TRUE : TRUE); + return TRUE; } /*- @@ -1207,7 +1231,7 @@ VarHead(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate, static Boolean VarTail(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate, char *word, Boolean addSpace, Buffer *buf, - void *dummy) + void *dummy MAKE_ATTR_UNUSED) { char *slash; @@ -1223,7 +1247,7 @@ VarTail(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate, } else { Buf_AddBytes(buf, strlen(word), word); } - return (dummy ? TRUE : TRUE); + return TRUE; } /*- @@ -1249,7 +1273,7 @@ VarTail(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate, static Boolean VarSuffix(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate, char *word, Boolean addSpace, Buffer *buf, - void *dummy) + void *dummy MAKE_ATTR_UNUSED) { char *dot; @@ -1263,7 +1287,7 @@ VarSuffix(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate, dot[-1] = '.'; addSpace = TRUE; } - return (dummy ? addSpace : addSpace); + return addSpace; } /*- @@ -1290,7 +1314,7 @@ VarSuffix(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate, static Boolean VarRoot(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate, char *word, Boolean addSpace, Buffer *buf, - void *dummy) + void *dummy MAKE_ATTR_UNUSED) { char *dot; @@ -1306,7 +1330,7 @@ VarRoot(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate, } else { Buf_AddBytes(buf, strlen(word), word); } - return (dummy ? TRUE : TRUE); + return TRUE; } /*- @@ -1377,8 +1401,9 @@ VarSYSVMatch(GNode *ctx, Var_Parse_State *vpstate, char *word, Boolean addSpace, Buffer *buf, void *patp) { - int len; + size_t len; char *ptr; + Boolean hasPercent; VarPattern *pat = (VarPattern *)patp; char *varexp; @@ -1387,9 +1412,9 @@ VarSYSVMatch(GNode *ctx, Var_Parse_State *vpstate, addSpace = TRUE; - if ((ptr = Str_SYSVMatch(word, pat->lhs, &len)) != NULL) { - varexp = Var_Subst(NULL, pat->rhs, ctx, 0); - Str_SYSVSubst(buf, varexp, ptr, len); + if ((ptr = Str_SYSVMatch(word, pat->lhs, &len, &hasPercent)) != NULL) { + varexp = Var_Subst(NULL, pat->rhs, ctx, VARF_WANTRES); + Str_SYSVSubst(buf, varexp, ptr, len, hasPercent); free(varexp); } else { Buf_AddBytes(buf, strlen(word), word); @@ -1628,14 +1653,14 @@ VarSubstitute(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate, *----------------------------------------------------------------------- */ static void -VarREError(int errnum, regex_t *pat, const char *str) +VarREError(int reerr, regex_t *pat, const char *str) { char *errbuf; int errlen; - errlen = regerror(errnum, pat, 0, 0); + errlen = regerror(reerr, pat, 0, 0); errbuf = bmake_malloc(errlen); - regerror(errnum, pat, errbuf, errlen); + regerror(reerr, pat, errbuf, errlen); Error("%s: %s", str, errbuf); free(errbuf); } @@ -1808,14 +1833,14 @@ VarLoopExpand(GNode *ctx MAKE_ATTR_UNUSED, if (word && *word) { Var_Set(loop->tvar, word, loop->ctxt, VAR_NO_EXPORT); - s = Var_Subst(NULL, loop->str, loop->ctxt, loop->errnum); + s = Var_Subst(NULL, loop->str, loop->ctxt, loop->errnum | VARF_WANTRES); if (s != NULL && *s != '\0') { if (addSpace && *s != '\n') Buf_AddByte(buf, ' '); Buf_AddBytes(buf, (slen = strlen(s)), s); addSpace = (slen > 0 && s[slen - 1] != '\n'); - free(s); } + free(s); } return addSpace; } @@ -1928,7 +1953,7 @@ VarRealpath(GNode *ctx MAKE_ATTR_UNUSED, Var_Parse_State *vpstate, Buf_AddByte(buf, vpstate->varSpace); } addSpace = TRUE; - rp = realpath(word, rbuf); + rp = cached_realpath(word, rbuf); if (rp && *rp == '/' && stat(rp, &st) == 0) word = rp; @@ -2117,6 +2142,51 @@ VarUniq(const char *str) return Buf_Destroy(&buf, FALSE); } +/*- + *----------------------------------------------------------------------- + * VarRange -- + * Return an integer sequence + * + * Input: + * str String whose words provide default range + * ac range length, if 0 use str words + * + * Side Effects: + * None. + * + *----------------------------------------------------------------------- + */ +static char * +VarRange(const char *str, int ac) +{ + Buffer buf; /* Buffer for new string */ + char tmp[32]; /* each element */ + char **av; /* List of words to affect */ + char *as; /* Word list memory */ + int i, n; + + Buf_Init(&buf, 0); + if (ac > 0) { + as = NULL; + av = NULL; + } else { + av = brk_string(str, &ac, FALSE, &as); + } + for (i = 0; i < ac; i++) { + n = snprintf(tmp, sizeof(tmp), "%d", 1 + i); + if (n >= (int)sizeof(tmp)) + break; + Buf_AddBytes(&buf, n, tmp); + if (i != ac - 1) + Buf_AddByte(&buf, ' '); + } + + free(as); + free(av); + + return Buf_Destroy(&buf, FALSE); +} + /*- *----------------------------------------------------------------------- @@ -2142,13 +2212,14 @@ VarUniq(const char *str) */ static char * VarGetPattern(GNode *ctxt, Var_Parse_State *vpstate MAKE_ATTR_UNUSED, - int errnum, const char **tstr, int delim, int *flags, + int flags, const char **tstr, int delim, int *vflags, int *length, VarPattern *pattern) { const char *cp; char *rstr; Buffer buf; int junk; + int errnum = flags & VARF_UNDEFERR; Buf_Init(&buf, 0); if (length == NULL) @@ -2170,16 +2241,16 @@ VarGetPattern(GNode *ctxt, Var_Parse_State *vpstate MAKE_ATTR_UNUSED, cp++; } else if (*cp == '$') { if (cp[1] == delim) { - if (flags == NULL) + if (vflags == NULL) Buf_AddByte(&buf, *cp); else /* * Unescaped $ at end of pattern => anchor * pattern at end. */ - *flags |= VAR_MATCH_END; + *vflags |= VAR_MATCH_END; } else { - if (flags == NULL || (*flags & VAR_NOSUBST) == 0) { + if (vflags == NULL || (*vflags & VAR_NOSUBST) == 0) { char *cp2; int len; void *freeIt; @@ -2189,10 +2260,10 @@ VarGetPattern(GNode *ctxt, Var_Parse_State *vpstate MAKE_ATTR_UNUSED, * delimiter, assume it's a variable * substitution and recurse. */ - cp2 = Var_Parse(cp, ctxt, errnum, &len, &freeIt); + cp2 = Var_Parse(cp, ctxt, errnum | VARF_WANTRES, &len, + &freeIt); Buf_AddBytes(&buf, strlen(cp2), cp2); - if (freeIt) - free(freeIt); + free(freeIt); cp += len - 1; } else { const char *cp2 = &cp[1]; @@ -2245,7 +2316,8 @@ VarGetPattern(GNode *ctxt, Var_Parse_State *vpstate MAKE_ATTR_UNUSED, /*- *----------------------------------------------------------------------- * VarQuote -- - * Quote shell meta-characters in the string + * Quote shell meta-characters and space characters in the string + * if quoteDollar is set, also quote and double any '$' characters. * * Results: * The quoted string @@ -2256,33 +2328,31 @@ VarGetPattern(GNode *ctxt, Var_Parse_State *vpstate MAKE_ATTR_UNUSED, *----------------------------------------------------------------------- */ static char * -VarQuote(char *str) +VarQuote(char *str, Boolean quoteDollar) { Buffer buf; - /* This should cover most shells :-( */ - static const char meta[] = "\n \t'`\";&<>()|*?{}[]\\$!#^~"; const char *newline; - size_t len, nlen; + size_t nlen; if ((newline = Shell_GetNewline()) == NULL) newline = "\\\n"; nlen = strlen(newline); Buf_Init(&buf, 0); - while (*str != '\0') { - if ((len = strcspn(str, meta)) != 0) { - Buf_AddBytes(&buf, len, str); - str += len; - } else if (*str == '\n') { + + for (; *str != '\0'; str++) { + if (*str == '\n') { Buf_AddBytes(&buf, nlen, newline); - ++str; - } else { - Buf_AddByte(&buf, '\\'); - Buf_AddByte(&buf, *str); - ++str; + continue; } + if (isspace((unsigned char)*str) || ismeta((unsigned char)*str)) + Buf_AddByte(&buf, '\\'); + Buf_AddByte(&buf, *str); + if (quoteDollar && *str == '$') + Buf_AddBytes(&buf, 2, "\\$"); } + str = Buf_Destroy(&buf, FALSE); if (DEBUG(VAR)) fprintf(debug_file, "QuoteMeta: [%s]\n", str); @@ -2313,7 +2383,7 @@ VarHash(char *str) Buffer buf; size_t len, len2; unsigned char *ustr = (unsigned char *)str; - uint32_t h, k, c1, c2; + unsigned int h, k, c1, c2; h = 0x971e137bU; c1 = 0x95543787U; @@ -2330,8 +2400,10 @@ VarHash(char *str) break; case 3: k |= (ustr[2] << 16); + /* FALLTHROUGH */ case 2: k |= (ustr[1] << 8); + /* FALLTHROUGH */ case 1: k |= ustr[0]; len = 0; @@ -2361,12 +2433,12 @@ VarHash(char *str) } static char * -VarStrftime(const char *fmt, int zulu) +VarStrftime(const char *fmt, int zulu, time_t utc) { char buf[BUFSIZ]; - time_t utc; - time(&utc); + if (!utc) + time(&utc); if (!*fmt) fmt = "%c"; strftime(buf, sizeof(buf), fmt, zulu ? gmtime(&utc) : localtime(&utc)); @@ -2463,23 +2535,28 @@ VarStrftime(const char *fmt, int zulu) /* we now have some modifiers with long names */ #define STRMOD_MATCH(s, want, n) \ (strncmp(s, want, n) == 0 && (s[n] == endc || s[n] == ':')) +#define STRMOD_MATCHX(s, want, n) \ + (strncmp(s, want, n) == 0 && (s[n] == endc || s[n] == ':' || s[n] == '=')) +#define CHARMOD_MATCH(c) (c == endc || c == ':') static char * ApplyModifiers(char *nstr, const char *tstr, int startc, int endc, - Var *v, GNode *ctxt, Boolean errnum, + Var *v, GNode *ctxt, int flags, int *lengthPtr, void **freePtr) { const char *start; const char *cp; /* Secondary pointer into str (place marker * for tstr) */ char *newStr; /* New value to return */ + char *ep; char termc; /* Character which terminated scan */ int cnt; /* Used to count brace pairs when variable in * in parens or braces */ char delim; int modifier; /* that we are processing */ Var_Parse_State parsestate; /* Flags passed to helper functions */ + time_t utc; /* for VarStrftime */ delim = '\0'; parsestate.oneBigWord = FALSE; @@ -2498,7 +2575,7 @@ ApplyModifiers(char *nstr, const char *tstr, int rlen; int c; - rval = Var_Parse(tstr, ctxt, errnum, &rlen, &freeIt); + rval = Var_Parse(tstr, ctxt, flags, &rlen, &freeIt); /* * If we have not parsed up to endc or ':', @@ -2508,8 +2585,7 @@ ApplyModifiers(char *nstr, const char *tstr, (c = tstr[rlen]) != '\0' && c != ':' && c != endc) { - if (freeIt) - free(freeIt); + free(freeIt); goto apply_mods; } @@ -2524,18 +2600,15 @@ ApplyModifiers(char *nstr, const char *tstr, int used; nstr = ApplyModifiers(nstr, rval, - 0, 0, - v, ctxt, errnum, &used, freePtr); + 0, 0, v, ctxt, flags, &used, freePtr); if (nstr == var_Error - || (nstr == varNoError && errnum == 0) + || (nstr == varNoError && (flags & VARF_UNDEFERR) == 0) || strlen(rval) != (size_t) used) { - if (freeIt) - free(freeIt); + free(freeIt); goto out; /* error already reported */ } } - if (freeIt) - free(freeIt); + free(freeIt); if (*tstr == ':') tstr++; else if (!*tstr && endc) { @@ -2564,6 +2637,7 @@ ApplyModifiers(char *nstr, const char *tstr, char *sv_name; VarPattern pattern; int how; + int vflags; if (v->name[0] == 0) goto bad_modifier; @@ -2599,8 +2673,9 @@ ApplyModifiers(char *nstr, const char *tstr, delim = startc == PROPEN ? PRCLOSE : BRCLOSE; pattern.flags = 0; - pattern.rhs = VarGetPattern(ctxt, &parsestate, errnum, - &cp, delim, NULL, + vflags = (flags & VARF_WANTRES) ? 0 : VAR_NOSUBST; + pattern.rhs = VarGetPattern(ctxt, &parsestate, flags, + &cp, delim, &vflags, &pattern.rightLen, NULL); if (v->flags & VAR_JUNK) { @@ -2614,26 +2689,27 @@ ApplyModifiers(char *nstr, const char *tstr, termc = *--cp; delim = '\0'; - switch (how) { - case '+': - Var_Append(v->name, pattern.rhs, v_ctxt); - break; - case '!': - newStr = Cmd_Exec(pattern.rhs, &emsg); - if (emsg) - Error(emsg, nstr); - else - Var_Set(v->name, newStr, v_ctxt, 0); - if (newStr) + if (flags & VARF_WANTRES) { + switch (how) { + case '+': + Var_Append(v->name, pattern.rhs, v_ctxt); + break; + case '!': + newStr = Cmd_Exec(pattern.rhs, &emsg); + if (emsg) + Error(emsg, nstr); + else + Var_Set(v->name, newStr, v_ctxt, 0); free(newStr); - break; - case '?': - if ((v->flags & VAR_JUNK) == 0) break; - /* FALLTHROUGH */ - default: - Var_Set(v->name, pattern.rhs, v_ctxt, 0); - break; + case '?': + if ((v->flags & VAR_JUNK) == 0) + break; + /* FALLTHROUGH */ + default: + Var_Set(v->name, pattern.rhs, v_ctxt, 0); + break; + } } free(UNCONST(pattern.rhs)); newStr = varNoError; @@ -2644,39 +2720,73 @@ ApplyModifiers(char *nstr, const char *tstr, case '@': { VarLoop_t loop; - int flags = VAR_NOSUBST; + int vflags = VAR_NOSUBST; cp = ++tstr; delim = '@'; - if ((loop.tvar = VarGetPattern(ctxt, &parsestate, errnum, + if ((loop.tvar = VarGetPattern(ctxt, &parsestate, flags, &cp, delim, - &flags, &loop.tvarLen, + &vflags, &loop.tvarLen, NULL)) == NULL) goto cleanup; - if ((loop.str = VarGetPattern(ctxt, &parsestate, errnum, + if ((loop.str = VarGetPattern(ctxt, &parsestate, flags, &cp, delim, - &flags, &loop.strLen, + &vflags, &loop.strLen, NULL)) == NULL) goto cleanup; termc = *cp; delim = '\0'; - loop.errnum = errnum; + loop.errnum = flags & VARF_UNDEFERR; loop.ctxt = ctxt; newStr = VarModify(ctxt, &parsestate, nstr, VarLoopExpand, &loop); + Var_Delete(loop.tvar, ctxt); free(loop.tvar); free(loop.str); break; } + case '_': /* remember current value */ + cp = tstr + 1; /* make sure it is set */ + if (STRMOD_MATCHX(tstr, "_", 1)) { + if (tstr[1] == '=') { + char *np; + int n; + + cp++; + n = strcspn(cp, ":)}"); + np = bmake_strndup(cp, n+1); + np[n] = '\0'; + cp = tstr + 2 + n; + Var_Set(np, nstr, ctxt, 0); + free(np); + } else { + Var_Set("_", nstr, ctxt, 0); + } + newStr = nstr; + termc = *cp; + break; + } + goto default_case; case 'D': case 'U': { Buffer buf; /* Buffer for patterns */ - int wantit; /* want data in buffer */ - + int nflags; + + if (flags & VARF_WANTRES) { + int wantres; + if (*tstr == 'U') + wantres = ((v->flags & VAR_JUNK) != 0); + else + wantres = ((v->flags & VAR_JUNK) == 0); + nflags = flags & ~VARF_WANTRES; + if (wantres) + nflags |= VARF_WANTRES; + } else + nflags = flags; /* * Pass through tstr looking for 1) escaped delimiters, * '$'s and backslashes (place the escaped character in @@ -2705,10 +2815,9 @@ ApplyModifiers(char *nstr, const char *tstr, int len; void *freeIt; - cp2 = Var_Parse(cp, ctxt, errnum, &len, &freeIt); + cp2 = Var_Parse(cp, ctxt, nflags, &len, &freeIt); Buf_AddBytes(&buf, strlen(cp2), cp2); - if (freeIt) - free(freeIt); + free(freeIt); cp += len - 1; } else { Buf_AddByte(&buf, *cp); @@ -2717,13 +2826,9 @@ ApplyModifiers(char *nstr, const char *tstr, termc = *cp; - if (*tstr == 'U') - wantit = ((v->flags & VAR_JUNK) != 0); - else - wantit = ((v->flags & VAR_JUNK) == 0); if ((v->flags & VAR_JUNK) != 0) v->flags |= VAR_KEEP; - if (wantit) { + if (nflags & VARF_WANTRES) { newStr = Buf_Destroy(&buf, FALSE); } else { newStr = nstr; @@ -2768,14 +2873,17 @@ ApplyModifiers(char *nstr, const char *tstr, pattern.flags = 0; delim = '!'; - + emsg = NULL; cp = ++tstr; - if ((pattern.rhs = VarGetPattern(ctxt, &parsestate, errnum, + if ((pattern.rhs = VarGetPattern(ctxt, &parsestate, flags, &cp, delim, NULL, &pattern.rightLen, NULL)) == NULL) goto cleanup; - newStr = Cmd_Exec(pattern.rhs, &emsg); + if (flags & VARF_WANTRES) + newStr = Cmd_Exec(pattern.rhs, &emsg); + else + newStr = varNoError; free(UNCONST(pattern.rhs)); if (emsg) Error(emsg, nstr); @@ -2800,7 +2908,7 @@ ApplyModifiers(char *nstr, const char *tstr, cp = tstr+1; /* point to char after '[' */ delim = ']'; /* look for closing ']' */ estr = VarGetPattern(ctxt, &parsestate, - errnum, &cp, delim, + flags, &cp, delim, NULL, NULL, NULL); if (estr == NULL) goto cleanup; /* report missing ']' */ @@ -2867,8 +2975,6 @@ ApplyModifiers(char *nstr, const char *tstr, * integer for :[N], or two integers * separated by ".." for :[start..end]. */ - char *ep; - VarSelectWords_t seldata = { 0, 0 }; seldata.start = strtol(estr, &ep, 0); @@ -2927,9 +3033,15 @@ ApplyModifiers(char *nstr, const char *tstr, } case 'g': cp = tstr + 1; /* make sure it is set */ - if (STRMOD_MATCH(tstr, "gmtime", 6)) { - newStr = VarStrftime(nstr, 1); - cp = tstr + 6; + if (STRMOD_MATCHX(tstr, "gmtime", 6)) { + if (tstr[6] == '=') { + utc = strtoul(&tstr[7], &ep, 10); + cp = ep; + } else { + utc = 0; + cp = tstr + 6; + } + newStr = VarStrftime(nstr, 1, utc); termc = *cp; } else { goto default_case; @@ -2947,9 +3059,15 @@ ApplyModifiers(char *nstr, const char *tstr, break; case 'l': cp = tstr + 1; /* make sure it is set */ - if (STRMOD_MATCH(tstr, "localtime", 9)) { - newStr = VarStrftime(nstr, 0); - cp = tstr + 9; + if (STRMOD_MATCHX(tstr, "localtime", 9)) { + if (tstr[9] == '=') { + utc = strtoul(&tstr[10], &ep, 10); + cp = ep; + } else { + utc = 0; + cp = tstr + 9; + } + newStr = VarStrftime(nstr, 0, utc); termc = *cp; } else { goto default_case; @@ -2977,6 +3095,9 @@ ApplyModifiers(char *nstr, const char *tstr, parsestate.varSpace = 0; /* no separator */ cp = tstr + 2; } else if (tstr[2] == '\\') { + const char *xp = &tstr[3]; + int base = 8; /* assume octal */ + switch (tstr[3]) { case 'n': parsestate.varSpace = '\n'; @@ -2986,12 +3107,19 @@ ApplyModifiers(char *nstr, const char *tstr, parsestate.varSpace = '\t'; cp = tstr + 4; break; + case 'x': + base = 16; + xp++; + goto get_numeric; + case '0': + base = 0; + goto get_numeric; default: if (isdigit((unsigned char)tstr[3])) { - char *ep; + get_numeric: parsestate.varSpace = - strtoul(&tstr[3], &ep, 0); + strtoul(xp, &ep, base); if (*ep != ':' && *ep != endc) goto bad_modifier; cp = ep; @@ -3151,7 +3279,7 @@ ApplyModifiers(char *nstr, const char *tstr, * expand it. */ cp2 = pattern; - pattern = Var_Subst(NULL, cp2, ctxt, errnum); + pattern = Var_Subst(NULL, cp2, ctxt, flags | VARF_WANTRES); free(cp2); } if (DEBUG(VAR)) @@ -3187,14 +3315,14 @@ ApplyModifiers(char *nstr, const char *tstr, } cp = tstr; - if ((pattern.lhs = VarGetPattern(ctxt, &parsestate, errnum, + if ((pattern.lhs = VarGetPattern(ctxt, &parsestate, flags, &cp, delim, &pattern.flags, &pattern.leftLen, NULL)) == NULL) goto cleanup; - if ((pattern.rhs = VarGetPattern(ctxt, &parsestate, errnum, + if ((pattern.rhs = VarGetPattern(ctxt, &parsestate, flags, &cp, delim, NULL, &pattern.rightLen, &pattern)) == NULL) @@ -3237,31 +3365,47 @@ ApplyModifiers(char *nstr, const char *tstr, { VarPattern pattern; Boolean value; - + int cond_rc; + int lhs_flags, rhs_flags; + /* find ':', and then substitute accordingly */ - + if (flags & VARF_WANTRES) { + cond_rc = Cond_EvalExpression(NULL, v->name, &value, 0, FALSE); + if (cond_rc == COND_INVALID) { + lhs_flags = rhs_flags = VAR_NOSUBST; + } else if (value) { + lhs_flags = 0; + rhs_flags = VAR_NOSUBST; + } else { + lhs_flags = VAR_NOSUBST; + rhs_flags = 0; + } + } else { + /* we are just consuming and discarding */ + cond_rc = value = 0; + lhs_flags = rhs_flags = VAR_NOSUBST; + } pattern.flags = 0; cp = ++tstr; delim = ':'; - if ((pattern.lhs = VarGetPattern(ctxt, &parsestate, errnum, - &cp, delim, NULL, + if ((pattern.lhs = VarGetPattern(ctxt, &parsestate, flags, + &cp, delim, &lhs_flags, &pattern.leftLen, NULL)) == NULL) goto cleanup; /* BROPEN or PROPEN */ delim = endc; - if ((pattern.rhs = VarGetPattern(ctxt, &parsestate, errnum, - &cp, delim, NULL, + if ((pattern.rhs = VarGetPattern(ctxt, &parsestate, flags, + &cp, delim, &rhs_flags, &pattern.rightLen, NULL)) == NULL) goto cleanup; termc = *--cp; delim = '\0'; - if (Cond_EvalExpression(NULL, v->name, &value, 0, FALSE) - == COND_INVALID) { + if (cond_rc == COND_INVALID) { Error("Bad conditional expression `%s' in %s?%s:%s", v->name, v->name, pattern.lhs, pattern.rhs); goto cleanup; @@ -3294,12 +3438,12 @@ ApplyModifiers(char *nstr, const char *tstr, cp = tstr; - if ((re = VarGetPattern(ctxt, &parsestate, errnum, &cp, delim, + if ((re = VarGetPattern(ctxt, &parsestate, flags, &cp, delim, NULL, NULL, NULL)) == NULL) goto cleanup; if ((pattern.replace = VarGetPattern(ctxt, &parsestate, - errnum, &cp, delim, NULL, + flags, &cp, delim, NULL, NULL, NULL)) == NULL){ free(re); goto cleanup; @@ -3348,9 +3492,10 @@ ApplyModifiers(char *nstr, const char *tstr, break; } #endif + case 'q': case 'Q': if (tstr[1] == endc || tstr[1] == ':') { - newStr = VarQuote(nstr); + newStr = VarQuote(nstr, modifier == 'q'); cp = tstr + 1; termc = *cp; break; @@ -3392,6 +3537,23 @@ ApplyModifiers(char *nstr, const char *tstr, break; } goto default_case; + case 'r': + cp = tstr + 1; /* make sure it is set */ + if (STRMOD_MATCHX(tstr, "range", 5)) { + int n; + + if (tstr[5] == '=') { + n = strtoul(&tstr[6], &ep, 10); + cp = ep; + } else { + n = 0; + cp = tstr + 5; + } + newStr = VarRange(nstr, n); + termc = *cp; + break; + } + goto default_case; case 'O': { char otype; @@ -3423,9 +3585,12 @@ ApplyModifiers(char *nstr, const char *tstr, case 's': if (tstr[1] == 'h' && (tstr[2] == endc || tstr[2] == ':')) { const char *emsg; - newStr = Cmd_Exec(nstr, &emsg); - if (emsg) - Error(emsg, nstr); + if (flags & VARF_WANTRES) { + newStr = Cmd_Exec(nstr, &emsg); + if (emsg) + Error(emsg, nstr); + } else + newStr = varNoError; cp = tstr + 2; termc = *cp; break; @@ -3473,12 +3638,12 @@ ApplyModifiers(char *nstr, const char *tstr, delim='='; cp = tstr; if ((pattern.lhs = VarGetPattern(ctxt, &parsestate, - errnum, &cp, delim, &pattern.flags, + flags, &cp, delim, &pattern.flags, &pattern.leftLen, NULL)) == NULL) goto cleanup; delim = endc; if ((pattern.rhs = VarGetPattern(ctxt, &parsestate, - errnum, &cp, delim, NULL, &pattern.rightLen, + flags, &cp, delim, NULL, &pattern.rightLen, &pattern)) == NULL) goto cleanup; @@ -3546,10 +3711,8 @@ ApplyModifiers(char *nstr, const char *tstr, if (delim != '\0') Error("Unclosed substitution for %s (%c missing)", v->name, delim); - if (*freePtr) { - free(*freePtr); - *freePtr = NULL; - } + free(*freePtr); + *freePtr = NULL; return (var_Error); } @@ -3563,7 +3726,9 @@ ApplyModifiers(char *nstr, const char *tstr, * Input: * str The string to parse * ctxt The context for the variable - * errnum TRUE if undefined variables are an error + * flags VARF_UNDEFERR if undefineds are an error + * VARF_WANTRES if we actually want the result + * VARF_ASSIGN if we are in a := assignment * lengthPtr OUT: The length of the specification * freePtr OUT: Non-NULL if caller should free *freePtr * @@ -3582,8 +3747,8 @@ ApplyModifiers(char *nstr, const char *tstr, */ /* coverity[+alloc : arg-*4] */ char * -Var_Parse(const char *str, GNode *ctxt, Boolean errnum, int *lengthPtr, - void **freePtr) +Var_Parse(const char *str, GNode *ctxt, int flags, + int *lengthPtr, void **freePtr) { const char *tstr; /* Pointer into str */ Var *v; /* Variable in invocation */ @@ -3641,17 +3806,17 @@ Var_Parse(const char *str, GNode *ctxt, Boolean errnum, int *lengthPtr, case '@': return UNCONST("$(.TARGET)"); case '%': - return UNCONST("$(.ARCHIVE)"); + return UNCONST("$(.MEMBER)"); case '*': return UNCONST("$(.PREFIX)"); case '!': - return UNCONST("$(.MEMBER)"); + return UNCONST("$(.ARCHIVE)"); } } /* * Error */ - return (errnum ? var_Error : varNoError); + return (flags & VARF_UNDEFERR) ? var_Error : varNoError; } else { haveModifier = FALSE; tstr = &str[1]; @@ -3688,12 +3853,11 @@ Var_Parse(const char *str, GNode *ctxt, Boolean errnum, int *lengthPtr, if (*tstr == '$') { int rlen; void *freeIt; - char *rval = Var_Parse(tstr, ctxt, errnum, &rlen, &freeIt); + char *rval = Var_Parse(tstr, ctxt, flags, &rlen, &freeIt); if (rval != NULL) { Buf_AddBytes(&buf, strlen(rval), rval); } - if (freeIt) - free(freeIt); + free(freeIt); tstr += rlen - 1; } else @@ -3802,7 +3966,7 @@ Var_Parse(const char *str, GNode *ctxt, Boolean errnum, int *lengthPtr, return(pstr); } else { Buf_Destroy(&buf, TRUE); - return (errnum ? var_Error : varNoError); + return (flags & VARF_UNDEFERR) ? var_Error : varNoError; } } else { /* @@ -3836,7 +4000,7 @@ Var_Parse(const char *str, GNode *ctxt, Boolean errnum, int *lengthPtr, */ nstr = Buf_GetAll(&v->val, NULL); if (strchr(nstr, '$') != NULL) { - nstr = Var_Subst(NULL, nstr, ctxt, errnum); + nstr = Var_Subst(NULL, nstr, ctxt, flags); *freePtr = nstr; } @@ -3849,7 +4013,7 @@ Var_Parse(const char *str, GNode *ctxt, Boolean errnum, int *lengthPtr, extraFree = NULL; if (extramodifiers != NULL) { nstr = ApplyModifiers(nstr, extramodifiers, '(', ')', - v, ctxt, errnum, &used, &extraFree); + v, ctxt, flags, &used, &extraFree); } if (haveModifier) { @@ -3857,11 +4021,9 @@ Var_Parse(const char *str, GNode *ctxt, Boolean errnum, int *lengthPtr, tstr++; nstr = ApplyModifiers(nstr, tstr, startc, endc, - v, ctxt, errnum, &used, freePtr); + v, ctxt, flags, &used, freePtr); tstr += used; - if (extraFree) { - free(extraFree); - } + free(extraFree); } else { *freePtr = extraFree; } @@ -3900,7 +4062,7 @@ Var_Parse(const char *str, GNode *ctxt, Boolean errnum, int *lengthPtr, nstr = bmake_strndup(start, *lengthPtr); *freePtr = nstr; } else { - nstr = errnum ? var_Error : varNoError; + nstr = (flags & VARF_UNDEFERR) ? var_Error : varNoError; } } if (nstr != Buf_GetAll(&v->val, NULL)) @@ -3915,14 +4077,16 @@ Var_Parse(const char *str, GNode *ctxt, Boolean errnum, int *lengthPtr, *----------------------------------------------------------------------- * Var_Subst -- * Substitute for all variables in the given string in the given context - * If undefErr is TRUE, Parse_Error will be called when an undefined + * If flags & VARF_UNDEFERR, Parse_Error will be called when an undefined * variable is encountered. * * Input: * var Named variable || NULL for all * str the string which to substitute * ctxt the context wherein to find variables - * undefErr TRUE if undefineds are an error + * flags VARF_UNDEFERR if undefineds are an error + * VARF_WANTRES if we actually want the result + * VARF_ASSIGN if we are in a := assignment * * Results: * The resulting string. @@ -3932,7 +4096,7 @@ Var_Parse(const char *str, GNode *ctxt, Boolean errnum, int *lengthPtr, *----------------------------------------------------------------------- */ char * -Var_Subst(const char *var, const char *str, GNode *ctxt, Boolean undefErr) +Var_Subst(const char *var, const char *str, GNode *ctxt, int flags) { Buffer buf; /* Buffer for forming things */ char *val; /* Value to substitute for a variable */ @@ -3956,6 +4120,8 @@ Var_Subst(const char *var, const char *str, GNode *ctxt, Boolean undefErr) * In such a case, we skip over the escape character and store the * dollar sign into the buffer directly. */ + if (save_dollars && (flags & VARF_ASSIGN)) + Buf_AddByte(&buf, *str); str++; Buf_AddByte(&buf, *str); str++; @@ -4030,7 +4196,7 @@ Var_Subst(const char *var, const char *str, GNode *ctxt, Boolean undefErr) continue; } - val = Var_Parse(str, ctxt, undefErr, &length, &freeIt); + val = Var_Parse(str, ctxt, flags, &length, &freeIt); /* * When we come down here, val should either point to the @@ -4047,7 +4213,7 @@ Var_Subst(const char *var, const char *str, GNode *ctxt, Boolean undefErr) */ if (oldVars) { str += length; - } else if (undefErr || val == var_Error) { + } else if ((flags & VARF_UNDEFERR) || val == var_Error) { /* * If variable is undefined, complain and skip the * variable. The complaint will stop us from doing anything @@ -4078,10 +4244,8 @@ Var_Subst(const char *var, const char *str, GNode *ctxt, Boolean undefErr) Buf_AddBytes(&buf, length, val); trailingBslash = length > 0 && val[length - 1] == '\\'; } - if (freeIt) { - free(freeIt); - freeIt = NULL; - } + free(freeIt); + freeIt = NULL; } } |