2004-01-08 16:34:31 +03:00
|
|
|
dnl -*- shell-script -*-
|
|
|
|
dnl
|
2005-11-05 22:57:48 +03:00
|
|
|
dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
|
|
|
|
dnl University Research and Technology
|
|
|
|
dnl Corporation. All rights reserved.
|
|
|
|
dnl Copyright (c) 2004-2005 The University of Tennessee and The University
|
|
|
|
dnl of Tennessee Research Foundation. All rights
|
|
|
|
dnl reserved.
|
2014-08-23 14:50:14 +04:00
|
|
|
dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
|
2004-11-28 23:09:25 +03:00
|
|
|
dnl University of Stuttgart. All rights reserved.
|
2005-03-24 15:43:37 +03:00
|
|
|
dnl Copyright (c) 2004-2005 The Regents of the University of California.
|
|
|
|
dnl All rights reserved.
|
2014-08-19 09:52:34 +04:00
|
|
|
dnl Copyright (c) 2014 Research Organization for Information Science
|
|
|
|
dnl and Technology (RIST). All rights reserved.
|
2014-08-23 14:50:14 +04:00
|
|
|
dnl Copyright (c) 2014 Cisco Systems, Inc. All rights reserved.
|
2004-11-22 04:38:40 +03:00
|
|
|
dnl $COPYRIGHT$
|
2014-08-23 14:50:14 +04:00
|
|
|
dnl
|
2004-11-22 04:38:40 +03:00
|
|
|
dnl Additional copyrights may follow
|
2014-08-23 14:50:14 +04:00
|
|
|
dnl
|
2004-01-08 16:34:31 +03:00
|
|
|
dnl $HEADER$
|
|
|
|
dnl
|
|
|
|
|
2014-05-06 22:03:08 +04:00
|
|
|
# _OPAL_C_WEAK_SYMBOLS(action_if_found, [action_if_not_found])
|
2005-09-14 05:40:25 +04:00
|
|
|
# ------------------------------------------------------------
|
2014-05-06 22:03:08 +04:00
|
|
|
AC_DEFUN([_OPAL_C_WEAK_SYMBOLS],[
|
2005-09-14 05:40:25 +04:00
|
|
|
# need two files because icc will incorrectly not create the
|
|
|
|
# symbols if they are not used in the object file in which they
|
|
|
|
# are defined. Blah!
|
2007-05-30 17:01:36 +04:00
|
|
|
# To get to compile with icc, have them in a separate header.
|
|
|
|
cat > conftest_weak.h <<EOF
|
|
|
|
int real(int i);
|
|
|
|
int fake(int i);
|
|
|
|
EOF
|
|
|
|
|
2005-09-14 05:40:25 +04:00
|
|
|
cat > conftest_weak.c <<EOF
|
2007-05-30 17:01:36 +04:00
|
|
|
#include "conftest_weak.h"
|
2005-09-14 05:40:25 +04:00
|
|
|
#pragma weak fake = real
|
|
|
|
int real(int i) { return i; }
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat > conftest.c <<EOF
|
2007-05-30 17:01:36 +04:00
|
|
|
#include "conftest_weak.h"
|
2006-09-23 03:58:23 +04:00
|
|
|
int main() { return fake(3); }
|
2005-09-14 05:40:25 +04:00
|
|
|
EOF
|
|
|
|
|
|
|
|
# Try the compile
|
2010-11-13 02:22:11 +03:00
|
|
|
OPAL_LOG_COMMAND(
|
2005-09-14 05:40:25 +04:00
|
|
|
[$CC $CFLAGS -c conftest_weak.c],
|
2014-08-23 14:50:14 +04:00
|
|
|
[OPAL_LOG_COMMAND(
|
2005-09-14 05:40:25 +04:00
|
|
|
[$CC $CFLAGS conftest.c conftest_weak.o -o conftest $LDFLAGS $LIBS],
|
2014-05-06 22:37:52 +04:00
|
|
|
[opal_c_weak_symbols_happy=1],
|
2014-08-23 14:50:14 +04:00
|
|
|
[opal_c_weak_symbols_happy=0])],
|
2014-05-06 22:37:52 +04:00
|
|
|
[opal_c_weak_symbols_happy=0])
|
2005-09-14 05:40:25 +04:00
|
|
|
|
2014-05-06 22:37:52 +04:00
|
|
|
AS_IF([test "$opal_c_weak_symbols_happy" = "1"], [$1], [$2])
|
2005-09-14 05:40:25 +04:00
|
|
|
|
2014-05-06 22:37:52 +04:00
|
|
|
unset opal_c_weak_symbols_happy
|
2007-11-06 15:20:58 +03:00
|
|
|
rm -f conftest_weak.h conftest_weak.c conftest.c conftest
|
2005-09-14 05:40:25 +04:00
|
|
|
])
|
|
|
|
|
|
|
|
|
2014-08-23 14:50:14 +04:00
|
|
|
# OPAL_C_WEAK_SYMBOLS()
|
|
|
|
# ---------------------
|
|
|
|
# sets OPAL_C_HAVE_WEAK_SYMBOLS=1 if C compiler has support for weak symbols
|
|
|
|
AC_DEFUN([OPAL_C_WEAK_SYMBOLS],[
|
|
|
|
AC_CACHE_CHECK([for weak symbol support],
|
|
|
|
[opal_cv_c_weak_symbols],
|
|
|
|
[_OPAL_C_WEAK_SYMBOLS([opal_cv_c_weak_symbols="yes"],
|
|
|
|
[opal_cv_c_weak_symbols="no"])])
|
|
|
|
|
|
|
|
AS_IF([test "$opal_cv_c_weak_symbols" = "yes"],
|
|
|
|
[OPAL_C_HAVE_WEAK_SYMBOLS=1], [OPAL_C_HAVE_WEAK_SYMBOLS=0])
|
|
|
|
]) dnl
|
|
|
|
|
|
|
|
########################################################################
|
|
|
|
|
2014-08-19 09:52:34 +04:00
|
|
|
# _OPAL_C_MACRO_WEAK_SYMBOLS(action_if_found, [action_if_not_found])
|
|
|
|
# ------------------------------------------------------------
|
|
|
|
AC_DEFUN([_OPAL_C_MACRO_WEAK_SYMBOLS],[
|
|
|
|
# need two files because icc will incorrectly not create the
|
|
|
|
# symbols if they are not used in the object file in which they
|
|
|
|
# are defined. Blah!
|
|
|
|
# To get to compile with icc, have them in a separate header.
|
|
|
|
cat > conftest_weak.h <<EOF
|
|
|
|
int real(int i);
|
|
|
|
int fake1(int i);
|
|
|
|
int fake2(int i);
|
|
|
|
|
|
|
|
#define GENERATE_WEAK_PRAGMA(x) _Pragma(#x)
|
|
|
|
#define GENERATE_TWO_WEAK_PRAGMAS(real, fake) \
|
|
|
|
GENERATE_WEAK_PRAGMA(weak fake##1 = real) \
|
|
|
|
GENERATE_WEAK_PRAGMA(weak fake##2 = real)
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat > conftest_weak.c <<EOF
|
|
|
|
#include "conftest_weak.h"
|
|
|
|
GENERATE_TWO_WEAK_PRAGMAS(real, fake)
|
|
|
|
int real(int i) { return i; }
|
|
|
|
EOF
|
|
|
|
|
|
|
|
cat > conftest.c <<EOF
|
|
|
|
#include "conftest_weak.h"
|
|
|
|
int main() { return fake1(3) + fake2(3); }
|
|
|
|
EOF
|
|
|
|
|
|
|
|
# Try the compile
|
|
|
|
OPAL_LOG_COMMAND(
|
|
|
|
[$CC $CFLAGS -c conftest_weak.c],
|
2014-08-23 14:50:14 +04:00
|
|
|
[OPAL_LOG_COMMAND(
|
2014-08-19 09:52:34 +04:00
|
|
|
[$CC $CFLAGS conftest.c conftest_weak.o -o conftest $LDFLAGS $LIBS],
|
|
|
|
[opal_c_macro_weak_symbols_happy=1],
|
2014-08-23 14:50:14 +04:00
|
|
|
[opal_c_macro_weak_symbols_happy=0])],
|
2014-08-19 09:52:34 +04:00
|
|
|
[opal_c_macro_weak_symbols_happy=0])
|
|
|
|
|
|
|
|
AS_IF([test "$opal_c_macro_weak_symbols_happy" = "1"], [$1], [$2])
|
|
|
|
|
|
|
|
unset opal_c_macro_weak_symbols_happy
|
|
|
|
rm -f conftest_weak.h conftest_weak.c conftest.c conftest
|
|
|
|
])
|
|
|
|
|
2014-08-23 14:50:14 +04:00
|
|
|
# OPAL_C_MACRO_WEAK_SYMBOLS
|
2005-07-09 22:52:53 +04:00
|
|
|
# ---------------------
|
2014-08-23 14:50:14 +04:00
|
|
|
# Sets OPAL_C_HAVE_MACRO_WEAK_SYMBOLS=1 if C compiler has support for weak
|
|
|
|
# symbols
|
|
|
|
AC_DEFUN([OPAL_C_MACRO_WEAK_SYMBOLS],[
|
|
|
|
AC_CACHE_CHECK([for macro weak symbol support],
|
|
|
|
[opal_cv_c_macro_weak_symbols],
|
2014-08-25 08:41:56 +04:00
|
|
|
[_OPAL_C_MACRO_WEAK_SYMBOLS([opal_cv_c_macro_weak_symbols="yes"],
|
|
|
|
[opal_cv_c_macro_weak_symbols="no"])])
|
2014-08-23 14:50:14 +04:00
|
|
|
|
|
|
|
AS_IF([test "$opal_cv_c_macro_weak_symbols" = "yes"],
|
|
|
|
[OPAL_C_HAVE_MACRO_WEAK_SYMBOLS=1],
|
|
|
|
[OPAL_C_HAVE_MACRO_WEAK_SYMBOLS=0])
|
2005-07-09 22:52:53 +04:00
|
|
|
]) dnl
|