Imported Upstream version 4.4
[platform/upstream/make.git] / tests / scripts / features / vpath
1 #                                                                     -*-perl-*-
2
3 $description = "Test vpath for particular classes of filenames.";
4
5 $details = "";
6
7 @files_to_touch = ("$workdir${pathsep}main.c","$workdir${pathsep}defs.h",
8                    "$workdir${pathsep}kbd.c","$workdir${pathsep}command.h",
9                    "$workdir${pathsep}commands.c","$workdir${pathsep}display.c",
10                    "$workdir${pathsep}buffer.h","$workdir${pathsep}insert.c",
11                    "$workdir${pathsep}command.c");
12
13 &touch(@files_to_touch);
14
15 run_make_test(q!
16 vpath %.c foo
17 vpath %.c #WORK#
18 vpath %.h #WORK#
19 objects = main.o kbd.o commands.o display.o insert.o
20 edit: $(objects) ; @echo cc -o $@ $^
21 main.o : main.c defs.h ; @echo cc -c $(firstword $^)
22 kbd.o : kbd.c defs.h command.h ; @echo cc -c kbd.c
23 commands.o : command.c defs.h command.h ; @echo cc -c commands.c
24 display.o : display.c defs.h buffer.h ; @echo cc -c display.c
25 insert.o : insert.c defs.h buffer.h ; @echo cc -c insert.c
26 !,
27     '', "cc -c $workdir${pathsep}main.c\ncc -c kbd.c\ncc -c commands.c\n"
28         ."cc -c display.c\ncc -c insert.c\n"
29         ."cc -o edit main.o kbd.o commands.o display.o insert.o\n");
30
31 unlink(@files_to_touch);
32
33 # TEST 2: after vpath lookup ensure we don't get incorrect circular dependency
34 # warnings due to change of struct file ptr.  Savannah bug #13529.
35
36 mkdir('vpath-d', 0777);
37
38 run_make_test(q!
39 vpath %.te vpath-d/
40 .SECONDARY:
41 default: vpath-d/a vpath-d/b
42 vpath-d/a: fail.te
43 vpath-d/b : fail.te
44 vpath-d/fail.te:
45 !,
46               '', "#MAKE#: Nothing to be done for 'default'.\n");
47
48 rmdir('vpath-d');
49
50 # Test VPATH vs vpath
51
52 run_make_test(q!
53 VPATH = #WORK#:#PWD#
54 vpath %.c foo
55 vpath %.c #WORK#
56 vpath %.c #PWD#
57 vpath %.h #WORK#
58 vpath %.c
59 vpath
60 all: ; @echo ALL IS WELL
61 !,
62               '', "ALL IS WELL\n");
63
64 # Test interaction of -lfoo and vpath
65
66 my @dirs_to_make = qw(a1 b1 a2 b2 b3);
67 for my $d (@dirs_to_make) {
68     mkdir($d, 0777);
69 }
70
71 my @files_to_touch = ("a1${pathsep}lib1.a",
72                       "a1${pathsep}libc.a",
73                       "b1${pathsep}lib1.so",
74                       "a2${pathsep}lib2.a",
75                       "b2${pathsep}lib2.so",
76                       "lib3.a",
77                       "b3${pathsep}lib3.so");
78 &touch(@files_to_touch);
79
80 my $answer = "a1${pathsep}lib1.a a1${pathsep}libc.a " .
81              "a2${pathsep}lib2.a lib3.a\n";
82 if ($port_type eq 'VMS-DCL') {
83     $answer =~ s/ /,/g;
84 }
85
86 run_make_test('
87 vpath %.h b3
88 vpath %.a a1
89 vpath %.so b1
90 vpath % a2 b2
91 vpath % b3
92 all: -l1 -lc -l2 -l3; @echo $^
93 ',
94               '', $answer);
95
96 unlink(@files_to_touch);
97 for my $d (@dirs_to_make) {
98     rmdir($d);
99 }
100
101 # Check that if we find find files with VPATH, we don't do pattern search
102
103 mkdir("vpa");
104
105 run_make_test(q!
106 VPATH = vpa
107 %.x: ; @echo pattern $@
108 vpa/foo.x: ; @echo vpath $@
109 !,
110               'foo.x', "vpath vpa/foo.x\n");
111
112 rmdir("vpa");
113
114 1;