| 1 |
$description = "\ |
| 2 |
The following test creates a makefile to test the presence |
| 3 |
of multiple rules for one target. One file can be the |
| 4 |
target of several rules if at most one rule has commands; |
| 5 |
the other rules can only have dependencies."; |
| 6 |
|
| 7 |
$details = "\ |
| 8 |
The makefile created in this test contains two hardcoded rules |
| 9 |
for foo.o and bar.o. It then gives another multiple target rule |
| 10 |
with the same names as above but adding more dependencies. |
| 11 |
Additionally, another variable extradeps is listed as a |
| 12 |
dependency but is defined to be null. It can however be defined |
| 13 |
on the make command line as extradeps=extra.h which adds yet |
| 14 |
another dependency to the targets."; |
| 15 |
|
| 16 |
open(MAKEFILE,"> $makefile"); |
| 17 |
|
| 18 |
# The Contents of the MAKEFILE ... |
| 19 |
|
| 20 |
print MAKEFILE <<EOF; |
| 21 |
objects = foo.o bar.o |
| 22 |
foo.o : defs.h |
| 23 |
bar.o : defs.h test.h |
| 24 |
extradeps = |
| 25 |
\$(objects) : config.h \$(extradeps) |
| 26 |
\t\@echo EXTRA EXTRA |
| 27 |
EOF |
| 28 |
|
| 29 |
# END of Contents of MAKEFILE |
| 30 |
|
| 31 |
close(MAKEFILE); |
| 32 |
|
| 33 |
&touch("defs.h","test.h","config.h"); |
| 34 |
|
| 35 |
if ($vos) |
| 36 |
{ |
| 37 |
$error_code = 3307; |
| 38 |
} |
| 39 |
else |
| 40 |
{ |
| 41 |
$error_code = 512; |
| 42 |
} |
| 43 |
|
| 44 |
&run_make_with_options($makefile, |
| 45 |
"extradeps=extra.h", |
| 46 |
&get_logfile, |
| 47 |
$error_code); |
| 48 |
|
| 49 |
# Create the answer to what should be produced by this Makefile |
| 50 |
$answer = "$make_name: *** No rule to make target 'extra.h', needed by 'foo.o'. Stop.\n"; |
| 51 |
|
| 52 |
&compare_output($answer,&get_logfile(1)); |
| 53 |
|
| 54 |
|
| 55 |
# TEST #2 |
| 56 |
# ------- |
| 57 |
|
| 58 |
&touch("extra.h"); |
| 59 |
|
| 60 |
&run_make_with_options($makefile, |
| 61 |
"extradeps=extra.h", |
| 62 |
&get_logfile, |
| 63 |
0); |
| 64 |
|
| 65 |
# Create the answer to what should be produced by this Makefile |
| 66 |
$answer = "EXTRA EXTRA\n"; |
| 67 |
|
| 68 |
&compare_output($answer,&get_logfile(1)); |
| 69 |
|
| 70 |
unlink("defs.h","test.h","config.h","extra.h"); |
| 71 |
|
| 72 |
# sv 62650. |
| 73 |
# Test the message that make prints when a file found by directory search |
| 74 |
# is preferred over the local one. |
| 75 |
run_make_test(q! |
| 76 |
vpath hello.c src |
| 77 |
all: hello.c; $(info $@ from $^) |
| 78 |
hello.c: ; $(info 1 $@) |
| 79 |
src/hello.c: ; $(info 2 $@) |
| 80 |
!, '', |
| 81 |
"#MAKEFILE#:4: Recipe was specified for file 'hello.c' at #MAKEFILE#:4, |
| 82 |
#MAKEFILE#:4: but 'hello.c' is now considered the same file as 'src/hello.c'. |
| 83 |
#MAKEFILE#:4: Recipe for 'hello.c' will be ignored in favor of the one for 'src/hello.c'. |
| 84 |
2 src/hello.c |
| 85 |
all from src/hello.c |
| 86 |
#MAKE#: 'all' is up to date.\n"); |
| 87 |
|
| 88 |
1; |