summaryrefslogtreecommitdiffstats
path: root/src/kmk/tests/scripts/targets/POSIX
blob: 5c3c7f89a61d01624c5ff2af390da4826a984f46 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#                                                                    -*-perl-*-

$description = "Test the behaviour of the .POSIX target.";

$details = "";


# Ensure turning on .POSIX enables the -e flag for the shell
# We can't assume the exit value of "false" because on different systems it's
# different.

my $script = 'false; true';
my $flags = '-ec';
my $out = `/bin/sh $flags '$script' 2>&1`;
my $err = $? >> 8;
run_make_test(qq!
.POSIX:
all: ; \@$script
!,
              '', "#MAKE#: *** [#MAKEFILE#:3: all] Error $err\n", 512);

# User settings must override .POSIX
$flags = '-xc';
$out = `/bin/sh $flags '$script' 2>&1`;
run_make_test(qq!
.SHELLFLAGS = $flags
.POSIX:
all: ; \@$script
!,
              '', $out);

# Test the default value of various POSIX-specific variables
my %POSIX = (AR => 'ar', ARFLAGS => '-rv',
             YACC => 'yacc', YFLAGS => '',
             LEX => 'lex', LFLAGS => '',
             LDFLAGS => '',
             CC => 'c99', CFLAGS => '-O',
             FC => 'fort77', FFLAGS => '-O 1',
             GET => 'get', GFLAGS => '',
             SCCSFLAGS => '', SCCSGETFLAGS => '-s');
my $make = join('', map { "\t\@echo '$_=\$($_)'\n" } sort keys %POSIX);
my $r = join('', map { "$_=$POSIX{$_}\n"} sort keys %POSIX);
run_make_test(qq!
.POSIX:
all:
$make
!,
              '', $r);

# Make sure that local settings take precedence
%extraENV = map { $_ => "xx-$_" } keys %POSIX;
$r = join('', map { "$_=xx-$_\n"} sort keys %POSIX);
run_make_test(undef, '', $r);

# This tells the test driver that the perl test script executed properly.
1;