diff --git a/acinclude.m4 b/acinclude.m4 index 33638c1fb0..e4d326102c 100644 --- a/acinclude.m4 +++ b/acinclude.m4 @@ -55,6 +55,7 @@ m4_include(config/ompi_config_asm.m4) m4_include(config/ompi_case_sensitive_fs_setup.m4) m4_include(config/ompi_check_broken_qsort.m4) +m4_include(config/ompi_check_func_lib.m4) m4_include(config/ompi_check_optflags.m4) m4_include(config/ompi_check_icc.m4) m4_include(config/ompi_check_gm.m4) diff --git a/config/ompi_check_func_lib.m4 b/config/ompi_check_func_lib.m4 new file mode 100644 index 0000000000..434fb7d29e --- /dev/null +++ b/config/ompi_check_func_lib.m4 @@ -0,0 +1,46 @@ +dnl -*- shell-script -*- +dnl +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. +dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart, +dnl University of Stuttgart. All rights reserved. +dnl Copyright (c) 2004-2005 The Regents of the University of California. +dnl All rights reserved. +dnl $COPYRIGHT$ +dnl +dnl Additional copyrights may follow +dnl +dnl $HEADER$ +dnl + +# OMPI_CHECK_FUNC_LIB(func, lib) +# ------------------------------ +# Try to find function func, first with the present LIBS, second with +# lib added to LIBS. If func is found with the libraries listed in +# LIBS, no modification to LIBS is made. If func is in lib (but not +# in LIBS) then lib is added to LIBS. If func is not in lib, then +# LIBS is not modified. +AC_DEFUN([OMPI_CHECK_FUNC_LIB],[ + AC_MSG_CHECKING([if we need -l$2 for $1]) + AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern char *]$1[;]], + [[char *bar = ]$1[;]])], + [MSG="no"], + [LIBS_save="$LIBS" + LIBS="$LIBS -l$2" + AC_LINK_IFELSE([AC_LANG_PROGRAM([[extern char *]$1[;]], + [[char *bar = ]$1[;]])], + [WRAPPER_EXTRA_LIBS="$WRAPPER_EXTRA_LIBS -l$2" + MSG="yes"], + [LIBS="$LIBS_save" + MSG="not found"])]) + AC_MSG_RESULT([$MSG]) + + # see if we actually have $1. Use AC_CHECK_FUNCS so that it + # does the glibs "not implemented" check. Will use the current LIBS, + # so will check in -l$2 if we decided we needed it above + AC_CHECK_FUNCS([$1]) +]) diff --git a/configure.ac b/configure.ac index 72bc29a6ae..ea391b8cd6 100644 --- a/configure.ac +++ b/configure.ac @@ -1166,63 +1166,15 @@ AC_DEFINE_UNQUOTED(OMPI_HAVE_UNDERSCORE_VA_COPY, $OMPI_HAVE_UNDERSCORE_VA_COPY, AC_CHECK_DECLS(__func__) -# -# Solaris has sched_yield in -lrt. Can't use a simple AC_CHECK_LIB, -# though, because Linux has sched_yield in glic (so linking in librt -# will "find" sched_yield, even though it would have been found anyway -# -- so -lrt would be useless [and potentially harmful?] in this -# case). -# -AC_MSG_CHECKING([if we need -lrt for sched_yield]) -AC_LINK_IFELSE(AC_LANG_PROGRAM([[extern char *sched_yield;]], -[[char *bar = sched_yield;]]), -[MSG=no],[MSG=not_found]) -if test "$MSG" = "not_found"; then - LIBS_save="$LIBS" - LIBS="$LIBS -lrt" - AC_LINK_IFELSE(AC_LANG_PROGRAM([[extern char *sched_yield;]], -[[char *bar = sched_yield;]]), -[MSG=yes],[MSG=not_found]) - if test "$MSG" = "not_found"; then - LIBS="$LIBS_save" - fi -fi -AC_MSG_RESULT([$MSG]) +# Solaris has sched_yeild in -lrt, usually in libc +OMPI_CHECK_FUNC_LIB([sched_yield], [rt]) -# see if we actually have sched_yeild. Use AC_CHECK_FUNCS so that it -# does the glibs "not implemented" check. Will use the current LIBS, -# so will check in -lrt if we decided we needed it above -AC_CHECK_FUNCS([sched_yield]) +# FreeBSD has backtrace in -lexecinfo, usually in libc +OMPI_CHECK_FUNC_LIB([backtrace], [execinfo]) -# -# FreeBSD has backtrace in -lexecinfo. Can't use a simple AC_CHECK_LIB, -# though, because Linux has backtrace in glic (so linking in libexecinfo -# will "find" backtrace, even though it would have been found anyway -# -- so -lexecinfo would be useless [and potentially harmful?] in this -# case). -# - -AC_MSG_CHECKING([if we need -lexecinfo for backtrace]) -AC_LINK_IFELSE(AC_LANG_PROGRAM([[extern char *backtrace;]], -[[char *bar = backtrace;]]), -[MSG=no],[MSG=not_found]) -if test "$MSG" = "not_found"; then - LIBS_save="$LIBS" - LIBS="$LIBS -lexecinfo" - AC_LINK_IFELSE(AC_LANG_PROGRAM([[extern char *backtrace;]], -[[char *bar = backtrace;]]), -[MSG=yes],[MSG=not_found]) - if test "$MSG" = "not_found"; then - LIBS="$LIBS_save" - fi -fi -AC_MSG_RESULT([$MSG]) - -# see if we actually have backtrace. Use AC_CHECK_FUNCS so that it -# does the glibs "not implemented" check. Will use the current LIBS, -# so will check in -lexecinfo if we decided we needed it above -AC_CHECK_FUNCS([backtrace]) +# IRIX has dirname in -lgen, usually in libc +OMPI_CHECK_FUNC_LIB([dirname], [gen]) # # See if we need the math library explicitly linked in