Skip to content

Commit 331fd6c

Browse files
jsquyresggouaillardet
authored andcommitted
event/external: prefer external event component
Signed-off-by: Jeff Squyres <[email protected]>
1 parent 3a5b901 commit 331fd6c

File tree

2 files changed

+126
-89
lines changed

2 files changed

+126
-89
lines changed

opal/mca/event/configure.m4

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,42 @@ dnl opal/mca/event/event.h.
1818
dnl We only want one winning component (vs. STOP_AT_FIRST_PRIORITY,
1919
dnl which will allow all components of the same priority who succeed to
2020
dnl win)
21+
2122
m4_define(MCA_opal_event_CONFIGURE_MODE, STOP_AT_FIRST)
2223

24+
dnl
25+
dnl Setup --with-libevent and --with-libevent-libdir
26+
dnl
27+
AC_DEFUN([MCA_opal_event_SETUP],[
28+
AC_ARG_WITH([libevent],
29+
[AC_HELP_STRING([--with-libevent=DIR],
30+
[Search for libevent headers and libraries in DIR. Should only be used if an external copy of libevent is being used.])])
31+
32+
# Bozo check
33+
AS_IF([test "$with_libevent" = "no"],
34+
[AC_MSG_WARN([It is not possible to configure Open MPI --without-libevent])
35+
AC_MSG_ERROR([Cannot continue])])
36+
AS_IF([test "$with_libevent" = "yes"],
37+
[with_libevent=])
38+
39+
AC_ARG_WITH([libevent-libdir],
40+
[AC_HELP_STRING([--with-libevent-libdir=DIR],
41+
[Search for libevent libraries in DIR. Should only be used if an external copy of libevent is being used.])])
42+
43+
# Make sure the user didn't specify --with-libevent=internal and
44+
# --with-libevent-libdir=whatever (because you can only specify
45+
# --with-libevent-libdir when external libevent is being used).
46+
AS_IF([test "$with_libevent" = "internal" && test -n "$with_libevent_libdir"],
47+
[AC_MSG_WARN([Both --with-libevent=internal and --with-libevent-libdir=DIR])
48+
AC_MSG_WARN([were specified, which does not make sense.])
49+
AC_MSG_ERROR([Cannot continue])])
50+
])
51+
2352
AC_DEFUN([MCA_opal_event_CONFIG],[
2453
opal_event_base_include=
2554

55+
MCA_opal_event_SETUP
56+
2657
# configure all the components
2758
MCA_CONFIGURE_FRAMEWORK($1, $2, 1)
2859

opal/mca/event/external/configure.m4

Lines changed: 95 additions & 89 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# -*- shell-script -*-
22
#
3-
# Copyright (c) 2009-2013 Cisco Systems, Inc. All rights reserved.
3+
# Copyright (c) 2009-2018 Cisco Systems, Inc. All rights reserved
44
# Copyright (c) 2013 Los Alamos National Security, LLC. All rights reserved.
5-
# Copyright (c) 2015-2017 Research Organization for Information Science
5+
# Copyright (c) 2015-2018 Research Organization for Information Science
66
# and Technology (RIST). All rights reserved.
77
#
88
# Copyright (c) 2017 Intel, Inc. All rights reserved.
@@ -56,72 +56,57 @@ AC_DEFUN([MCA_opal_event_external_POST_CONFIG],[
5656
AC_DEFUN([MCA_opal_event_external_CONFIG],[
5757
AC_CONFIG_FILES([opal/mca/event/external/Makefile])
5858

59-
OPAL_VAR_SCOPE_PUSH([opal_event_external_CPPFLAGS_save opal_event_external_CFLAGS_save opal_event_external_LDFLAGS_save opal_event_external_LIBS_save])
60-
61-
AC_ARG_WITH([libevent],
62-
[AC_HELP_STRING([--with-libevent=DIR],
63-
[Search for libevent headers and libraries in DIR. Should only be used if an external copy of libevent is being used.])])
64-
65-
# Bozo check
66-
AS_IF([test "$with_libevent" = "no"],
67-
[AC_MSG_WARN([It is not possible to configure Open MPI --without-libevent])
68-
AC_MSG_ERROR([Cannot continue])])
69-
70-
AC_ARG_WITH([libevent-libdir],
71-
[AC_HELP_STRING([--with-libevent-libdir=DIR],
72-
[Search for libevent libraries in DIR. Should only be used if an external copy of libevent is being used.])])
73-
74-
# Make sure the user didn't specify --with-libevent=internal and
75-
# --with-libevent-libdir=whatever (because you can only specify
76-
# --with-libevent-libdir when external libevent is being used).
77-
AS_IF([test "$with_libevent" = "internal" && test -n "$with_libevent_libdir"],
78-
[AC_MSG_WARN([Both --with-libevent=internal and --with-libevent-libdir=DIR])
79-
AC_MSG_WARN([were specified, which does not make sense.])
80-
AC_MSG_ERROR([Cannot continue])])
81-
82-
# Do we want this external component? (slightly redundant logic,
83-
# but hopefully slightly more clear...)
84-
opal_event_external_want=no
85-
AS_IF([test "$with_libevent" = "external"], [opal_event_external_want=yes])
86-
AS_IF([test -n "$with_libevent_libdir"], [opal_event_external_want=yes])
87-
AS_IF([test -n "$with_libevent" && test "$with_libevent" != "no" && test "$with_libevent" != "internal"], [opal_event_external_want=yes])
88-
89-
# If we want external support, try it
90-
AS_IF([test "$opal_event_external_want" = "yes"],
91-
[ # Error out if the specified dir does not exist
92-
OPAL_CHECK_WITHDIR([libevent-libdir], [$with_libevent_libdir],
93-
[libevent.*])
94-
95-
AC_MSG_CHECKING([for external libevent in])
96-
AS_IF([test "$with_libevent" != "external" && test "$with_libevent" != "yes"],
97-
[opal_event_dir=$with_libevent
98-
AC_MSG_RESULT([$opal_event_dir])
99-
OPAL_CHECK_WITHDIR([libevent], [$opal_event_dir],
100-
[include/event.h])
101-
AS_IF([test -z "$with_libevent_libdir" || test "$with_libevent_libdir" = "yes"],
102-
[AC_MSG_CHECKING([for $with_libevent/lib64])
103-
AS_IF([test -d "$with_libevent/lib64"],
104-
[opal_event_libdir_found=yes
105-
AC_MSG_RESULT([found])],
106-
[opal_event_libdir_found=no
107-
AC_MSG_RESULT([not found])])
108-
AS_IF([test "$opal_event_libdir_found" = "yes"],
109-
[opal_event_libdir="$with_libevent/lib64"],
110-
[AC_MSG_CHECKING([for $with_libevent/lib])
111-
AS_IF([test -d "$with_libevent/lib"],
112-
[AC_MSG_RESULT([found])
113-
opal_event_libdir="$with_libevent/lib"],
114-
[AC_MSG_RESULT([not found])
115-
AC_MSG_WARN([Library directories were not found:])
116-
AC_MSG_WARN([ $with_libevent/lib64])
117-
AC_MSG_WARN([ $with_libevent/lib])
118-
AC_MSG_WARN([Please use --with-libevent-libdir to identify it.])
119-
AC_MSG_ERROR([Cannot continue])])])])],
120-
[AC_MSG_RESULT([(default search paths)])])
121-
AS_IF([test ! -z "$with_libevent_libdir" && test "$with_libevent_libdir" != "yes"],
122-
[opal_event_libdir="$with_libevent_libdir"])
123-
124-
opal_event_external_CPPFLAGS_save=$CPPFLAGS
59+
OPAL_VAR_SCOPE_PUSH([opal_event_external_CPPFLAGS_save opal_event_external_CFLAGS_save opal_event_external_LDFLAGS_save opal_event_external_LIBS_save opal_event_dir opal_event_external_support])
60+
61+
# Make some processing below easier ($with_libevent==yes and
62+
# $with_libevent==no has already been filtered out).
63+
AS_IF([test "$with_libevent" = "external"],
64+
[with_libevent=])
65+
66+
# Once we get to this point, $with_libevent is either: blank, a
67+
# directory location, or "internal".
68+
69+
# Check the value of $with_libevent_libdir. This macro safely
70+
# handles "yes", "no", blank, and directory name values.
71+
OPAL_CHECK_WITHDIR([libevent-libdir], [$with_libevent_libdir],
72+
[libevent.*])
73+
74+
# Did the user want us to check for libevent in a specific location?
75+
AC_MSG_CHECKING([for external libevent in])
76+
AS_IF([test -n "$with_libevent" && \
77+
test "$with_libevent" != "external" && \
78+
test "$with_libevent" != "internal" && \
79+
test "$with_libevent" != "yes" && \
80+
test "$with_libevent" != "no"],
81+
[opal_event_dir=$with_libevent
82+
AC_MSG_RESULT([$opal_event_dir])
83+
OPAL_CHECK_WITHDIR([libevent], [$opal_event_dir],
84+
[include/event.h])
85+
AS_IF([test -z "$with_libevent_libdir" || test "$with_libevent_libdir" = "yes"],
86+
[AC_MSG_CHECKING([for $with_libevent/lib64])
87+
AS_IF([test -d "$with_libevent/lib64"],
88+
[opal_event_libdir_found=yes
89+
AC_MSG_RESULT([found])],
90+
[opal_event_libdir_found=no
91+
AC_MSG_RESULT([not found])])
92+
AS_IF([test "$opal_event_libdir_found" = "yes"],
93+
[opal_event_libdir="$with_libevent/lib64"],
94+
[AC_MSG_CHECKING([for $with_libevent/lib])
95+
AS_IF([test -d "$with_libevent/lib"],
96+
[AC_MSG_RESULT([found])
97+
opal_event_libdir="$with_libevent/lib"],
98+
[AC_MSG_RESULT([not found])
99+
AC_MSG_WARN([Library directories were not found:])
100+
AC_MSG_WARN([ $with_libevent/lib64])
101+
AC_MSG_WARN([ $with_libevent/lib])
102+
AC_MSG_WARN([Please use --with-libevent-libdir to identify it.])
103+
AC_MSG_ERROR([Cannot continue])])])])],
104+
[AC_MSG_RESULT([(default search paths)])])
105+
AS_IF([test ! -z "$with_libevent_libdir" && test "$with_libevent_libdir" != "yes"],
106+
[opal_event_libdir="$with_libevent_libdir"])
107+
108+
AS_IF([test "$with_libevent" != "internal"],
109+
[opal_event_external_CPPFLAGS_save=$CPPFLAGS
125110
opal_event_external_CFLAGS_save=$CFLAGS
126111
opal_event_external_LDFLAGS_save=$LDFLAGS
127112
opal_event_external_LIBS_save=$LIBS
@@ -136,24 +121,41 @@ AC_DEFUN([MCA_opal_event_external_CONFIG],[
136121
[opal_event_external_support=yes],
137122
[opal_event_external_support=no])
138123

139-
# Ensure that this libevent has the symbol
140-
# "evthread_set_lock_callbacks", which will only exist if
141-
# libevent was configured with thread support.
142-
LIBS="$opal_event_external_LDFLAGS $LIBS"
143-
AC_CHECK_LIB([event], [evthread_set_lock_callbacks],
144-
[],
145-
[AC_MSG_WARN([External libevent does not have thread support])
146-
AC_MSG_WARN([Open MPI requires libevent to be compiled with])
147-
AC_MSG_WARN([thread support enabled])
148-
AC_MSG_ERROR([Cannot continue])])
149-
150-
AC_CHECK_LIB([event_pthreads], [evthread_use_pthreads],
151-
[],
152-
[AC_MSG_WARN([External libevent does not have thread support])
153-
AC_MSG_WARN([Open MPI requires libevent to be compiled with])
154-
AC_MSG_WARN([thread support enabled])
155-
AC_MSG_ERROR([Cannot continue])])
156-
124+
AS_IF([test "$opal_event_external_support" = "yes"],
125+
[# Ensure that this libevent has the symbol
126+
# "evthread_set_lock_callbacks", which will only exist if
127+
# libevent was configured with thread support.
128+
LIBS="$opal_event_external_LDFLAGS $LIBS"
129+
AC_CHECK_LIB([event], [evthread_set_lock_callbacks],
130+
[],
131+
[AC_MSG_WARN([External libevent does not have thread support])
132+
AC_MSG_WARN([Open MPI requires libevent to be compiled with])
133+
AC_MSG_WARN([thread support enabled])
134+
opal_event_external_support=no])])
135+
136+
AS_IF([test "$opal_event_external_support" = "yes"],
137+
[AC_CHECK_LIB([event_pthreads], [evthread_use_pthreads],
138+
[],
139+
[AC_MSG_WARN([External libevent does not have thread support])
140+
AC_MSG_WARN([Open MPI requires libevent to be compiled with])
141+
AC_MSG_WARN([thread support enabled])
142+
opal_event_external_support=no])])
143+
144+
AS_IF([test "$opal_event_external_support" = "yes" &&
145+
test -z "$with_libevent"],
146+
[AC_MSG_CHECKING([if external libevent version is 2.0.21 or greater])
147+
AC_COMPILE_IFELSE(
148+
[AC_LANG_PROGRAM([[#include <event.h>]],
149+
[[
150+
#if _EVENT_NUMERIC_VERSION < 0x02001500
151+
#error "libevent API version is less than 0x02001500"
152+
#endif
153+
]])],
154+
[AC_MSG_RESULT([yes])],
155+
[AC_MSG_RESULT([no])
156+
AC_MSG_WARN([external libevent version is less than internal version (2.0.21)])
157+
AC_MSG_WARN([using internal libevent])
158+
opal_hwloc_external_support=no])])
157159
CPPFLAGS=$opal_event_external_CPPFLAGS_save
158160
CFLAGS=$opal_event_external_CFLAGS_save
159161
LDFLAGS=$opal_event_external_LDFLAGS_save
@@ -171,19 +173,23 @@ AC_DEFUN([MCA_opal_event_external_CONFIG],[
171173
# building with developer headers so that our headers can
172174
# be found.
173175
event_external_WRAPPER_EXTRA_LDFLAGS=$opal_event_external_LDFLAGS
174-
event_external_WRAPPER_EXTRA_LIBS=$opal_event_external_LIBS
175-
])
176+
event_external_WRAPPER_EXTRA_LIBS=$opal_event_external_LIBS])
177+
178+
##################################################################
176179

177180
# Done!
178181
AS_IF([test "$opal_event_external_support" = "yes"],
179-
[ # If we configured successfully, set
182+
[# If we configured successfully, set
180183
# OPAL_HAVE_WORKING_EVENTOPS to 1 (it's a calculated value
181184
# in the embedded Open MPI libevent, so we can only assume
182185
# what it is in the installed libevent :-\ ).
183186
file=$opal_event_dir/include/libevent/config.h
184187
OPAL_HAVE_WORKING_EVENTOPS=1
185188
$1],
186189
[OPAL_HAVE_WORKING_EVENTOPS=0
190+
AS_IF([test "$with_libevent" != internal && test -n "$with_libevent"],
191+
[AC_MSG_WARN([external libevent requested but cannot be built])
192+
AC_MSG_ERROR([Cannot continue.])])
187193
$2])
188194

189195
OPAL_VAR_SCOPE_POP

0 commit comments

Comments
 (0)