test init: refactor: new function 'am_setup_testdir'
[automake.git] / t / compile6.sh
blobee47c174ee10f53157f7cd23203911fc0c1f7e99
1 #! /bin/sh
2 # Copyright (C) 2010-2012 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 <http://www.gnu.org/licenses/>.
17 # Make sure 'compile' searches libraries correctly
19 am_create_testdir=empty
20 required=xsi-lib-shell
21 . ./defs || exit 1
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 rm -rf lib lib2 syslib "sys lib2"
40 mkdir syslib
41 : > syslib/foo.lib
43 syslib=$(pwd)/syslib
44 LIB=$syslib
45 export LIB
47 mkdir lib
48 : > lib/bar.lib
49 : > lib/bar.dll.lib
51 # Check if compile library search correctly
52 opts=$(./compile ./cl foo.c -o foo -L${sp}lib -l${sp}bar -l${sp}foo)
53 test x"$opts" = x"foo.c -Fefoo lib/bar.dll.lib $syslib/foo.lib -link -LIBPATH:lib"
55 # Check if -static makes compile avoid bar.dll.lib
56 opts=$(./compile ./cl foo.c -o foo -L${sp}lib -static -l${sp}bar -l${sp}foo)
57 test x"$opts" = x"foo.c -Fefoo lib/bar.lib $syslib/foo.lib -link -LIBPATH:lib"
59 : > syslib/bar.lib
60 : > syslib/bar.dll.lib
62 # Check if compile finds bar.dll.lib in syslib
63 opts=$(./compile ./cl foo.c -o foo -l${sp}bar -l${sp}foo)
64 test x"$opts" = x"foo.c -Fefoo $syslib/bar.dll.lib $syslib/foo.lib"
66 # Check if compile prefers -L over $LIB
67 opts=$(./compile ./cl foo.c -o foo -L${sp}lib -l${sp}bar -l${sp}foo)
68 test x"$opts" = x"foo.c -Fefoo lib/bar.dll.lib $syslib/foo.lib -link -LIBPATH:lib"
70 mkdir lib2
71 : > lib2/bar.dll.lib
73 # Check if compile avoids bar.dll.lib in lib2 when -static
74 opts=$(./compile ./cl foo.c -o foo -L${sp}lib2 -static -l${sp}bar -l${sp}foo)
75 test x"$opts" = x"foo.c -Fefoo $syslib/bar.lib $syslib/foo.lib -link -LIBPATH:lib2"
77 # Check if compile gets two different bar libraries when -static
78 # is added in the middle
79 opts=$(./compile ./cl foo.c -o foo -L${sp}lib2 -L${sp}lib -l${sp}bar -static -l${sp}bar)
80 test x"$opts" = x"foo.c -Fefoo lib2/bar.dll.lib lib/bar.lib -link -LIBPATH:lib2 -LIBPATH:lib"
82 # Check if compile gets the correct bar.dll.lib
83 opts=$(./compile ./cl foo.c -o foo -L${sp}lib -L${sp}lib2 -l${sp}bar -l${sp}foo)
84 test x"$opts" = x"foo.c -Fefoo lib/bar.dll.lib $syslib/foo.lib -link -LIBPATH:lib -LIBPATH:lib2"
86 # Check if compile gets the correct bar.dll.lib
87 opts=$(./compile ./cl foo.c -o foo -L${sp}lib2 -L${sp}lib -l${sp}bar -l${sp}foo)
88 test x"$opts" = x"foo.c -Fefoo lib2/bar.dll.lib $syslib/foo.lib -link -LIBPATH:lib2 -LIBPATH:lib"
90 mkdir "sys lib2"
91 : > "sys lib2/foo.dll.lib"
93 syslib2="$(pwd)/sys lib2"
94 LIB="$syslib2;$LIB"
96 # Check if compile handles spaces in $LIB and that it prefers the order
97 # in a multi-component $LIB.
98 opts=$(./compile ./cl foo.c -o foo -l${sp}foo)
99 test x"$opts" = x"foo.c -Fefoo $syslib2/foo.dll.lib"
101 # Check if compile handles the 2nd directory in a multi-component $LIB.
102 opts=$(./compile ./cl foo.c -o foo -static -l${sp}foo)
103 test x"$opts" = x"foo.c -Fefoo $syslib/foo.lib"
105 done