there was an #include directive missing
[openmpi-llc.git] / config / ompi_get_libtool_linker_flags.m4
blob53704c7a34d50073486650aae537349b5c603bb7
1 dnl -*- shell-script -*-
2 dnl
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
8 dnl                         reserved.
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.
13 dnl $COPYRIGHT$
14 dnl 
15 dnl Additional copyrights may follow
16 dnl 
17 dnl $HEADER$
18 dnl
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])
28 libtool="$1"
29 extra_flags="$2"
31 # Get the directory where libtool lives
33 start="`pwd`"
34 d="`dirname $libtool`"
35 cd "$d"
36 libtool="`pwd`/libtool"
37 cd "$start"
38 unset d start
40 # Make a playground to work in
42 mkdir conftest.$$
43 cd conftest.$$
45 cat > foo.c <<EOF
46 int foo(void) { return 0; }
47 EOF
49 ompi_check_linker_flags_work() {
50     OMPI_LOG_MSG([$cmd], [yes])
51     eval $cmd >&5 2>&5
52     if test -n "[$]1"; then
53         output=`eval $cmd 2>/dev/null | head -n 1 | sed 's,^libtool:\( \| link: \),,'`
54     fi
55     status="$?"
56     OMPI_LOG_MSG([\$? = $status], [yes])
57     if test "$status" != "0"; then
58         AC_MSG_RESULT([libtool error!])
59         AC_MSG_ERROR([Cannot continue])
60     fi
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
79 eval "set $output"
80 extra_ldflags=
81 while test -n "[$]1"; do
82     case "[$]1" in
83     $CC) ;;
84     *.libs/bar*) ;;
85     bar*) ;;
86     -I*) ;;
87     -L*) ;;
88     -R*) ;;
89     -lfoo) ;;
90     *.libs/libfoo.*) ;;
91     -o) ;;
92     *.so) ;;
93     *.a) ;;
94     *)
95         extra_ldflags="$extra_ldflags [$]1"
96         ;;
97     esac
98     shift
99 done
101 if test -n "$extra_ldflags"; then
102     AC_MSG_RESULT([$extra_ldflags])
103 else
104     AC_MSG_RESULT([no extra flags])
107 cd ..
108 rm -rf conftest.$$])dnl