1
1
openmpi/config/ompi_fortran_check_optional_args.m4
Jeff Squyres b29b852281 Consolidate all the opal/orte/ompi .m4 files back to the top-level
config/ directory.  We split them apart a while ago in the hopes that
it would simplify things, but it didn't really (e.g., because there
were still some ompi/opal .m4 files in the top-level config/
directory, resulting in developer confusion where any given m4 macro
was defined).

So this commit consolidates them back into the top-level directory for
simplicity.  

There's still (at least) two changes that would be nice to make:

 1. Split any generated .m4 file (e.g., autogen-generated .m4 files)
    into a separate directory somewhere so that a top-level -Iconfig/
    will only get our explicitly defined macros, not the autogen stuff
    (e.g., with libevent2019 needing to get the visibility macro, but
    NOT all the autogen-generated inclusion of component configure.m4
    files).
 1. Change configure to be of the form:
{{{
# ...a small amount of preamble/setup...
OPAL_SETUP
m4_ifdef([project_orte], [ORTE_SETUP])
m4_ifdef([project_ompi], [OMPI_SETUP])
# ...a small amount of finishing stuff...
}}}

I doubt we'll ever get anything as clean as that, but that would be
the goal to shoot for.

This commit was SVN r27704.
2012-12-19 00:00:36 +00:00

114 строки
3.6 KiB
Bash

dnl -*- shell-script -*-
dnl
dnl Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
dnl University Research and Technology
dnl Corporation. All rights reserved.
dnl Copyright (c) 2004-2005 The University of Tennessee and The University
dnl of Tennessee Research Foundation. All rights
dnl reserved.
dnl Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
dnl University of Stuttgart. All rights reserved.
dnl Copyright (c) 2004-2005 The Regents of the University of California.
dnl All rights reserved.
dnl Copyright (c) 2010-2012 Cisco Systems, Inc. All rights reserved.
dnl $COPYRIGHT$
dnl
dnl Additional copyrights may follow
dnl
dnl $HEADER$
dnl
# Check whether or not the Fortran compiler supports optional
# arguments or not, and we (generally) don't need wrapper subroutines.
# OMPI_FORTRAN_CHECK_OPTIONAL_ARGS([action if found],
# [action if not found])
# ----------------------------------------------------
AC_DEFUN([OMPI_FORTRAN_CHECK_OPTIONAL_ARGS],[
unset happy
OPAL_VAR_SCOPE_PUSH([happy ompi_conftest_h])
AC_CACHE_CHECK([if Fortran compiler supports optional arguments],
[ompi_cv_fortran_optional_args],
[ompi_cv_fortran_optional_args=no
OMPI_FORTRAN_MAKE_C_FUNCTION([ompi_ac_check_op_fn], [check_op])
cat > conftestf.f90 <<EOF
program check_for_optional
use, intrinsic :: iso_c_binding
interface
subroutine check_op(i, ierror)
integer, intent(in), value :: i
integer, intent(out), optional :: ierror
end subroutine check_op
end interface
integer :: ierror
call check_op(0)
call check_op(1, ierror)
end program
EOF
# C module
if test -f conftest.h; then
ompi_conftest_h="#include \"conftest.h\""
else
ompi_conftest_h=""
fi
cat > conftest.c <<EOF
#include <stdio.h>
#include <stdlib.h>
$ompi_conftest_h
#ifdef __cplusplus
extern "C" {
#endif
void $ompi_ac_check_op_fn(int has_op, int *ierror)
{
/* Force a segv if the conditions are wrong */
char *bogus = 0;
if (0 == has_op) {
/* won't have optional argument */
if (NULL != ierror) *bogus= 13;
} else {
/* will have optional argument */
if (NULL == ierror) *bogus= 13;
*ierror = 33;
}
}
#ifdef __cplusplus
}
#endif
EOF
OPAL_LOG_COMMAND([$CC $CFLAGS -I. -c conftest.c],
[OPAL_LOG_COMMAND([$FC $FCFLAGS conftestf.f90 conftest.o -o conftest $LDFLAGS $LIBS],
[happy="yes"], [happy="no"])],
[happy="c_fail"])
AS_IF([test "$happy" = "c_fail"],
[AC_MSG_RESULT([error])
AC_MSG_ERROR([This error should not happen -- contact the Open MPI developers])
])
AS_IF([test "$happy" = "no"],
[AC_MSG_RESULT([unknown])
AC_MSG_WARN([Cannot determine if Fortran compiler supports optional arguments])
AC_MSG_WARN([Assuming: no])
])
AS_IF([test "$cross_compiling" = "yes"],
[AC_MSG_RESULT([cross-compiling])
AC_MSG_ERROR([Cannot determine if Fortran compiler supports optional arguments when cross-compiling])],
[OPAL_LOG_COMMAND([./conftest],
[ompi_cv_fortran_optional_args=yes])
])
rm -f conftest*
])dnl
AS_VAR_COPY([happy], [ompi_cv_fortran_optional_args])
AS_IF([test "$happy" = "yes"], [$1], [$2])
OPAL_VAR_SCOPE_POP
])