# -*- shell-script -*- # # Copyright (c) 2004-2007 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-2010 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 (c) 2009 Oak Ridge National Labs. All rights reserved. # Copyright (c) 2010 Cisco Systems, Inc. All rights reserved. # $COPYRIGHT$ # # Additional copyrights may follow # # $HEADER$ # # # Search the generated warnings for # keywords regarding skipping or ignoring certain attributes # Intel: ignore # Sun C++: skip # AC_DEFUN([_ATTRIBUTE_FAIL_SEARCH],[ AC_REQUIRE([AC_PROG_GREP]) if test -s conftest.err ; then # icc uses 'invalid attribute' and 'attribute "__XXX__" ignored' # Sun 12.1 emits 'warning: attribute parameter "__printf__" is undefined' for i in invalid ignore skip undefined ; do $GREP -iq $i conftest.err if test "$?" = "0" ; then _cv___attribute__[$1]=0 break; fi done fi ]) # # Check for one specific attribute by compiling with C and C++ # and possibly using a cross-check. # # If the cross-check is defined, a static function "usage" should be # defined, which is to be called from main (to circumvent warnings # regarding unused function in main file) # static int usage (int * argument); # # The last argument is for specific CFLAGS, that need to be set # for the compiler to generate a warning on the cross-check. # This may need adaption for future compilers / CFLAG-settings. # AC_DEFUN([_CHECK_SPECIFIC_ATTRIBUTE], [ AC_MSG_CHECKING([for __attribute__([$1])]) AC_CACHE_VAL(_cv___attribute__[$1], [ # # Try to compile using the C compiler # AC_TRY_COMPILE([$2],[], [ # # In case we did succeed: Fine, but was this due to the # attribute being ignored/skipped? Grep for IgNoRe/skip in conftest.err # and if found, reset the _cv__attribute__var=0 # _cv___attribute__[$1]=1 _ATTRIBUTE_FAIL_SEARCH([$1]) ], [_cv___attribute__[$1]=0]) ]) if test "$_cv___attribute__[$1]" = "1" ; then AC_MSG_RESULT([yes]) else AC_MSG_RESULT([no]) fi ]) # # Test the availability of __attribute__ and with the help # of _CHECK_SPECIFIC_ATTRIBUTE for the support of # particular attributes. Compilers, that do not support an # attribute most often fail with a warning (when the warning # level is set). # The compilers output is parsed in _ATTRIBUTE_FAIL_SEARCH # # To add a new attributes __NAME__ add the # _cv___attribute__NAME # add a new check with _CHECK_SPECIFIC_ATTRIBUTE (possibly with a cross-check) # _CHECK_SPECIFIC_ATTRIBUTE([name], [int foo (int arg) __attribute__ ((__name__));], [], []) # and define the corresponding # AC_DEFINE_UNQUOTED(HAVE_ATTRIBUTE_NAME, [$_cv___attribute__NAME], # [Whether your compiler has __attribute__ NAME or not]) # and decide on a correct macro (in /include/config_bottom.h): # # define ___attribute_NAME(x) __attribute__(__NAME__) # # Please use the "__"-notation of the attribute in order not to # clash with predefined names or macros (e.g. const, which some compilers # do not like..) # AC_DEFUN([EVENT_CHECK_ATTRIBUTES], [ AC_LANG(C) AC_MSG_CHECKING(for __attribute__) AC_CACHE_VAL(_cv___attribute__, [ AC_TRY_COMPILE( [#include /* Check for the longest available __attribute__ (since gcc-2.3) */ struct foo { char a; int x[2] __attribute__ ((__packed__)); }; ], [], [_cv___attribute__=1], [_cv___attribute__=0], ) if test "$_cv___attribute__" = "1" ; then AC_TRY_COMPILE( [#include /* Check for the longest available __attribute__ (since gcc-2.3) */ struct foo { char a; int x[2] __attribute__ ((__packed__)); }; ], [], [_cv___attribute__=1], [_cv___attribute__=0], ) fi ]) AC_DEFINE_UNQUOTED(HAVE_ATTRIBUTE, [$_cv___attribute__], [Whether your compiler has __attribute__ or not]) # # Now that we know the compiler support __attribute__ let's check which kind of # attributed are supported. # if test "$_cv___attribute__" = "0" ; then AC_MSG_RESULT([no]) _cv___attribute__visibility=0 else AC_MSG_RESULT([yes]) # # Ignored by PGI-6.2.5 (pgCC) -- recognized by the output-parser # _CHECK_SPECIFIC_ATTRIBUTE([visibility], [ int square(int arg1) __attribute__ ((__visibility__("hidden"))); ], [], []) fi # Now that all the values are set, define them AC_DEFINE_UNQUOTED(HAVE_ATTRIBUTE_VISIBILITY, [$_cv___attribute__visibility], [Whether your compiler has __attribute__ visibility or not]) ]) # IFDEF_IFELSE(symbol, [action-if-defined], # [action-if-not-defined]) # ---------------------------------------------- # Run compiler to determine if preprocessor symbol "symbol" is # defined by the compiler. AC_DEFUN([IF_IFELSE], [ AC_COMPILE_IFELSE([#if !( $1 ) #error "condition $1 not met" choke me #endif], [$2], [$3])]) # CHECK_VISIBILITY # -------------------------------------------------------- AC_DEFUN([EVENT_CHECK_VISIBILITY],[ AC_REQUIRE([AC_PROG_GREP]) AC_REQUIRE([EVENT_CHECK_ATTRIBUTES]) # Check if this is the Sun compiler AS_IF([test "$sun" = "no"], [IF_IFELSE([defined(__SUNPRO_C) || defined(__SUNPRO_CC)], ["$sun" = "yes"])]) # Check if the compiler has support for visibility, like some versions of gcc, icc Sun Studio cc. if test "$_cv___attribute__visibility" = "0"; then AC_MSG_CHECKING([enable symbol visibility]) AC_MSG_RESULT([no]) have_visibility=0 else CFLAGS_orig="$CFLAGS" add= # check using gcc -fvisibility=hidden flag CFLAGS="$CFLAGS_orig -fvisibility=hidden" AC_CACHE_CHECK([if $CC supports -fvisibility], [_cv_cc_fvisibility], [AC_TRY_LINK([ #include __attribute__((visibility("default"))) int foo; void bar(void) { fprintf(stderr, "bar\n"); } ],[], [if test -s conftest.err ; then $GREP -iq "visibility" conftest.err if test "$?" = "0" ; then _cv_cc_fvisibility="no" else _cv_cc_fvisibility="yes" fi else _cv_cc_fvisibility="yes" fi], [_cv_cc_fvisibility="no"]) ]) if test "$sun" = "yes" ; then # Check using Sun Studio -xldscope=hidden flag CFLAGS="$CFLAGS_orig -xldscope=hidden" AC_CACHE_CHECK([if $CC supports -xldscope], [_cv_cc_xldscope], [AC_TRY_LINK([ #include __attribute__((visibility("default"))) int foo; void bar(void) { fprintf(stderr, "bar\n"); } ],[], [if test -s conftest.err ; then $GREP -iq "visibility" conftest.err if test "$?" = "0" ; then _cv_cc_xldscope="no" else _cv_cc_xldscope="yes" fi else _cv_cc_xldscope="yes" fi], [_cv_cc_xldscope="no"]) ]) fi if test "$_cv_cc_fvisibility" = "yes" ; then add=" -fvisibility=hidden" have_visibility=1 AC_MSG_CHECKING([enable symbol visibility]) AC_MSG_RESULT([yes]) AC_MSG_WARN([$add has been added to CFLAGS]) elif test "$_cv_cc_xldscope" = "yes" ; then add=" -xldscope=hidden" have_visibility=1 AC_MSG_CHECKING([enable symbol visibility]) AC_MSG_RESULT([yes]) AC_MSG_WARN([$add has been added to CFLAGS]) elif test "$enable_visibility" = "yes"; then AC_MSG_ERROR([Symbol visibility support requested but compiler does not seem to support it. Aborting]) else AC_MSG_CHECKING([enable symbol visibility]) AC_MSG_RESULT([no]) have_visibility=0 fi CFLAGS="$CFLAGS_orig$add" VISIBILITY_CFLAGS="$add" unset add fi AC_DEFINE_UNQUOTED([C_HAVE_VISIBILITY], [$have_visibility], [Whether C compiler supports -fvisibility]) ]) AC_DEFUN([OPAL_CONFIGURE_LIBEVENT_OPTIONS],[ enable_dns=no AM_CONDITIONAL(DNS, [test 0 = 1]) AC_DEFINE(HAVE_DNS, 0, [Libevent: we do not want DNS suport]) enable_http=no AM_CONDITIONAL(HTTP, [test 0 = 1]) AC_DEFINE(HAVE_HTTP, 0, [Libevent: we do not want HTTP suport]) enable_rpc=no AM_CONDITIONAL(RPC, [test 0 = 1]) AC_DEFINE(HAVE_RPC, 0, [Libevent: we do not want RPC suport]) AC_ARG_ENABLE(select, AS_HELP_STRING(--disable-select, disable select support), [], [enable_select=yes]) AC_ARG_ENABLE(poll, AS_HELP_STRING(--disable-poll, disable poll support), [], [enable_poll=yes]) AC_ARG_ENABLE(devpoll, AS_HELP_STRING(--disable-devpoll, disable devpoll support), [], [enable_devpoll=yes]) AC_ARG_ENABLE(kqueue, AS_HELP_STRING(--disable-kqueue, disable kqueue support), [], [enable_kqueue=yes]) AC_ARG_ENABLE(epoll, AS_HELP_STRING(--disable-epoll, disable epoll support), [], [enable_epoll=yes]) AC_ARG_ENABLE(evport, AS_HELP_STRING(--disable-evport, disable evport support), [], [enable_evport=yes]) AC_ARG_ENABLE(signal, AS_HELP_STRING(--disable-signal, disable signal support), [], [enable_signal=yes]) ]) AC_DEFUN([OPAL_CONFIGURE_LIBEVENT_MODES],[ AC_REQUIRE([EVENT_CHECK_VISIBILITY]) echo ============Open MPI libevent checks start # This AM_CONDITIONAL replaces one provided by the main libevent # configure.in AM_CONDITIONAL(SELECT_BACKEND, [test "$enable_select" != "no" && test "x$haveselect" = "xyes"]) AC_MSG_CHECKING([Open MPI: for select]) AS_IF([test "$enable_select" != "no" && test "x$haveselect" = "xyes"], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])]) dnl Turn poll off for Darwin if test "$host" = "apple-darwin" ; then havepoll=no fi if test "x$havepoll" = "xyes" ; then needsignal=yes fi # This AM_CONDITIONAL replaces one provided by the main libevent # configure.in AM_CONDITIONAL(POLL_BACKEND, [test "$enable_poll" != "no" && test "x$havepoll" = "xyes"]) AC_MSG_CHECKING([Open MPI: for poll]) AS_IF([test "$enable_poll" != "no" && test "x$havepoll" = "xyes"], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])]) dnl Need more stringent test for kqueue then libevent provides havekqueue=no if test "x$ac_cv_header_sys_event_h" = "xyes"; then # All versions of MAC OS X before at least 10.5.2 are # completely broken when kqueue is used with pty. So, until # they get fixed, completely disable kqueue on MAC OS X. case "$host" in *apple-darwin*) AC_MSG_CHECKING(for working kqueue) havekqueue="no" AC_MSG_RESULT([no (MAC OS X)]) ;; *) AC_CHECK_FUNCS(kqueue, [havekqueue=yes], ) ;; esac if test "x$havekqueue" = "xyes" ; then AC_MSG_CHECKING(for working kqueue) AC_TRY_RUN( #include #include #include #include #include #include #include int main() { int kq; int n; int fd[[2]]; struct kevent ev; struct timespec ts; char buf[[8000]]; if (pipe(fd) == -1) exit(1); if (fcntl(fd[[1]], F_SETFL, O_NONBLOCK) == -1) exit(1); while ((n = write(fd[[1]], buf, sizeof(buf))) == sizeof(buf)) ; if ((kq = kqueue()) == -1) exit(1); ev.ident = fd[[1]]; ev.filter = EVFILT_WRITE; ev.flags = EV_ADD | EV_ENABLE; n = kevent(kq, &ev, 1, NULL, 0, NULL); if (n == -1) exit(1); read(fd[[0]], buf, sizeof(buf)); ts.tv_sec = 0; ts.tv_nsec = 0; n = kevent(kq, NULL, 0, &ev, 1, &ts); if (n == -1 || n == 0) exit(1); exit(0); }, [AC_MSG_RESULT(yes) AC_DEFINE(HAVE_WORKING_KQUEUE, 1, [Define if kqueue works correctly with pipes]) havekqueue=yes ], AC_MSG_RESULT(no), AC_MSG_RESULT(no)) fi fi # This AM_CONDITIONAL replaces one provided by the main libevent # configure.in AM_CONDITIONAL(KQUEUE_BACKEND, [test "$enable_kqueue" != "no" && test "x$havekqueue" = "xyes"]) AC_MSG_CHECKING([Open MPI: for kqueue]) AS_IF([test "$enable_kqueue" != "no" && test "x$havekqueue" = "xyes"], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])]) dnl Need more stringent test for epoll than libevent provides haveepollsyscall=no haveepoll=no AC_CHECK_FUNCS(epoll_ctl, [haveepoll=yes], ) if test "x$haveepoll" = "xyes" -a "$cross_compiling" != "yes" ; then # OMPI: Unfortunately, this test is not sufficient on some # Linux distros (e.g., RH 9), where the function is defined # and you can link against it, but it's hardwired to return # ENOSYS -- and /usr/include/gnu/stubs.h fails to define # __stub_epoll_ctl (the usual mechanism in glibc to indicate # that a function is a stub and isn't really implemented). # Hence, the test succeeds because it thinks it can use # epoll_ctl (and friends). So we have to do a better test # after we determine that epoll_ctl is linkable. Grumble. # If we are cross compiling, just trust AC_CHECK_FUNCS # OMPI: Unfortunately, this test is not sufficient for another # reason. The event_poll struct is defined in the sys/epoll.h # file. The structure is the interface between the application # and the kernel and is therefore compiled into both. The # event_poll struct is defined with a compiler directive # __attribute__ ((__packed__). It turns out that there is # at least one compiler (Sun Studio) that does not currently # recognize this directive. This means that the event_poll # struct may be packed in the kernel, but not in the OMPI # library. Badness ensues. Therefore, check to see that # this struct gets correctly passed between OMPI and the # kernel. # In this test we use epoll in Level Triggered mode. We create a pipe # and the write only file descriptor of the pipe is added to # the epoll set. The test is successful if epoll_wait() returns 1 # indicating that the fd is ready to be written to. haveepoll=no AC_MSG_CHECKING([for working epoll library interface]) AC_RUN_IFELSE(AC_LANG_PROGRAM([[ AC_INCLUDES_DEFAULT #include ]], [[ struct epoll_event epevin; struct epoll_event epevout; int res; int epfd; int fildes[[2]]; if ((epfd = epoll_create(1)) == -1) exit(1); if (pipe(&fildes[[0]]) < 0) exit(1); memset(&epevin, 0, sizeof(epevin)); memset(&epevout, 0, sizeof(epevout)); memset(&epevin.data.ptr, 5, sizeof(epevin.data.ptr)); epevin.events = EPOLLIN | EPOLLOUT; if (epoll_ctl(epfd, EPOLL_CTL_ADD, fildes[[1]], &epevin) == -1) exit(1); res = epoll_wait(epfd, &epevout, 1, 0); if (res != 1) { exit(1); } else { if (epevout.data.ptr != epevin.data.ptr) { exit(1); } } /* SUCCESS */ ]]), [haveepoll=yes AC_DEFINE(HAVE_EPOLL, 1, [Define if your system supports the epoll interface]) # OMPI: Don't use AC_LIBOBJ needsignal=yes]) AC_MSG_RESULT([$haveepoll]) fi # This AM_CONDITIONAL replaces one provided by the main libevent # configure.in AM_CONDITIONAL(EPOLL_BACKEND, [test "$enable_epoll" != "no" && test "x$haveepoll" = "xyes"]) AC_MSG_CHECKING([Open MPI: for kqueue]) AS_IF([test "$enable_epoll" != "no" && test "x$haveepoll" = "xyes"], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])]) haveepollsyscall=no if test "x$ac_cv_header_sys_epoll_h" = "xyes" -a "x$haveepoll" = "xno" -a "$cross_compiling" != "yes"; then # OMPI: See comment above. This test uses the epoll system call # interface instead of the library interface. AC_MSG_CHECKING(for working epoll system call) AC_RUN_IFELSE(AC_LANG_PROGRAM([[ AC_INCLUDES_DEFAULT #include #include ]], [[ struct epoll_event epevin; struct epoll_event epevout; int res; int epfd; int fildes[[2]]; if ((epfd = syscall(__NR_epoll_create, 1)) == -1) exit(1); if (pipe(&fildes[[0]]) < 0) exit(1); memset(&epevin, 0, sizeof(epevin)); memset(&epevout, 0, sizeof(epevout)); memset(&epevin.data.ptr, 5, sizeof(epevin.data.ptr)); epevin.events = EPOLLIN | EPOLLOUT; if (syscall(__NR_epoll_ctl, epfd, EPOLL_CTL_ADD, fildes[[1]], &epevin) == -1) exit(1); res = syscall(__NR_epoll_wait, epfd, &epevout, 1, 0); if (res != 1) { exit(1); } else { if (epevout.data.ptr != epevin.data.ptr) { exit(1); } } /* SUCCESS */ ]]), [haveepollsyscall=yes AC_DEFINE(HAVE_EPOLL, 1, [Define if your system supports the epoll interface]) # OMPI: don't use AC_LIBOBJ needsignal=yes]) AC_MSG_RESULT([$haveepollsyscall]) fi # JMS Is this AM_CONDITIONAL relevant anymore? AM_CONDITIONAL(EPOLL_SUB_BACKEND, [test "$enable_epoll" != "no" && test "haveepollsyscall" = "xyes"]) AC_MSG_CHECKING([Open MPI: for epoll syscall]) AS_IF([test "$enable_epoll" != "no" && test "x$haveepollsyscall" = "xyes"], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])]) # This AM_CONDITIONAL replaces one provided by the main libevent # configure.in AM_CONDITIONAL(DEVPOLL_BACKEND, [test "$enable_devpoll" != "no" && test "x$ac_cv_header_sys_devpoll_h" = "xyes"]) AC_MSG_CHECKING([Open MPI: for devpoll]) AS_IF([test "$enable_devpoll" != "no" && test "x$ac_cv_header_sys_devpoll_h" = "xyes"], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])]) # This AM_CONDITIONAL replaces one provided by the main libevent # configure.in AM_CONDITIONAL(EVPORT_BACKEND, [test "$enable_evport" != "no" && test "x$haveeventports" = "xyes"]) AC_MSG_CHECKING([Open MPI: for evport]) AS_IF([test "$enable_evport" != "no" && test "x$haveeventports" = "xyes"], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])]) # This AM_CONDITIONAL replaces one provided by the main libevent # configure.in dnl Do this last so we know about needsignal AM_CONDITIONAL(SIGNAL_SUPPORT, [test "$enable_signal" != "no" && test "x$needsignal" = "xyes"]) AC_MSG_CHECKING([Open MPI: for needsignal]) AS_IF([test "$enable_signal" != "no" && test "x$needsignal" = "xyes"], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])]) AC_MSG_CHECKING(event_ops) if test "$enable_select" != "no" && test "x$haveselect" = "xyes" ; then have_ops=yes elif test "$enable_poll" != "no" && test "x$havepoll" = "xyes" ; then have_ops=yes elif test "$enable_kqueue" != "no" && test "x$havekqueue" = "xyes" ; then have_ops=yes elif test "$enable_epoll" != "no" && test "x$haveepoll" = "xyes" ; then have_ops=yes else have_ops=no fi AS_IF([test "$have_ops" = "yes"], [AC_MSG_RESULT(yes) AC_DEFINE(HAVE_WORKING_EVENTOPS, 1, [Define if there is a working event op])], AC_MSG_RESULT(no)) AC_MSG_CHECKING([Open MPI: for working ops]) AS_IF([test "$have_ops" = "yes"], [AC_MSG_RESULT([yes])], [AC_MSG_RESULT([no])]) echo ============Open MPI libevent checks end ])