1 # flags.at -- libtool passing of flags -*- Autotest -*-
3 # Copyright (C) 2009, 2010 Free Software Foundation, Inc.
5 # This file is part of GNU Libtool.
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.
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.
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.
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]))
29 LDFLAGS="$LDFLAGS -no-undefined"
30 eval "`$LIBTOOL --config | $EGREP '^(FGREP)='`"
34 [[int main () { return 0; }
36 compile="$CC $CPPFLAGS $CFLAGS" link="$CC $CFLAGS $LDFLAGS" source=a.c
38 [CXX], [AT_DATA([a.cpp],
39 [[int main () { return 0; }
41 compile="$CXX $CPPFLAGS $CXXFLAGS" link="$CXX $CXXFLAGS $LDFLAGS" source=a.cpp
43 [F77], [AT_DATA([a.f],
47 compile="$F77 $FFLAGS" link="$F77 $FFLAGS $LDFLAGS" source=a.f
49 [FC], [AT_DATA([a.f90],
53 compile="$FC $FCFLAGS" link="$FC $FCFLAGS $LDFLAGS" source=a.f90
55 [GCJ], [AT_DATA([a.java],
58 compile="$GCJ $GCJFLAGS" link="$GCJ $GCJFLAGS $LDFLAGS" source=a.java
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"'
68 eval "`$LIBTOOL --tag=lt_tag --config | $EGREP '^(wl|archive_cmds)='`"
70 AT_CHECK([$LIBTOOL --tag=lt_tag --mode=compile $compile -c $source],
71 [], [ignore], [ignore])
73 # Linker flags are prefixed with ${wl} iff they are passed to the
74 # compiler driver, instead of directly to the linker.
76 *\$LD*\$linker_flags*) maybe_wl= compiler_flags_in_liblink=false ;;
77 *) maybe_wl=$wl compiler_flags_in_liblink=: ;;
80 for flag in -Wc, -Wl, '-Xcompiler ' '-Xlinker '; do
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])
88 flags_in_liblink=$compiler_flags_in_liblink
92 flag_prefix_lib=$maybe_wl
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])
101 eval set x "$library_and_module"
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])
110 AT_CHECK([$FGREP " $flag_prefix_lib-foo" stdout], [1])
116 ])dnl m4_foreach(tag)