1 dnl -*- shell-script -*-
3 dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
4 dnl University Research and Technology
5 dnl Corporation. All rights reserved.
6 dnl Copyright (c) 2004-2005 The University of Tennessee and The University
7 dnl of Tennessee Research Foundation. All rights
9 dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
10 dnl University of Stuttgart. All rights reserved.
11 dnl Copyright (c) 2004-2005 The Regents of the University of California.
12 dnl All rights reserved.
15 dnl Additional copyrights may follow
20 AC_DEFUN([OMPI_CHECK_LINKER_FLAGS],[
22 # libtool has been created by this point
23 # Try to see if it will add any additional flags for dependant libraries
26 AC_MSG_CHECKING([for libtool-supplied linker flags])
31 # Get the directory where libtool lives
34 d="`dirname $libtool`"
36 libtool="`pwd`/libtool"
40 # Make a playground to work in
46 int foo(void) { return 0; }
49 ompi_check_linker_flags_work() {
50 OMPI_LOG_MSG([$cmd], [yes])
52 if test -n "[$]1"; then
53 output=`eval $cmd 2>/dev/null | head -n 1 | sed 's,^libtool:\( \| link: \),,'`
56 OMPI_LOG_MSG([\$? = $status], [yes])
57 if test "$status" != "0"; then
58 AC_MSG_RESULT([libtool error!])
59 AC_MSG_ERROR([Cannot continue])
64 # First make a sample library with the current LDFLAGS and LIBS
67 cmd="$libtool --mode=compile --tag=CC $CC $CFLAGS -c -o foo.o foo.c"
68 ompi_check_linker_flags_work
69 cmd="$libtool --mode=link --tag=CC $CC $CFLAGS foo.lo $LDFLAGS $LIBS -o libfoo.la"
70 ompi_check_linker_flags_work
73 # Now fake linking to it and capture the output from libtool
76 cmd="$libtool --dry-run --mode=link --tag=CC $CC bar.lo libfoo.la -o bar $extra_flags"
77 ompi_check_linker_flags_work yes
81 while test -n "[$]1"; do
95 extra_ldflags="$extra_ldflags [$]1"
101 if test -n "$extra_ldflags"; then
102 AC_MSG_RESULT([$extra_ldflags])
104 AC_MSG_RESULT([no extra flags])
108 rm -rf conftest.$$])dnl