tests: cosmetic changes in t/extra-sources.sh
[platform/upstream/automake.git] / t / compile3.sh
1 #! /bin/sh
2 # Copyright (C) 2010-2013 Free Software Foundation, Inc.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2, or (at your option)
7 # any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
16
17 # Make sure 'compile' wraps the Microsoft C/C++ compiler (cl) correctly
18
19 am_create_testdir=empty
20 required=xsi-lib-shell
21 . test-init.sh
22
23 get_shell_script compile
24
25 # Use a dummy cl, since cl isn't readily available on all systems
26 cat >cl <<'END'
27 #! /bin/sh
28 echo "$@"
29 END
30
31 chmod +x ./cl
32
33 # POSIX mandates that the compiler accepts a space between the -I,
34 # -l and -L options and their respective arguments.  Traditionally,
35 # this should work also without a space.  Try both usages.
36 for sp in '' ' '; do
37
38   # Check if compile handles "-o foo", -I, -l, -L, -Xlinker -Wl,
39   opts=$(LIB= ./compile ./cl foo.c -o foo -l${sp}bar -L${sp}gazonk \
40                              -I${sp}baz -Xlinker foobar -Wl,-foo,bar)
41   test x"$opts" = \
42        x"foo.c -Fefoo bar.lib -Ibaz -link -LIBPATH:gazonk foobar -foo bar"
43
44   # Check if compile handles "-o foo.obj"
45   opts=$(./compile ./cl -c foo.c -o foo.obj -I${sp}baz)
46   test x"$opts" = x"-c foo.c -Fofoo.obj -Ibaz"
47
48   # Check if compile handles "-o foo.o"
49   opts=$(./compile ./cl -c foo.c -o foo.o -I${sp}baz)
50   test x"$opts" = x"-c foo.c -Fofoo.o -Ibaz"
51
52   # Check if compile handles "foo.cc" as C++.
53   opts=$(./compile ./cl -c foo.cc -o foo.o -I${sp}baz)
54   test x"$opts" = x"-c -Tpfoo.cc -Fofoo.o -Ibaz"
55
56   # Check if compile clears the "eat" variable properly.
57   opts=$(eat=1 ./compile ./cl -c foo.c -o foo.obj -I${sp}baz)
58   test x"$opts" = x"-c foo.c -Fofoo.obj -Ibaz"
59
60 done
61
62 :