2004-01-12 00:35:37 +03:00
dnl -*- shell-script -*-
dnl
dnl $HEADER$
dnl
2004-06-07 19:33:53 +04:00
AC_DEFUN([OMPI_MCA],[
2004-01-12 00:35:37 +03:00
# Find which modules should be built as run-time loadable modules
# Acceptable combinations:
#
2004-07-01 20:25:44 +04:00
# [default -- no option given]
# --enable-mca-dso
# --enable-mca-dso=[.+,]*COMPONENT_TYPE[.+,]*
# --enable-mca-dso=[.+,]*COMPONENT_TYPE-COMPONENT_NAME[.+,]*
# --disable-mca-dso
2004-01-12 00:35:37 +03:00
#
AC_MSG_CHECKING([which modules should be run-time loadable])
2004-07-01 20:25:44 +04:00
AC_ARG_ENABLE(mca-dso,
AC_HELP_STRING([--enable-mca-dso=LIST],
[comma-separated list of types and/or type-component pairs that will be built as run-time loadable modules (as opposed to statically linked in), if supported on this platform. The default is to build all components as DSOs; the --disable-mca-dso[=LIST] form can be used to disable building all or some types/components as DSOs]))
2004-01-12 00:35:37 +03:00
2004-07-01 20:25:44 +04:00
# First, check to see if we're only building static libraries. If so,
# then override everything and only build components as static
# libraries.
if test "$enable_shared" = "no"; then
DSO_all=0
2004-07-01 02:45:33 +04:00
msg=none
2004-07-01 20:25:44 +04:00
elif test -z "$enable_mca_dso" -o "$enable_mca_dso" = "yes"; then
DSO_all=1
2004-01-12 00:35:37 +03:00
msg=all
2004-07-01 20:25:44 +04:00
elif test "$enable_mca_dso" = "no"; then
DSO_all=0
msg=none
2004-01-12 00:35:37 +03:00
else
2004-07-01 20:25:44 +04:00
DSO_all=0
2004-01-12 00:35:37 +03:00
ifs_save="$IFS"
IFS="${IFS}$PATH_SEPARATOR,"
msg=
2004-07-01 20:25:44 +04:00
for item in $enable_mca_dso; do
str="`echo DSO_$item=1 | sed s/-/_/g`"
2004-01-12 00:35:37 +03:00
eval $str
2004-07-01 20:25:44 +04:00
msg="$item $msg"
2004-01-12 00:35:37 +03:00
done
IFS="$ifs_save"
fi
AC_MSG_RESULT([$msg])
unset msg
2004-07-01 20:25:44 +04:00
if test "$enable_shared" = "no"; then
AC_MSG_WARN([*** Shared libraries have been disabled (--disable-shared])
AC_MSG_WARN([*** Building MCA components as DSOs automatically disabled])
fi
2004-01-12 00:35:37 +03:00
2004-02-13 06:58:56 +03:00
# The list of MCA types (it's fixed)
2004-01-12 00:35:37 +03:00
AC_MSG_CHECKING([for MCA types])
2004-07-01 20:25:44 +04:00
found_types="allocator coll common gpr io mpool ns one oob op pcm pml ptl topo"
2004-02-13 06:58:56 +03:00
AC_MSG_RESULT([$found_types])
2004-01-12 00:35:37 +03:00
2004-02-13 06:58:56 +03:00
# Get the list of all the non-configure MCA modules that were found by
# autogen.sh.
2004-01-12 00:35:37 +03:00
2004-02-13 06:58:56 +03:00
# config/mca_no_configure_modules.m4
MCA_FIND_NO_CONFIGURE_MODULES
2004-01-12 00:35:37 +03:00
2004-02-13 06:58:56 +03:00
# Now determine the configurable modules in each of the types. This
2004-07-01 20:25:44 +04:00
# is a little redundant and could be combined into
# MCA_FIND_NO_CONFIGURE_MODULES, but we separate it out for clarity.
# The extern statements and array of pointers to the module global
# structs are written to a file for each type that is #include'd in
# the file for each type.
2004-01-12 00:35:37 +03:00
for type in $found_types; do
all_modules=
static_modules=
2004-07-01 20:25:44 +04:00
dso_modules=
2004-01-12 00:35:37 +03:00
static_ltlibs=
# Ensure that the directory where the #include file is to live
# exists. Need to do this for VPATH builds, because the directory
# may not exist yet.
2004-03-17 22:06:06 +03:00
outdir=src/mca/$type/base
2004-01-12 00:35:37 +03:00
total_dir="."
for dir_part in `IFS='/\\'; set X $outdir; shift; echo "$[@]"`; do
total_dir=$total_dir/$dir_part
test -d "$total_dir" ||
mkdir "$total_dir" ||
AC_MSG_ERROR([cannot create $total_dir])
done
# Also ensure that the dynamic-mca base directory exists
total_dir="."
2004-07-01 20:25:44 +04:00
dyndir=src/dynamic-mca/$type
2004-01-12 00:35:37 +03:00
for dir_part in `IFS='/\\'; set X $dyndir; shift; echo "$[@]"`; do
total_dir=$total_dir/$dir_part
test -d "$total_dir" ||
mkdir "$total_dir" ||
AC_MSG_ERROR([cannot create $total_dir])
done
# Remove any previous generated #include files
outfile=$outdir/static-modules.h
rm -f $outfile $outfile.struct $outfile.extern \
2004-02-13 06:58:56 +03:00
$outfile.all $outfile.static $outfile.dyanmic
2004-01-12 00:35:37 +03:00
touch $outfile.struct $outfile.extern \
2004-07-01 20:25:44 +04:00
$outfile.all $outfile.static $outfile.dso
2004-01-12 00:35:37 +03:00
# Manual conversion of $type to its generic name (e.g., crmpi->cr,
2004-06-07 19:33:53 +04:00
# crompi->cr).
2004-01-12 00:35:37 +03:00
# JMS Fix this
case "$type" in
crmpi)
generic_type="cr"
;;
2004-06-07 19:33:53 +04:00
crompi)
2004-01-12 00:35:37 +03:00
generic_type="cr"
;;
*)
generic_type="$type"
;;
esac
2004-02-13 06:58:56 +03:00
# Iterate through the list of no-configure modules
foo="found_modules=\$MCA_${type}_NO_CONFIGURE_SUBDIRS"
eval $foo
for module in $found_modules; do
m=`basename "$module"`
2004-06-07 19:33:53 +04:00
if test -d $srcdir/$module -a ! -f $srcdir/$module/.ompi_ignore; then
ompi_show_subtitle "MCA module $type:$m (no configure script)"
2004-02-13 06:58:56 +03:00
# Remove any possible sym link in the mca-dynamic tree
2004-07-01 20:25:44 +04:00
rm -f src/dynamic-mca/$type/$m
2004-02-13 06:58:56 +03:00
# Now process the module
2004-03-17 22:06:06 +03:00
MCA_PROCESS_MODULE(1, 1, $type, $m)
2004-02-13 06:58:56 +03:00
# Note that the AM_CONDITIONAL for this module is set in
# config/mca_module_list.m4 -- which is generated by
# autogen.sh because we cannot have a variable
# AM_CONDITIONAL name (which we need here). Since
# autogen.sh knows the name that is necessary, it just
# generated the AM_CONDITIONAL directly. Here, we fill in
# the variable that is used in that AM_CONDITIONAL.
2004-07-01 20:25:44 +04:00
if test "$compile_mode" = "dso"; then
2004-02-13 06:58:56 +03:00
value=1
else
value=0
fi
2004-07-01 20:25:44 +04:00
foo="BUILD_${type}_${m}_DSO=$value"
2004-02-13 06:58:56 +03:00
eval $foo
fi
done
# Find all configureable modules, run their configure scripts,
# etc.
2004-01-12 00:35:37 +03:00
2004-03-17 22:06:06 +03:00
for module in $srcdir/src/mca/$type/*; do
2004-01-12 00:35:37 +03:00
FOUND=0
HAPPY=0
m="`basename $module`"
if test -d $module -a -x $module/configure -a \
2004-06-07 19:33:53 +04:00
! -f $module/.ompi_ignore; then
ompi_show_subtitle "MCA module $type:$m (need to configure)"
2004-01-12 00:35:37 +03:00
# We found one!
FOUND=1
# Remove any possible sym link in the mca-dynamic tree
2004-07-01 20:25:44 +04:00
rm -f src/dyanmic-mca/$type/$m
2004-02-13 06:58:56 +03:00
# Configure the module subdirectory
2004-06-07 19:33:53 +04:00
OMPI_CONFIG_SUBDIR([src/mca/$type/$m],
[$ompi_subdir_args],
2004-01-12 00:35:37 +03:00
[HAPPY=1], [HAPPY=0])
fi
2004-02-13 06:58:56 +03:00
# Process this module
2004-01-12 00:35:37 +03:00
2004-03-17 22:06:06 +03:00
MCA_PROCESS_MODULE($FOUND, $HAPPY, $type, $m)
2004-01-12 00:35:37 +03:00
done
# m4 weirdness: must also do the echo after the sort, or we get a
# string with newlines in it
2004-02-13 06:58:56 +03:00
all_modules="`sort $outfile.all`"
2004-01-12 00:35:37 +03:00
all_modules="`echo $all_modules`"
2004-02-13 06:58:56 +03:00
static_modules="`sort $outfile.static`"
2004-01-12 00:35:37 +03:00
static_modules="`echo $static_modules`"
2004-07-01 20:25:44 +04:00
dso_modules="`sort $outfile.dso`"
dso_modules="`echo $dso_modules`"
rm -f $outfile $outfile.all $outfile.static $outfile.dso
2004-01-12 00:35:37 +03:00
# Create the final .h file that will be included in the type's
# top-level glue. This lists all the static modules.
cat > $outfile <<EOF
/*
* \$HEADER\$
*/
`cat $outfile.extern`
2004-01-22 03:32:44 +03:00
const mca_base_module_t *mca_${type}_base_static_modules[[]] = {
2004-01-12 00:35:37 +03:00
`cat $outfile.struct`
NULL
};
EOF
rm -f $outfile.struct $outfile.extern
# Save the results for the Makefile.am's. Note the whacky shell
# script escaping that is necessary because $modules may be
# multiple words, but we also need to substitute on ${type}...
foo="MCA_${type}_ALL_SUBDIRS"'="$all_modules"'
eval "$foo"
foo="MCA_${type}_STATIC_SUBDIRS"'="$static_modules"'
eval "$foo"
2004-07-01 20:25:44 +04:00
foo="MCA_${type}_DSO_SUBDIRS"'="$dso_modules"'
2004-01-12 00:35:37 +03:00
eval "$foo"
foo="MCA_${type}_STATIC_LTLIBS"'="$static_ltlibs"'
eval "$foo"
done
unset foo type m modules structs outfile outdir total_dir file \
2004-07-01 20:25:44 +04:00
all_modules static_modules dso_modules static_ltlibs
2004-01-12 00:35:37 +03:00
# Grumble. It seems that AC_SUBST and AC_DEFINE don't let you
# substitue on a variable name that contains a variable (e.g.,
2004-06-07 19:33:53 +04:00
# OMPI_MCA_$type_SUBDIRS). So we have to do this manually. :-(
2004-01-12 00:35:37 +03:00
2004-06-16 21:07:09 +04:00
# Common types
AC_SUBST(MCA_common_ALL_SUBDIRS)
AC_SUBST(MCA_common_STATIC_SUBDIRS)
2004-07-01 20:25:44 +04:00
AC_SUBST(MCA_common_DSO_SUBDIRS)
2004-06-16 21:07:09 +04:00
AC_SUBST(MCA_common_STATIC_LTLIBS)
2004-06-07 19:33:53 +04:00
# OMPI types
2004-01-12 00:35:37 +03:00
AC_SUBST(MCA_oob_ALL_SUBDIRS)
AC_SUBST(MCA_oob_STATIC_SUBDIRS)
2004-07-01 20:25:44 +04:00
AC_SUBST(MCA_oob_DSO_SUBDIRS)
2004-01-12 00:35:37 +03:00
AC_SUBST(MCA_oob_STATIC_LTLIBS)
AC_SUBST(MCA_pcm_ALL_SUBDIRS)
AC_SUBST(MCA_pcm_STATIC_SUBDIRS)
2004-07-01 20:25:44 +04:00
AC_SUBST(MCA_pcm_DSO_SUBDIRS)
2004-01-12 00:35:37 +03:00
AC_SUBST(MCA_pcm_STATIC_LTLIBS)
2004-06-16 21:07:09 +04:00
AC_SUBST(MCA_gpr_ALL_SUBDIRS)
AC_SUBST(MCA_gpr_STATIC_SUBDIRS)
2004-07-01 20:25:44 +04:00
AC_SUBST(MCA_gpr_DSO_SUBDIRS)
2004-06-16 21:07:09 +04:00
AC_SUBST(MCA_gpr_STATIC_LTLIBS)
2004-01-12 00:35:37 +03:00
# MPI types
2004-06-15 20:57:18 +04:00
AC_SUBST(MCA_allocator_ALL_SUBDIRS)
AC_SUBST(MCA_allocator_STATIC_SUBDIRS)
2004-07-01 20:25:44 +04:00
AC_SUBST(MCA_allocator_DSO_SUBDIRS)
2004-06-15 20:57:18 +04:00
AC_SUBST(MCA_allocator_STATIC_LTLIBS)
2004-01-12 00:35:37 +03:00
AC_SUBST(MCA_coll_ALL_SUBDIRS)
AC_SUBST(MCA_coll_STATIC_SUBDIRS)
2004-07-01 20:25:44 +04:00
AC_SUBST(MCA_coll_DSO_SUBDIRS)
2004-01-12 00:35:37 +03:00
AC_SUBST(MCA_coll_STATIC_LTLIBS)
AC_SUBST(MCA_io_ALL_SUBDIRS)
AC_SUBST(MCA_io_STATIC_SUBDIRS)
2004-07-01 20:25:44 +04:00
AC_SUBST(MCA_io_DSO_SUBDIRS)
2004-01-12 00:35:37 +03:00
AC_SUBST(MCA_io_STATIC_LTLIBS)
2004-06-15 23:07:45 +04:00
AC_SUBST(MCA_mpool_ALL_SUBDIRS)
AC_SUBST(MCA_mpool_STATIC_SUBDIRS)
2004-07-01 20:25:44 +04:00
AC_SUBST(MCA_mpool_DSO_SUBDIRS)
2004-06-15 23:07:45 +04:00
AC_SUBST(MCA_mpool_STATIC_LTLIBS)
2004-01-12 00:35:37 +03:00
AC_SUBST(MCA_one_ALL_SUBDIRS)
AC_SUBST(MCA_one_STATIC_SUBDIRS)
2004-07-01 20:25:44 +04:00
AC_SUBST(MCA_one_DSO_SUBDIRS)
2004-01-12 00:35:37 +03:00
AC_SUBST(MCA_one_STATIC_LTLIBS)
AC_SUBST(MCA_pml_ALL_SUBDIRS)
AC_SUBST(MCA_pml_STATIC_SUBDIRS)
2004-07-01 20:25:44 +04:00
AC_SUBST(MCA_pml_DSO_SUBDIRS)
2004-01-12 00:35:37 +03:00
AC_SUBST(MCA_pml_STATIC_LTLIBS)
AC_SUBST(MCA_ptl_ALL_SUBDIRS)
AC_SUBST(MCA_ptl_STATIC_SUBDIRS)
2004-07-01 20:25:44 +04:00
AC_SUBST(MCA_ptl_DSO_SUBDIRS)
2004-01-12 00:35:37 +03:00
AC_SUBST(MCA_ptl_STATIC_LTLIBS)
AC_SUBST(MCA_topo_ALL_SUBDIRS)
AC_SUBST(MCA_topo_STATIC_SUBDIRS)
2004-07-01 20:25:44 +04:00
AC_SUBST(MCA_topo_DSO_SUBDIRS)
2004-01-12 00:35:37 +03:00
AC_SUBST(MCA_topo_STATIC_LTLIBS)
2004-02-13 06:58:56 +03:00
# Finally, now that we've filled in all the test variables, get all
# the AM_CONDITIONALs that indicate whether to build modules as shared
# or static.
# config/mca_no_configure_modules.m4
MCA_AMC_NO_CONFIGURE_MODULES])
dnl -----------------------------------------------------------------------
dnl -----------------------------------------------------------------------
dnl -----------------------------------------------------------------------
AC_DEFUN([MCA_PROCESS_MODULE],[
2004-06-25 17:17:19 +04:00
FOUND=$1
HAPPY=$2
2004-03-17 22:06:06 +03:00
type=$3
m=$4
2004-02-13 06:58:56 +03:00
# See if it dropped an output file for us to pick up some
# shell variables in.
2004-03-17 22:06:06 +03:00
infile="src/mca/$type/$m/post_configure.sh"
2004-02-13 06:58:56 +03:00
# Did we find a valid module, and did its configure run
# successfully?
if test "$HAPPY" = "1"; then
# Add this subdir to the mast list of all MCA module subdirs
echo $m >> $outfile.all
# Is this module going to built staic or shared?
2004-07-01 20:25:44 +04:00
str="SHARED_TYPE=\$DSO_$type"
2004-02-13 06:58:56 +03:00
eval $str
2004-07-01 20:25:44 +04:00
str="SHARED_GENERIC_TYPE=\$DSO_$generic_type"
2004-02-13 06:58:56 +03:00
eval $str
2004-07-01 20:25:44 +04:00
str="SHARED_MODULE=\$DSO_${type}_$m"
2004-02-13 06:58:56 +03:00
eval $str
shared_mode_override=static
# Setup for either shared or static
2004-07-01 20:25:44 +04:00
if test "$shared_mode_override" = "dso" -o \
2004-02-13 06:58:56 +03:00
"$SHARED_TYPE" = "1" -o \
"$SHARED_GENERIC_TYPE" = "1" -o \
"$SHARED_MODULE" = "1" -o \
2004-07-01 20:25:44 +04:00
"$DSO_all" = "1"; then
compile_mode="dso"
echo $m >> $outfile.dso
2004-06-17 06:34:26 +04:00
rm -f "src/dynamic-mca/$type/$m"
2004-06-07 19:33:53 +04:00
$LN_S "$OMPI_TOP_BUILDDIR/src/mca/$type/$m" \
2004-06-16 03:56:18 +04:00
"src/dynamic-mca/$type/$m"
2004-02-13 06:58:56 +03:00
else
2004-03-17 22:34:02 +03:00
static_ltlibs="$m/libmca_${type}_${m}.la $static_ltlibs"
2004-02-13 06:58:56 +03:00
echo "extern const mca_base_module_t mca_${type}_${m}_module;" >> $outfile.extern
echo " &mca_${type}_${m}_module, " >> $outfile.struct
compile_mode="static"
echo $m >> $outfile.static
fi
# Output pretty results
AC_MSG_CHECKING([if MCA module $type:$m can compile])
AC_MSG_RESULT([yes])
AC_MSG_CHECKING([for MCA module $type:$m compile mode])
AC_MSG_RESULT([$compile_mode])
# If there's an output file, add the values to
# scope_EXTRA_flags.
if test -f $infile; then
# First check for the ABORT tag
line="`grep ABORT= $infile | cut -d= -f2-`"
if test -n "$line" -a "$line" != "no"; then
AC_MSG_WARN([MCA module configure script told me to abort])
AC_MSG_ERROR([cannot continue])
fi
# Now check for the rest of the tags
2004-06-30 01:35:46 +04:00
for scope in LIBMPI WRAPPER; do
2004-02-13 06:58:56 +03:00
for flags in CFLAGS CXXFLAGS FFLAGS LDFLAGS LIBS; do
var="${scope}_EXTRA_${flags}"
line="`grep $var= $infile | cut -d= -f2-`"
if test -n "$line"; then
str="$var="'"$'"$var $line"'"'
eval $str
fi
done
done
fi
elif test "$FOUND" = "1"; then
AC_MSG_CHECKING([if MCA module $type:$m can compile])
AC_MSG_RESULT([no])
# If this module was requested as the default for this
# type, then abort.
str="foo="'"$'"with_$type"'"'
eval $str
str="bar="'"$'"with_$generic_type"'"'
eval $str
if test "$foo" = "$m" -o "$bar" = "$m"; then
AC_MSG_WARN([MCA module "$m" failed to configure properly])
AC_MSG_WARN([This module was selected as the default])
AC_MSG_ERROR([Cannot continue])
exit 1
fi
fi
2004-01-12 00:35:37 +03:00
])