2008-10-28 20:22:29 +03:00
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.
2015-02-09 22:45:54 +03:00
dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
2008-10-28 20:22:29 +03:00
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 (c) 2007 Sun Microsystems, Inc. All rights reserved.
2009-05-27 16:54:40 +04:00
dnl Copyright (c) 2009 Oak Ridge National Labs. All rights reserved.
2015-02-09 22:44:00 +03:00
dnl Copyright (c) 2009-2015 Cisco Systems, Inc. All rights reserved.
2014-05-07 08:51:45 +04:00
dnl Copyright (c) 2014 Intel, Inc. All rights reserved.
2015-02-03 09:19:22 +03:00
dnl Copyright (c) 2015 Research Organization for Information Science
dnl and Technology (RIST). All rights reserved.
2009-05-27 16:54:40 +04:00
dnl
2008-10-28 20:22:29 +03:00
dnl $COPYRIGHT$
2015-02-09 22:45:54 +03:00
dnl
2008-10-28 20:22:29 +03:00
dnl Additional copyrights may follow
2015-02-09 22:45:54 +03:00
dnl
2008-10-28 20:22:29 +03:00
dnl $HEADER$
dnl
2009-09-05 07:42:40 +04:00
dnl Portions of this file derived from GASNet v1.12 (see "GASNet"
dnl comments, below)
2009-09-05 05:46:49 +04:00
dnl Copyright 2004, Dan Bonachea <bonachea@cs.berkeley.edu>
dnl
dnl IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY FOR
dnl DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT
dnl OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF THE UNIVERSITY OF
dnl CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
2015-02-09 22:45:54 +03:00
dnl
2009-09-05 05:46:49 +04:00
dnl THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES,
dnl INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
dnl AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS
dnl ON AN "AS IS" BASIS, AND THE UNIVERSITY OF CALIFORNIA HAS NO OBLIGATION TO
dnl PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS.
dnl
2008-10-28 20:22:29 +03:00
2010-11-13 02:22:11 +03:00
AC_DEFUN([OPAL_CONFIGURE_SETUP],[
2008-10-28 20:22:29 +03:00
# Some helper script functions. Unfortunately, we cannot use $1 kinds
# of arugments here because of the m4 substitution. So we have to set
# special variable names before invoking the function. :-\
2014-05-06 02:35:23 +04:00
opal_show_title() {
2008-10-28 20:22:29 +03:00
cat <<EOF
============================================================================
== ${1}
============================================================================
EOF
2013-01-26 01:59:42 +04:00
OPAL_LOG_MSG([=== ${1}], 1)
2008-10-28 20:22:29 +03:00
}
2014-05-06 02:35:23 +04:00
opal_show_subtitle() {
2008-10-28 20:22:29 +03:00
cat <<EOF
*** ${1}
EOF
2013-01-26 01:59:42 +04:00
OPAL_LOG_MSG([*** ${1}], 1)
2008-10-28 20:22:29 +03:00
}
2014-05-07 08:51:45 +04:00
opal_show_subsubtitle() {
2008-10-28 20:22:29 +03:00
cat <<EOF
+++ ${1}
EOF
2013-01-26 01:59:42 +04:00
OPAL_LOG_MSG([+++ ${1}], 1)
2008-10-28 20:22:29 +03:00
}
2014-05-07 08:51:45 +04:00
opal_show_subsubsubtitle() {
2008-10-28 20:22:29 +03:00
cat <<EOF
--- ${1}
EOF
2013-01-26 01:59:42 +04:00
OPAL_LOG_MSG([--- ${1}], 1)
2008-10-28 20:22:29 +03:00
}
2014-12-03 04:50:44 +03:00
opal_show_verbose() {
if test "$V" = "1"; then
cat <<EOF
+++ VERBOSE: ${1}
EOF
OPAL_LOG_MSG([--- ${1}], 1)
fi
}
2008-10-28 20:22:29 +03:00
#
# Save some stats about this build
#
2010-11-13 02:22:11 +03:00
OPAL_CONFIGURE_USER="`whoami`"
OPAL_CONFIGURE_HOST="`hostname | head -n 1`"
OPAL_CONFIGURE_DATE="`date`"
2008-10-28 20:22:29 +03:00
#
2014-05-07 08:51:45 +04:00
# Save these details so that they can be used in opal_info later
2008-10-28 20:22:29 +03:00
#
2010-11-13 02:22:11 +03:00
AC_SUBST(OPAL_CONFIGURE_USER)
AC_SUBST(OPAL_CONFIGURE_HOST)
AC_SUBST(OPAL_CONFIGURE_DATE)])dnl
2008-10-28 20:22:29 +03:00
dnl #######################################################################
dnl #######################################################################
dnl #######################################################################
2010-11-13 02:22:11 +03:00
AC_DEFUN([OPAL_BASIC_SETUP],[
2008-10-28 20:22:29 +03:00
#
# Save some stats about this build
#
2010-11-13 02:22:11 +03:00
OPAL_CONFIGURE_USER="`whoami`"
OPAL_CONFIGURE_HOST="`hostname | head -n 1`"
OPAL_CONFIGURE_DATE="`date`"
2008-10-28 20:22:29 +03:00
#
# Make automake clean emacs ~ files for "make clean"
#
CLEANFILES="*~ .\#*"
AC_SUBST(CLEANFILES)
#
2014-05-07 08:51:45 +04:00
# See if we can find an old installation of OPAL to overwrite
2008-10-28 20:22:29 +03:00
#
2014-05-07 08:51:45 +04:00
# Stupid autoconf 2.54 has a bug in AC_PREFIX_PROGRAM -- if opal_clean
2008-10-28 20:22:29 +03:00
# is not found in the path and the user did not specify --prefix,
# we'll get a $prefix of "."
2014-05-07 08:51:45 +04:00
opal_prefix_save="$prefix"
AC_PREFIX_PROGRAM(opal_clean)
2008-10-28 20:22:29 +03:00
if test "$prefix" = "."; then
2014-05-07 08:51:45 +04:00
prefix="$opal_prefix_save"
2008-10-28 20:22:29 +03:00
fi
2014-05-07 08:51:45 +04:00
unset opal_prefix_save
2008-10-28 20:22:29 +03:00
#
# Basic sanity checking; we can't install to a relative path
#
case "$prefix" in
/*/bin)
prefix="`dirname $prefix`"
2015-02-09 22:45:54 +03:00
echo installing to directory \"$prefix\"
2008-10-28 20:22:29 +03:00
;;
2015-02-09 22:45:54 +03:00
/*)
echo installing to directory \"$prefix\"
2008-10-28 20:22:29 +03:00
;;
NONE)
2015-02-09 22:45:54 +03:00
echo installing to directory \"$ac_default_prefix\"
2008-10-28 20:22:29 +03:00
;;
@<:@a-zA-Z@:>@:*)
2015-02-09 22:45:54 +03:00
echo installing to directory \"$prefix\"
2008-10-28 20:22:29 +03:00
;;
2015-02-09 22:45:54 +03:00
*)
AC_MSG_ERROR(prefix "$prefix" must be an absolute directory path)
2008-10-28 20:22:29 +03:00
;;
esac
2009-09-05 07:42:40 +04:00
# BEGIN: Derived from GASNet
2009-09-05 05:46:49 +04:00
# Suggestion from Paul Hargrove to disable --program-prefix and
# friends. Heavily influenced by GASNet 1.12 acinclude.m4
# functionality to do the same thing (copyright listed at top of this
# file).
# echo program_prefix=$program_prefix program_suffix=$program_suffix program_transform_name=$program_transform_name
# undo prefix autoconf automatically adds during cross-compilation
if test "$cross_compiling" = yes && test "$program_prefix" = "${target_alias}-" ; then
program_prefix=NONE
fi
# normalize empty prefix/suffix
if test -z "$program_prefix" ; then
program_prefix=NONE
fi
if test -z "$program_suffix" ; then
program_suffix=NONE
fi
# undo transforms caused by empty prefix/suffix
2010-11-10 02:36:30 +03:00
if expr "$program_transform_name" : 's.^..$' >/dev/null || \
expr "$program_transform_name" : 's.$$..$' >/dev/null || \
expr "$program_transform_name" : 's.$$..;s.^..$' >/dev/null ; then
2009-09-05 05:46:49 +04:00
program_transform_name="s,x,x,"
fi
if test "$program_prefix$program_suffix$program_transform_name" != "NONENONEs,x,x," ; then
2010-11-10 02:36:30 +03:00
AC_MSG_WARN([*** The Open MPI configure script does not support --program-prefix, --program-suffix or --program-transform-name. Users are recommended to instead use --prefix with a unique directory and make symbolic links as desired for renaming.])
2009-09-05 05:46:49 +04:00
AC_MSG_ERROR([*** Cannot continue])
2009-09-05 07:42:40 +04:00
fi
# END: Derived from GASNet
])dnl
2008-10-28 20:22:29 +03:00
dnl #######################################################################
dnl #######################################################################
dnl #######################################################################
2010-11-13 02:22:11 +03:00
AC_DEFUN([OPAL_LOG_MSG],[
2008-10-28 20:22:29 +03:00
# 1 is the message
# 2 is whether to put a prefix or not
if test -n "$2"; then
echo "configure:__oline__: $1" >&5
else
echo $1 >&5
fi])dnl
dnl #######################################################################
dnl #######################################################################
dnl #######################################################################
2010-11-13 02:22:11 +03:00
AC_DEFUN([OPAL_LOG_FILE],[
2008-10-28 20:22:29 +03:00
# 1 is the filename
2015-02-03 09:19:22 +03:00
if test -n "$1" && test -f "$1"; then
2008-10-28 20:22:29 +03:00
cat $1 >&5
fi])dnl
dnl #######################################################################
dnl #######################################################################
dnl #######################################################################
2010-11-13 02:22:11 +03:00
AC_DEFUN([OPAL_LOG_COMMAND],[
2008-10-28 20:22:29 +03:00
# 1 is the command
# 2 is actions to do if success
# 3 is actions to do if fail
echo "configure:__oline__: $1" >&5
$1 1>&5 2>&1
2014-05-07 08:51:45 +04:00
opal_status=$?
OPAL_LOG_MSG([\$? = $opal_status], 1)
if test "$opal_status" = "0"; then
unset opal_status
2008-10-28 20:22:29 +03:00
$2
else
2014-05-07 08:51:45 +04:00
unset opal_status
2008-10-28 20:22:29 +03:00
$3
fi])dnl
dnl #######################################################################
dnl #######################################################################
dnl #######################################################################
2010-11-13 02:22:11 +03:00
AC_DEFUN([OPAL_UNIQ],[
2008-10-28 20:22:29 +03:00
# 1 is the variable name to be uniq-ized
2014-05-07 08:51:45 +04:00
opal_name=$1
2008-10-28 20:22:29 +03:00
# Go through each item in the variable and only keep the unique ones
2014-05-07 08:51:45 +04:00
opal_count=0
2008-10-28 20:22:29 +03:00
for val in ${$1}; do
2014-05-07 08:51:45 +04:00
opal_done=0
opal_i=1
opal_found=0
2008-10-28 20:22:29 +03:00
# Loop over every token we've seen so far
2014-05-07 08:51:45 +04:00
opal_done="`expr $opal_i \> $opal_count`"
2015-02-03 09:19:22 +03:00
while test "$opal_found" = "0" && test "$opal_done" = "0"; do
2008-10-28 20:22:29 +03:00
# Have we seen this token already? Prefix the comparison with
# "x" so that "-Lfoo" values won't be cause an error.
2014-05-07 08:51:45 +04:00
opal_eval="expr x$val = x\$opal_array_$opal_i"
opal_found=`eval $opal_eval`
2008-10-28 20:22:29 +03:00
# Check the ending condition
2014-05-07 08:51:45 +04:00
opal_done="`expr $opal_i \>= $opal_count`"
2008-10-28 20:22:29 +03:00
# Increment the counter
2014-05-07 08:51:45 +04:00
opal_i="`expr $opal_i + 1`"
2008-10-28 20:22:29 +03:00
done
# If we didn't find the token, add it to the "array"
2014-05-07 08:51:45 +04:00
if test "$opal_found" = "0"; then
opal_eval="opal_array_$opal_i=$val"
eval $opal_eval
opal_count="`expr $opal_count + 1`"
2008-10-28 20:22:29 +03:00
else
2014-05-07 08:51:45 +04:00
opal_i="`expr $opal_i - 1`"
2008-10-28 20:22:29 +03:00
fi
done
# Take all the items in the "array" and assemble them back into a
# single variable
2014-05-07 08:51:45 +04:00
opal_i=1
opal_done="`expr $opal_i \> $opal_count`"
opal_newval=
while test "$opal_done" = "0"; do
opal_eval="opal_newval=\"$opal_newval \$opal_array_$opal_i\""
eval $opal_eval
2008-10-28 20:22:29 +03:00
2014-05-07 08:51:45 +04:00
opal_eval="unset opal_array_$opal_i"
eval $opal_eval
2008-10-28 20:22:29 +03:00
2014-05-07 08:51:45 +04:00
opal_done="`expr $opal_i \>= $opal_count`"
opal_i="`expr $opal_i + 1`"
2008-10-28 20:22:29 +03:00
done
# Done; do the assignment
2014-05-07 08:51:45 +04:00
opal_newval="`echo $opal_newval`"
opal_eval="$opal_name=\"$opal_newval\""
eval $opal_eval
2008-10-28 20:22:29 +03:00
# Clean up
2014-05-07 08:51:45 +04:00
unset opal_name opal_i opal_done opal_newval opal_eval opal_count])dnl
2008-10-28 20:22:29 +03:00
dnl #######################################################################
dnl #######################################################################
dnl #######################################################################
2013-01-29 04:00:43 +04:00
# OPAL_APPEND_UNIQ(variable, new_argument)
# ----------------------------------------
# Append new_argument to variable if not already in variable. This assumes a
# space seperated list.
#
# This could probably be made more efficient :(.
AC_DEFUN([OPAL_APPEND_UNIQ], [
for arg in $2; do
2014-05-07 08:51:45 +04:00
opal_found=0;
2013-01-29 04:00:43 +04:00
for val in ${$1}; do
if test "x$val" = "x$arg" ; then
2014-05-07 08:51:45 +04:00
opal_found=1
2013-01-29 04:00:43 +04:00
break
fi
done
2014-05-07 08:51:45 +04:00
if test "$opal_found" = "0" ; then
2013-01-29 04:00:43 +04:00
if test -z "$$1"; then
$1="$arg"
else
$1="$$1 $arg"
fi
fi
done
2014-05-07 08:51:45 +04:00
unset opal_found
2013-01-29 04:00:43 +04:00
])
dnl #######################################################################
dnl #######################################################################
dnl #######################################################################
2013-12-14 01:24:45 +04:00
# Remove all duplicate -I, -L, and -l flags from the variable named $1
AC_DEFUN([OPAL_FLAGS_UNIQ],[
# 1 is the variable name to be uniq-ized
2014-05-07 08:51:45 +04:00
opal_name=$1
2013-12-14 01:24:45 +04:00
# Go through each item in the variable and only keep the unique ones
2014-05-07 08:51:45 +04:00
opal_count=0
2013-12-14 01:24:45 +04:00
for val in ${$1}; do
2014-05-07 08:51:45 +04:00
opal_done=0
opal_i=1
opal_found=0
2013-12-14 01:24:45 +04:00
# Loop over every token we've seen so far
2014-05-07 08:51:45 +04:00
opal_done="`expr $opal_i \> $opal_count`"
2015-02-03 09:19:22 +03:00
while test "$opal_found" = "0" && test "$opal_done" = "0"; do
2013-12-14 01:24:45 +04:00
# Have we seen this token already? Prefix the comparison
# with "x" so that "-Lfoo" values won't be cause an error.
2014-05-07 08:51:45 +04:00
opal_eval="expr x$val = x\$opal_array_$opal_i"
opal_found=`eval $opal_eval`
2013-12-14 01:24:45 +04:00
# Check the ending condition
2014-05-07 08:51:45 +04:00
opal_done="`expr $opal_i \>= $opal_count`"
2013-12-14 01:24:45 +04:00
# Increment the counter
2014-05-07 08:51:45 +04:00
opal_i="`expr $opal_i + 1`"
2013-12-14 01:24:45 +04:00
done
# Check for special cases where we do want to allow repeated
# arguments (per
2015-01-06 01:58:30 +03:00
# http://www.open-mpi.org/community/lists/devel/2012/08/11362.php
# and
# https://github.com/open-mpi/ompi/issues/324).
2013-12-14 01:24:45 +04:00
case $val in
-Xclang)
2014-05-07 08:51:45 +04:00
opal_found=0
opal_i=`expr $opal_count + 1`
2013-12-14 01:24:45 +04:00
;;
2014-12-24 01:42:19 +03:00
--param)
ompi_found=0
ompi_i=`expr $ompi_count + 1`
;;
2013-12-14 01:24:45 +04:00
esac
# If we didn't find the token, add it to the "array"
2014-05-07 08:51:45 +04:00
if test "$opal_found" = "0"; then
opal_eval="opal_array_$opal_i=$val"
eval $opal_eval
opal_count="`expr $opal_count + 1`"
2013-12-14 01:24:45 +04:00
else
2014-05-07 08:51:45 +04:00
opal_i="`expr $opal_i - 1`"
2013-12-14 01:24:45 +04:00
fi
done
# Take all the items in the "array" and assemble them back into a
# single variable
2014-05-07 08:51:45 +04:00
opal_i=1
opal_done="`expr $opal_i \> $opal_count`"
opal_newval=
while test "$opal_done" = "0"; do
opal_eval="opal_newval=\"$opal_newval \$opal_array_$opal_i\""
eval $opal_eval
2013-12-14 01:24:45 +04:00
2014-05-07 08:51:45 +04:00
opal_eval="unset opal_array_$opal_i"
eval $opal_eval
2013-12-14 01:24:45 +04:00
2014-05-07 08:51:45 +04:00
opal_done="`expr $opal_i \>= $opal_count`"
opal_i="`expr $opal_i + 1`"
2013-12-14 01:24:45 +04:00
done
# Done; do the assignment
2014-05-07 08:51:45 +04:00
opal_newval="`echo $opal_newval`"
opal_eval="$opal_name=\"$opal_newval\""
eval $opal_eval
2013-12-14 01:24:45 +04:00
# Clean up
2014-05-07 08:51:45 +04:00
unset opal_name opal_i opal_done opal_newval opal_eval opal_count
2013-12-14 01:24:45 +04:00
])dnl
dnl #######################################################################
dnl #######################################################################
dnl #######################################################################
# OPAL_FLAGS_APPEND_UNIQ(variable, new_argument)
# ----------------------------------------------
# Append new_argument to variable if:
#
# - the argument does not begin with -I, -L, or -l, or
# - the argument begins with -I, -L, or -l, and it's not already in variable
#
# This macro assumes a space seperated list.
AC_DEFUN([OPAL_FLAGS_APPEND_UNIQ], [
OPAL_VAR_SCOPE_PUSH([opal_tmp opal_append])
for arg in $2; do
opal_tmp=`echo $arg | cut -c1-2`
opal_append=1
2015-02-03 09:19:22 +03:00
AS_IF([test "$opal_tmp" = "-I" || test "$opal_tmp" = "-L" || test "$opal_tmp" = "-l"],
2013-12-14 01:24:45 +04:00
[for val in ${$1}; do
AS_IF([test "x$val" = "x$arg"], [opal_append=0])
done])
AS_IF([test "$opal_append" = "1"],
[AS_IF([test -z "$$1"], [$1=$arg], [$1="$$1 $arg"])])
done
OPAL_VAR_SCOPE_POP
])
dnl #######################################################################
dnl #######################################################################
dnl #######################################################################
2008-10-28 20:22:29 +03:00
# Macro that serves as an alternative to using `which <prog>`. It is
# preferable to simply using `which <prog>` because backticks (`) (aka
# backquotes) invoke a sub-shell which may source a "noisy"
# ~/.whatever file (and we do not want the error messages to be part
# of the assignment in foo=`which <prog>`). This macro ensures that we
# get a sane executable value.
2010-11-13 02:22:11 +03:00
AC_DEFUN([OPAL_WHICH],[
2008-10-28 20:22:29 +03:00
# 1 is the variable name to do "which" on
# 2 is the variable name to assign the return value to
2014-05-07 08:51:45 +04:00
OPAL_VAR_SCOPE_PUSH([opal_prog opal_file opal_dir opal_sentinel])
2008-10-28 20:22:29 +03:00
2014-05-07 08:51:45 +04:00
opal_prog=$1
2008-10-28 20:22:29 +03:00
IFS_SAVE=$IFS
IFS="$PATH_SEPARATOR"
2014-05-07 08:51:45 +04:00
for opal_dir in $PATH; do
if test -x "$opal_dir/$opal_prog"; then
$2="$opal_dir/$opal_prog"
2008-10-28 20:22:29 +03:00
break
fi
done
IFS=$IFS_SAVE
2010-11-13 02:22:11 +03:00
OPAL_VAR_SCOPE_POP
2008-10-28 20:22:29 +03:00
])dnl
dnl #######################################################################
dnl #######################################################################
dnl #######################################################################
2014-05-07 08:51:45 +04:00
# Declare some variables; use OPAL_VAR_SCOPE_END to ensure that they
2008-10-28 20:22:29 +03:00
# are cleaned up / undefined.
2010-11-13 02:22:11 +03:00
AC_DEFUN([OPAL_VAR_SCOPE_PUSH],[
2008-10-28 20:22:29 +03:00
# Is the private index set? If not, set it.
2014-05-07 08:51:45 +04:00
if test "x$opal_scope_index" = "x"; then
opal_scope_index=1
2008-10-28 20:22:29 +03:00
fi
# First, check to see if any of these variables are already set.
# This is a simple sanity check to ensure we're not already
# overwriting pre-existing variables (that have a non-empty
# value). It's not a perfect check, but at least it's something.
2014-05-07 08:51:45 +04:00
for opal_var in $1; do
opal_str="opal_str=\"\$$opal_var\""
eval $opal_str
2008-10-28 20:22:29 +03:00
2014-05-07 08:51:45 +04:00
if test "x$opal_str" != "x"; then
2008-10-28 20:22:29 +03:00
AC_MSG_WARN([Found configure shell variable clash!])
2014-05-07 08:51:45 +04:00
AC_MSG_WARN([[OPAL_VAR_SCOPE_PUSH] called on "$opal_var",])
AC_MSG_WARN([but it is already defined with value "$opal_str"])
2008-10-28 20:22:29 +03:00
AC_MSG_WARN([This usually indicates an error in configure.])
AC_MSG_ERROR([Cannot continue])
fi
done
# Ok, we passed the simple sanity check. Save all these names so
# that we can unset them at the end of the scope.
2014-05-07 08:51:45 +04:00
opal_str="opal_scope_$opal_scope_index=\"$1\""
eval $opal_str
unset opal_str
2008-10-28 20:22:29 +03:00
2014-05-07 08:51:45 +04:00
env | grep opal_scope
opal_scope_index=`expr $opal_scope_index + 1`
2008-10-28 20:22:29 +03:00
])dnl
# Unset a bunch of variables that were previously set
2010-11-13 02:22:11 +03:00
AC_DEFUN([OPAL_VAR_SCOPE_POP],[
2008-10-28 20:22:29 +03:00
# Unwind the index
2014-05-07 08:51:45 +04:00
opal_scope_index=`expr $opal_scope_index - 1`
opal_scope_test=`expr $opal_scope_index \> 0`
if test "$opal_scope_test" = "0"; then
AC_MSG_WARN([[OPAL_VAR_SCOPE_POP] popped too many OPAL configure scopes.])
2008-10-28 20:22:29 +03:00
AC_MSG_WARN([This usually indicates an error in configure.])
AC_MSG_ERROR([Cannot continue])
fi
# Get the variable names from that index
2014-05-07 08:51:45 +04:00
opal_str="opal_str=\"\$opal_scope_$opal_scope_index\""
eval $opal_str
2008-10-28 20:22:29 +03:00
# Iterate over all the variables and unset them all
2014-05-07 08:51:45 +04:00
for opal_var in $opal_str; do
unset $opal_var
2008-10-28 20:22:29 +03:00
done
])dnl
2009-05-27 16:54:40 +04:00
dnl #######################################################################
dnl #######################################################################
dnl #######################################################################
#
2009-05-29 00:28:43 +04:00
# OPAL_WITH_OPTION_MIN_MAX_VALUE(NAME,DEFAULT_VALUE,LOWER_BOUND,UPPER_BOUND)
2009-05-27 16:54:40 +04:00
# Defines a variable OPAL_MAX_xxx, with "xxx" being specified as parameter $1 as "variable_name".
# If not set at configure-time using --with-max-xxx, the default-value ($2) is assumed.
# If set, value is checked against lower (value >= $3) and upper bound (value <= $4)
#
2009-05-29 00:28:43 +04:00
AC_DEFUN([OPAL_WITH_OPTION_MIN_MAX_VALUE], [
2009-05-27 16:54:40 +04:00
max_value=[$2]
AC_MSG_CHECKING([maximum length of ]m4_translit($1, [_], [ ]))
AC_ARG_WITH([max-]m4_translit($1, [_], [-]),
AC_HELP_STRING([--with-max-]m4_translit($1, [_], [-])[=VALUE],
[maximum length of ]m4_translit($1, [_], [ ])[s. VALUE argument has to be specified (default: [$2]).]))
2015-02-03 09:19:22 +03:00
if test ! -z "$with_max_[$1]" && test "$with_max_[$1]" != "no" ; then
2009-05-27 16:54:40 +04:00
# Ensure it's a number (hopefully an integer!), and >0
expr $with_max_[$1] + 1 > /dev/null 2> /dev/null
AS_IF([test "$?" != "0"], [happy=0],
2015-02-03 09:19:22 +03:00
[AS_IF([test $with_max_[$1] -ge $3 && test $with_max_[$1] -le $4],
2009-05-27 16:54:40 +04:00
[happy=1], [happy=0])])
# If badness in the above tests, bail
AS_IF([test "$happy" = "0"],
[AC_MSG_RESULT([bad value ($with_max_[$1])])
AC_MSG_WARN([--with-max-]m4_translit($1, [_], [-])[s value must be >= $3 and <= $4])
AC_MSG_ERROR([Cannot continue])])
max_value=$with_max_[$1]
fi
AC_MSG_RESULT([$max_value])
AC_DEFINE_UNQUOTED([OPAL_MAX_]m4_toupper($1), $max_value,
[Maximum length of ]m4_translit($1, [_], [ ])[s (default is $2)])
2009-05-29 00:28:43 +04:00
[OPAL_MAX_]m4_toupper($1)=$max_value
2009-05-27 23:29:34 +04:00
AC_SUBST([OPAL_MAX_]m4_toupper($1))
2009-05-27 16:54:40 +04:00
])dnl
2012-12-22 20:24:36 +04:00
dnl #######################################################################
dnl #######################################################################
dnl #######################################################################
# Usage: OPAL_COMPUTE_MAX_VALUE(number_bytes, variable_to_set, action if overflow)
# Compute maximum value of datatype of
# number_bytes, setting the result in the second argument. Assumes a
# signed datatype.
AC_DEFUN([OPAL_COMPUTE_MAX_VALUE], [
# This is more complicated than it really should be. But some
# expr implementations (OpenBSD) have an expr with a max value of
# 2^31 - 1, and we sometimes want to compute the max value of a
# type as big or bigger than that...
2014-05-07 08:51:45 +04:00
opal_num_bits=`expr $1 \* 8 - 1`
2012-12-22 20:24:36 +04:00
newval=1
value=1
overflow=0
2014-05-07 08:51:45 +04:00
while test $opal_num_bits -ne 0 ; do
2012-12-22 20:24:36 +04:00
newval=`expr $value \* 2`
if test 0 -eq `expr $newval \< 0` ; then
# if the new value is not negative, next iteration...
value=$newval
2014-05-07 08:51:45 +04:00
opal_num_bits=`expr $opal_num_bits - 1`
2012-12-22 20:24:36 +04:00
# if this was the last iteration, subtract 1 (as signed
# max positive is 2^num_bits - 1). Do this here instead
# of outside of the while loop because we might have
# already subtracted 1 by then if we're trying to find the
# max value of the same datatype expr uses as it's
# internal representation (ie, if we hit the else
# below...)
2014-05-07 08:51:45 +04:00
if test 0 -eq $opal_num_bits ; then
2012-12-22 20:24:36 +04:00
value=`expr $value - 1`
fi
else
# if the new value is negative, we've over flowed. First,
# try adding value - 1 instead of value (see if we can get
# to positive max of expr)
newval=`expr $value - 1 + $value`
if test 0 -eq `expr $newval \< 0` ; then
value=$newval
# Still positive, this is as high as we can go. If
2014-05-07 08:51:45 +04:00
# opal_num_bits is 1, we didn't actually overflow.
2012-12-22 20:24:36 +04:00
# Otherwise, we overflowed.
2014-05-07 08:51:45 +04:00
if test 1 -ne $opal_num_bits ; then
2012-12-22 20:24:36 +04:00
overflow=1
fi
else
# stil negative. Time to give up.
overflow=1
fi
2014-05-07 08:51:45 +04:00
opal_num_bits=0
2012-12-22 20:24:36 +04:00
fi
done
AS_VAR_SET([$2], [$value])
AS_IF([test $overflow -ne 0], [$3])
])dnl