summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorPeter Rosin <peda@lysator.liu.se>2010-09-21 20:59:54 +0200
committerPeter Rosin <peda@lysator.liu.se>2010-09-21 20:59:54 +0200
commit0431dc4403e5c611bc1009f0cf47b20f26407994 (patch)
tree15229db49415c518eceb117175b0b424a0127e31 /tests
parent0a99a243f943f02f97e9fc2df5020d33997a76d0 (diff)
downloadautomake-0431dc4403e5c611bc1009f0cf47b20f26407994.tar.gz
compile: implement library search to support MSVC static linking
* lib/compile (func_cl_wrapper): Implement library search and -static option so that the user can select whether to prefer dll import libraries or static libraries. This enables MSVC to link against dlls generated by libtool without requiring libtool or workarounds such as -lfoo.dll etc. Makes the tests/static.at test case in libtool pass. * tests/compile3.test: Don't trip up if there happens to exist a "foo" library in the library search path. * tests/compile6.test: New test, verifying the library search. * tests/Makefile.am (TESTS): Update. Signed-off-by: Peter Rosin <peda@lysator.liu.se>
Diffstat (limited to 'tests')
-rw-r--r--tests/Makefile.am1
-rw-r--r--tests/Makefile.in1
-rwxr-xr-xtests/compile3.test2
-rwxr-xr-xtests/compile6.test98
4 files changed, 101 insertions, 1 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 01acd768e..816405af2 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -162,6 +162,7 @@ compile2.test \
compile3.test \
compile4.test \
compile5.test \
+compile6.test \
compile_f90_c_cxx.test \
compile_f_c_cxx.test \
cond.test \
diff --git a/tests/Makefile.in b/tests/Makefile.in
index ff547a0fb..e1b170a3d 100644
--- a/tests/Makefile.in
+++ b/tests/Makefile.in
@@ -400,6 +400,7 @@ compile2.test \
compile3.test \
compile4.test \
compile5.test \
+compile6.test \
compile_f90_c_cxx.test \
compile_f_c_cxx.test \
cond.test \
diff --git a/tests/compile3.test b/tests/compile3.test
index b77237b93..e376800c5 100755
--- a/tests/compile3.test
+++ b/tests/compile3.test
@@ -31,7 +31,7 @@ END
chmod +x ./cl
# Check if compile handles "-o foo", -I, -l, -L, -Xlinker -Wl,
-opts=`./compile ./cl foo.c -o foo -lbar -Lgazonk -Ibaz -Xlinker foobar -Wl,-foo,bar`
+opts=`LIB= ./compile ./cl foo.c -o foo -lbar -Lgazonk -Ibaz -Xlinker foobar -Wl,-foo,bar`
test x"$opts" = x"foo.c -Fefoo bar.lib -Ibaz -link -LIBPATH:gazonk foobar -foo bar"
# Check if compile handles "-o foo.obj"
diff --git a/tests/compile6.test b/tests/compile6.test
new file mode 100755
index 000000000..0f09e84db
--- /dev/null
+++ b/tests/compile6.test
@@ -0,0 +1,98 @@
+#! /bin/sh
+# Copyright (C) 2010 Free Software Foundation, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+# Make sure `compile' searches libraries correctly
+
+. ./defs || Exit 1
+
+set -e
+
+cp "$testsrcdir/../lib/compile" .
+
+# Use a dummy cl, since cl isn't readily available on all systems
+cat >cl <<'END'
+#! /bin/sh
+echo "$@"
+END
+
+chmod +x ./cl
+
+mkdir syslib
+:> syslib/foo.lib
+
+syslib=`pwd`/syslib
+LIB=$syslib
+export LIB
+
+mkdir lib
+:> lib/bar.lib
+:> lib/bar.dll.lib
+
+# Check if compile library search correctly
+opts=`./compile ./cl foo.c -o foo -Llib -lbar -lfoo`
+test x"$opts" = x"foo.c -Fefoo lib/bar.dll.lib $syslib/foo.lib -link -LIBPATH:lib"
+
+# Check if -static makes compile avoid bar.dll.lib
+opts=`./compile ./cl foo.c -o foo -Llib -static -lbar -lfoo`
+test x"$opts" = x"foo.c -Fefoo lib/bar.lib $syslib/foo.lib -link -LIBPATH:lib"
+
+:> syslib/bar.lib
+:> syslib/bar.dll.lib
+
+# Check if compile finds bar.dll.lib in syslib
+opts=`./compile ./cl foo.c -o foo -lbar -lfoo`
+test x"$opts" = x"foo.c -Fefoo $syslib/bar.dll.lib $syslib/foo.lib"
+
+# Check if compile prefers -L over $LIB
+opts=`./compile ./cl foo.c -o foo -Llib -lbar -lfoo`
+test x"$opts" = x"foo.c -Fefoo lib/bar.dll.lib $syslib/foo.lib -link -LIBPATH:lib"
+
+mkdir lib2
+:> lib2/bar.dll.lib
+
+# Check if compile avoids bar.dll.lib in lib2 when -static
+opts=`./compile ./cl foo.c -o foo -Llib2 -static -lbar -lfoo`
+test x"$opts" = x"foo.c -Fefoo $syslib/bar.lib $syslib/foo.lib -link -LIBPATH:lib2"
+
+# Check if compile gets two different bar libraries when -static
+# is added in the middle
+opts=`./compile ./cl foo.c -o foo -Llib2 -Llib -lbar -static -lbar`
+test x"$opts" = x"foo.c -Fefoo lib2/bar.dll.lib lib/bar.lib -link -LIBPATH:lib2 -LIBPATH:lib"
+
+# Check if compile gets the correct bar.dll.lib
+opts=`./compile ./cl foo.c -o foo -Llib -Llib2 -lbar -lfoo`
+test x"$opts" = x"foo.c -Fefoo lib/bar.dll.lib $syslib/foo.lib -link -LIBPATH:lib -LIBPATH:lib2"
+
+# Check if compile gets the correct bar.dll.lib
+opts=`./compile ./cl foo.c -o foo -Llib2 -Llib -lbar -lfoo`
+test x"$opts" = x"foo.c -Fefoo lib2/bar.dll.lib $syslib/foo.lib -link -LIBPATH:lib2 -LIBPATH:lib"
+
+mkdir "sys lib2"
+:> "sys lib2/foo.dll.lib"
+
+syslib2="`pwd`/sys lib2"
+LIB="$syslib2;$LIB"
+
+# Check if compile handles spaces in $LIB and that it prefers the order
+# in a multi-component $LIB.
+opts=`./compile ./cl foo.c -o foo -lfoo`
+test x"$opts" = x"foo.c -Fefoo $syslib2/foo.dll.lib"
+
+# Check if compile handles the 2nd directory in a multi-component $LIB.
+opts=`./compile ./cl foo.c -o foo -static -lfoo`
+test x"$opts" = x"foo.c -Fefoo $syslib/foo.lib"
+
+: