From c96f8706740b68fdb33e1e9e662de02f0c40edd1 Mon Sep 17 00:00:00 2001 From: Brian Barrett Date: Mon, 16 Jan 2006 01:48:03 +0000 Subject: [PATCH] * Merge of wrapper compiler updates from the bwb-wrapper-fix branch (r8690 - r8698), with changes below: - Split wrapper flags into those required for each of the three projects, and cleaned up some cruft (including the LIBMPI_EXTRA_*FLAGS) through- out the build system - Added opal_init_util and opal_finalize_util to allow init / cleanup of all the opal code that doesn't require the MCA system - Create standalone key=value file parser, based on the one that used to be in the mca param parser, so that it can be shared in multiple places - Add wrapper datafiles for opal, orte, and ompi wrappers, and add wrapper compiler with support for all the old features This commit was SVN r8699. The following SVN revisions from the original message are invalid or inconsistent and therefore were not cross-referenced: r8690 r8698 --- config/ompi_check_func_lib.m4 | 3 +- config/ompi_mca.m4 | 96 +-- config/ompi_setup_wrappers.m4 | 228 ++++++-- configure.ac | 92 ++- ompi/tools/ompi_info/Makefile.am | 4 +- ompi/tools/wrappers/Makefile.am | 59 +- .../wrappers/ompic++-wrapper-data.txt.in | 13 + .../tools/wrappers/ompicc-wrapper-data.txt.in | 13 + .../wrappers/ompif77-wrapper-data.txt.in | 13 + .../wrappers/ompif90-wrapper-data.txt.in | 13 + opal/Makefile.am | 2 +- opal/mca/base/Makefile.am | 8 +- opal/mca/base/mca_base_close.c | 3 - opal/mca/base/mca_base_open.c | 4 - opal/mca/base/mca_base_parse_paramfile.c | 114 +--- opal/runtime/opal.h | 41 +- opal/runtime/opal_finalize.c | 66 ++- opal/runtime/opal_init.c | 63 +- opal/tools/Makefile.am | 27 + opal/tools/wrappers/Makefile.am | 61 ++ opal/tools/wrappers/help-opal-wrapper.txt | 51 ++ opal/tools/wrappers/opal_wrapper.c | 548 ++++++++++++++++++ .../wrappers/opalc++-wrapper-data.txt.in | 13 + .../tools/wrappers/opalcc-wrapper-data.txt.in | 13 + opal/util/Makefile.am | 6 + opal/util/keyval/Makefile.am | 29 + .../keyval/keyval_lex.h} | 30 +- .../keyval/keyval_lex.l} | 40 +- opal/util/keyval_parse.c | 155 +++++ opal/util/keyval_parse.h | 57 ++ orte/tools/Makefile.am | 6 +- orte/tools/openmpi/Makefile.am | 4 +- orte/tools/orted/Makefile.am | 4 +- orte/tools/orteprobe/Makefile.am | 4 +- orte/tools/wrappers/Makefile.am | 46 ++ .../wrappers/ortec++-wrapper-data.txt.in | 13 + .../tools/wrappers/ortecc-wrapper-data.txt.in | 13 + 37 files changed, 1537 insertions(+), 418 deletions(-) create mode 100644 ompi/tools/wrappers/ompic++-wrapper-data.txt.in create mode 100644 ompi/tools/wrappers/ompicc-wrapper-data.txt.in create mode 100644 ompi/tools/wrappers/ompif77-wrapper-data.txt.in create mode 100644 ompi/tools/wrappers/ompif90-wrapper-data.txt.in create mode 100644 opal/tools/Makefile.am create mode 100644 opal/tools/wrappers/Makefile.am create mode 100644 opal/tools/wrappers/help-opal-wrapper.txt create mode 100644 opal/tools/wrappers/opal_wrapper.c create mode 100644 opal/tools/wrappers/opalc++-wrapper-data.txt.in create mode 100644 opal/tools/wrappers/opalcc-wrapper-data.txt.in create mode 100644 opal/util/keyval/Makefile.am rename opal/{mca/base/mca_base_parse_paramfile_lex.h => util/keyval/keyval_lex.h} (67%) rename opal/{mca/base/mca_base_parse_paramfile_lex.l => util/keyval/keyval_lex.l} (66%) create mode 100644 opal/util/keyval_parse.c create mode 100644 opal/util/keyval_parse.h create mode 100644 orte/tools/wrappers/Makefile.am create mode 100644 orte/tools/wrappers/ortec++-wrapper-data.txt.in create mode 100644 orte/tools/wrappers/ortecc-wrapper-data.txt.in diff --git a/config/ompi_check_func_lib.m4 b/config/ompi_check_func_lib.m4 index a92c2a333f..837c8b12ec 100644 --- a/config/ompi_check_func_lib.m4 +++ b/config/ompi_check_func_lib.m4 @@ -37,8 +37,7 @@ AC_DEFUN([OMPI_CHECK_FUNC_LIB],[ [AS_VAR_SET(ompi_var, "not found")]) LIBS="$LIBS_save"])]) AS_IF([test "AS_VAR_GET(ompi_var)" = "yes"], - [LIBS="$LIBS -l$2" - WRAPPER_EXTRA_LIBS="$WRAPPER_EXTRA_LIBS -l$2"]) + [LIBS="$LIBS -l$2"]) # see if we actually have $1. Use AC_CHECK_FUNCS so that it # does the glibc "not implemented" check. Will use the current LIBS, diff --git a/config/ompi_mca.m4 b/config/ompi_mca.m4 index 3907b99759..937d2fc323 100644 --- a/config/ompi_mca.m4 +++ b/config/ompi_mca.m4 @@ -698,54 +698,17 @@ AC_DEFUN([MCA_PROCESS_COMPONENT],[ AC_MSG_ERROR([cannot continue]) fi - # If we're not compiling statically, then only take the - # "ALWAYS" tags (a uniq will be performed at the end -- no - # need to worry about duplicate flags here) - for flags in LDFLAGS LIBS; do - var_in="LIBMPI_ALWAYS_EXTRA_${flags}" - var_out="LIBMPI_EXTRA_${flags}" - line="`grep $var_in= $infile | cut -d= -f2-`" - eval "line=$line" - if test -n "$line"; then - str="$var_out="'"$'"$var_out $var_in $line"'"' - eval $str - fi - done - - for flags in CFLAGS CXXFLAGS FFLAGS FCFLAGS LDFLAGS LIBS; do - var_in="WRAPPER_ALWAYS_EXTRA_${flags}" - var_out="WRAPPER_EXTRA_${flags}" - line="`grep $var_in= $infile | cut -d= -f2-`" - eval "line=$line" - if test -n "$line"; then - str="$var_out="'"$'"$var_out $var_in $line"'"' - eval $str - fi - done - # Check for flags passed up from the component. If we're # compiling statically, then take all flags passed up from the # component. if test "$8" = "static"; then - for flags in LDFLAGS LIBS; do - var="LIBMPI_EXTRA_${flags}" - line="`grep $var= $infile | cut -d= -f2-`" + m4_foreach(flags, [LDFLAGS, LIBS], + [[line="`grep WRAPPER_EXTRA_]flags[= $infile | cut -d= -f2-`"] eval "line=$line" if test -n "$line"; then - str="$var="'"$'"$var $line"'"' - eval $str + $1[_WRAPPER_EXTRA_]flags[="$]$1[_WRAPPER_EXTRA_]flags[ $line"] fi - done - - for flags in CFLAGS CXXFLAGS FFLAGS FCFLAGS LDFLAGS LIBS; do - var="WRAPPER_EXTRA_${flags}" - line="`grep $var= $infile | cut -d= -f2-`" - eval "line=$line" - if test -n "$line"; then - str="$var="'"$'"$var $line"'"' - eval $str - fi - done + ])dnl fi dnl check for direct call header to include. This will be @@ -771,58 +734,21 @@ AC_MSG_ERROR([*** ${framework} component ${component} was supposed to be direct- fi fi - # # now add the flags that were set in the environment variables # framework_component_FOO (for example, the flags set by # m4_configure components) # - - # If we're not compiling statically, then only take the - # "ALWAYS" tags (a uniq will be performed at the end -- no - # need to worry about duplicate flags here) - for flags in LDFLAGS LIBS; do - str="line=\$${framework}_${component}_LIBMPI_ALWAYS_EXTRA_${flags}" - eval "$str" - var_out="LIBMPI_EXTRA_${flags}" - if test -n "$line"; then - str="$var_out="'"$'"$var_out $line"'"' - eval $str - fi - done - - for flags in CFLAGS CXXFLAGS FFLAGS FCFLAGS LDFLAGS LIBS; do - str="line=\$${framework}_${component}_WRAPPER_ALWAYS_EXTRA_${flags}" - eval "$str" - var_out="WRAPPER_EXTRA_${flags}" - if test -n "$line"; then - str="$var_out="'"$'"$var_out $line"'"' - eval $str - fi - done - # Check for flags passed up from the component. If we're # compiling statically, then take all flags passed up from the # component. if test "$8" = "static"; then - for flags in LDFLAGS LIBS; do - str="line=\$${framework}_${component}_LIBMPI_EXTRA_${flags}" - eval "$str" - var_out="LIBMPI_EXTRA_${flags}" - if test -n "$line"; then - str="$var_out="'"$'"$var_out $line"'"' - eval $str - fi - done - - for flags in CFLAGS CXXFLAGS FFLAGS FCFLAGS LDFLAGS LIBS; do - str="line=\$${framework}_${component}_WRAPPER_EXTRA_${flags}" - eval "$str" - var_out="WRAPPER_EXTRA_${flags}" - if test -n "$line"; then - str="$var_out="'"$'"$var_out $line"'"' - eval $str - fi - done + m4_foreach(flags, [LDFLAGS, LIBS], + [[str="line=\$${framework}_${component}_WRAPPER_EXTRA_]flags["] + eval "$str" + if test -n "$line" ; then + $1[_WRAPPER_EXTRA_]flags[="$]$1[_WRAPPER_EXTRA_]flags[ $line"] + fi + ])dnl fi ]) diff --git a/config/ompi_setup_wrappers.m4 b/config/ompi_setup_wrappers.m4 index c910269bb4..7d160c4fd3 100644 --- a/config/ompi_setup_wrappers.m4 +++ b/config/ompi_setup_wrappers.m4 @@ -27,6 +27,7 @@ dnl # don't want them to go through OMPI_UNIQ because that has resulted in # unexpected behavior for the user in the past. AC_DEFUN([OMPI_SETUP_WRAPPER_INIT],[ + WRAPPER_EXTRA_CPPFLAGS= WRAPPER_EXTRA_CFLAGS= WRAPPER_EXTRA_CXXFLAGS= WRAPPER_EXTRA_FFLAGS= @@ -98,70 +99,197 @@ AC_DEFUN([OMPI_SETUP_WRAPPER_INIT],[ AC_DEFUN([OMPI_SETUP_WRAPPER_FINAL],[ + OMPI_UNIQ([WRAPPER_EXTRA_CPPFLAGS]) + OMPI_UNIQ([WRAPPER_EXTRA_CFLAGS]) + OMPI_UNIQ([WRAPPER_EXTRA_CXXFLAGS]) + OMPI_UNIQ([WRAPPER_EXTRA_FFLAGS]) + OMPI_UNIQ([WRAPPER_EXTRA_FCFLAGS]) + OMPI_UNIQ([WRAPPER_EXTRA_LDFLAGS]) + # - # Adding WRAPPER_* flags so that extra flags needed for wrappper compilers + # OPAL # - # WRAPPER_EXTRA_CFLAGS + OMPI_UNIQ([opal_WRAPPER_EXTRA_LDFLAGS]) + OMPI_UNIQ([opal_WRAPPER_EXTRA_LIBS]) + + AC_MSG_CHECKING([for OPAL CPPFLAGS]) + OPAL_WRAPPER_EXTRA_CPPFLAGS="$WRAPPER_EXTRA_CPPFLAGS $USER_WRAPPER_EXTRA_CPPFLAGS" + AC_SUBST([OPAL_WRAPPER_EXTRA_CPPFLAGS]) + AC_MSG_RESULT([$OPAL_WRAPPER_EXTRA_CPPFLAGS]) + + AC_MSG_CHECKING([for OPAL CFLAGS]) + OPAL_WRAPPER_EXTRA_CFLAGS="$WRAPPER_EXTRA_CFLAGS $USER_WRAPPER_EXTRA_CFLAGS" + AC_SUBST([OPAL_WRAPPER_EXTRA_CFLAGS]) + AC_MSG_RESULT([$OPAL_WRAPPER_EXTRA_CFLAGS]) + + AC_MSG_CHECKING([for OPAL CXXFLAGS]) + OPAL_WRAPPER_EXTRA_CXXFLAGS="$WRAPPER_EXTRA_CXXFLAGS $USER_WRAPPER_EXTRA_CXXFLAGS" + AC_SUBST([OPAL_WRAPPER_EXTRA_CXXFLAGS]) + AC_MSG_RESULT([$OPAL_WRAPPER_EXTRA_CXXFLAGS]) + + AC_MSG_CHECKING([for OPAL LDFLAGS]) + OPAL_WRAPPER_EXTRA_LDFLAGS="$opal_WRAPPER_EXTRA_LDFLAGS $WRAPPER_EXTRA_LDFLAGS $USER_WRAPPER_EXTRA_LDFLAGS" + AC_SUBST([OPAL_WRAPPER_EXTRA_LDFLAGS]) + AC_MSG_RESULT([$OPAL_WRAPPER_EXTRA_LDFLAGS]) + + AC_MSG_CHECKING([for OPAL LIBS]) + OPAL_WRAPPER_EXTRA_LIBS="$opal_WRAPPER_EXTRA_LIBS $WRAPPER_EXTRA_LIBS $USER_WRAPPER_EXTRA_LIBS" + AC_SUBST([OPAL_WRAPPER_EXTRA_LIBS]) + AC_MSG_RESULT([$OPAL_WRAPPER_EXTRA_LIBS]) + + AC_MSG_CHECKING([for OPAL extra include dirs]) + if test "$WANT_INSTALL_HEADERS" = "1" ; then + OPAL_WRAPPER_EXTRA_INCLUDES="openmpi openmpi/opal" + else + OPAL_WRAPPER_EXTRA_INCLUDES= + fi + AC_SUBST([OPAL_WRAPPER_EXTRA_INCLUDES]) + AC_MSG_RESULT([$OPAL_WRAPPER_EXTRA_INCLUDES]) + + # - AC_MSG_CHECKING([for mpicc CFLAGS]) - OMPI_UNIQ(WRAPPER_EXTRA_CFLAGS) - WRAPPER_EXTRA_CFLAGS="$WRAPPER_EXTRA_CFLAGS $USER_WRAPPER_EXTRA_CFLAGS" + # ORTE + # + OMPI_UNIQ([orte_WRAPPER_EXTRA_LDFLAGS]) + OMPI_UNIQ([orte_WRAPPER_EXTRA_LIBS]) + + AC_MSG_CHECKING([for ORTE CPPFLAGS]) + ORTE_WRAPPER_EXTRA_CPPFLAGS="$OPAL_WRAPPER_EXTRA_CPPFLAGS" + AC_SUBST([ORTE_WRAPPER_EXTRA_CPPFLAGS]) + AC_MSG_RESULT([$ORTE_WRAPPER_EXTRA_CPPFLAGS]) + + AC_MSG_CHECKING([for ORTE CFLAGS]) + ORTE_WRAPPER_EXTRA_CFLAGS="$OPAL_WRAPPER_EXTRA_CFLAGS" + AC_SUBST([ORTE_WRAPPER_EXTRA_CFLAGS]) + AC_MSG_RESULT([$ORTE_WRAPPER_EXTRA_CFLAGS]) + + AC_MSG_CHECKING([for ORTE CXXFLAGS]) + ORTE_WRAPPER_EXTRA_CXXFLAGS="$OPAL_WRAPPER_EXTRA_CXXFLAGS" + AC_SUBST([ORTE_WRAPPER_EXTRA_CXXFLAGS]) + AC_MSG_RESULT([$ORTE_WRAPPER_EXTRA_CXXFLAGS]) + + AC_MSG_CHECKING([for ORTE LDFLAGS]) + ORTE_WRAPPER_EXTRA_LDFLAGS="$orte_WRAPPER_EXTRA_LDFLAGS $OPAL_WRAPPER_EXTRA_LDFLAGS" + AC_SUBST([ORTE_WRAPPER_EXTRA_LDFLAGS]) + AC_MSG_RESULT([$ORTE_WRAPPER_EXTRA_LDFLAGS]) + + AC_MSG_CHECKING([for ORTE LIBS]) + ORTE_WRAPPER_EXTRA_LIBS="$orte_WRAPPER_EXTRA_LIBS $OPAL_WRAPPER_EXTRA_LIBS" + AC_SUBST([ORTE_WRAPPER_EXTRA_LIBS]) + AC_MSG_RESULT([$ORTE_WRAPPER_EXTRA_LIBS]) + + AC_MSG_CHECKING([for ORTE extra include dirs]) + if test "$WANT_INSTALL_HEADERS" = "1" ; then + ORTE_WRAPPER_EXTRA_INCLUDES="$OPAL_WRAPPER_EXTRA_INCLUDES openmpi openmpi/opal openmpi/orte" + else + ORTE_WRAPPER_EXTRA_INCLUDES="$OPAL_WRAPPER_EXTRA_INCLUDES" + fi + AC_SUBST([ORTE_WRAPPER_EXTRA_INCLUDES]) + AC_MSG_RESULT([$ORTE_WRAPPER_EXTRA_INCLUDES]) + + + # + # OMPI + # + OMPI_UNIQ([ompi_WRAPPER_EXTRA_LDFLAGS]) + OMPI_UNIQ([ompi_WRAPPER_EXTRA_LIBS]) + + AC_MSG_CHECKING([for OMPI CPPFLAGS]) + OMPI_WRAPPER_EXTRA_CPPFLAGS="$ORTE_WRAPPER_EXTRA_CPPFLAGS" + AC_SUBST([OMPI_WRAPPER_EXTRA_CPPFLAGS]) + AC_MSG_RESULT([$OMPI_WRAPPER_EXTRA_CPPFLAGS]) + + AC_MSG_CHECKING([for OMPI CFLAGS]) + OMPI_WRAPPER_EXTRA_CFLAGS="$ORTE_WRAPPER_EXTRA_CFLAGS" + AC_SUBST([OMPI_WRAPPER_EXTRA_CFLAGS]) + AC_MSG_RESULT([$OMPI_WRAPPER_EXTRA_CFLAGS]) + + AC_MSG_CHECKING([for OMPI CXXFLAGS]) + OMPI_WRAPPER_EXTRA_CXXFLAGS="$ORTE_WRAPPER_EXTRA_CXXFLAGS" + AC_SUBST([OMPI_WRAPPER_EXTRA_CXXFLAGS]) + AC_MSG_RESULT([$OMPI_WRAPPER_EXTRA_CXXFLAGS]) + + AC_MSG_CHECKING([for OMPI FFLAGS]) + OMPI_WRAPPER_EXTRA_FFLAGS="$WRAPPER_EXTRA_FFLAGS $USER_WRAPPER_EXTRA_FFLAGS" + AC_SUBST([OMPI_WRAPPER_EXTRA_FFLAGS]) + AC_MSG_RESULT([$OMPI_WRAPPER_EXTRA_FFLAGS]) + + AC_MSG_CHECKING([for OMPI FCFLAGS]) + OMPI_WRAPPER_EXTRA_FCFLAGS="$WRAPPER_EXTRA_FCFLAGS $USER_WRAPPER_EXTRA_FCFLAGS" + AC_SUBST([OMPI_WRAPPER_EXTRA_FCFLAGS]) + AC_MSG_RESULT([$OMPI_WRAPPER_EXTRA_FCFLAGS]) + + AC_MSG_CHECKING([for OMPI LDFLAGS]) + OMPI_WRAPPER_EXTRA_LDFLAGS="$ompi_WRAPPER_EXTRA_LDFLAGS $ORTE_WRAPPER_EXTRA_LDFLAGS" + AC_SUBST([OMPI_WRAPPER_EXTRA_LDFLAGS]) + AC_MSG_RESULT([$OMPI_WRAPPER_EXTRA_LDFLAGS]) + + AC_MSG_CHECKING([for OMPI LIBS]) + OMPI_WRAPPER_EXTRA_LIBS="$ompi_WRAPPER_EXTRA_LIBS $ORTE_WRAPPER_EXTRA_LIBS" + AC_SUBST([OMPI_WRAPPER_EXTRA_LIBS]) + AC_MSG_RESULT([$OMPI_WRAPPER_EXTRA_LIBS]) + + AC_MSG_CHECKING([for OMPI extra include dirs]) + if test "$WANT_INSTALL_HEADERS" = "1" ; then + OMPI_WRAPPER_EXTRA_INCLUDES="$ORTE_WRAPPER_EXTRA_INCLUDES openmpi openmpi/opal openmpi/orte openmpi/ompi" + else + OMPI_WRAPPER_EXTRA_INCLUDES="$ORTE_WRAPPER_EXTRA_INCLUDES openmpi/ompi" + fi + AC_SUBST([OMPI_WRAPPER_EXTRA_INCLUDES]) + AC_MSG_RESULT([$OMPI_WRAPPER_EXTRA_INCLUDES]) + + # language binding support. C++ is a bit different, as the + # compiler should work even if there is no language support. + if test "$WANT_MPI_CXX_SUPPORT" = "1" ; then + OMPI_WRAPPER_CXX_LIB="-lmpi_cxx" + OMPI_WRAPPER_CXX_REQUIRED_FILE="libmpi_cxx.la" + else + OMPI_WRAPPER_CXX_LIB="" + OMPI_WRAPPER_CXX_REQUIRED_FILE="" + fi + AC_SUBST([OMPI_WRAPPER_CXX_LIB]) + AC_SUBST([OMPI_WRAPPER_CXX_REQUIRED_FILE]) + + if test "$OMPI_WANT_F77_BINDINGS" = "1" ; then + OMPI_WRAPPER_F77_REQUIRED_FILE="" + else + OMPI_WRAPPER_F77_REQUIRED_FILE="not supported" + fi + AC_SUBST([OMPI_WRAPPER_F77_REQUIRED_FILE]) + + if test "$OMPI_WANT_F90_BINDINGS" = "1" ; then + OMPI_WRAPPER_F90_REQUIRED_FILE="libmpi_f90.la" + else + OMPI_WRAPPER_F90_REQUIRED_FILE="not supported" + fi + AC_SUBST([OMPI_WRAPPER_F90_REQUIRED_FILE]) + + + # compatibility defines that will eventually go away + WRAPPER_EXTRA_CFLAGS="$OMPI_WRAPPER_EXTRA_CFLAGS" + WRAPPER_EXTRA_CXXFLAGS="$OMPI_WRAPPER_EXTRA_CXXFLAGS" + WRAPPER_EXTRA_FFLAGS="$OMPI_WRAPPER_EXTRA_FFLAGS" + WRAPPER_EXTRA_FCFLAGS="$OMPI_WRAPPER_EXTRA_FCFLAGS" + WRAPPER_EXTRA_LDFLAGS="$OMPI_WRAPPER_EXTRA_LDFLAGS" + WRAPPER_EXTRA_LIBS="$OMPI_WRAPPER_EXTRA_LIBS" + AC_SUBST(WRAPPER_EXTRA_CFLAGS) + AC_SUBST(WRAPPER_EXTRA_CXXFLAGS) + AC_SUBST(WRAPPER_EXTRA_FFLAGS) + AC_SUBST(WRAPPER_EXTRA_FCFLAGS) + AC_SUBST(WRAPPER_EXTRA_LDFLAGS) + AC_SUBST(WRAPPER_EXTRA_LIBS) + AC_DEFINE_UNQUOTED(WRAPPER_EXTRA_CFLAGS, "$WRAPPER_EXTRA_CFLAGS", [Additional CFLAGS to pass through the wrapper compilers]) - AC_MSG_RESULT([$WRAPPER_EXTRA_CFLAGS]) - - # - # WRAPPER_EXTRA_CXXFLAGS - # - AC_MSG_CHECKING([for mpiCC CXXFLAGS]) - OMPI_UNIQ(WRAPPER_EXTRA_CXXFLAGS) - WRAPPER_EXTRA_CXXFLAGS="$WRAPPER_EXTRA_CXXFLAGS $USER_WRAPPER_EXTRA_CXXFLAGS" - AC_SUBST(WRAPPER_EXTRA_CXXFLAGS) AC_DEFINE_UNQUOTED(WRAPPER_EXTRA_CXXFLAGS, "$WRAPPER_EXTRA_CXXFLAGS", [Additional CXXFLAGS to pass through the wrapper compilers]) - AC_MSG_RESULT([$WRAPPER_EXTRA_CXXFLAGS]) - - # - # WRAPPER_EXTRA_FFLAGS - # - AC_MSG_CHECKING([for mpif77/mpif90 FFLAGS]) - OMPI_UNIQ(WRAPPER_EXTRA_FFLAGS) - WRAPPER_EXTRA_FFLAGS="$WRAPPER_EXTRA_FFLAGS $USER_WRAPPER_EXTRA_FFLAGS" - AC_SUBST(WRAPPER_EXTRA_FFLAGS) AC_DEFINE_UNQUOTED(WRAPPER_EXTRA_FFLAGS, "$WRAPPER_EXTRA_FFLAGS", [Additional FFLAGS to pass through the wrapper compilers]) - AC_MSG_RESULT([$WRAPPER_EXTRA_FFLAGS]) - - # - # WRAPPER_EXTRA_FCFLAGS - # - AC_MSG_CHECKING([for mpif77/mpif90 FCFLAGS]) - OMPI_UNIQ(WRAPPER_EXTRA_FCFLAGS) - WRAPPER_EXTRA_FCFLAGS="$WRAPPER_EXTRA_FCFLAGS $USER_WRAPPER_EXTRA_FCFLAGS" - AC_SUBST(WRAPPER_EXTRA_FCFLAGS) AC_DEFINE_UNQUOTED(WRAPPER_EXTRA_FCFLAGS, "$WRAPPER_EXTRA_FCFLAGS", [Additional FCFLAGS to pass through the wrapper compilers]) - AC_MSG_RESULT([$WRAPPER_EXTRA_FCFLAGS]) - - # - # WRAPPER_EXTRA_LDFLAGS - # - AC_MSG_CHECKING([for wrapper compiler LDFLAGS]) - OMPI_UNIQ(WRAPPER_EXTRA_LDFLAGS) - WRAPPER_EXTRA_LDFLAGS="$WRAPPER_EXTRA_LDFLAGS $USER_WRAPPER_EXTRA_LDFLAGS" - AC_SUBST(WRAPPER_EXTRA_LDFLAGS) AC_DEFINE_UNQUOTED(WRAPPER_EXTRA_LDFLAGS, "$WRAPPER_EXTRA_LDFLAGS", [Additional LDFLAGS to pass through the wrapper compilers]) - AC_MSG_RESULT([$WRAPPER_EXTRA_LDFLAGS]) - - # - # WRAPPER_EXTRA_LIBS - # - AC_MSG_CHECKING([for wrapper compiler LIBS]) - WRAPPER_EXTRA_LIBS="$WRAPPER_EXTRA_LIBS $USER_WRAPPER_EXTRA_LIBS" - AC_SUBST(WRAPPER_EXTRA_LIBS) AC_DEFINE_UNQUOTED(WRAPPER_EXTRA_LIBS, "$WRAPPER_EXTRA_LIBS", [Additional LIBS to pass through the wrapper compilers]) - AC_MSG_RESULT([$WRAPPER_EXTRA_LIBS]) ]) diff --git a/configure.ac b/configure.ac index 84ade9feb3..0f3cd73dba 100644 --- a/configure.ac +++ b/configure.ac @@ -1155,17 +1155,23 @@ AC_CACHE_SAVE ompi_show_title "Library and Function tests" -AC_CHECK_LIB([util], [openpty], - [WRAPPER_EXTRA_LIBS="$WRAPPER_EXTRA_LIBS -lutil" - LIBS="$LIBS -lutil"]) +AC_CHECK_LIB([util], [openpty]) -AC_CHECK_LIB([nsl], [gethostbyname], - [WRAPPER_EXTRA_LIBS="$WRAPPER_EXTRA_LIBS -lnsl" - LIBS="$LIBS -lnsl"]) +AC_CHECK_LIB([nsl], [gethostbyname]) -AC_CHECK_LIB([socket], [socket], - [WRAPPER_EXTRA_LIBS="$WRAPPER_EXTRA_LIBS -lsocket" - LIBS="$LIBS -lsocket"]) +AC_CHECK_LIB([socket], [socket]) + +# Solaris has sched_yeild in -lrt, usually in libc +OMPI_CHECK_FUNC_LIB([sched_yield], [rt]) + +# FreeBSD has backtrace in -lexecinfo, usually in libc +OMPI_CHECK_FUNC_LIB([backtrace], [execinfo]) + +# IRIX has dirname in -lgen, usually in libc +OMPI_CHECK_FUNC_LIB([dirname], [gen]) + +# Darwin doesn't need -lm, as it's a symlink to libSystem.dylib +OMPI_CHECK_FUNC_LIB([ceil], [m]) AC_CHECK_FUNCS([asprintf snprintf vasprintf vsnprintf openpty isatty htonl ntohl htons ntohs getpwuid fork waitpid execve pipe setsid mmap]) @@ -1185,19 +1191,6 @@ AC_DEFINE_UNQUOTED(OMPI_HAVE_UNDERSCORE_VA_COPY, $OMPI_HAVE_UNDERSCORE_VA_COPY, AC_CHECK_DECLS(__func__) - -# Solaris has sched_yeild in -lrt, usually in libc -OMPI_CHECK_FUNC_LIB([sched_yield], [rt]) - -# FreeBSD has backtrace in -lexecinfo, usually in libc -OMPI_CHECK_FUNC_LIB([backtrace], [execinfo]) - -# IRIX has dirname in -lgen, usually in libc -OMPI_CHECK_FUNC_LIB([dirname], [gen]) - -# Darwin doesn't need -lm, as it's a symlink to libSystem.dylib -OMPI_CHECK_FUNC_LIB([ceil], [m]) - # checkpoint results AC_CACHE_SAVE @@ -1285,12 +1278,14 @@ CXXCPPFLAGS="$CXXCPPFLAGS $THREAD_CXXCPPFLAGS" LDFLAGS="$LDFLAGS $THREAD_LDFLAGS" LIBS="$LIBS $THREAD_LIBS" + +WRAPPER_EXTRA_CPPFLAGS="$WRAPPER_EXTRA_CPPFLAGS $THREAD_CPPFLAGS" WRAPPER_EXTRA_CFLAGS="$WRAPPER_EXTRA_CFLAGS $THREAD_CFLAGS" WRAPPER_EXTRA_CXXFLAGS="$WRAPPER_EXTRA_CXXFLAGS $THREAD_CXXFLAGS" WRAPPER_EXTRA_FFLAGS="$WRAPPER_EXTRA_FFLAGS $THREAD_FFLAGS" WRAPPER_EXTRA_FCFLAGS="$WRAPPER_EXTRA_FCFLAGS $THREAD_FFLAGS" WRAPPER_EXTRA_LDFLAGS="$WRAPPER_EXTRA_LDFLAGS $THREAD_LDFLAGS" -WRAPPER_EXTRA_LIBS="$WRAPPER_EXTRA_LIBS $THREAD_LIBS" +# no need to update WRAPPER_EXTRA_LIBS - we'll get it from LT later # # What is the local equivalent of "ln -s" @@ -1448,28 +1443,35 @@ opal/libltdl/config.log. You can also disable GNU libltdl (which will disable dynamic shared object loading) by configuring with --disable-dlopen.]) fi CFLAGS="$CFLAGS_save" + OPAL_LTDL_CPPFLAGS='-I$(top_srcdir)/opal/libltdl' else AC_MSG_WARN([libltdl support disabled (by --disable-dlopen)]) LIBLTDL_SUBDIR= LIBLTDL_LTLIB= WANT_LIBLTDL=0 + OPAL_LTDL_CPPFLAGS= + + # append instead of prepend, since LIBS are going to be system + # type things needed by everyone. Normally, libltdl will push + # these into LIBS, but since we've disabled libltdl, we need + # to do it here. + WRAPPER_EXTRA_LIBS="$WRAPPER_EXTRA_LIBS $LIBS" fi AC_SUBST(LIBLTDL_SUBDIR) AC_SUBST(LIBLTDL_LTLIB) -AM_CONDITIONAL(WANT_LIBLTDL, test "$WANT_LIBLTDL" = "1") -AC_DEFINE_UNQUOTED(OMPI_WANT_LIBLTDL, $WANT_LIBLTDL, - [Whether to include support for libltdl or not]) - # Have a variable that can be used to indicate where ltdl.h lives. Do # this specifically so that we get the included ltdl.h (which we know # will work properly with the compiled code, including libltdl), not # the system one (which is likely to be far too old and buggy). - -OPAL_LTDL_CPPFLAGS='-I$(top_srcdir)/opal/libltdl' AC_SUBST(OPAL_LTDL_CPPFLAGS) +AM_CONDITIONAL(WANT_LIBLTDL, test "$WANT_LIBLTDL" = "1") +AC_DEFINE_UNQUOTED(OMPI_WANT_LIBLTDL, $WANT_LIBLTDL, + [Whether to include support for libltdl or not]) + + ############################################################################ # final compiler config ############################################################################ @@ -1512,27 +1514,6 @@ AC_MSG_RESULT([$TOTALVIEW_DEBUG_FLAGS]) AC_SUBST(CFLAGS_WITHOUT_OPTFLAGS) AC_SUBST(TOTALVIEW_DEBUG_FLAGS) -# -# Adding LIBMPI_* flags from the components that are necessary to -# compile with libmpi -# -# LIBMPI_EXTRA_LDFLAGS -# -AC_MSG_CHECKING([for libmpi additional LDFLAGS]) -OMPI_UNIQ(LIBMPI_EXTRA_LDFLAGS) -AC_SUBST(LIBMPI_EXTRA_LDFLAGS) -AC_DEFINE_UNQUOTED(LIBMPI_EXTRA_LDFLAGS, "$LIBMPI_EXTRA_LDFLAGS", - [Additional LDFLAGS to compile against libmpi]) -AC_MSG_RESULT([$LIBMPI_EXTRA_LDFLAGS]) - -# -# LIBMPI_EXTRA_LIBS -# -AC_MSG_CHECKING([for libmpi additional LIBS]) -AC_SUBST(LIBMPI_EXTRA_LIBS) -AC_DEFINE_UNQUOTED(LIBMPI_EXTRA_LIBS, "$LIBMPI_EXTRA_LIBS", - [Additional LIBS to compile against libmpi]) -AC_MSG_RESULT([$LIBMPI_EXTRA_LIBS]) # # Delayed the substitution of CFLAGS and CXXFLAGS until now because @@ -1577,7 +1558,11 @@ AC_CONFIG_FILES([ opal/event/compat/Makefile opal/event/compat/sys/Makefile opal/util/Makefile + opal/util/keyval/Makefile opal/mca/base/Makefile + opal/tools/wrappers/Makefile + opal/tools/wrappers/opalcc-wrapper-data.txt + opal/tools/wrappers/opalc++-wrapper-data.txt orte/Makefile @@ -1586,6 +1571,9 @@ AC_CONFIG_FILES([ orte/tools/orteprobe/Makefile orte/tools/orterun/Makefile orte/tools/openmpi/Makefile + orte/tools/wrappers/Makefile + orte/tools/wrappers/ortecc-wrapper-data.txt + orte/tools/wrappers/ortec++-wrapper-data.txt ompi/Makefile @@ -1604,6 +1592,10 @@ AC_CONFIG_FILES([ ompi/tools/ompi_info/Makefile ompi/tools/wrappers/Makefile + ompi/tools/wrappers/ompicc-wrapper-data.txt + ompi/tools/wrappers/ompic++-wrapper-data.txt + ompi/tools/wrappers/ompif77-wrapper-data.txt + ompi/tools/wrappers/ompif90-wrapper-data.txt test/Makefile test/asm/Makefile diff --git a/ompi/tools/ompi_info/Makefile.am b/ompi/tools/ompi_info/Makefile.am index 18e87b7285..5c933711ec 100644 --- a/ompi/tools/ompi_info/Makefile.am +++ b/ompi/tools/ompi_info/Makefile.am @@ -63,8 +63,8 @@ ompi_info_SOURCES = \ output.cc \ param.cc \ version.cc -ompi_info_LDADD = $(libs) $(LIBMPI_EXTRA_LIBS) -ompi_info_LDFLAGS = $(LIBMPI_EXTRA_LDFLAGS) +ompi_info_LDADD = $(libs) +ompi_info_LDFLAGS = ompi_info_DEPENDENCIES = $(libs) clean-local: diff --git a/ompi/tools/wrappers/Makefile.am b/ompi/tools/wrappers/Makefile.am index 7f3fa1d23a..08eb679deb 100644 --- a/ompi/tools/wrappers/Makefile.am +++ b/ompi/tools/wrappers/Makefile.am @@ -16,7 +16,11 @@ # $HEADER$ # -dist_pkgdata_DATA = help-wrapper.txt +dist_pkgdata_DATA = help-wrapper.txt \ + ompicc-wrapper-data.txt \ + ompic++-wrapper-data.txt \ + ompif77-wrapper-data.txt \ + ompif90-wrapper-data.txt # This is ugly, but we need it so that people can change things at # "make" time (e.g., "make sysconfdir=/foo/bar all") as documented in @@ -44,23 +48,23 @@ libs = \ wrap_sources = wrap.cc wrap_engine.cc ompi_wrap.h mpicc_SOURCES = mpicc.cc ompi_wrap.h $(wrap_sources) -mpicc_LDADD = $(libs) $(LIBMPI_EXTRA_LIBS) -mpicc_LDFLAGS = $(LIBMPI_EXTRA_LDFLAGS) +mpicc_LDADD = $(libs) +mpicc_LDFLAGS = mpicc_DEPENDENCIES = $(libs) mpic___SOURCES = mpicxx.cc ompi_wrap.h $(wrap_sources) -mpic___LDADD = $(libs) $(LIBMPI_EXTRA_LIBS) -mpic___LDFLAGS = $(LIBMPI_EXTRA_LDFLAGS) +mpic___LDADD = $(libs) +mpic___LDFLAGS = mpic___DEPENDENCIES = $(libs) mpif77_SOURCES = mpif77.cc ompi_wrap.h $(wrap_sources) -mpif77_LDADD = $(libs) $(LIBMPI_EXTRA_LIBS) -mpif77_LDFLAGS = $(LIBMPI_EXTRA_LDFLAGS) +mpif77_LDADD = $(libs) +mpif77_LDFLAGS = mpif77_DEPENDENCIES = $(libs) mpif90_SOURCES = mpif90.cc ompi_wrap.h $(wrap_sources) -mpif90_LDADD = $(libs) $(LIBMPI_EXTRA_LIBS) -mpif90_LDFLAGS = $(LIBMPI_EXTRA_LDFLAGS) +mpif90_LDADD = $(libs) +mpif90_LDFLAGS = mpif90_DEPENDENCIES = $(libs) # Since this is C++ and we use templates (the STL), also ditch the @@ -114,17 +118,50 @@ if CASE_SENSITIVE_FS install-exec-hook: (cd $(DESTDIR)$(bindir); rm -f mpiCC$(EXEEXT); $(LN_S) mpic++ mpiCC) (cd $(DESTDIR)$(bindir); rm -f mpicxx$(EXEEXT); $(LN_S) mpic++ mpicxx) + + (cd $(DESTDIR)$(bindir); rm -f ompicc$(EXEEXT); $(LN_S) opal_wrapper ompicc) + (cd $(DESTDIR)$(bindir); rm -f ompic++$(EXEEXT); $(LN_S) opal_wrapper ompic++) + (cd $(DESTDIR)$(bindir); rm -f ompiCC$(EXEEXT); $(LN_S) opal_wrapper ompiCC) + (cd $(DESTDIR)$(bindir); rm -f ompicxx$(EXEEXT); $(LN_S) opal_wrapper ompicxx) + (cd $(DESTDIR)$(bindir); rm -f ompif77$(EXEEXT); $(LN_S) opal_wrapper ompif77) + (cd $(DESTDIR)$(bindir); rm -f ompif90$(EXEEXT); $(LN_S) opal_wrapper ompif90) + + (cd $(DESTDIR)$(pkgdatadir); rm -f ompiCC-wrapper-data.txt; $(LN_S) ompic++-wrapper-data.txt ompiCC-wrapper-data.txt) + (cd $(DESTDIR)$(pkgdatadir); rm -f ompicxx-wrapper-data.txt; $(LN_S) ompic++-wrapper-data.txt ompicxx-wrapper-data.txt) else install-exec-hook: (cd $(DESTDIR)$(bindir); rm -f mpicxx$(EXEEXT); $(LN_S) mpic++ mpicxx) + + (cd $(DESTDIR)$(bindir); rm -f ompicc$(EXEEXT); $(LN_S) opal_wrapper ompicc) + (cd $(DESTDIR)$(bindir); rm -f ompic++$(EXEEXT); $(LN_S) opal_wrapper ompic++) + (cd $(DESTDIR)$(bindir); rm -f ompicxx$(EXEEXT); $(LN_S) opal_wrapper ompicxx) + (cd $(DESTDIR)$(bindir); rm -f ompif77$(EXEEXT); $(LN_S) opal_wrapper ompif77) + (cd $(DESTDIR)$(bindir); rm -f ompif90$(EXEEXT); $(LN_S) opal_wrapper ompif90) + + (cd $(DESTDIR)$(pkgdatadir); rm -f ompicxx-wrapper-data.txt; $(LN_S) ompic++-wrapper-data.txt ompicxx-wrapper-data.txt) endif if CASE_SENSITIVE_FS uninstall-local: rm -f $(DESTDIR)$(bindir)/mpiCC$(EXEEXT) \ - $(DESTDIR)$(bindir)/mpicxx$(EXEEXT) + $(DESTDIR)$(bindir)/mpicxx$(EXEEXT) \ + $(DESTDIR)$(bindir)/ompicc$(EXEEXT) \ + $(DESTDIR)$(bindir)/ompic++$(EXEEXT) \ + $(DESTDIR)$(bindir)/ompiCC$(EXEEXT) \ + $(DESTDIR)$(bindir)/ompicxx$(EXEEXT) \ + $(DESTDIR)$(bindir)/ompif77$(EXEEXT) \ + $(DESTDIR)$(bindir)/ompif90$(EXEEXT) \ + $(DESTDIR)$(pkgdatadir)/ompiCC-wrapper-data.txt \ + $(DESTDIR)$(pkgdatadir)/ompicxx-wrapper-data.txt + else uninstall-local: - rm -f $(DESTDIR)$(bindir)/mpicxx$(EXEEXT) + rm -f $(DESTDIR)$(bindir)/mpicxx$(EXEEXT) \ + $(DESTDIR)$(bindir)/ompicc$(EXEEXT) \ + $(DESTDIR)$(bindir)/ompic++$(EXEEXT) \ + $(DESTDIR)$(bindir)/ompicxx$(EXEEXT) \ + $(DESTDIR)$(bindir)/ompif77$(EXEEXT) \ + $(DESTDIR)$(bindir)/ompif90$(EXEEXT) \ + $(DESTDIR)$(pkgdatadir)/ompicxx-wrapper-data.txt endif endif diff --git a/ompi/tools/wrappers/ompic++-wrapper-data.txt.in b/ompi/tools/wrappers/ompic++-wrapper-data.txt.in new file mode 100644 index 0000000000..29ecca7cc6 --- /dev/null +++ b/ompi/tools/wrappers/ompic++-wrapper-data.txt.in @@ -0,0 +1,13 @@ +project=Open MPI +project_short=OMPI +version=@OMPI_VERSION@ +language=C++ +compiler_env=CXX +compiler_flags_env=CXXFLAGS +compiler=@CXX@ +extra_includes=@OMPI_WRAPPER_EXTRA_INCLUDES@ +preprocessor_flags=@OMPI_WRAPPER_EXTRA_CPPFLAGS@ +compiler_flags=@OMPI_WRAPPER_EXTRA_CXXFLAGS@ +linker_flags=@OMPI_WRAPPER_EXTRA_LDFLAGS@ +libs=@OMPI_WRAPPER_CXX_LIB@ -lmpi -lorte -lopal @OMPI_WRAPPER_EXTRA_LIBS@ +required_file=@OMPI_WRAPPER_CXX_REQUIRED_FILE@ diff --git a/ompi/tools/wrappers/ompicc-wrapper-data.txt.in b/ompi/tools/wrappers/ompicc-wrapper-data.txt.in new file mode 100644 index 0000000000..61cec812cd --- /dev/null +++ b/ompi/tools/wrappers/ompicc-wrapper-data.txt.in @@ -0,0 +1,13 @@ +project=Open MPI +project_short=OMPI +version=@OMPI_VERSION@ +language=C +compiler_env=CC +compiler_flags_env=CFLAGS +compiler=@CC@ +extra_includes=@OMPI_WRAPPER_EXTRA_INCLUDES@ +preprocessor_flags=@OMPI_WRAPPER_EXTRA_CPPFLAGS@ +compiler_flags=@OMPI_WRAPPER_EXTRA_CFLAGS@ +linker_flags=@OMPI_WRAPPER_EXTRA_LDFLAGS@ +libs=-lmpi -lorte -lopal @OMPI_WRAPPER_EXTRA_LIBS@ +required_file= diff --git a/ompi/tools/wrappers/ompif77-wrapper-data.txt.in b/ompi/tools/wrappers/ompif77-wrapper-data.txt.in new file mode 100644 index 0000000000..18abb16e6c --- /dev/null +++ b/ompi/tools/wrappers/ompif77-wrapper-data.txt.in @@ -0,0 +1,13 @@ +project=Open MPI +project_short=OMPI +version=@OMPI_VERSION@ +language=Fortran 77 +compiler_env=F77 +compiler_flags_env=FFLAGS +compiler=@F77@ +extra_includes= +preprocessor_flags= +compiler_flags=@OMPI_WRAPPER_EXTRA_FFLAGS@ +linker_flags=@OMPI_WRAPPER_EXTRA_LDFLAGS@ +libs=-lmpi -lorte -lopal @OMPI_WRAPPER_EXTRA_LIBS@ +required_file=@OMPI_WRAPPER_F77_REQUIRED_FILE@ diff --git a/ompi/tools/wrappers/ompif90-wrapper-data.txt.in b/ompi/tools/wrappers/ompif90-wrapper-data.txt.in new file mode 100644 index 0000000000..3c0ba0671e --- /dev/null +++ b/ompi/tools/wrappers/ompif90-wrapper-data.txt.in @@ -0,0 +1,13 @@ +project=Open MPI +project_short=OMPI +version=@OMPI_VERSION@ +language=Fortran 90 +compiler_env=FC +compiler_flags_env=FCFLAGS +compiler=@FC@ +extra_includes= +preprocessor_flags= +compiler_flags=@OMPI_WRAPPER_EXTRA_FFLAGS@ +linker_flags=@OMPI_WRAPPER_EXTRA_LDFLAGS@ +libs=-lmpi_f90 -lmpi -lorte -lopal @OMPI_WRAPPER_EXTRA_LIBS@ +required_file=@OMPI_WRAPPER_F90_REQUIRED_FILE@ diff --git a/opal/Makefile.am b/opal/Makefile.am index 8d1767b8b5..df6dfdc9ea 100644 --- a/opal/Makefile.am +++ b/opal/Makefile.am @@ -80,4 +80,4 @@ include runtime/Makefile.am include threads/Makefile.am include mca/Makefile.am include win32/Makefile.am - +include tools/Makefile.am diff --git a/opal/mca/base/Makefile.am b/opal/mca/base/Makefile.am index 85cd1ea25a..f5a7637718 100644 --- a/opal/mca/base/Makefile.am +++ b/opal/mca/base/Makefile.am @@ -23,8 +23,6 @@ AM_CPPFLAGS = \ $(OPAL_LTDL_CPPFLAGS) \ -DOMPI_PKGLIBDIR=\"$(pkglibdir)\" \ -DOMPI_SYSCONFDIR=\"$(sysconfdir)\" -AM_LFLAGS = -Pmca_base_yy -LEX_OUTPUT_ROOT = lex.mca_base_yy noinst_LTLIBRARIES = libmca_base.la @@ -38,8 +36,7 @@ headers = \ mca_base_msgbuf.h \ mca_base_msgbuf_internal.h \ mca_base_param.h \ - mca_base_param_internal.h \ - mca_base_parse_paramfile_lex.h + mca_base_param_internal.h # Library @@ -56,8 +53,7 @@ libmca_base_la_SOURCES = \ mca_base_msgbuf.c \ mca_base_open.c \ mca_base_param.c \ - mca_base_parse_paramfile.c \ - mca_base_parse_paramfile_lex.l + mca_base_parse_paramfile.c # Conditionally install the header files diff --git a/opal/mca/base/mca_base_close.c b/opal/mca/base/mca_base_close.c index bfa6ca1ad3..a67dbf1e8f 100644 --- a/opal/mca/base/mca_base_close.c +++ b/opal/mca/base/mca_base_close.c @@ -31,9 +31,6 @@ int mca_base_close(void) { extern bool mca_base_opened; if (mca_base_opened) { - /* Clear out all the registered MCA params */ - - mca_base_param_finalize(); /* Close down the component repository */ diff --git a/opal/mca/base/mca_base_open.c b/opal/mca/base/mca_base_open.c index b8a55786a1..30999a9a14 100644 --- a/opal/mca/base/mca_base_open.c +++ b/opal/mca/base/mca_base_open.c @@ -63,10 +63,6 @@ int mca_base_open(void) return OMPI_SUCCESS; } - /* Setup the parameter system */ - - mca_base_param_init(); - /* Register some params */ #ifdef __WINDOWS__ diff --git a/opal/mca/base/mca_base_parse_paramfile.c b/opal/mca/base/mca_base_parse_paramfile.c index 6524abca80..69aa9047d0 100644 --- a/opal/mca/base/mca_base_parse_paramfile.c +++ b/opal/mca/base/mca_base_parse_paramfile.c @@ -26,112 +26,17 @@ #include "opal/mca/mca.h" #include "opal/mca/base/base.h" #include "opal/mca/base/mca_base_param_internal.h" -#include "opal/mca/base/mca_base_parse_paramfile_lex.h" #include "ompi/include/constants.h" +#include "opal/util/keyval_parse.h" - -static const char *filename; - - -static int parse_line(void); -static void save_value(char *name, char *value); -static void parse_error(int num); - +static void save_value(const char *name, const char *value); int mca_base_parse_paramfile(const char *paramfile) { - int val; - - /* Open the parameter file */ - - mca_base_yyin = fopen(paramfile, "r"); - if (NULL == mca_base_yyin) { - return OMPI_ERR_NOT_FOUND; - } - - filename = paramfile; - mca_base_parse_done = false; - mca_base_yynewlines = 1; - mca_base_param_init_buffer(mca_base_yyin); - while (!mca_base_parse_done) { - val = mca_base_yylex(); - switch (val) { - case MCA_BASE_PARSE_DONE: - /* This will also set mca_base_parse_done to true, so just - break here */ - break; - - case MCA_BASE_PARSE_NEWLINE: - /* blank line! ignore it */ - break; - - case MCA_BASE_PARSE_SINGLE_WORD: - parse_line(); - break; - - default: - /* anything else is an error */ - parse_error(1); - break; - } - } - fclose(mca_base_yyin); - - return OMPI_SUCCESS; + return opal_util_keyval_parse(paramfile, save_value); } - -static int parse_line(void) -{ - int val; - char *name; - - /* Save the parameter name */ - - name = strdup(mca_base_yytext); - - /* The first thing we have to see is an "=" */ - - val = mca_base_yylex(); - if (mca_base_parse_done || MCA_BASE_PARSE_EQUAL != val) { - parse_error(2); - free(name); - return OMPI_ERROR; - } - - /* Next we get the value */ - - val = mca_base_yylex(); - if (MCA_BASE_PARSE_SINGLE_WORD == val || - MCA_BASE_PARSE_VALUE == val) { - save_value(name, mca_base_yytext); - - /* Now we need to see the newline */ - - val = mca_base_yylex(); - if (MCA_BASE_PARSE_NEWLINE == val || - MCA_BASE_PARSE_DONE == val) { - return OMPI_SUCCESS; - } - } - - /* Did we get an EOL or EOF? */ - - else if (MCA_BASE_PARSE_DONE == val || - MCA_BASE_PARSE_NEWLINE == val) { - save_value(name, NULL); - return OMPI_SUCCESS; - } - - /* Nope -- we got something unexpected. Bonk! */ - - parse_error(3); - free(name); - return OMPI_ERROR; -} - - -static void save_value(char *name, char *value) +static void save_value(const char *name, const char *value) { opal_list_item_t *item; mca_base_param_file_value_t *fv; @@ -145,7 +50,6 @@ static void save_value(char *name, char *value) item = opal_list_get_next(item)) { fv = (mca_base_param_file_value_t *) item; if (0 == strcmp(name, fv->mbpfv_param)) { - free(name); free(fv->mbpfv_value); fv->mbpfv_value = strdup(value); return; @@ -156,7 +60,7 @@ static void save_value(char *name, char *value) fv = OBJ_NEW(mca_base_param_file_value_t); if (NULL != fv) { - fv->mbpfv_param = name; + fv->mbpfv_param = strdup(name); if (NULL != value) { fv->mbpfv_value = strdup(value); } else { @@ -165,11 +69,3 @@ static void save_value(char *name, char *value) opal_list_append(&mca_base_param_file_values, (opal_list_item_t*) fv); } } - - -static void parse_error(int num) -{ - /* JMS need better error/warning message here */ - opal_output(0, "paramfile: error %d reading file %s at line %d:\n %s\n", - num, filename, mca_base_yynewlines, mca_base_yytext); -} diff --git a/opal/runtime/opal.h b/opal/runtime/opal.h index 6543e24365..a4d5161f6e 100644 --- a/opal/runtime/opal.h +++ b/opal/runtime/opal.h @@ -26,26 +26,53 @@ extern "C" { #endif /** - * Initialize the OPAL utilities + * Initialize the OPAL layer, including the MCA system. * * @retval ORTE_SUCCESS Upon success. * @retval ORTE_ERROR Upon failure. * - * This function performs + * \note If this function is called, opal_init_util() should *not* be + * called. */ -int opal_init(void); +OMPI_DECLSPEC int opal_init(void); /** - * Finalize the OPAL utilities + * Finalize the OPAL layer, including the MCA system. * * @retval ORTE_SUCCESS Upon success. * @retval ORTE_ERROR Upon failure. * - * This function performs + * \note If this function is called, opal_finalize_util() should *not* + * be called. */ -int opal_finalize(void); +OMPI_DECLSPEC int opal_finalize(void); -int opal_register_params(void); +/** + * Initialize the OPAL layer, excluding the MCA system. + * + * @retval ORTE_SUCCESS Upon success. + * @retval ORTE_ERROR Upon failure. + * + * \note If this function is called, opal_init() should *not* + * be called. + */ +OMPI_DECLSPEC int opal_init_util(void); + +/** + * Finalize the OPAL layer, excluding the MCA system. + * + * @retval ORTE_SUCCESS Upon success. + * @retval ORTE_ERROR Upon failure. + * + * \note If this function is called, opal_finalize() should *not* + * be called. + */ +OMPI_DECLSPEC int opal_finalize_util(void); + +/** + * Internal function. Do not call. + */ +OMPI_DECLSPEC int opal_register_params(void); #if defined(c_plusplus) || defined(__cplusplus) } diff --git a/opal/runtime/opal_finalize.c b/opal/runtime/opal_finalize.c index ef4c9b27a6..017d9dd651 100644 --- a/opal/runtime/opal_finalize.c +++ b/opal/runtime/opal_finalize.c @@ -25,6 +25,7 @@ #include "opal/util/output.h" #include "opal/util/malloc.h" #include "opal/util/if.h" +#include "opal/util/keyval_parse.h" #include "opal/memoryhooks/memory.h" #include "opal/mca/base/base.h" #include "opal/runtime/opal.h" @@ -32,39 +33,20 @@ #include "opal/mca/memory/base/base.h" #include "opal/mca/timer/base/base.h" #include "opal/mca/paffinity/base/base.h" +#include "opal/include/constants.h" -/** - * Finalize the OPAL utilities - * - * @retval ORTE_SUCCESS Upon success. - * @retval ORTE_ERROR Upon failure. - * - * This function performs - */ -int opal_finalize(void) +int +opal_finalize_util(void) { + /* Clear out all the registered MCA params */ + mca_base_param_finalize(); + /* close interfaces code. This is lazy opened, but protected from close when not opened internally */ opal_iffinalize(); - /* close high resolution timers */ - opal_timer_base_close(); - - /* close the processor affinity base */ - opal_paffinity_base_close(); - - /* close the memory manager components. Registered hooks can - still be fired any time between now and the call to - opal_mem_free_finalize(), and callbacks from the memory manager - hooks to the bowels of the mem_free code can still occur any - time between now and end of application (even post main()!) */ - opal_memory_base_close(); - - /* finalize the mca */ - mca_base_close(); - - /* finalize the memory manager / tracker */ - opal_mem_hooks_finalize(); + /* keyval lex-based parser */ + opal_util_keyval_parse_finalize(); /* finalize the memory allocator */ opal_malloc_finalize(); @@ -81,5 +63,35 @@ int opal_finalize(void) /* finalize the class/object system */ opal_class_finalize(); + return OPAL_SUCCESS; +} + + +int +opal_finalize(void) +{ + + /* close high resolution timers */ + opal_timer_base_close(); + + /* close the memory manager components. Registered hooks can + still be fired any time between now and the call to + opal_mem_free_finalize(), and callbacks from the memory manager + hooks to the bowels of the mem_free code can still occur any + time between now and end of application (even post main()!) */ + opal_memory_base_close(); + + /* finalize the memory manager / tracker */ + opal_mem_hooks_finalize(); + + /* close the processor affinity base */ + opal_paffinity_base_close(); + + /* finalize the mca */ + mca_base_close(); + + /* finalize util code */ + opal_finalize_util(); + return ORTE_SUCCESS; } diff --git a/opal/runtime/opal_init.c b/opal/runtime/opal_init.c index 78d7dcd647..738fa21f25 100644 --- a/opal/runtime/opal_init.c +++ b/opal/runtime/opal_init.c @@ -33,6 +33,7 @@ #include "opal/include/constants.h" #include "opal/util/error.h" #include "opal/util/stacktrace.h" +#include "opal/util/keyval_parse.h" static const char * opal_err2str(int errnum) @@ -114,15 +115,8 @@ opal_err2str(int errnum) } -/** - * Initialize the OPAL utilities - * - * @retval OPAL_SUCCESS Upon success. - * @retval OPAL_ERROR Upon failure. - * - * This function performs - */ -int opal_init(void) +int +opal_init_util(void) { int ret; char *error = NULL; @@ -143,9 +137,15 @@ int opal_init(void) goto return_error; } - /* initialize the mca */ - if (OMPI_SUCCESS != (ret = mca_base_open())) { - error = "mca_base_open"; + /* keyval lex-based parser */ + if (OPAL_SUCCESS != (ret = opal_util_keyval_parse_init())) { + error = "opal_util_keyval_parse_init"; + goto return_error; + } + + /* Setup the parameter system */ + if (OPAL_SUCCESS != (ret = mca_base_param_init())) { + error = "mca_base_param_init"; goto return_error; } @@ -155,6 +155,39 @@ int opal_init(void) goto return_error; } + /* pretty-print stack handlers */ + if (OPAL_SUCCESS != (ret = opal_util_register_stackhandlers ())) { + error = "util_register_stackhandlers() failed"; + goto return_error; + } + + return OPAL_SUCCESS; + + return_error: + opal_show_help( "help-opal-runtime", + "opal_init:startup:internal-failure", true, + error, ret ); + return ret; +} + + +int +opal_init(void) +{ + int ret; + char *error = NULL; + + /* initialize util code */ + if (OPAL_SUCCESS != (ret = opal_init_util())) { + return ret; + } + + /* initialize the mca */ + if (OPAL_SUCCESS != (ret = mca_base_open())) { + error = "mca_base_open"; + goto return_error; + } + /* open the processor affinity base */ opal_paffinity_base_open(); opal_paffinity_base_select(); @@ -179,12 +212,6 @@ int opal_init(void) goto return_error; } - /* pretty-print stack handlers */ - if (OMPI_SUCCESS != (ret = opal_util_register_stackhandlers ())) { - error = "util_register_stackhandlers() failed"; - goto return_error; - } - return OPAL_SUCCESS; return_error: diff --git a/opal/tools/Makefile.am b/opal/tools/Makefile.am new file mode 100644 index 0000000000..ebb8009e11 --- /dev/null +++ b/opal/tools/Makefile.am @@ -0,0 +1,27 @@ +# -*- makefile -*- +# +# 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. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# + +# This makefile.am does not stand on its own - it is included from +# opal/Makefile.am + +SUBDIRS += \ + tools/wrappers + +DIST_SUBDIRS += \ + tools/wrappers diff --git a/opal/tools/wrappers/Makefile.am b/opal/tools/wrappers/Makefile.am new file mode 100644 index 0000000000..a720e675a5 --- /dev/null +++ b/opal/tools/wrappers/Makefile.am @@ -0,0 +1,61 @@ +# +# 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. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# + +nodist_pkgdata_DATA = \ + help-opal-wrapper.txt \ + opalcc-wrapper-data.txt \ + opalc++-wrapper-data.txt + +AM_CPPFLAGS = \ + -DOPAL_LIBDIR="\"$(libdir)\"" \ + -DOPAL_INCDIR="\"$(includedir)\"" \ + -DOPAL_PKGDATADIR="\"$(pkgdatadir)\"" + +bin_PROGRAMS = opal_wrapper + +opal_wrapper_SOURCES = \ + opal_wrapper.h \ + opal_wrapper.c + +opal_wrapper_LDADD = $(top_builddir)/opal/libopal.la +opal_wrapper_DEPENDENCIES = $(top_builddir)/opal/libopal.la + +if CASE_SENSITIVE_FS +install-exec-hook: + (cd $(DESTDIR)$(bindir); rm -f opalcc$(EXEEXT); $(LN_S) opal_wrapper opalcc) + (cd $(DESTDIR)$(bindir); rm -f opalc++$(EXEEXT); $(LN_S) opal_wrapper opalc++) + (cd $(DESTDIR)$(bindir); rm -f opalCC$(EXEEXT); $(LN_S) opal_wrapper opalCC) + + (cd $(DESTDIR)$(pkgdatadir); rm -f opalCC-wrapper-data.txt; $(LN_S) opalc++-wrapper-data.txt opalCC-wrapper-data.txt) + +uninstall-local: + rm -f $(DESTDIR)$(bindir)/opalcc$(EXEEXT) \ + $(DESTDIR)$(bindir)/opalc++$(EXEEXT) \ + $(DESTDIR)$(bindir)/opalCC$(EXEEXT) \ + $(DESTDIR)$(pkgdatadir)/opalCC-wrapper-data.txt + +else +install-exec-hook: + (cd $(DESTDIR)$(bindir); rm -f opalcc$(EXEEXT); $(LN_S) opal_wrapper opalcc) + (cd $(DESTDIR)$(bindir); rm -f opalc++$(EXEEXT); $(LN_S) opal_wrapper opalc++) + +uninstall-local: + rm -f $(DESTDIR)$(bindir)/opalcc$(EXEEXT) \ + $(DESTDIR)$(bindir)/opalc++$(EXEEXT) + +endif diff --git a/opal/tools/wrappers/help-opal-wrapper.txt b/opal/tools/wrappers/help-opal-wrapper.txt new file mode 100644 index 0000000000..c2523e3d79 --- /dev/null +++ b/opal/tools/wrappers/help-opal-wrapper.txt @@ -0,0 +1,51 @@ +# -*- text -*- +# +# 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. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# +# This is the US/English help file for Open MPI wrapper compiler error +# messages. +# +[no-language-support] +Unfortunately, this installation of Open MPI was not compiled with +%s support. As such, the %s compiler is non-functional. +[no-profiling-support] +warning: "-lpmpi" was included on the command line indicating use of MPI +warning: profiling layer. However, Open MPI was not compiled with support +warning: for the MPI profiling layer; this flag has been ignored. +[no-compiler-found] +The Open MPI wrapper compiler was unable to find the specified compiler +%s in your PATH. + +Note that this compiler was either specified at configure time or in +one of several possible environment variables. +[version] +%s: %s %s (Language: %s) +[usage] +%s [-showme[:]] args + + -showme:command Show command used to invoke real compiler + -showme:compile Show flags added when compiling + -showme:link Show flags added when linking + -showme:incdirs Show list of include dirs added when compiling + -showme:libdirs Show list of library dirs added when linking + -showme:libs Show list of libraries added when linking + -showme:version Show version of %s + +[file-not-found] +%s could not find the file %s, needed for %s support. +This may indicate an incomplete install and linking will likely fail. diff --git a/opal/tools/wrappers/opal_wrapper.c b/opal/tools/wrappers/opal_wrapper.c new file mode 100644 index 0000000000..03722fb056 --- /dev/null +++ b/opal/tools/wrappers/opal_wrapper.c @@ -0,0 +1,548 @@ +/* + * 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. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +#include "ompi_config.h" + +#include +#include +#ifdef HAVE_SYS_STAT_H +#include +#endif +#ifdef HAVE_LIBGEN_H +#include +#endif + +#include "opal/runtime/opal.h" +#include "opal/include/constants.h" +#include "opal/util/argv.h" +#include "opal/util/keyval_parse.h" +#include "opal/util/show_help.h" +#include "opal/util/path.h" +#include "opal/util/few.h" + +extern char **environ; + +struct { + char *language; + char *project; + char *project_short; + char *version; + char *compiler_env; + char *compiler_flags_env; + char *compiler; + char **preproc_flags; + char **comp_flags; + char **link_flags; + char **libs; + char *req_file; +} data; + +#define COMP_DRY_RUN 0x001 +#define COMP_SHOW_ERROR 0x002 +#define COMP_WANT_COMMAND 0x004 +#define COMP_WANT_PREPROC 0x008 +#define COMP_WANT_COMPILE 0x010 +#define COMP_WANT_LINK 0x020 +#define COMP_WANT_PMPI 0x040 + +static void +data_callback(const char *key, const char *value) +{ + if (0 == strcmp(key, "language")) { + if (NULL != value) data.language = strdup(value); + } else if (0 == strcmp(key, "compiler")) { + if (NULL != value) data.compiler = strdup(value); + } else if (0 == strcmp(key, "project")) { + if (NULL != value) data.project = strdup(value); + } else if (0 == strcmp(key, "version")) { + if (NULL != value) data.version = strdup(value); + } else if (0 == strcmp(key, "extra_includes")) { + /* this is the hard one - need to put it together... */ + int i; + char **values = opal_argv_split(value, ' '); + + for (i = 0 ; i < opal_argv_count(values) ; ++i) { + char *line; + asprintf(&line, "-I%s%s%s", OPAL_INCDIR, OMPI_PATH_SEP, values[i]); + opal_argv_append_nosize(&data.preproc_flags, line); + free(line); + } + } else if (0 == strcmp(key, "preprocessor_flags")) { + char **values = opal_argv_split(value, ' '); + opal_argv_insert(&data.preproc_flags, + opal_argv_count(data.preproc_flags), + values); + opal_argv_free(values); + } else if (0 == strcmp(key, "compiler_flags")) { + char **values = opal_argv_split(value, ' '); + opal_argv_insert(&data.comp_flags, + opal_argv_count(data.comp_flags), + values); + opal_argv_free(values); + } else if (0 == strcmp(key, "linker_flags")) { + char **values = opal_argv_split(value, ' '); + opal_argv_insert(&data.link_flags, + opal_argv_count(data.link_flags), + values); + opal_argv_free(values); + } else if (0 == strcmp(key, "libs")) { + char **values = opal_argv_split(value, ' '); + opal_argv_insert(&data.libs, + opal_argv_count(data.libs), + values); + opal_argv_free(values); + } else if (0 == strcmp(key, "required_file")) { + if (NULL != value) data.req_file = strdup(value); + } else if (0 == strcmp(key, "project_short")) { + if (NULL != value) data.project_short = strdup(value); + } else if (0 == strcmp(key, "compiler_env")) { + if (NULL != value) data.compiler_env = strdup(value); + } else if (0 == strcmp(key, "compiler_flags_env")) { + if (NULL != value) data.compiler_flags_env = strdup(value); + } +} + +static int +data_init(const char *appname) +{ + int ret; + char *datafile; + + data.language = NULL; + data.compiler = NULL; + data.project = NULL; + data.project_short = NULL; + data.version = NULL; + data.compiler_env = NULL; + data.compiler_flags_env = NULL; + data.preproc_flags = malloc(sizeof(char*)); + data.preproc_flags[0] = NULL; + data.comp_flags = malloc(sizeof(char*)); + data.comp_flags[0] = NULL; + data.link_flags = malloc(sizeof(char*)); + data.link_flags[0] = NULL; + data.libs = malloc(sizeof(char*)); + data.libs[0] = NULL; + data.req_file = NULL; + + /* load the default -I and -L */ + if (0 != strcmp(OPAL_INCDIR, "/usr/include")) { + char *line; + asprintf(&line, "-I%s", OPAL_INCDIR); + opal_argv_append_nosize(&data.preproc_flags, line); + free(line); + } + if (0 != strcmp(OPAL_LIBDIR, "/usr/lib")) { + char *line; + asprintf(&line, "-L%s", OPAL_LIBDIR); + opal_argv_append_nosize(&data.link_flags, line); + free(line); + } + + /* now load the data */ + asprintf(&datafile, "%s%s%s-wrapper-data.txt", + OPAL_PKGDATADIR, OMPI_PATH_SEP, appname); + if (NULL == datafile) return OPAL_ERR_TEMP_OUT_OF_RESOURCE; + + ret = opal_util_keyval_parse(datafile, data_callback); + + free(datafile); + + return ret; +} + + +static int +data_finalize(void) +{ + if (NULL != data.language) free(data.language); + if (NULL != data.compiler) free(data.compiler); + if (NULL != data.project) free(data.project); + if (NULL != data.project_short) free(data.project_short); + if (NULL != data.version) free(data.version); + if (NULL != data.compiler_env) free(data.compiler_env); + if (NULL != data.compiler_flags_env) free(data.compiler_flags_env); + opal_argv_free(data.preproc_flags); + opal_argv_free(data.comp_flags); + opal_argv_free(data.link_flags); + opal_argv_free(data.libs); + if (NULL != data.req_file) free(data.req_file); + + return OPAL_SUCCESS; +} + + +static void +print_flags(char **args, char *pattern) +{ + int i; + bool found = false; + + for (i = 0 ; args[i] != NULL ; ++i) { + if (0 == strncmp(args[i], pattern, strlen(pattern))) { + if (found) printf(" "); + printf("%s", args[i] + strlen(pattern)); + found = true; + } + } + + if (found) printf("\n"); +} + + +static void +load_env_data(const char *project, const char *flag, char **data) +{ + char *envname; + char *envvalue; + + if (NULL == project || NULL == flag) return; + + asprintf(&envname, "%s_MPI%s", project, flag); + if (NULL == (envvalue = getenv(envname))) { + free(envname); + asprintf(&envname, "%s_%s", project, flag); + if (NULL == (envvalue = getenv(envname))) { + free(envname); + return; + } + } + free(envname); + + if (NULL != *data) free(*data); + *data = strdup(envvalue); +} + + +static void +load_env_data_argv(const char *project, const char *flag, char ***data) +{ + char *envname; + char *envvalue; + + if (NULL == project || NULL == flag) return; + + asprintf(&envname, "%s_MPI%s", project, flag); + if (NULL == (envvalue = getenv(envname))) { + free(envname); + asprintf(&envname, "%s_%s", project, flag); + if (NULL == (envvalue = getenv(envname))) { + free(envname); + return; + } + } + free(envname); + + if (NULL != *data) opal_argv_free(*data); + + *data = opal_argv_split(envvalue, ' '); +} + + +int +main(int argc, char *argv[]) +{ + int exit_status = 0, ret, flags = 0, i; + int exec_argc = 0, user_argc = 0; + char **exec_argv = NULL, **user_argv = NULL; + char *exec_command, *base_argv0; + bool disable_flags = true; + bool real_flag = false; + + if (OPAL_SUCCESS != (ret = opal_init_util())) { + return ret; + } + + + /**************************************************** + * + * Setup compiler information + * + ****************************************************/ + + base_argv0 = basename(argv[0]); + if (OPAL_SUCCESS != (ret = data_init(base_argv0))) { + return ret; + } + + /* compiler */ + load_env_data(data.project_short, data.compiler_env, &data.compiler); + + /* preprocessor flags */ + load_env_data_argv(data.project_short, "CPPFLAGS", &data.preproc_flags); + + /* compiler flags */ + load_env_data_argv(data.project_short, data.compiler_flags_env, + &data.comp_flags); + + /* linker flags */ + load_env_data_argv(data.project_short, "LDFLAGS", &data.link_flags); + + /* libs */ + load_env_data_argv(data.project_short, "LIBS", &data.libs); + + + /**************************************************** + * + * Sanity Checks + * + ****************************************************/ + + if (NULL != data.req_file) { + /* make sure the language is supported */ + if (0 == strcmp(data.req_file, "not supported")) { + opal_show_help("help-opal-wrapper.txt", "no-language-support", true, + data.language, base_argv0, NULL); + goto cleanup; + } + + if (data.req_file[0] != '\0') { + char *filename; + struct stat buf; + asprintf(&filename, "%s%s%s", OPAL_LIBDIR, OMPI_PATH_SEP, data.req_file); + if (0 != stat(filename, &buf)) { + opal_show_help("help-opal-wrapper.txt", "file-not-found", true, + base_argv0, data.req_file, data.language, NULL); + } + } + } + + /**************************************************** + * + * Parse user flags + * + ****************************************************/ + flags = COMP_WANT_COMMAND|COMP_WANT_PREPROC| + COMP_WANT_COMPILE|COMP_WANT_LINK; + + user_argv = opal_argv_copy(argv + 1); + user_argc = opal_argv_count(user_argv); + + for (i = 0 ; i < user_argc ; ++i) { + if (0 == strncmp(user_argv[i], "-showme", strlen("-showme")) || + 0 == strncmp(user_argv[i], "--showme", strlen("--showme")) || + 0 == strncmp(user_argv[i], "-show", strlen("-show")) || + 0 == strncmp(user_argv[i], "--show", strlen("--show"))) { + bool done_now = false; + + /* check for specific things we want to see. First three + still invoke all the building routines. Last set want + to parse out certain flags, so we don't go through the + normal build routine - skip to cleanup. */ + if (0 == strncmp(user_argv[i], "-showme:command", strlen("-showme:command")) || + 0 == strncmp(user_argv[i], "--showme:command", strlen("--showme:command"))) { + flags = COMP_WANT_COMMAND; + /* we know what we want, so don't process any more args */ + done_now = true; + } else if (0 == strncmp(user_argv[i], "-showme:compile", strlen("-showme:compile")) || + 0 == strncmp(user_argv[i], "--showme:compile", strlen("--showme:compile"))) { + flags = COMP_WANT_PREPROC|COMP_WANT_COMPILE; + /* we know what we want, so don't process any more args */ + done_now = true; + } else if (0 == strncmp(user_argv[i], "-showme:link", strlen("-showme:link")) || + 0 == strncmp(user_argv[i], "--showme:link", strlen("--showme:link"))) { + flags = COMP_WANT_COMPILE|COMP_WANT_LINK; + /* we know what we want, so don't process any more args */ + done_now = true; + } else if (0 == strncmp(user_argv[i], "-showme:incdirs", strlen("-showme:incdirs")) || + 0 == strncmp(user_argv[i], "--showme:incdirs", strlen("--showme:incdirs"))) { + print_flags(data.preproc_flags, "-I"); + goto cleanup; + } else if (0 == strncmp(user_argv[i], "-showme:libdirs", strlen("-showme:libdirs")) || + 0 == strncmp(user_argv[i], "--showme:libdirs", strlen("--showme:libdirs"))) { + print_flags(data.link_flags, "-L"); + goto cleanup; + } else if (0 == strncmp(user_argv[i], "-showme:libs", strlen("-showme:libs")) || + 0 == strncmp(user_argv[i], "--showme:libs", strlen("--showme:libs"))) { + print_flags(data.libs, "-l"); + goto cleanup; + } else if (0 == strncmp(user_argv[i], "-showme:version", strlen("-showme:version")) || + 0 == strncmp(user_argv[i], "--showme:version", strlen("--showme:version"))) { + opal_show_help("help-opal-wrapper.txt", "version", false, + argv[0], data.project, data.version, data.language, NULL); + goto cleanup; + } else if (0 == strncmp(user_argv[i], "-showme:", strlen("-showme:")) || + 0 == strncmp(user_argv[i], "--showme:", strlen("--showme:"))) { + opal_show_help("help-opal-wrapper.txt", "usage", true, + argv[0], data.project, NULL); + goto cleanup; + } + + flags |= (COMP_DRY_RUN|COMP_SHOW_ERROR); + /* remove element from user_argv */ + opal_argv_delete(&user_argc, &user_argv, i, 1); + --i; + + if (done_now) { + disable_flags = false; + break; + } + + } else if (0 == strcmp(user_argv[i], "-c")) { + flags &= ~COMP_WANT_LINK; + real_flag = true; + } else if (0 == strcmp(user_argv[i], "-E") || + 0 == strcmp(user_argv[i], "-M")) { + flags &= ~(COMP_WANT_COMPILE | COMP_WANT_LINK); + real_flag = true; + } else if (0 == strcmp(user_argv[i], "-S")) { + flags &= ~COMP_WANT_LINK; + real_flag = true; + } else if (0 == strcmp(user_argv[i], "-lpmpi")) { + flags |= COMP_WANT_PMPI; + + /* remove element from user_argv */ + opal_argv_delete(&user_argc, &user_argv, i, 1); + --i; + } else if ('-' != user_argv[i][0]) { + disable_flags = false; + flags |= COMP_SHOW_ERROR; + real_flag = true; + } else { + real_flag = true; + } + } + + /* clear out the want_flags if we got no arguments not starting + with a - (dash) and -showme wasn't given OR -showme was given + and we had at least one more non-showme argument that started + with a - (dash) and no other non-dash arguments. Some examples: + + opal_wrapper : clear our flags + opal_wrapper -v : clear our flags + opal_wrapper -E a.c : don't clear our flags + opal_wrapper a.c : don't clear our flags + opal_wrapper -showme : don't clear our flags + opal_wrapper -showme -v : clear our flags + opal_wrapper -showme -E a.c : don't clear our flags + opal_wrapper -showme a.c : don't clear our flags + */ + if (disable_flags && !((flags & COMP_DRY_RUN) && !real_flag)) { + flags &= ~(COMP_WANT_PREPROC|COMP_WANT_COMPILE|COMP_WANT_LINK); + } + +#if !OMPI_ENABLE_MPI_PROFILING + /* sanity check */ + if (flags & COMP_WANT_PMPI) { + opal_show_help("help-opal-wrapper.txt", "no-profiling-support", true, + argv[0], NULL); + } +#endif + + + /**************************************************** + * + * Assemble the command line + * + ****************************************************/ + + /* compiler (may be multiple arguments, so split) */ + if (flags & COMP_WANT_COMMAND) { + exec_argv = opal_argv_split(data.compiler, ' '); + exec_argc = opal_argv_count(exec_argv); + } else { + exec_argv = malloc(sizeof(char*)); + exec_argv[0] = NULL; + exec_argc = 0; + } + + /* preproc flags */ + if (flags & COMP_WANT_PREPROC) { + opal_argv_insert(&exec_argv, exec_argc, data.preproc_flags); + exec_argc = opal_argv_count(exec_argv); + } + + /* compiler flags */ + if (flags & COMP_WANT_COMPILE) { + opal_argv_insert(&exec_argv, exec_argc, data.comp_flags); + exec_argc = opal_argv_count(exec_argv); + } + + /* add all the user arguments */ + opal_argv_insert(&exec_argv, exec_argc, user_argv); + exec_argc = opal_argv_count(exec_argv); + + /* link flags and libs */ + if (flags & COMP_WANT_LINK) { + opal_argv_insert(&exec_argv, exec_argc, data.link_flags); + exec_argc = opal_argv_count(exec_argv); + + opal_argv_insert(&exec_argv, exec_argc, data.libs); + exec_argc = opal_argv_count(exec_argv); + } + + + /**************************************************** + * + * Execute the command + * + ****************************************************/ + + if (flags & COMP_DRY_RUN) { + exec_command = opal_argv_join(exec_argv, ' '); + printf("%s\n", exec_command); + } else { + char *tmp; + +#if 1 + exec_command = opal_argv_join(exec_argv, ' '); + printf("command: %s\n", exec_command); +#endif + + tmp = opal_path_findv(exec_argv[0], 0, environ, NULL); + if (NULL == tmp) { + opal_show_help("help-opal-wrapper.txt", "no-compiler-found", true, + exec_argv[0], NULL); + errno = 0; + exit_status = 1; + } else { + int status; + + free(tmp); + ret = opal_few(exec_argv, &status); + exit_status = WIFEXITED(status) ? WEXITSTATUS(status) : + (WIFSIGNALED(status) ? WTERMSIG(status) : + (WIFSTOPPED(status) ? WSTOPSIG(status) : 255)); + + if (0 != ret && 0 != errno && (flags & COMP_SHOW_ERROR)) { + perror(base_argv0); + } + } + } + + /**************************************************** + * + * Cleanup + * + ****************************************************/ + cleanup: + + opal_argv_free(exec_argv); + opal_argv_free(user_argv); + if (NULL != base_argv0) free(base_argv0); + + if (OPAL_SUCCESS != (ret = data_finalize())) { + return ret; + } + + if (OPAL_SUCCESS != (ret = opal_finalize_util())) { + return ret; + } + + return exit_status; +} diff --git a/opal/tools/wrappers/opalc++-wrapper-data.txt.in b/opal/tools/wrappers/opalc++-wrapper-data.txt.in new file mode 100644 index 0000000000..48207fc1df --- /dev/null +++ b/opal/tools/wrappers/opalc++-wrapper-data.txt.in @@ -0,0 +1,13 @@ +project=Open Portable Access Layer (OPAL) +project_short=OPAL +version=@OPAL_VERSION@ +language=C++ +compiler_env=CXX +compiler_flags_env=CXXFLAGS +compiler=@CXX@ +extra_includes=@OPAL_WRAPPER_EXTRA_INCLUDES@ +preprocessor_flags=@OPAL_WRAPPER_EXTRA_CPPFLAGS@ +compiler_flags=@OPAL_WRAPPER_EXTRA_CXXFLAGS@ +linker_flags=@OPAL_WRAPPER_EXTRA_LDFLAGS@ +libs=-lopal @OPAL_WRAPPER_EXTRA_LIBS@ +required_file= diff --git a/opal/tools/wrappers/opalcc-wrapper-data.txt.in b/opal/tools/wrappers/opalcc-wrapper-data.txt.in new file mode 100644 index 0000000000..7d1efabd96 --- /dev/null +++ b/opal/tools/wrappers/opalcc-wrapper-data.txt.in @@ -0,0 +1,13 @@ +project=Open Portable Access Layer (OPAL) +project_short=OPAL +version=@OPAL_VERSION@ +language=C +compiler_env=CC +compiler_flags_env=CFLAGS +compiler=@CC@ +extra_includes=@OPAL_WRAPPER_EXTRA_INCLUDES@ +preprocessor_flags=@OPAL_WRAPPER_EXTRA_CPPFLAGS@ +compiler_flags=@OPAL_WRAPPER_EXTRA_CFLAGS@ +linker_flags=@OPAL_WRAPPER_EXTRA_LDFLAGS@ +libs=-lopal @OPAL_WRAPPER_EXTRA_LIBS@ +required_file= diff --git a/opal/util/Makefile.am b/opal/util/Makefile.am index e2124ab9a9..dc83510703 100644 --- a/opal/util/Makefile.am +++ b/opal/util/Makefile.am @@ -37,6 +37,7 @@ headers = \ error.h \ few.h \ if.h \ + keyval_parse.h \ malloc.h \ numtostr.h \ opal_environ.h \ @@ -64,6 +65,7 @@ libopalutil_la_SOURCES = \ error.c \ few.c \ if.c \ + keyval_parse.c \ malloc.c \ numtostr.c \ opal_environ.c \ @@ -79,6 +81,10 @@ libopalutil_la_SOURCES = \ stacktrace.c \ strncpy.c \ trace.c +libopalutil_la_LIBADD = \ + keyval/libopalutilkeyval.la +libopalutil_la_DEPENDENCIES = \ + keyval/libopalutilkeyval.la # Conditionally install the header files diff --git a/opal/util/keyval/Makefile.am b/opal/util/keyval/Makefile.am new file mode 100644 index 0000000000..7c8bad35e8 --- /dev/null +++ b/opal/util/keyval/Makefile.am @@ -0,0 +1,29 @@ +# +# 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. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# + + +AM_LFLAGS = -Popal_util_keyval_yy +LEX_OUTPUT_ROOT = lex.opal_util_keyval_yy + +noinst_LTLIBRARIES = libopalutilkeyval.la + +# Source code files + +libopalutilkeyval_la_SOURCES = \ + keyval_lex.h \ + keyval_lex.l diff --git a/opal/mca/base/mca_base_parse_paramfile_lex.h b/opal/util/keyval/keyval_lex.h similarity index 67% rename from opal/mca/base/mca_base_parse_paramfile_lex.h rename to opal/util/keyval/keyval_lex.h index f23f0e1195..8e12092f0b 100644 --- a/opal/mca/base/mca_base_parse_paramfile_lex.h +++ b/opal/util/keyval/keyval_lex.h @@ -17,8 +17,8 @@ * $HEADER$ */ -#ifndef MCA_BASE_PARSE_PARAMFILE_LEX_H_ -#define MCA_BASE_PARSE_PARAMFILE_LEX_H_ +#ifndef OPAL_UTIL_KEYVAL_LEX_H_ +#define OPAL_UTIL_KEYVAL_LEX_H_ #include "ompi_config.h" @@ -34,13 +34,13 @@ #include -int mca_base_yylex(void); -int mca_base_param_init_buffer(FILE *file); +int opal_util_keyval_yylex(void); +int opal_util_keyval_init_buffer(FILE *file); -extern FILE *mca_base_yyin; -extern bool mca_base_parse_done; -extern char *mca_base_yytext; -extern int mca_base_yynewlines; +extern FILE *opal_util_keyval_yyin; +extern bool opal_util_keyval_parse_done; +extern char *opal_util_keyval_yytext; +extern int opal_util_keyval_yynewlines; /* * Make lex-generated files not issue compiler warnings @@ -52,15 +52,15 @@ extern int mca_base_yynewlines; #define YY_NO_UNPUT 1 enum { - MCA_BASE_PARSE_DONE, - MCA_BASE_PARSE_ERROR, + OPAL_UTIL_KEYVAL_PARSE_DONE, + OPAL_UTIL_KEYVAL_PARSE_ERROR, - MCA_BASE_PARSE_NEWLINE, - MCA_BASE_PARSE_EQUAL, - MCA_BASE_PARSE_SINGLE_WORD, - MCA_BASE_PARSE_VALUE, + OPAL_UTIL_KEYVAL_PARSE_NEWLINE, + OPAL_UTIL_KEYVAL_PARSE_EQUAL, + OPAL_UTIL_KEYVAL_PARSE_SINGLE_WORD, + OPAL_UTIL_KEYVAL_PARSE_VALUE, - MCA_BASE_PARSE_MAX + OPAL_UTIL_KEYVAL_PARSE_MAX }; #endif diff --git a/opal/mca/base/mca_base_parse_paramfile_lex.l b/opal/util/keyval/keyval_lex.l similarity index 66% rename from opal/mca/base/mca_base_parse_paramfile_lex.l rename to opal/util/keyval/keyval_lex.l index a6dfda5694..20464e3170 100644 --- a/opal/mca/base/mca_base_parse_paramfile_lex.l +++ b/opal/util/keyval/keyval_lex.l @@ -24,20 +24,20 @@ #include #endif -#include "mca/base/mca_base_parse_paramfile_lex.h" +#include "opal/util/keyval/keyval_lex.h" /* * local functions */ static int finish_parsing(void) ; -static int mca_base_yywrap(void); +static int opal_util_keyval_yywrap(void); /* * global variables */ -int mca_base_yynewlines = 1; -bool mca_base_parse_done = false; -char *mca_base_string = NULL; +int opal_util_keyval_yynewlines = 1; +bool opal_util_keyval_parse_done = false; +char *opal_util_keyval_string = NULL; #define yyterminate() \ return finish_parsing() @@ -52,27 +52,27 @@ CHAR [A-Za-z0-9_\-\.] %% -{WHITE}*\n { mca_base_yynewlines++; return MCA_BASE_PARSE_NEWLINE; } -#.*\n { mca_base_yynewlines++; return MCA_BASE_PARSE_NEWLINE; } -"//".*\n { mca_base_yynewlines++; return MCA_BASE_PARSE_NEWLINE; } +{WHITE}*\n { opal_util_keyval_yynewlines++; return OPAL_UTIL_KEYVAL_PARSE_NEWLINE; } +#.*\n { opal_util_keyval_yynewlines++; return OPAL_UTIL_KEYVAL_PARSE_NEWLINE; } +"//".*\n { opal_util_keyval_yynewlines++; return OPAL_UTIL_KEYVAL_PARSE_NEWLINE; } "/*" { BEGIN(comment); - return MCA_BASE_PARSE_NEWLINE; } + return OPAL_UTIL_KEYVAL_PARSE_NEWLINE; } [^*\n]* ; /* Eat up non '*'s */ "*"+[^*/\n]* ; /* Eat '*'s not followed by a '/' */ -\n { mca_base_yynewlines++; - return MCA_BASE_PARSE_NEWLINE; } +\n { opal_util_keyval_yynewlines++; + return OPAL_UTIL_KEYVAL_PARSE_NEWLINE; } "*"+"/" { BEGIN(INITIAL); /* Done with Block Comment */ - return MCA_BASE_PARSE_NEWLINE; } + return OPAL_UTIL_KEYVAL_PARSE_NEWLINE; } -{WHITE}*"="{WHITE}* { BEGIN(VALUE); return MCA_BASE_PARSE_EQUAL; } +{WHITE}*"="{WHITE}* { BEGIN(VALUE); return OPAL_UTIL_KEYVAL_PARSE_EQUAL; } {WHITE}+ ; /* whitespace */ -{CHAR}+ { return MCA_BASE_PARSE_SINGLE_WORD; } +{CHAR}+ { return OPAL_UTIL_KEYVAL_PARSE_SINGLE_WORD; } -{WHITE}*\n { BEGIN(INITIAL); return MCA_BASE_PARSE_NEWLINE; } -[^\n]*[^\t \n]/[\t ]* { return MCA_BASE_PARSE_VALUE; } +{WHITE}*\n { BEGIN(INITIAL); return OPAL_UTIL_KEYVAL_PARSE_NEWLINE; } +[^\n]*[^\t \n]/[\t ]* { return OPAL_UTIL_KEYVAL_PARSE_VALUE; } -. { return MCA_BASE_PARSE_ERROR; } +. { return OPAL_UTIL_KEYVAL_PARSE_ERROR; } %% @@ -95,9 +95,9 @@ static int finish_parsing(void) } -static int mca_base_yywrap(void) +static int opal_util_keyval_yywrap(void) { - mca_base_parse_done = true; + opal_util_keyval_parse_done = true; return 1; } @@ -111,7 +111,7 @@ static int mca_base_yywrap(void) * have a valid buffer. Hence, here we ensure to give it a valid * buffer. */ -int mca_base_param_init_buffer(FILE *file) +int opal_util_keyval_init_buffer(FILE *file) { YY_BUFFER_STATE buf = yy_create_buffer(file, YY_BUF_SIZE); yy_switch_to_buffer(buf); diff --git a/opal/util/keyval_parse.c b/opal/util/keyval_parse.c new file mode 100644 index 0000000000..b2549c1be3 --- /dev/null +++ b/opal/util/keyval_parse.c @@ -0,0 +1,155 @@ + +#include "ompi_config.h" + +#include "opal/include/constants.h" +#include "opal/util/keyval_parse.h" +#include "opal/util/keyval/keyval_lex.h" +#include "opal/util/output.h" +#include "opal/threads/mutex.h" + + +static const char *keyval_filename; +static opal_keyval_parse_fn_t keyval_callback; +static char *key_buffer = NULL; +static size_t key_buffer_len = 0; +static opal_mutex_t keyval_mutex; + +static int parse_line(void); +static void parse_error(int num); + +int opal_util_keyval_parse_init(void) +{ + OBJ_CONSTRUCT(&keyval_mutex, opal_mutex_t); + + return OPAL_SUCCESS; +} + + +int +opal_util_keyval_parse_finalize(void) +{ + if (NULL != key_buffer) free(key_buffer); + + OBJ_DESTRUCT(&keyval_mutex); + + return OPAL_SUCCESS; +} + + +int +opal_util_keyval_parse(const char *filename, + opal_keyval_parse_fn_t callback) +{ + int val; + int ret = OPAL_SUCCESS;; + + OPAL_THREAD_LOCK(&mutex); + + keyval_filename = filename; + keyval_callback = callback; + + /* Open the opal */ + opal_util_keyval_yyin = fopen(keyval_filename, "r"); + if (NULL == opal_util_keyval_yyin) { + ret = OPAL_ERR_NOT_FOUND; + goto cleanup; + } + + opal_util_keyval_parse_done = false; + opal_util_keyval_yynewlines = 1; + opal_util_keyval_init_buffer(opal_util_keyval_yyin); + while (!opal_util_keyval_parse_done) { + val = opal_util_keyval_yylex(); + switch (val) { + case OPAL_UTIL_KEYVAL_PARSE_DONE: + /* This will also set opal_util_keyval_parse_done to true, so just + break here */ + break; + + case OPAL_UTIL_KEYVAL_PARSE_NEWLINE: + /* blank line! ignore it */ + break; + + case OPAL_UTIL_KEYVAL_PARSE_SINGLE_WORD: + parse_line(); + break; + + default: + /* anything else is an error */ + parse_error(1); + break; + } + } + fclose(opal_util_keyval_yyin); + +cleanup: + OPAL_THREAD_UNLOCK(&mutex); + return ret; +} + + + +static int parse_line(void) +{ + int val; + + /* Save the name name */ + if (key_buffer_len < strlen(opal_util_keyval_yytext) + 1) { + char *tmp; + key_buffer_len = strlen(opal_util_keyval_yytext) + 1; + tmp = realloc(key_buffer, key_buffer_len); + if (NULL == tmp) { + free(key_buffer); + key_buffer_len = 0; + key_buffer = NULL; + return OPAL_ERR_TEMP_OUT_OF_RESOURCE; + } + key_buffer = tmp; + } + + strncpy(key_buffer, opal_util_keyval_yytext, key_buffer_len); + + /* The first thing we have to see is an "=" */ + + val = opal_util_keyval_yylex(); + if (opal_util_keyval_parse_done || OPAL_UTIL_KEYVAL_PARSE_EQUAL != val) { + parse_error(2); + return OPAL_ERROR; + } + + /* Next we get the value */ + + val = opal_util_keyval_yylex(); + if (OPAL_UTIL_KEYVAL_PARSE_SINGLE_WORD == val || + OPAL_UTIL_KEYVAL_PARSE_VALUE == val) { + keyval_callback(key_buffer, opal_util_keyval_yytext); + + /* Now we need to see the newline */ + + val = opal_util_keyval_yylex(); + if (OPAL_UTIL_KEYVAL_PARSE_NEWLINE == val || + OPAL_UTIL_KEYVAL_PARSE_DONE == val) { + return OPAL_SUCCESS; + } + } + + /* Did we get an EOL or EOF? */ + + else if (OPAL_UTIL_KEYVAL_PARSE_DONE == val || + OPAL_UTIL_KEYVAL_PARSE_NEWLINE == val) { + keyval_callback(key_buffer, NULL); + return OPAL_SUCCESS; + } + + /* Nope -- we got something unexpected. Bonk! */ + parse_error(3); + return OPAL_ERROR; +} + + +static void parse_error(int num) +{ + /* JMS need better error/warning message here */ + opal_output(0, "keyval parser: error %d reading file %s at line %d:\n %s\n", + num, keyval_filename, opal_util_keyval_yynewlines, opal_util_keyval_yytext); +} diff --git a/opal/util/keyval_parse.h b/opal/util/keyval_parse.h new file mode 100644 index 0000000000..67e9fa53a9 --- /dev/null +++ b/opal/util/keyval_parse.h @@ -0,0 +1,57 @@ +/* + * 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. + * $COPYRIGHT$ + * + * Additional copyrights may follow + * + * $HEADER$ + */ + +/** @file */ + +#ifndef OPAL_UTIL_KEYVAL_PARSE_H +#define OPAL_UTIL_KEYVAL_PARSE_H + +#if defined(c_plusplus) || defined(__cplusplus) +extern "C" { +#endif + +/** + * Callback triggered for each key = value pair + * + * Callback triggered from opal_util_keyval_parse for each key = value + * pair. Both key and value will be pointers into static buffers. + * The buffers must not be free()ed and contents may be overwritten + * immediately after the callback returns. + */ +typedef void (*opal_keyval_parse_fn_t)(const char *key, const char *value); + +/** + * Parse \c filename, made up of key = value pairs. + * + * Parse \c filename, made up of key = value pairs. For each line + * that appears to contain a key = value pair, \c callback will be + * called exactly once. In a multithreaded context, calls to + * opal_util_keyval_parse() will serialize multiple calls. + */ +OMPI_DECLSPEC int opal_util_keyval_parse(const char *filename, + opal_keyval_parse_fn_t callback); + +OMPI_DECLSPEC int opal_util_keyval_parse_init(void); + +OMPI_DECLSPEC int opal_util_keyval_parse_finalize(void); + +#if defined(c_plusplus) || defined(__cplusplus) +} +#endif + +#endif diff --git a/orte/tools/Makefile.am b/orte/tools/Makefile.am index 314d47b16e..2f52154877 100644 --- a/orte/tools/Makefile.am +++ b/orte/tools/Makefile.am @@ -24,11 +24,13 @@ SUBDIRS += \ tools/openmpi \ tools/orted \ tools/orteprobe \ - tools/orterun + tools/orterun \ + tools/wrappers DIST_SUBDIRS += \ tools/console \ tools/openmpi \ tools/orted \ tools/orteprobe \ - tools/orterun + tools/orterun \ + tools/wrappers diff --git a/orte/tools/openmpi/Makefile.am b/orte/tools/openmpi/Makefile.am index 0e2d4a0e7d..9bb2152305 100644 --- a/orte/tools/openmpi/Makefile.am +++ b/orte/tools/openmpi/Makefile.am @@ -37,8 +37,8 @@ libs = \ bin_PROGRAMS = openmpi openmpi_SOURCES = openmpi.h openmpi.c -openmpi_LDADD = $(LIBMPI_EXTRA_LIBS) $(libs) -openmpi_DFLAGS = $(LIBMPI_EXTRA_LDFLAGS) +openmpi_LDADD = $(libs) +openmpi_DFLAGS = openmpi_DEPENDENCIES = $(libs) clean-local: diff --git a/orte/tools/orted/Makefile.am b/orte/tools/orted/Makefile.am index 9cb2629b39..87d6c9891b 100644 --- a/orte/tools/orted/Makefile.am +++ b/orte/tools/orted/Makefile.am @@ -48,8 +48,8 @@ orted_SOURCES = \ $(headers) \ orted.c -orted_LDADD = $(libs) $(LIBMPI_EXTRA_LIBS) -orted_LDFLAGS = $(LIBMPI_EXTRA_LDFLAGS) +orted_LDADD = $(libs) +orted_LDFLAGS = orted_DEPENDENCIES = $(libs) diff --git a/orte/tools/orteprobe/Makefile.am b/orte/tools/orteprobe/Makefile.am index bbb254084b..99bf6d3806 100644 --- a/orte/tools/orteprobe/Makefile.am +++ b/orte/tools/orteprobe/Makefile.am @@ -46,8 +46,8 @@ orteprobe_SOURCES = \ orteprobe.h \ orteprobe.c -orteprobe_LDADD = $(libs) $(LIBMPI_EXTRA_LIBS) -orteprobe_LDFLAGS = $(LIBMPI_EXTRA_LDFLAGS) +orteprobe_LDADD = $(libs) +orteprobe_LDFLAGS = orteprobe_DEPENDENCIES = $(libs) clean-local: diff --git a/orte/tools/wrappers/Makefile.am b/orte/tools/wrappers/Makefile.am new file mode 100644 index 0000000000..e22978abe9 --- /dev/null +++ b/orte/tools/wrappers/Makefile.am @@ -0,0 +1,46 @@ +# +# 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. +# $COPYRIGHT$ +# +# Additional copyrights may follow +# +# $HEADER$ +# + +nodist_pkgdata_DATA = \ + ortecc-wrapper-data.txt \ + ortec++-wrapper-data.txt + +if CASE_SENSITIVE_FS +install-exec-hook: + (cd $(DESTDIR)$(bindir); rm -f ortecc$(EXEEXT); $(LN_S) opal_wrapper ortecc) + (cd $(DESTDIR)$(bindir); rm -f ortec++$(EXEEXT); $(LN_S) opal_wrapper ortec++) + (cd $(DESTDIR)$(bindir); rm -f orteCC$(EXEEXT); $(LN_S) opal_wrapper orteCC) + + (cd $(DESTDIR)$(pkgdatadir); rm -f orteCC-wrapper-data.txt; $(LN_S) ortec++-wrapper-data.txt orteCC-wrapper-data.txt) + +uninstall-local: + rm -f $(DESTDIR)$(bindir)/ortecc$(EXEEXT) \ + $(DESTDIR)$(bindir)/ortec++$(EXEEXT) \ + $(DESTDIR)$(bindir)/orteCC$(EXEEXT) \ + $(DESTDIR)$(pkgdatadir)/orteCC-wrapper-data.txt + +else +install-exec-hook: + (cd $(DESTDIR)$(bindir); rm -f ortecc$(EXEEXT); $(LN_S) opal_wrapper ortecc) + (cd $(DESTDIR)$(bindir); rm -f ortec++$(EXEEXT); $(LN_S) opal_wrapper ortec++) + +uninstall-local: + rm -f $(DESTDIR)$(bindir)/ortecc$(EXEEXT) \ + $(DESTDIR)$(bindir)/ortec++$(EXEEXT) + +endif diff --git a/orte/tools/wrappers/ortec++-wrapper-data.txt.in b/orte/tools/wrappers/ortec++-wrapper-data.txt.in new file mode 100644 index 0000000000..89d52d9fe8 --- /dev/null +++ b/orte/tools/wrappers/ortec++-wrapper-data.txt.in @@ -0,0 +1,13 @@ +project=Open Run-Time Environment (ORTE) +project_short=ORTE +version=@ORTE_VERSION@ +language=C++ +compiler_env=CXX +compiler_flags_env=CXXFLAGS +compiler=@CXX@ +extra_includes=@ORTE_WRAPPER_EXTRA_INCLUDES@ +preprocessor_flags=@ORTE_WRAPPER_EXTRA_CPPFLAGS@ +compiler_flags=@ORTE_WRAPPER_EXTRA_CXXFLAGS@ +linker_flags=@ORTE_WRAPPER_EXTRA_LDFLAGS@ +libs=-lorte -lopal @ORTE_WRAPPER_EXTRA_LIBS@ +required_file= diff --git a/orte/tools/wrappers/ortecc-wrapper-data.txt.in b/orte/tools/wrappers/ortecc-wrapper-data.txt.in new file mode 100644 index 0000000000..1adfcc5416 --- /dev/null +++ b/orte/tools/wrappers/ortecc-wrapper-data.txt.in @@ -0,0 +1,13 @@ +project=Open Run-Time Environment (ORTE) +project_short=ORTE +version=@ORTE_VERSION@ +language=C +compiler_env=CC +compiler_flags_env=CFLAGS +compiler=@CC@ +extra_includes=@ORTE_WRAPPER_EXTRA_INCLUDES@ +preprocessor_flags=@ORTE_WRAPPER_EXTRA_CPPFLAGS@ +compiler_flags=@ORTE_WRAPPER_EXTRA_CFLAGS@ +linker_flags=@ORTE_WRAPPER_EXTRA_LDFLAGS@ +libs=-lorte -lopal @ORTE_WRAPPER_EXTRA_LIBS@ +required_file=