Ignore:
Timestamp:
Mar 14, 2018, 10:28:10 PM (7 years ago)
Author:
bird
Message:

kmk: Merged in changes from GNU make 4.2.1 (2e55f5e4abdc0e38c1d64be703b446695e70b3b6 / https://git.savannah.gnu.org/git/make.git).

Location:
trunk/src/kmk
Files:
10 edited
2 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/kmk

  • trunk/src/kmk/tests/scripts/functions/call

    r969 r3140  
    55results.\n";
    66
    7 open(MAKEFILE, "> $makefile");
    8 
    9 # The Contents of the MAKEFILE ...
    10 
    11 print MAKEFILE <<'EOMAKE';
     7run_make_test(q!
    128# Simple, just reverse two things
    139#
    1410reverse = $2 $1
    1511
    16 # A complex `map' function, using recursive `call'.
     12# A complex 'map' function, using recursive 'call'.
    1713#
    1814map = $(foreach a,$2,$(call $1,$a))
     
    3935DEP_baz = quux blarp
    4036rest = $(wordlist 2,$(words ${1}),${1})
    41 tclose = $(if $1,$(firstword $1) \
     37tclose = $(if $1,$(firstword $1)\
    4238                $(call tclose,$(sort ${DEP_$(firstword $1)} $(call rest,$1))))
    4339
     
    4945        echo '$(call my-if,a,b,c)'; \
    5046        echo '$(call two,bar,baz)'; \
    51         echo '$(call tclose,foo)'
     47        echo '$(call tclose,foo)';
     48!,
     49              "", "foo bar\ndefault file file\nb d f\n\n\nb\nbar foo baz\nfoo bar baz blarp quux \n");
    5250
    53 
    54 
    55 EOMAKE
    56 
    57 # These won't work until/unless PR/1527 is resolved.
    58 #        echo '$(call my-foreach,a,x y z,$(a)$(a))'; \
    59 #        echo '$(call my-if,,$(warning don't print this),ok)'
     51# These won't work because call expands all its arguments first, before
     52# passing them on, then marks them as resolved/simple, so they're not
     53# expanded again by the function.
    6054#
    61 # $answer = "xx yy zz\nok\n";
    62 
    63 # END of Contents of MAKEFILE
    64 
    65 close(MAKEFILE);
    66 
    67 &run_make_with_options($makefile, "", &get_logfile);
    68 $answer = "foo bar\ndefault file file\nb d f\n\n\nb\nbar foo baz\nfoo bar baz blarp quux \n";
    69 &compare_output($answer, &get_logfile(1));
    70 
     55#        echo '$(call my-foreach,a,x y z,$$(a)$$(a))'; \
     56#        echo '$(call my-if,,$$(info don't print this),$$(info do print this))'
     57#
     58# $answer = "xx yy zz\ndo print this\n";
    7159
    7260# TEST eclipsing of arguments when invoking sub-calls
    7361
    74 $makefile2 = &get_tmpfile;
    75 
    76 open(MAKEFILE,"> $makefile2");
    77 
    78 print MAKEFILE <<'EOF';
    79 
     62run_make_test(q!
    8063all = $1 $2 $3 $4 $5 $6 $7 $8 $9
    8164
     
    8972        @echo $(call level2,1,2,3,4,5,6,7,8)
    9073        @echo $(call level3,1,2,3,4,5,6,7,8)
    91 EOF
     74!,
     75              "", "1 2 3 4 5 6 7 8 9\n1 2 3 4 5\n1 2 3\n1 2 3\n");
    9276
    93 close(MAKEFILE);
     77# Ensure that variables are defined in global scope even in a $(call ...)
    9478
    95 &run_make_with_options($makefile2, "", &get_logfile);
    96 $answer = "1 2 3 4 5 6 7 8 9\n1 2 3 4 5\n1 2 3\n1 2 3\n";
    97 &compare_output($answer,&get_logfile(1));
     79delete $ENV{X123};
     80
     81run_make_test('
     82tst = $(eval export X123)
     83$(call tst)
     84all: ; @echo "$${X123-not set}"
     85',
     86              '', "\n");
    9887
    99881;
     89
     90### Local Variables:
     91### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     92### End:
  • trunk/src/kmk/tests/scripts/functions/error

    r969 r3140  
    5555
    5656&run_make_with_options($makefile, "ERROR4=definitely", &get_logfile, 512);
    57 $answer = "Some stuff\n$makefile:16: *** error is definitely.  Stop.\n";
     57$answer = "Some stuff\n$makefile:17: *** error is definitely.  Stop.\n";
    5858&compare_output($answer,&get_logfile(1));
    5959
     
    67671;
    6868
    69 
    70 
    71 
    72 
    73 
     69### Local Variables:
     70### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     71### End:
  • trunk/src/kmk/tests/scripts/functions/filter-out

    r969 r3140  
    11#                                                                    -*-perl-*-
    22
    3 $description = "Test the filter-out function.";
     3$description = "Test the filter and filter-out functions.";
    44
    55$details = "The makefile created in this test has two variables.  The
     
    1212functions is the same single .elc name.\n";
    1313
    14 open(MAKEFILE,"> $makefile");
     14# Basic test -- filter
     15run_make_test(q!
     16files1 := $(filter %.o, foo.elc bar.o lose.o)
     17files2 := $(filter %.o foo.i, foo.i bar.i lose.i foo.elc bar.o lose.o)
     18all: ; @echo '$(files1) $(files2)'
     19!,
     20              '', "bar.o lose.o foo.i bar.o lose.o\n");
    1521
    16 print MAKEFILE <<'EOF';
     22# Basic test -- filter-out
     23run_make_test(q!
    1724files1 := $(filter-out %.o, foo.elc bar.o lose.o)
    1825files2 := $(filter-out foo.i bar.i lose.i %.o, foo.i bar.i lose.i foo.elc bar.o lose.o)
    19 all: ; @echo $(files1) $(files2)
    20 EOF
     26all: ; @echo '$(files1) $(files2)'
     27!,
     28              '', "foo.elc foo.elc\n");
    2129
    22 close(MAKEFILE);
     30# Escaped patterns
     31run_make_test(q!all:;@echo '$(filter foo\%bar,foo%bar fooXbar)'!,
     32              '', "foo%bar\n");
    2333
    24 &run_make_with_options($makefile, "", &get_logfile, 0);
    25 $answer = "foo.elc foo.elc\n";
    26 &compare_output($answer,&get_logfile(1));
     34run_make_test(q!all:;@echo '$(filter foo\%\%\\\\\%\%bar,foo%%\\%%bar fooX\\Ybar)'!,
     35              '', "foo%%\\%%bar\n");
     36
     37run_make_test(q!
     38X = $(filter foo\\\\\%bar,foo\%bar foo\Xbar)
     39all:;@echo '$(X)'!,
     40              '', "foo\\%bar\n");
    2741
    28421;
  • trunk/src/kmk/tests/scripts/functions/foreach

    r2175 r3140  
    11#                                                                    -*-perl-*-
    2 # $Id: foreach,v 1.5 2006/03/10 02:20:46 psmith Exp $
     2# $Id$
    33
    44$description = "Test the foreach function.";
     
    5656              'FOREACH');
    5757
     58# Allow variable names with trailing space
     59run_make_test(q!
     60$(foreach \
     61  a \
     62, b c d \
     63, $(info $a))
     64all:;@:
     65!,
     66              "", "b\nc\nd\n");
    5867
    59 # TEST 2: Check some error conditions.
     68# Allow empty variable names.  We still expand the body.
     69
     70run_make_test('
     71x = $(foreach ,1 2 3,a)
     72y := $x
     73
     74all: ; @echo $y',
     75              '', "a a a\n");
     76
     77# Check some error conditions.
    6078
    6179run_make_test('
     
    6583all: ; @echo $y',
    6684              '',
    67               "#MAKEFILE#:2: *** insufficient number of arguments (1) to function `foreach'.  Stop.",
     85              "#MAKEFILE#:2: *** insufficient number of arguments (1) to function 'foreach'.  Stop.",
    6886              512);
    6987
    7088run_make_test('
    71 x = $(foreach )
     89x = $(foreach x,y)
    7290y := $x
    7391
    7492all: ; @echo $y',
    7593              '',
    76               "#MAKEFILE#:2: *** insufficient number of arguments (1) to function `foreach'.  Stop.",
     94              "#MAKEFILE#:2: *** insufficient number of arguments (2) to function 'foreach'.  Stop.",
    7795              512);
    7896
  • trunk/src/kmk/tests/scripts/functions/shell

    r2591 r3140  
    55$details = '';
    66
     7# Test standard shell
     8run_make_test('.PHONY: all
     9OUT := $(shell echo hi)
     10all: ; @echo $(OUT)
     11              ','','hi');
    712
    813# Test shells inside rules.
    914run_make_test('.PHONY: all
    1015all: ; @echo $(shell echo hi)
    11 ','','hi');
     16              ','','hi');
     17
     18# Verify .SHELLSTATUS
     19run_make_test('.PHONY: all
     20PRE := $(.SHELLSTATUS)
     21$(shell exit 0)
     22OK := $(.SHELLSTATUS)
     23$(shell exit 1)
     24BAD := $(.SHELLSTATUS)
     25all: ; @echo PRE=$(PRE) OK=$(OK) BAD=$(BAD)
     26              ','','PRE= OK=0 BAD=1');
    1227
    1328
     
    2843.PHONY: all
    2944all: ; @echo $$HI
    30 ','','hi');
     45    ','','hi');
     46
     47# Test shell errors in recipes including offset
     48run_make_test('
     49all:
     50        @echo hi
     51        $(shell ./basdfdfsed there)
     52        @echo there
     53',
     54              '', "#MAKE#: ./basdfdfsed: Command not found\nhi\nthere\n");
    3155
    32561;
     57
     58### Local Variables:
     59### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     60### End:
  • trunk/src/kmk/tests/scripts/functions/sort

    r969 r3140  
    1 $description = "The following test creates a makefile to verify\n"
    2               ."the ability of make to sort lists of object. Sort\n"
    3               ."will also remove any duplicate entries. This will also\n"
    4               ."be tested.";
     1#                                                                    -*-perl-*-
    52
    6 $details = "The make file is built with a list of object in a random order\n"
    7           ."and includes some duplicates. Make should sort all of the elements\n"
    8           ."remove all duplicates\n";
     3$description = "The following test creates a makefile to verify
     4the ability of make to sort lists of object. Sort
     5will also remove any duplicate entries. This will also
     6be tested.";
    97
    10 open(MAKEFILE,"> $makefile");
     8$details = "The make file is built with a list of object in a random order
     9and includes some duplicates. Make should sort all of the elements
     10remove all duplicates\n";
    1111
    12 # The Contents of the MAKEFILE ...
    13 
    14 print MAKEFILE "foo := moon_light days \n"
    15               ."foo1:= jazz\n"
    16               ."bar := captured \n"
    17               ."bar2 = boy end, has rise A midnight \n"
    18               ."bar3:= \$(foo)\n"
    19               ."s1  := _by\n"
    20               ."s2  := _and_a\n"
    21               ."t1  := \$(addsuffix \$(s1), \$(bar) )\n"
    22               ."t2  := \$(addsuffix \$(s2), \$(foo1) )\n"
    23               ."t3  := \$(t2) \$(t2) \$(t2) \$(t2) \$(t2) \$(t2) \$(t2) \$(t2) \$(t2) \$(t2) \n"
    24               ."t4  := \$(t3) \$(t3) \$(t3) \$(t3) \$(t3) \$(t3) \$(t3) \$(t3) \$(t3) \$(t3) \n"
    25               ."t5  := \$(t4) \$(t4) \$(t4) \$(t4) \$(t4) \$(t4) \$(t4) \$(t4) \$(t4) \$(t4) \n"
    26               ."t6  := \$(t5) \$(t5) \$(t5) \$(t5) \$(t5) \$(t5) \$(t5) \$(t5) \$(t5) \$(t5) \n"
    27               ."t7  := \$(t6) \$(t6) \$(t6) \n"
    28               ."p1  := \$(addprefix \$(foo1), \$(s2) )\n"
    29               ."blank:= \n"
    30               ."all:\n"
    31               ."\t\@echo \$(sort \$(bar2) \$(foo)  \$(addsuffix \$(s1), \$(bar) ) \$(t2) \$(bar2) \$(bar3))\n"
    32               ."\t\@echo \$(sort \$(blank) \$(foo) \$(bar2) \$(t1) \$(p1) )\n"
    33               ."\t\@echo \$(sort \$(foo) \$(bar2) \$(t1) \$(t4) \$(t5) \$(t7) \$(t6) )\n";
     12run_make_test('
     13foo := moon_light days
     14foo1:= jazz
     15bar := captured
     16bar2 = boy end, has rise A midnight
     17bar3:= $(foo)
     18s1  := _by
     19s2  := _and_a
     20t1  := $(addsuffix $(s1), $(bar) )
     21t2  := $(addsuffix $(s2), $(foo1) )
     22t3  := $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) $(t2) $(t2)
     23t4  := $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) $(t3) $(t3)
     24t5  := $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) $(t4) $(t4)
     25t6  := $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) $(t5) $(t5)
     26t7  := $(t6) $(t6) $(t6)
     27p1  := $(addprefix $(foo1), $(s2) )
     28blank:=
     29all:
     30        @echo $(sort $(bar2) $(foo)  $(addsuffix $(s1), $(bar) ) $(t2) $(bar2) $(bar3))
     31        @echo $(sort $(blank) $(foo) $(bar2) $(t1) $(p1) )
     32        @echo $(sort $(foo) $(bar2) $(t1) $(t4) $(t5) $(t7) $(t6) )
     33',
     34              '', 'A boy captured_by days end, has jazz_and_a midnight moon_light rise
     35A boy captured_by days end, has jazz_and_a midnight moon_light rise
     36A boy captured_by days end, has jazz_and_a midnight moon_light rise
     37');
    3438
    3539
    36 # END of Contents of MAKEFILE
     40# Test with non-space/tab whitespace.  Note that you can't see the
     41# original bug except using valgrind.
    3742
    38 close(MAKEFILE);
    39 
    40 &run_make_with_options($makefile,"",&get_logfile);
    41 
    42 # Create the answer to what should be produced by this Makefile
    43 $answer = "A boy captured_by days end, has jazz_and_a midnight moon_light rise\n"
    44          ."A boy captured_by days end, has jazz_and_a midnight moon_light rise\n"
    45          ."A boy captured_by days end, has jazz_and_a midnight moon_light rise\n";
    46 
    47 &compare_output($answer,&get_logfile(1));
     43run_make_test("FOO = a b\tc\rd\fe \f \f \f \f \ff
     44all: ; \@echo \$(words \$(sort \$(FOO)))\n",
     45              '', "6\n");
    4846
    49471;
    5048
    51 
    52 
    53 
    54 
    55 
     49### Local Variables:
     50### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     51### End:
  • trunk/src/kmk/tests/scripts/functions/warning

    r969 r3140  
    5353
    5454&run_make_with_options($makefile, "WARNING4=definitely", &get_logfile, 0);
    55 $answer = "Some stuff\n$makefile:14: warning is definitely\nhi\nthere\n";
     55$answer = "Some stuff\n$makefile:15: warning is definitely\nhi\nthere\n";
    5656&compare_output($answer,&get_logfile(1));
     57
     58# Test linenumber offset
     59
     60run_make_test(q!
     61all: one two
     62        $(warning in $@ line 3)
     63        @true
     64        $(warning in $@ line 5)
     65
     66one two:
     67        $(warning in $@ line 8)
     68        @true
     69        $(warning in $@ line 10)
     70!,
     71              '', "#MAKEFILE#:8: in one line 8
     72#MAKEFILE#:10: in one line 10
     73#MAKEFILE#:8: in two line 8
     74#MAKEFILE#:10: in two line 10
     75#MAKEFILE#:3: in all line 3
     76#MAKEFILE#:5: in all line 5\n");
    5777
    5878# This tells the test driver that the perl test script executed properly.
    59791;
    6080
    61 
    62 
    63 
    64 
    65 
     81### Local Variables:
     82### eval: (setq whitespace-action (delq 'auto-cleanup whitespace-action))
     83### End:
  • trunk/src/kmk/tests/scripts/functions/wildcard

    r2591 r3140  
    8989              '', "\n");
    9090
     91# TEST #5: wildcard used to verify file existence
     92
     93touch('xxx.yyy');
     94
     95run_make_test(q!exists: ; @echo file=$(wildcard xxx.yyy)!,
     96              '', "file=xxx.yyy\n");
     97
     98unlink('xxx.yyy');
     99
     100run_make_test(q!exists: ; @echo file=$(wildcard xxx.yyy)!,
     101              '', "file=\n");
     102
    911031;
  • trunk/src/kmk/tests/scripts/functions/word

    r969 r3140  
    5757wordlist-e3: ; @echo $(wordlist 1, 12a ,$(FOO))',
    5858              'word-e1',
    59               "#MAKEFILE#:3: *** non-numeric first argument to `word' function: ''.  Stop.",
     59              "#MAKEFILE#:3: *** non-numeric first argument to 'word' function: ''.  Stop.",
    6060              512);
    6161
    6262run_make_test(undef,
    6363              'word-e2',
    64               "#MAKEFILE#:4: *** non-numeric first argument to `word' function: 'abc '.  Stop.",
     64              "#MAKEFILE#:4: *** non-numeric first argument to 'word' function: 'abc '.  Stop.",
    6565              512);
    6666
    6767run_make_test(undef,
    6868              'word-e3',
    69               "#MAKEFILE#:5: *** non-numeric first argument to `word' function: '1a'.  Stop.",
     69              "#MAKEFILE#:5: *** non-numeric first argument to 'word' function: '1a'.  Stop.",
    7070              512);
    7171
    7272run_make_test(undef,
    7373              'wordlist-e1',
    74               "#MAKEFILE#:7: *** non-numeric first argument to `wordlist' function: ''.  Stop.",
     74              "#MAKEFILE#:7: *** non-numeric first argument to 'wordlist' function: ''.  Stop.",
    7575              512);
    7676
    7777run_make_test(undef,
    7878              'wordlist-e2',
    79               "#MAKEFILE#:8: *** non-numeric first argument to `wordlist' function: 'abc '.  Stop.",
     79              "#MAKEFILE#:8: *** non-numeric first argument to 'wordlist' function: 'abc '.  Stop.",
    8080              512);
    8181
    8282run_make_test(undef,
    8383              'wordlist-e3',
    84               "#MAKEFILE#:9: *** non-numeric second argument to `wordlist' function: ' 12a '.  Stop.",
     84              "#MAKEFILE#:9: *** non-numeric second argument to 'wordlist' function: ' 12a '.  Stop.",
    8585              512);
    8686
     
    9595wordlist-e: ; @echo $(WL)',
    9696              'word-e x=',
    97               "#MAKEFILE#:3: *** non-numeric first argument to `word' function: ''.  Stop.",
     97              "#MAKEFILE#:3: *** non-numeric first argument to 'word' function: ''.  Stop.",
    9898              512);
    9999
    100100run_make_test(undef,
    101101              'word-e x=abc',
    102               "#MAKEFILE#:3: *** non-numeric first argument to `word' function: 'abc'.  Stop.",
     102              "#MAKEFILE#:3: *** non-numeric first argument to 'word' function: 'abc'.  Stop.",
    103103              512);
    104104
    105105run_make_test(undef,
    106106              'word-e x=0',
    107               "#MAKEFILE#:3: *** first argument to `word' function must be greater than 0.  Stop.",
     107              "#MAKEFILE#:3: *** first argument to 'word' function must be greater than 0.  Stop.",
    108108              512);
    109109
    110110run_make_test(undef,
    111111              'wordlist-e s= e=',
    112               "#MAKEFILE#:4: *** non-numeric first argument to `wordlist' function: ''.  Stop.",
     112              "#MAKEFILE#:4: *** non-numeric first argument to 'wordlist' function: ''.  Stop.",
    113113              512);
    114114
    115115run_make_test(undef,
    116116              'wordlist-e s=abc e=',
    117               "#MAKEFILE#:4: *** non-numeric first argument to `wordlist' function: 'abc'.  Stop.",
     117              "#MAKEFILE#:4: *** non-numeric first argument to 'wordlist' function: 'abc'.  Stop.",
    118118              512);
    119119
    120120run_make_test(undef,
    121121              'wordlist-e s=4 e=12a',
    122               "#MAKEFILE#:4: *** non-numeric second argument to `wordlist' function: '12a'.  Stop.",
     122              "#MAKEFILE#:4: *** non-numeric second argument to 'wordlist' function: '12a'.  Stop.",
    123123              512);
    124124
    125125run_make_test(undef,
    126126              'wordlist-e s=0 e=12',
    127               "#MAKEFILE#:4: *** invalid first argument to `wordlist' function: `0'.  Stop.",
     127              "#MAKEFILE#:4: *** invalid first argument to 'wordlist' function: '0'.  Stop.",
    128128              512);
    129129
Note: See TracChangeset for help on using the changeset viewer.