| 1 |
# -*-perl-*- |
| 2 |
|
| 3 |
$description = "Test the behaviour of the .POSIX target."; |
| 4 |
|
| 5 |
$details = ""; |
| 6 |
|
| 7 |
|
| 8 |
# Ensure turning on .POSIX enables the -e flag for the shell |
| 9 |
|
| 10 |
run_make_test(q! |
| 11 |
.POSIX: |
| 12 |
all: ; @#HELPER# -q fail 1; #HELPER# out hello |
| 13 |
!, |
| 14 |
'', "#MAKE#: *** [#MAKEFILE#:3: all] Error 1\n", 512); |
| 15 |
|
| 16 |
# But explicit settings must still take precedence |
| 17 |
|
| 18 |
run_make_test(q! |
| 19 |
.POSIX: |
| 20 |
all: ; @-#HELPER# -q fail 1; #HELPER# out hello |
| 21 |
.SHELLFLAGS = -c |
| 22 |
!, |
| 23 |
'', "hello"); |
| 24 |
|
| 25 |
run_make_test(q! |
| 26 |
.POSIX: |
| 27 |
all: ; @-#HELPER# -q fail 1; #HELPER# out hello |
| 28 |
all: .SHELLFLAGS = -c |
| 29 |
!, |
| 30 |
'', "hello"); |
| 31 |
|
| 32 |
# SV 63667: We shouldn't add -e to sh if errors are ignored |
| 33 |
|
| 34 |
run_make_test(q! |
| 35 |
.POSIX: |
| 36 |
all: ; @-#HELPER# -q fail 1; #HELPER# out hello |
| 37 |
!, |
| 38 |
'', "hello\n"); |
| 39 |
|
| 40 |
# But explicit settings must still take precedence |
| 41 |
|
| 42 |
run_make_test(q! |
| 43 |
.POSIX: |
| 44 |
all: ; @-#HELPER# -q fail 1; #HELPER# out hello |
| 45 |
.SHELLFLAGS = -ec |
| 46 |
!, |
| 47 |
'', "#MAKE#: [#MAKEFILE#:3: all] Error 1 (ignored)\n"); |
| 48 |
|
| 49 |
run_make_test(q! |
| 50 |
.POSIX: |
| 51 |
all: ; @-#HELPER# -q fail 1; #HELPER# out hello |
| 52 |
all: .SHELLFLAGS = -ec |
| 53 |
!, |
| 54 |
'', "#MAKE#: [#MAKEFILE#:3: all] Error 1 (ignored)\n"); |
| 55 |
|
| 56 |
# User settings must override .POSIX |
| 57 |
# In the standard .POSIX must be the first thing in the makefile |
| 58 |
# but we relax that rule in GNU Make. |
| 59 |
|
| 60 |
# Different versions of sh generate different output for -x so check it |
| 61 |
my $script = subst_make_string('#HELPER# -q fail 1; true'); |
| 62 |
my $flags = '-xc'; |
| 63 |
my $out = `$sh_name $flags '$script' 2>&1`; |
| 64 |
|
| 65 |
run_make_test(qq! |
| 66 |
.SHELLFLAGS = $flags |
| 67 |
.POSIX: |
| 68 |
all: ; \@$script |
| 69 |
!, |
| 70 |
'', $out); |
| 71 |
|
| 72 |
# Test the default value of various POSIX-specific variables |
| 73 |
my %POSIX = (AR => 'ar', ARFLAGS => '-rv', |
| 74 |
YACC => 'yacc', YFLAGS => '', |
| 75 |
LEX => 'lex', LFLAGS => '', |
| 76 |
LDFLAGS => '', |
| 77 |
CC => 'c99', CFLAGS => '-O1', |
| 78 |
FC => 'fort77', FFLAGS => '-O1', |
| 79 |
SCCSFLAGS => '', SCCSGETFLAGS => '-s'); |
| 80 |
my $make = join('', map { "\t\@echo '$_=\$($_)'\n" } sort keys %POSIX); |
| 81 |
my $r = join('', map { "$_=$POSIX{$_}\n"} sort keys %POSIX); |
| 82 |
run_make_test(qq! |
| 83 |
.POSIX: |
| 84 |
all: |
| 85 |
$make |
| 86 |
!, |
| 87 |
'', $r); |
| 88 |
|
| 89 |
# Make sure that local settings take precedence |
| 90 |
%ENV = (%ENV, map { $_ => "xx-$_" } keys %POSIX); |
| 91 |
$r = join('', map { "$_=xx-$_\n"} sort keys %POSIX); |
| 92 |
run_make_test(undef, '', $r); |
| 93 |
|
| 94 |
# This tells the test driver that the perl test script executed properly. |
| 95 |
1; |