tests: Let 'ltorder.sh' run successfully with Guix dynamic loader
[automake.git] / t / compile3.sh
blob1351fcf44309287a6d3adb336656ba8ede1c5070
1 #! /bin/sh
2 # Copyright (C) 2010-2018 Free Software Foundation, Inc.
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.
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.
14 # You should have received a copy of the GNU General Public License
15 # along with this program. If not, see <https://www.gnu.org/licenses/>.
17 # Make sure 'compile' wraps the Microsoft C/C++ compiler (cl) correctly
19 am_create_testdir=empty
20 required=xsi-lib-shell
21 . test-init.sh
23 get_shell_script compile
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
31 chmod +x ./cl
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
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"
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"
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"
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"
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"
60 done