| 1 | # -*-mode: perl; rm-trailing-spaces: nil-*-
|
|---|
| 2 |
|
|---|
| 3 | $description = "Test various forms of the GNU make `include' command.";
|
|---|
| 4 |
|
|---|
| 5 | $details = "\
|
|---|
| 6 | Test include, -include, sinclude and various regressions involving them.
|
|---|
| 7 | Test extra whitespace at the end of the include, multiple -includes and
|
|---|
| 8 | sincludes (should not give an error) and make sure that errors are reported
|
|---|
| 9 | for targets that were also -included.";
|
|---|
| 10 |
|
|---|
| 11 | $makefile2 = &get_tmpfile;
|
|---|
| 12 |
|
|---|
| 13 | open(MAKEFILE,"> $makefile");
|
|---|
| 14 |
|
|---|
| 15 | # The contents of the Makefile ...
|
|---|
| 16 |
|
|---|
| 17 | print MAKEFILE <<EOF;
|
|---|
| 18 | \#Extra space at the end of the following file name
|
|---|
| 19 | include $makefile2
|
|---|
| 20 | all: ; \@echo There should be no errors for this makefile.
|
|---|
| 21 |
|
|---|
| 22 | -include nonexistent.mk
|
|---|
| 23 | -include nonexistent.mk
|
|---|
| 24 | sinclude nonexistent.mk
|
|---|
| 25 | sinclude nonexistent-2.mk
|
|---|
| 26 | -include makeit.mk
|
|---|
| 27 | sinclude makeit.mk
|
|---|
| 28 |
|
|---|
| 29 | error: makeit.mk
|
|---|
| 30 | EOF
|
|---|
| 31 |
|
|---|
| 32 | close(MAKEFILE);
|
|---|
| 33 |
|
|---|
| 34 |
|
|---|
| 35 | open(MAKEFILE,"> $makefile2");
|
|---|
| 36 |
|
|---|
| 37 | print MAKEFILE "ANOTHER: ; \@echo This is another included makefile\n";
|
|---|
| 38 |
|
|---|
| 39 | close(MAKEFILE);
|
|---|
| 40 |
|
|---|
| 41 | # Create the answer to what should be produced by this Makefile
|
|---|
| 42 | &run_make_with_options($makefile, "all", &get_logfile);
|
|---|
| 43 | $answer = "There should be no errors for this makefile.\n";
|
|---|
| 44 | &compare_output($answer, &get_logfile(1));
|
|---|
| 45 |
|
|---|
| 46 | &run_make_with_options($makefile, "ANOTHER", &get_logfile);
|
|---|
| 47 | $answer = "This is another included makefile\n";
|
|---|
| 48 | &compare_output($answer, &get_logfile(1));
|
|---|
| 49 |
|
|---|
| 50 | $makefile = undef;
|
|---|
| 51 |
|
|---|
| 52 | # Try to build the "error" target; this will fail since we don't know
|
|---|
| 53 | # how to create makeit.mk, but we should also get a message (even though
|
|---|
| 54 | # the -include suppressed it during the makefile read phase, we should
|
|---|
| 55 | # see one during the makefile run phase).
|
|---|
| 56 |
|
|---|
| 57 | run_make_test
|
|---|
| 58 | ('
|
|---|
| 59 | -include foo.mk
|
|---|
| 60 | error: foo.mk ; @echo $@
|
|---|
| 61 | ',
|
|---|
| 62 | '',
|
|---|
| 63 | "#MAKE#: *** No rule to make target `foo.mk', needed by `error'. Stop.\n",
|
|---|
| 64 | 512
|
|---|
| 65 | );
|
|---|
| 66 |
|
|---|
| 67 | # Make sure that target-specific variables don't impact things. This could
|
|---|
| 68 | # happen because a file record is created when a target-specific variable is
|
|---|
| 69 | # set.
|
|---|
| 70 |
|
|---|
| 71 | run_make_test
|
|---|
| 72 | ('
|
|---|
| 73 | bar.mk: foo := baz
|
|---|
| 74 | -include bar.mk
|
|---|
| 75 | hello: ; @echo hello
|
|---|
| 76 | ',
|
|---|
| 77 | '',
|
|---|
| 78 | "hello\n"
|
|---|
| 79 | );
|
|---|
| 80 |
|
|---|
| 81 |
|
|---|
| 82 | # Test inheritance of dontcare flag when rebuilding makefiles.
|
|---|
| 83 | #
|
|---|
| 84 | run_make_test('
|
|---|
| 85 | .PHONY: all
|
|---|
| 86 | all: ; @:
|
|---|
| 87 |
|
|---|
| 88 | -include foo
|
|---|
| 89 |
|
|---|
| 90 | foo: bar; @:
|
|---|
| 91 | ', '', '');
|
|---|
| 92 |
|
|---|
| 93 | 1;
|
|---|
| 94 |
|
|---|
| 95 |
|
|---|
| 96 | # Make sure that we don't die when the command fails but we dontcare.
|
|---|
| 97 | # (Savannah bug #13216).
|
|---|
| 98 | #
|
|---|
| 99 | run_make_test('
|
|---|
| 100 | .PHONY: all
|
|---|
| 101 | all:; @:
|
|---|
| 102 |
|
|---|
| 103 | -include foo
|
|---|
| 104 |
|
|---|
| 105 | foo: bar; @:
|
|---|
| 106 |
|
|---|
| 107 | bar:; @exit 1
|
|---|
| 108 | ', '', '');
|
|---|
| 109 |
|
|---|
| 110 | # Check include, sinclude, -include with no filenames.
|
|---|
| 111 | # (Savannah bug #1761).
|
|---|
| 112 |
|
|---|
| 113 | run_make_test('
|
|---|
| 114 | .PHONY: all
|
|---|
| 115 | all:; @:
|
|---|
| 116 | include
|
|---|
| 117 | -include
|
|---|
| 118 | sinclude', '', '');
|
|---|
| 119 |
|
|---|
| 120 | 1;
|
|---|