2008-10-28 20:22:29 +03:00
# -*- shell-script -*-
#
# Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
# University Research and Technology
# Corporation. All rights reserved.
# Copyright (c) 2004-2005 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
# University of Stuttgart. All rights reserved.
# Copyright (c) 2004-2005 The Regents of the University of California.
# All rights reserved.
2013-12-07 03:40:34 +04:00
# Copyright (c) 2006-2013 Cisco Systems, Inc. All rights reserved.
2008-10-28 20:22:29 +03:00
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#
2009-10-24 05:04:35 +04:00
# ORTE_CHECK_TM_LIBS_FLAGS(prefix, [LIBS or LDFLAGS])
2008-10-28 20:22:29 +03:00
# ---------------------------------------------------
2009-10-24 05:04:35 +04:00
AC_DEFUN([ORTE_CHECK_TM_LIBS_FLAGS],[
2013-12-07 03:40:34 +04:00
OPAL_VAR_SCOPE_PUSH([orte_check_tm_flags])
2009-10-24 05:04:35 +04:00
orte_check_tm_flags=`$orte_check_tm_pbs_config --libs`
for orte_check_tm_val in $orte_check_tm_flags; do
if test "`echo $orte_check_tm_val | cut -c1-2`" = "-l"; then
2008-10-28 20:22:29 +03:00
if test "$2" = "LIBS"; then
2009-10-24 05:04:35 +04:00
$1_$2="$$1_$2 $orte_check_tm_val"
2008-10-28 20:22:29 +03:00
fi
else
if test "$2" = "LDFLAGS"; then
2009-10-24 05:04:35 +04:00
$1_$2="$$1_$2 $orte_check_tm_val"
2008-10-28 20:22:29 +03:00
fi
fi
done
2013-12-07 03:40:34 +04:00
OPAL_VAR_SCOPE_POP
2008-10-28 20:22:29 +03:00
])
2009-10-24 05:04:35 +04:00
# ORTE_CHECK_TM(prefix, [action-if-found], [action-if-not-found])
2008-10-28 20:22:29 +03:00
# --------------------------------------------------------
2009-10-24 05:04:35 +04:00
AC_DEFUN([ORTE_CHECK_TM],[
2013-12-07 03:40:34 +04:00
OPAL_VAR_SCOPE_PUSH([orte_check_tm_found orte_check_tm_happy orte_check_tm_dir orte_check_tm_pbs_config LDFLAGS_save CPPFLAGS_save LIBS_save])
2008-10-28 20:22:29 +03:00
AC_ARG_WITH([tm],
2008-12-02 02:13:13 +03:00
[AC_HELP_STRING([--with-tm(=DIR)],
2009-04-11 02:32:00 +04:00
[Build TM (Torque, PBSPro, and compatible) support, optionally adding DIR/include, DIR/lib, and DIR/lib64 to the search path for headers and libraries])])
2009-01-29 20:59:04 +03:00
OMPI_CHECK_WITHDIR([tm], [$with_tm], [include/tm.h])
2008-10-28 20:22:29 +03:00
2009-10-24 05:04:35 +04:00
orte_check_tm_found=no
2008-10-28 20:22:29 +03:00
AS_IF([test "$with_tm" = "no"],
2009-10-24 05:04:35 +04:00
[orte_check_tm_happy="no"],
[orte_check_tm_happy="yes"
2008-10-28 20:22:29 +03:00
AS_IF([test ! -z "$with_tm" -a "$with_tm" != "yes"],
2009-10-24 05:04:35 +04:00
[orte_check_tm_dir="$with_tm"],
[orte_check_tm_dir=""])])
2008-10-28 20:22:29 +03:00
2009-10-24 05:04:35 +04:00
AS_IF([test "$orte_check_tm_happy" = "yes"],
2008-10-28 20:22:29 +03:00
[AC_MSG_CHECKING([for pbs-config])
2009-10-24 05:04:35 +04:00
orte_check_tm_pbs_config="not found"
AS_IF([test "$orte_check_tm_dir" != "" -a -d "$orte_check_tm_dir" -a -x "$orte_check_tm_dir/bin/pbs-config"],
[orte_check_tm_pbs_config="$orte_check_tm_dir/bin/pbs-config"],
2008-10-28 20:22:29 +03:00
[AS_IF([pbs-config --prefix >/dev/null 2>&1],
2009-10-24 05:04:35 +04:00
[orte_check_tm_pbs_config="pbs-config"])])
AC_MSG_RESULT([$orte_check_tm_pbs_config])])
2008-10-28 20:22:29 +03:00
# If we have pbs-config, get the flags we need from there and then
# do simplistic tests looking for the tm headers and symbols
2009-10-24 05:04:35 +04:00
AS_IF([test "$orte_check_tm_happy" = "yes" -a "$orte_check_tm_pbs_config" != "not found"],
[$1_CPPFLAGS=`$orte_check_tm_pbs_config --cflags`
2010-11-13 02:22:11 +03:00
OPAL_LOG_MSG([$1_CPPFLAGS from pbs-config: $$1_CPPFLAGS], 1)
2008-10-28 20:22:29 +03:00
2009-10-24 05:04:35 +04:00
ORTE_CHECK_TM_LIBS_FLAGS([$1], [LDFLAGS])
2010-11-13 02:22:11 +03:00
OPAL_LOG_MSG([$1_LDFLAGS from pbs-config: $$1_LDFLAGS], 1)
2008-10-28 20:22:29 +03:00
2009-10-24 05:04:35 +04:00
ORTE_CHECK_TM_LIBS_FLAGS([$1], [LIBS])
2010-11-13 02:22:11 +03:00
OPAL_LOG_MSG([$1_LIBS from pbs-config: $$1_LIBS], 1)
2008-10-28 20:22:29 +03:00
# Now that we supposedly have the right flags, try them out.
CPPFLAGS_save="$CPPFLAGS"
LDFLAGS_save="$LDFLAGS"
LIBS_save="$LIBS"
CPPFLAGS="$CPPFLAGS $$1_CPPFLAGS"
LIBS="$LIBS $$1_LIBS"
LDFLAGS="$LDFLAGS $$1_LDFLAGS"
AC_CHECK_HEADER([tm.h],
[AC_CHECK_FUNC([tm_finalize],
2009-10-24 05:04:35 +04:00
[orte_check_tm_found="yes"])])
2008-10-28 20:22:29 +03:00
CPPFLAGS="$CPPFLAGS_save"
LDFLAGS="$LDFLAGS_save"
LIBS="$LIBS_save"])
# If we don't have pbs-config, then we have to look around
# manually.
# Note that Torque 2.1.0 changed the name of their back-end
# library to "libtorque". So we have to check for both libpbs and
# libtorque. First, check for libpbs.
2009-10-24 05:04:35 +04:00
orte_check_package_$1_save_CPPFLAGS="$CPPFLAGS"
orte_check_package_$1_save_LDFLAGS="$LDFLAGS"
orte_check_package_$1_save_LIBS="$LIBS"
2008-10-28 20:22:29 +03:00
2009-10-24 05:04:35 +04:00
orte_check_package_$1_orig_CPPFLAGS="$$1_CPPFLAGS"
orte_check_package_$1_orig_LDFLAGS="$$1_LDFLAGS"
orte_check_package_$1_orig_LIBS="$$1_LIBS"
2008-10-28 20:22:29 +03:00
2009-10-24 05:04:35 +04:00
AS_IF([test "$orte_check_tm_found" = "no"],
[AS_IF([test "$orte_check_tm_happy" = "yes"],
2008-10-28 20:22:29 +03:00
[_OMPI_CHECK_PACKAGE_HEADER([$1],
[tm.h],
2009-10-24 05:04:35 +04:00
[$orte_check_tm_dir],
[orte_check_tm_found="yes"],
[orte_check_tm_found="no"])])
2008-10-28 20:22:29 +03:00
2009-10-24 05:04:35 +04:00
AS_IF([test "$orte_check_tm_found" = "yes"],
2008-10-28 20:22:29 +03:00
[_OMPI_CHECK_PACKAGE_LIB([$1],
[pbs],
[tm_init],
[],
2009-10-24 05:04:35 +04:00
[$orte_check_tm_dir],
[$orte_check_tm_libdir],
[orte_check_tm_found="yes"],
2008-10-28 20:22:29 +03:00
[_OMPI_CHECK_PACKAGE_LIB([$1],
[torque],
[tm_init],
[],
2009-10-24 05:04:35 +04:00
[$orte_check_tm_dir],
[$orte_check_tm_libdir],
[orte_check_tm_found="yes"],
[orte_check_tm_found="no"])])])])
2008-10-28 20:22:29 +03:00
2009-10-24 05:04:35 +04:00
CPPFLAGS="$orte_check_package_$1_save_CPPFLAGS"
LDFLAGS="$orte_check_package_$1_save_LDFLAGS"
LIBS="$orte_check_package_$1_save_LIBS"
2008-10-28 20:22:29 +03:00
# Did we find the right stuff?
2009-10-24 05:04:35 +04:00
AS_IF([test "$orte_check_tm_happy" = "yes" -a "$orte_check_tm_found" = "yes"],
2008-10-28 20:22:29 +03:00
[$2],
[AS_IF([test ! -z "$with_tm" -a "$with_tm" != "no"],
[AC_MSG_ERROR([TM support requested but not found. Aborting])])
$3])
2013-12-07 03:40:34 +04:00
OPAL_VAR_SCOPE_POP
2008-10-28 20:22:29 +03:00
])