Imported Upstream version 2.4.2
[platform/upstream/libtool.git] / tests / flags.at
1 # flags.at -- libtool passing of flags             -*- Autotest -*-
2 #
3 #   Copyright (C) 2009, 2010 Free Software Foundation, Inc.
4 #
5 #   This file is part of GNU Libtool.
6 #
7 # GNU Libtool is free software; you can redistribute it and/or
8 # modify it under the terms of the GNU General Public License as
9 # published by the Free Software Foundation; either version 2 of
10 # the License, or (at your option) any later version.
11 #
12 # GNU Libtool is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 # GNU General Public License for more details.
16 #
17 # You should have received a copy of the GNU General Public License
18 # along with GNU Libtool; see the file COPYING.  If not, a copy
19 # can be downloaded from  http://www.gnu.org/licenses/gpl.html,
20 # or obtained by writing to the Free Software Foundation, Inc.,
21 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 ####
23
24 m4_foreach([lt_tag], [CC, CXX, F77, FC, GCJ],
25 [AT_SETUP([passing lt_tag flags through libtool])
26 AT_KEYWORDS([libtool])
27 LT_AT_TAG(m4_defn([lt_tag]))
28
29 LDFLAGS="$LDFLAGS -no-undefined"
30 eval "`$LIBTOOL --config | $EGREP '^(FGREP)='`"
31
32 m4_case(lt_tag,
33 [CC], [AT_DATA([a.c],
34 [[int main () { return 0; }
35 ]])
36 compile="$CC $CPPFLAGS $CFLAGS" link="$CC $CFLAGS $LDFLAGS" source=a.c
37 ],
38 [CXX], [AT_DATA([a.cpp],
39 [[int main () { return 0; }
40 ]])
41 compile="$CXX $CPPFLAGS $CXXFLAGS" link="$CXX $CXXFLAGS $LDFLAGS" source=a.cpp
42 ],
43 [F77], [AT_DATA([a.f],
44 [[      program main
45       end
46 ]])
47 compile="$F77 $FFLAGS" link="$F77 $FFLAGS $LDFLAGS" source=a.f
48 ],
49 [FC], [AT_DATA([a.f90],
50 [[      program main
51       end
52 ]])
53 compile="$FC $FCFLAGS" link="$FC $FCFLAGS $LDFLAGS" source=a.f90
54 ],
55 [GCJ], [AT_DATA([a.java],
56 [[class a {}
57 ]])
58 compile="$GCJ $GCJFLAGS" link="$GCJ $GCJFLAGS $LDFLAGS" source=a.java
59 ])
60
61 # Linker flags are not passed to the archiver, so don't test static libraries.
62 if $LIBTOOL --features | grep 'enable shared libraries'; then
63   library_and_module='library.la "module.la -module -avoid-version"'
64 else
65   library_and_module=
66 fi
67
68 eval "`$LIBTOOL --tag=lt_tag --config | $EGREP '^(wl|archive_cmds)='`"
69
70 AT_CHECK([$LIBTOOL --tag=lt_tag --mode=compile $compile -c $source],
71          [], [ignore], [ignore])
72
73 # Linker flags are prefixed with ${wl} iff they are passed to the
74 # compiler driver, instead of directly to the linker.
75 case $archive_cmds in
76 *\$LD*\$linker_flags*) maybe_wl= compiler_flags_in_liblink=false ;;
77 *) maybe_wl=$wl compiler_flags_in_liblink=: ;;
78 esac
79
80 for flag in -Wc, -Wl, '-Xcompiler ' '-Xlinker '; do
81   case $flag in
82   -Wc, | -Xcompiler\ )
83     AT_CHECK([$LIBTOOL -n --tag=lt_tag --mode=compile $compile ]dnl
84              [$flag-foo -c $source], [], [stdout], [ignore])
85     AT_CHECK([$FGREP " -foo" stdout], [], [ignore])
86     flag_prefix_prog=
87     flag_prefix_lib=
88     flags_in_liblink=$compiler_flags_in_liblink
89     ;;
90   -Wl, | -Xlinker\ )
91     flag_prefix_prog=$wl
92     flag_prefix_lib=$maybe_wl
93     flags_in_liblink=:
94     ;;
95   esac
96
97   AT_CHECK([$LIBTOOL -n --tag=lt_tag --mode=link $link ]dnl
98            [-o program$EXEEXT a.lo $flag-foo], [], [stdout], [ignore])
99   AT_CHECK([$FGREP " $flag_prefix_prog-foo" stdout], [], [ignore])
100
101   eval set x "$library_and_module"
102   for output
103   do
104     test x = "$output" && continue
105     AT_CHECK([$LIBTOOL -n --tag=lt_tag --mode=link $link ]dnl
106              [-o $output a.lo -rpath /nowhere $flag-foo], [], [stdout], [ignore])
107     if $flags_in_liblink; then
108       AT_CHECK([$FGREP " $flag_prefix_lib-foo" stdout], [], [ignore])
109     else
110       AT_CHECK([$FGREP " $flag_prefix_lib-foo" stdout], [1])
111     fi
112   done
113 done
114
115 AT_CLEANUP
116 ])dnl m4_foreach(tag)