mirror of
git://git.savannah.gnu.org/libtool.git
synced 2025-02-17 15:10:02 +08:00
97 lines
3.0 KiB
Plaintext
97 lines
3.0 KiB
Plaintext
|
# flags.at -- libtool passing of flags -*- Autotest -*-
|
||
|
#
|
||
|
# Copyright (C) 2009 Free Software Foundation, Inc.
|
||
|
#
|
||
|
# This file is part of GNU Libtool.
|
||
|
#
|
||
|
# GNU Libtool 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 of
|
||
|
# the License, or (at your option) any later version.
|
||
|
#
|
||
|
# GNU Libtool 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 GNU Libtool; see the file COPYING. If not, a copy
|
||
|
# can be downloaded from http://www.gnu.org/licenses/gpl.html,
|
||
|
# or obtained by writing to the Free Software Foundation, Inc.,
|
||
|
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||
|
####
|
||
|
|
||
|
AT_SETUP([passing flags through libtool])
|
||
|
AT_KEYWORDS([libtool])
|
||
|
AT_KEYWORDS([CXX F77 FC])
|
||
|
|
||
|
LDFLAGS="$LDFLAGS -no-undefined"
|
||
|
eval "`$LIBTOOL --config | $EGREP '^(FGREP)='`"
|
||
|
|
||
|
AT_DATA([a.c],
|
||
|
[[int main () { return 0; }
|
||
|
]])
|
||
|
|
||
|
AT_DATA([a.f],
|
||
|
[[ program main
|
||
|
end
|
||
|
]])
|
||
|
|
||
|
cp a.c a.cpp
|
||
|
cp a.f a.f90
|
||
|
|
||
|
# Linker flags are not passed to the archiver, so don't test static libraries.
|
||
|
if $LIBTOOL --features | grep 'enable shared libraries'; then
|
||
|
library_and_module='library.la "module.la -module -avoid-version"'
|
||
|
else
|
||
|
library_and_module=
|
||
|
fi
|
||
|
|
||
|
for tag in CC CXX F77 FC; do
|
||
|
if $LIBTOOL --tag=$tag 2>&1 | grep 'unknown tag'; then
|
||
|
continue
|
||
|
fi
|
||
|
case $tag in
|
||
|
CC) compile="$CC $CPPFLAGS $CFLAGS" link="$CC $CFLAGS $LDFLAGS" source=a.c ;;
|
||
|
CXX) compile="$CXX $CPPFLAGS $CXXFLAGS" link="$CXX $CXXFLAGS $LDFLAGS" source=a.cpp;;
|
||
|
F77) compile="$CC $CPPFLAGS $CFLAGS" link="$CC $CFLAGS $LDFLAGS" source=a.f ;;
|
||
|
FC) compile="$CC $CPPFLAGS $CFLAGS" link="$CC $CFLAGS $LDFLAGS" source=a.f90 ;;
|
||
|
esac
|
||
|
|
||
|
eval "`$LIBTOOL --tag=$tag --config | $EGREP '^(wl|archive_cmds|reload_cmds)='`"
|
||
|
|
||
|
AT_CHECK([$LIBTOOL --tag=$tag --mode=compile $compile -c $source],
|
||
|
[], [ignore], [ignore])
|
||
|
|
||
|
# Linker flags are prefixed with ${wl} iff they are passed to the
|
||
|
# compiler driver, instead of directly to the linker.
|
||
|
case $archive_cmds in
|
||
|
*\$LD*\$linker_flags*) maybe_wl= ;;
|
||
|
*) maybe_wl=$wl ;;
|
||
|
esac
|
||
|
|
||
|
for flag in -Wc, -Wl, '-Xcompiler ' '-Xlinker '; do
|
||
|
case $flag in
|
||
|
-Wc, | -Xcompiler\ )
|
||
|
AT_CHECK([$LIBTOOL -n --tag=$tag --mode=compile $compile ]dnl
|
||
|
[$flag-foo -c $source], [], [stdout], [ignore])
|
||
|
AT_CHECK([$FGREP " -foo" stdout], [], [ignore])
|
||
|
flag_prefix=
|
||
|
;;
|
||
|
-Wl, | -Xlinker\ )
|
||
|
flag_prefix=$maybe_wl
|
||
|
;;
|
||
|
esac
|
||
|
|
||
|
eval set program "$library_and_module"
|
||
|
for output
|
||
|
do
|
||
|
AT_CHECK([$LIBTOOL -n --tag=$tag --mode=link $link ]dnl
|
||
|
[-o $output a.lo -rpath /nowhere $flag-foo], [], [stdout], [ignore])
|
||
|
AT_CHECK([$FGREP " $flag_prefix-foo" stdout], [], [ignore])
|
||
|
done
|
||
|
done
|
||
|
done
|
||
|
|
||
|
AT_CLEANUP
|