# Setting parallelism with the environment
# Command line should take precedence over the environment
-$extraENV{MAKEFLAGS} = "-j2 $np";
+$ENV{MAKEFLAGS} = "-j2 $np";
run_make_test(q!
SHOW = $(patsubst --jobserver-auth=%,--jobserver-auth=<auth>,$(MAKEFLAGS))
recurse: ; @echo $@: "/$(SHOW)/"; $(MAKE) -f #MAKEFILE# all
all:;@echo $@: "/$(SHOW)/"
!,
'', "recurse: /-j2 --jobserver-auth=<auth> $np/\nall: /-j2 --jobserver-auth=<auth> $np/\n");
-delete $extraENV{MAKEFLAGS};
# Test override of -jN
-$extraENV{MAKEFLAGS} = "-j9 $np";
+$ENV{MAKEFLAGS} = "-j9 $np";
run_make_test(q!
SHOW = $(patsubst --jobserver-auth=%,--jobserver-auth=<auth>,$(MAKEFLAGS))
recurse: ; @echo $@: "/$(SHOW)/"; $(MAKE) -j3 -f #MAKEFILE# recurse2
all:;@echo $@: "/$(SHOW)/"
!,
"-j2 $np", "recurse: /-j2 --jobserver-auth=<auth> $np/\n#MAKE#[1]: warning: -j3 forced in submake: resetting jobserver mode.\nrecurse2: /-j3 --jobserver-auth=<auth> $np/\nall: /-j3 --jobserver-auth=<auth> $np/\n");
-delete $extraENV{MAKEFLAGS};
# Test override of -jN with -j
run_make_test(q!
unlink('inc.mk');
run_make_test(q!
+.RECIPEPREFIX = >
-include inc.mk
recur:
-# @echo 'MAKEFLAGS = $(MAKEFLAGS)'
- @rm -f inc.mk
- @$(MAKE) -j2 -f #MAKEFILE# all
+#> @echo 'MAKEFLAGS = $(MAKEFLAGS)'
+> @rm -f inc.mk
+> @$(MAKE) -j2 -f #MAKEFILE# all
all:
-# @echo 'MAKEFLAGS = $(MAKEFLAGS)'
- @echo $@
+#> @echo 'MAKEFLAGS = $(MAKEFLAGS)'
+> @echo $@
inc.mk:
-# @echo 'MAKEFLAGS = $(MAKEFLAGS)'
- @echo 'FOO = bar' > $@
+#> @echo 'MAKEFLAGS = $(MAKEFLAGS)'
+> @echo 'FOO = bar' > $@
!,
"$np -j2", "#MAKE#[1]: warning: -j2 forced in submake: resetting jobserver mode.\nall\n");
# Test recursion which is hidden from make.
# See Savannah bug #39934
# Or Red Hat bug https://bugzilla.redhat.com/show_bug.cgi?id=885474
-# Windows doesn't use a pipe, and doesn't close access, so this won't happen.
+# Environments that don't use a pipe won't close access, so this won't happen.
if ($port_type ne 'W32') {
- open(MAKEFILE,"> Makefile2");
- print MAKEFILE '
- vpath %.c ../
- foo:
- ';
- close(MAKEFILE);
+ create_file('Makefile2', "vpath %.c ../\n", "foo:\n");
run_make_test(q!
default: ; @ #MAKEPATH# -f Makefile2
!,
- "-j2 $np",
+ "--jobserver-style=pipe -j2 $np",
"#MAKE#[1]: warning: jobserver unavailable: using -j1. Add '+' to parent make rule.
#MAKE#[1]: Nothing to be done for 'foo'.");
rmfiles('Makefile2');
}
-1;
+# For Windows and named pipes, we don't need to worry about recursion
+if ($port_type eq 'W32' || exists $FEATURES{'jobserver-fifo'}) {
+ create_file('Makefile2', "vpath %.c ../\n", "foo:\n");
+
+ run_make_test(q!
+default: ; @ #MAKEPATH# -f Makefile2
+!,
+ "-j2 $np",
+"#MAKE#[1]: Nothing to be done for 'foo'.");
+
+ rmfiles('Makefile2');
+}
+
+# Ensure enter/leave directory messages appear before jobserver warnings
-### Local Variables:
-### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
-### End:
+run_make_test(q!
+all: ; @$(MAKE) -C . -f #MAKEFILE# recurse -j1
+recurse: ; @echo hi
+!,
+ '-w -j2', "#MAKE#: Entering directory '#PWD#'
+#MAKE#[1]: Entering directory '#PWD#'
+#MAKE#[1]: warning: -j1 forced in submake: resetting jobserver mode.
+hi
+#MAKE#[1]: Leaving directory '#PWD#'
+#MAKE#: Leaving directory '#PWD#'\n");
+
+# Check for invalid jobserver-style options
+
+run_make_test(q!
+all: a
+all a: ; @echo $@
+!,
+ '--jobserver-style=foo -j8',
+ "#MAKE#: *** Unknown jobserver auth style 'foo'. Stop.", 512);
+
+# sv 62908.
+# Test that when mkfifo fails, make switches to pipe and succeeds.
+# Force mkfifo to fail by attempting to create a fifo in a non existent
+# directory.
+# run_make_test does not allow matching a multiline pattern, therefore run the
+# test twice.
+# First time look for /$ERR_no_such_file/ to ensure mkfifo failed.
+# Second time look for /Nothing to be done/ to ensure make succeeded.
+if (exists $FEATURES{'jobserver-fifo'}) {
+ $ENV{TMPDIR} = "nosuchdir";
+ run_make_test("all:\n", '-j2', "/$ERR_no_such_file/");
+
+ $ENV{TMPDIR} = "nosuchdir";
+ run_make_test(undef, '-j2', "/Nothing to be done/");
+
+ # Verify that MAKE_TMPDIR is preferred if provided
+ $ENV{MAKE_TMPDIR} = '.';
+ $ENV{TMPDIR} = 'nosuchdir';
+
+ run_make_test(q!
+recurse: ; @$(MAKE) -f #MAKEFILE# all
+all:;@echo "$$MAKEFLAGS"
+!,
+ "-j2 --no-print-directory", "/--jobserver-auth=fifo:\\./");
+}
+
+1;