freebsd-nq/share/mk
Bryan Drewery abb02fa2f9 Fix most cases of bsd.progs.mk running duplicate or missing commands.
This mostly fixes an interaction with bsd.test.mk with PROGS and SCRIPTS.
This was most notable with 'make clean' and 'make install', which r281055
and r272055 attempted to address but were inadequate.

It also addresses similar issues in bsd.progs.mk when not using bsd.test.mk.

This also fixes cases of NOT running commands in the parent when using
bsd.progs.mk:
  - 'make clean' was not run for the main process for Makefiles which had both
    FILES and SUBDIR but no PROGS or SCRIPTS.  This usually was just a
    leftover Kyuafile.auto.  One such example is usr.bin/bmake/tests/sysmk/t1/2.
  - 'make obj' was not running in the current directory with bsd.test.mk due
    to early inclusion of bsd.subdir.mk.  This was not really a problem due to
    the SUBDIRS using 'mkdir -p' for their objdirs.

There were subtle bugs causing this wrong behavior:
  1. bsd.progs.mk needs to set SCRIPTS to empty when recursing to avoid
     the sub-makes from installing, cleaning or building the SCRIPTS;
     only the parent make should be doing this.  r281055 effectively did
     the same but wasn't enough.
  2. CLEANFILES may contain (especially from *.test.mk) files which only
     the parent should clean, such as from FILES and SCRIPTS.  To resolve
     sub-makes also cleaning these, reset CLEANFILES and CLEANDIRS in the
     children before including bsd.prog.mk.  A tempting alternative would be
     to only handle CLEANFILES in the parent but then the child bsd.prog.mk
     CLEANFILES of per-PROGS wouldn't be setup.
  3. bsd.subdir.mk was included too soon in bsd.test.mk.  It needs to be
     included after bsd.prog.mk as the SCRIPTS logic is short-circuitted if
     'install:' is already defined (which bsd.subdir.mk does).  There is
     actually no need to include bsd.subdir.mk from bsd.test.mk as bsd.prog.mk
     and bsd.obj.mk will do so in the proper order.  The description in r257095
     covers this for FILES and was fixed differently, though changing the
     handling of target(install) in bsd.prog.mk may make sense after more
     research.
  4. bsd.progs.mk had extra logic to handle recursing SCRIPTS if PROGS was
     empty, which isn't its business to be doing.  SCRIPTS is handled fine
     by bsd.prog.mk.  This mostly reverts and reworks the fix in r259209 and
     partially reverts r272055.
  5. bsd.progs.mk has no need to depend 'all:' on SCRIPTS and FILES.  These
     are handled by bsd.prog.mk/bsd.files.mk fine.  This also partially reverts
     r272055.
  6. bsd.progs.mk was not drop-in safe for bsd.prog.mk.  Move the PROGS
     check from r273186 to allow it to be used safely.

Specific tested cases:
  SCRIPTS:no PROGS:no FILES:yes SUBDIR:yes
    usr.bin/bmake/tests/sysmk/t1/2

  SCRIPTS:yes PROGS:no FILES:yes SUBDIR:no
    usr.bin/bmake/tests/sysmk/t1/2/1

  SCRIPTS:yes PROGS:yes FILES:yes SUBDIR:yes
    lib/libthr/tests

  SCRIPTS:yes PROGS:no FILES:yes SUBDIR:no
    usr.bin/yacc/tests
    libexec/atf/atf-sh/tests

A full buildworld/installworld/clean comparison with mtree was also done.
The only relevant difference was the new fixed behavior of removing
Kyuafile.auto from the objdir in 'clean'.

Converting SCRIPTS to be a special case FILES group will make this less
fragile and is being explored.

One known remaining issue is 'cleandepend' removing the tags files for
every recursive call.

Note that the 'make clean' command runs for the CURDIR last, which can make
it appear to run multiple times when cleaning in tests/, but each command is
for a SUBDIR returning up the chain.  This is purely bsd.subdir.mk behavior.

PR:		191055
PR:		191955
MFC after:	2 weeks
Sponsored by:	EMC / Isilon Storage Division
2015-09-23 23:20:49 +00:00
..
atf.test.mk Remove ALLOW_DEPRECATED_ATF_TOOLS/ATFFILE support from atf.test.mk 2015-06-15 06:38:59 +00:00
auto.obj.mk Add META_MODE support. 2015-06-13 19:20:56 +00:00
bsd.arch.inc.mk
bsd.compiler.mk Mention what 'common' is for 2015-06-10 19:36:53 +00:00
bsd.cpu.mk After consultations with the arm community, don't define softfp for 2015-08-26 17:10:43 +00:00
bsd.crunchgen.mk Use ${CRUNCHGEN} rather than bare word. 2015-06-13 15:36:13 +00:00
bsd.dep.mk Building on fmake is no longer possible so removed tests for bmake. 2015-06-10 18:14:38 +00:00
bsd.doc.mk Use .CURDIR in soelim's include path instead of SRCDIR 2015-06-20 00:17:57 +00:00
bsd.dtb.mk Add infrastructure to build dtb files from dts files. 2015-01-08 18:28:06 +00:00
bsd.endian.mk Start to import support for the AArch64 architecture from ARM. This change 2015-03-19 13:53:47 +00:00
bsd.files.mk For each FOO in FILESLISTS, append the value of FOO.yes, sort, and 2015-08-27 01:52:45 +00:00
bsd.incs.mk Simplify symlinks on include files by using bmake's multivariable .for loops 2015-06-21 22:27:52 +00:00
bsd.info.mk Remove MK_INFO guards in bsd.info.mk per r276556 2015-01-02 22:55:30 +00:00
bsd.init.mk Avoid anoying warning 2015-06-14 03:27:22 +00:00
bsd.kmod.mk Eliminate bsd.sys.mk on purpose. Do not put it back. 2015-01-01 04:26:45 +00:00
bsd.lib.mk bsd.lib.mk: Simplify CLEANFILES handling. 2015-09-22 05:05:53 +00:00
bsd.libnames.mk Significant upgrades to sa(4) and mt(1). 2015-02-23 21:59:30 +00:00
bsd.links.mk Fix DESTDIR support 2015-03-15 23:40:50 +00:00
bsd.man.mk Fix typo which breaks build of manpages when WITHOUT_MANCOMPRESS is set 2015-07-08 22:24:55 +00:00
bsd.mkopt.mk Appy := to dependent opts once value determined. 2015-06-22 19:01:09 +00:00
bsd.nls.mk Allow staging to be help up (by .WAIT) until other 2013-03-08 22:02:08 +00:00
bsd.obj.mk With MK_AUTO_OBJ=yes objdir is created during sys.mk 2015-06-11 13:53:15 +00:00
bsd.opts.mk Add META_MODE support. 2015-06-13 19:20:56 +00:00
bsd.own.mk Remove now unused LIBPRIVATEDIR 2015-08-24 13:46:12 +00:00
bsd.port.mk Avoid sub-shell for realpath(1) for bmake by using its built-in :tA. 2015-09-03 17:01:58 +00:00
bsd.port.options.mk
bsd.port.post.mk
bsd.port.pre.mk
bsd.port.subdir.mk Avoid sub-shell for realpath(1) for bmake by using its built-in :tA. 2015-09-03 17:01:58 +00:00
bsd.prog.mk Fix most cases of bsd.progs.mk running duplicate or missing commands. 2015-09-23 23:20:49 +00:00
bsd.progs.mk Fix most cases of bsd.progs.mk running duplicate or missing commands. 2015-09-23 23:20:49 +00:00
bsd.README Document bsd.endian.mk. 2015-08-27 22:42:02 +00:00
bsd.snmpmod.mk
bsd.stand.mk Use CFLAGS_NO_SIMD in preference to varying lists of -mno-xxxx flags. 2015-08-27 23:46:42 +00:00
bsd.subdir.mk Automatically append SUBDIR.yes to the SUBDIR variable, and 2015-08-27 01:55:00 +00:00
bsd.symver.mk
bsd.sys.mk Garbage collect _SHLIBDIRPREFIX leftovers from r284898. 2015-09-18 22:28:13 +00:00
bsd.test.mk Fix most cases of bsd.progs.mk running duplicate or missing commands. 2015-09-23 23:20:49 +00:00
dirdeps.mk Add META_MODE support. 2015-06-13 19:20:56 +00:00
gendirdeps.mk Add META_MODE support. 2015-06-13 19:20:56 +00:00
host-target.mk Add META_MODE support. 2015-06-13 19:20:56 +00:00
install-new.mk Add META_MODE support. 2015-06-13 19:20:56 +00:00
local.autodep.mk Add META_MODE support. 2015-06-13 19:20:56 +00:00
local.dirdeps.mk Watch out for bin/cat in host stage tree 2015-06-14 03:28:25 +00:00
local.gendirdeps.mk Avoid trailing white-space 2015-06-14 03:28:48 +00:00
local.init.mk do not include src.opts.mk from here 2015-06-15 19:23:47 +00:00
local.meta.sys.mk META_MODE: Fix 2nd build causing everything to rebuild due to changed CC. 2015-09-23 22:36:01 +00:00
local.sys.env.mk Move include of make.conf back to its old position. 2015-06-19 14:56:24 +00:00
local.sys.mk Move include of make.conf back to its old position. 2015-06-19 14:56:24 +00:00
Makefile Add META_MODE support. 2015-06-13 19:20:56 +00:00
meta2deps.py Add META_MODE support. 2015-06-13 19:20:56 +00:00
meta2deps.sh Add META_MODE support. 2015-06-13 19:20:56 +00:00
meta.autodep.mk Add META_MODE support. 2015-06-13 19:20:56 +00:00
meta.stage.mk Normally a staging conflict causes an error. 2015-06-16 23:06:43 +00:00
meta.subdir.mk Add META_MODE support. 2015-06-13 19:20:56 +00:00
meta.sys.mk Add META_MODE support. 2015-06-13 19:20:56 +00:00
netbsd-tests.test.mk Import proper fix for misc/49356 (/usr/include/atf-c/config.h) after atf-c/config.h 2014-11-04 05:02:22 +00:00
plain.test.mk As an optimization (in simple, well used cases) only call cat ${.ALLSRC} when 2014-11-04 01:57:31 +00:00
src.libnames.mk Remove last traces of USEPRIVATELIB 2015-09-06 20:17:14 +00:00
src.opts.mk Separate ELFTOOLCHAIN_BOOTSTRAP from BINUTILS_BOOTSTRAP 2015-08-17 10:48:55 +00:00
src.sys.env.mk Move include of make.conf back to its old position. 2015-06-19 14:56:24 +00:00
src.sys.mk Trim space 2015-09-17 21:51:48 +00:00
stage-install.sh Add META_MODE support. 2015-06-13 19:20:56 +00:00
suite.test.mk Add support for TEST_METADATA 2015-07-04 02:37:36 +00:00
sys.dependfile.mk Add META_MODE support. 2015-06-13 19:20:56 +00:00
sys.mk META_MODE: Follow-up r287879 and have 'make -V .OBJDIR' still invoke auto.obj.mk. 2015-09-23 20:46:23 +00:00
tap.test.mk As an optimization (in simple, well used cases) only call cat ${.ALLSRC} when 2014-11-04 01:57:31 +00:00
version_gen.awk