Skip to content

Commit 69aa46e

Browse files
committed
libevent2022/configure.m4: always invoke sub-configure
In order to make "make distclean" (and friends) work, we need to *always* invoke the embedded configure script -- even if we know that we're not going to use this component. But in cases where we know we're not going to use this component, we also need to avoid the side effects of the code path that is used when we *do* want to use this component. So split the two possibilities into two different macros: 1. MCA_opal_event_libevent2022_FAKE_CONFIG: which does almost nothing except invoke the underlying "configure" script. 2. MCA_opal_event_libevent2022_REAL_CONFIG: which does all the real work (including invoking the underlying "configure" script). Signed-off-by: Jeff Squyres <[email protected]>
1 parent 80df3f0 commit 69aa46e

File tree

1 file changed

+65
-35
lines changed

1 file changed

+65
-35
lines changed

opal/mca/event/libevent2022/configure.m4

Lines changed: 65 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ AC_DEFUN([MCA_opal_event_libevent2022_POST_CONFIG], [
3535
# copied from libevent's Makefile.am.
3636

3737
AC_CONFIG_COMMANDS([opal/mca/event/libevent2022/libevent/include/event2/event-config.h],
38-
[libevent_basedir="opal/mca/event/libevent2022"
39-
libevent_file="$libevent_basedir/libevent/include/event2/event-config.h"
38+
[opal_event_libevent2022_basedir="opal/mca/event/libevent2022"
39+
libevent_file="$opal_event_libevent2022_basedir/libevent/include/event2/event-config.h"
4040
rm -f "$libevent_file.new"
4141
cat > "$libevent_file.new" <<EOF
4242
/* event2/event-config.h
@@ -56,7 +56,7 @@ EOF
5656

5757
sed -e 's/#define /#define _EVENT_/' \
5858
-e 's/#undef /#undef _EVENT_/' \
59-
-e 's/#ifndef /#ifndef _EVENT_/' < "$libevent_basedir/libevent/config.h" >> "$libevent_file.new"
59+
-e 's/#ifndef /#ifndef _EVENT_/' < "$opal_event_libevent2022_basedir/libevent/config.h" >> "$libevent_file.new"
6060
echo "#endif" >> "$libevent_file.new"
6161

6262
# Only make a new .h libevent_file if the
@@ -75,7 +75,7 @@ EOF
7575

7676
# Add some stuff to CPPFLAGS so that the rest of the source
7777
# tree can be built
78-
libevent_file=$libevent_basedir/libevent
78+
libevent_file=$opal_event_libevent2022_basedir/libevent
7979
CPPFLAGS="-I$OPAL_TOP_SRCDIR/$libevent_file -I$OPAL_TOP_SRCDIR/$libevent_file/include $CPPFLAGS"
8080
AS_IF([test "$OPAL_TOP_BUILDDIR" != "$OPAL_TOP_SRCDIR"],
8181
[CPPFLAGS="-I$OPAL_TOP_BUILDDIR/$libevent_file/include $CPPFLAGS"])
@@ -87,25 +87,47 @@ dnl MCA_event_libevent2022_CONFIG([action-if-can-compile],
8787
dnl [action-if-cant-compile])
8888
dnl ------------------------------------------------
8989
AC_DEFUN([MCA_opal_event_libevent2022_CONFIG],[
90+
AC_CONFIG_FILES([opal/mca/event/libevent2022/Makefile])
91+
opal_event_libevent2022_basedir="opal/mca/event/libevent2022"
92+
9093
# We know that the external event component will be configured
9194
# before this one because of its priority. This component is only
9295
# needed if the external component was not successful in selecting
9396
# itself.
9497
AC_MSG_CHECKING([if event external component succeeded])
9598
AS_IF([test "$opal_event_external_support" = "yes"],
9699
[AC_MSG_RESULT([yes])
97-
AC_MSG_NOTICE([event:external succeeded, so this component will be skipped])
98-
$2],
100+
AC_MSG_NOTICE([event:external succeeded, so this component will be configured, but then will be skipped])
101+
MCA_opal_event_libevent2022_FAKE_CONFIG($2)],
99102
[AC_MSG_RESULT([no])
100103
AC_MSG_NOTICE([event:external failed, so this component will be used])
101-
MCA_opal_event_libevent2022_BACKEND_CONFIG($1, $2)])
104+
MCA_opal_event_libevent2022_REAL_CONFIG($1, $2)])
102105
])
103106

104-
AC_DEFUN([MCA_opal_event_libevent2022_BACKEND_CONFIG],[
105-
OPAL_VAR_SCOPE_PUSH([CFLAGS_save CPPFLAGS_save libevent_file event_args libevent_happy])
107+
dnl
108+
dnl This macro is invoked when event:external is going to be used (and
109+
dnl this component is *not* going to be used).
110+
dnl
111+
dnl $1: action if this component can compile
112+
dnl (we still invoke $1 so that "make distclean" and friends will work)
113+
dnl
114+
AC_DEFUN([MCA_opal_event_libevent2022_FAKE_CONFIG],[
115+
MCA_opal_event_libevent2022_SUB_CONFIGURE([], [], [])
116+
AC_MSG_NOTICE([remember: event:external will be used; this component was configured, but will be skipped])
117+
$1
118+
])
106119

107-
AC_CONFIG_FILES([opal/mca/event/libevent2022/Makefile])
108-
libevent_basedir="opal/mca/event/libevent2022"
120+
dnl
121+
dnl This macro has a bunch of side effects. It is only meant to be
122+
dnl invoked when this component is going to be used (i.e., when
123+
dnl event:external is *not* going to be used). If this macro is invoked
124+
dnl when event:external is used, Terrible Things will happen.
125+
dnl
126+
dnl $1: action if this component can compile
127+
dnl $2: action if this component cannot compile
128+
dnl
129+
AC_DEFUN([MCA_opal_event_libevent2022_REAL_CONFIG],[
130+
OPAL_VAR_SCOPE_PUSH([CFLAGS_save CPPFLAGS_save libevent_file event_args libevent_happy])
109131

110132
CFLAGS_save="$CFLAGS"
111133
CFLAGS="$OPAL_CFLAGS_BEFORE_PICKY $OPAL_VISIBILITY_CFLAGS"
@@ -175,14 +197,14 @@ AC_DEFUN([MCA_opal_event_libevent2022_BACKEND_CONFIG],[
175197

176198
AC_MSG_RESULT([$event_args])
177199

200+
# Invoke the embedded configure script.
178201
# We define "random" to be "opal_random" so that Libevent will not
179202
# use random(3) internally (and potentially unexpectedly perturb
180203
# values returned by rand(3) to the application).
181-
182204
CPPFLAGS="$CPPFLAGS -Drandom=opal_random"
183-
OPAL_CONFIG_SUBDIR([$libevent_basedir/libevent],
184-
[$event_args $opal_subdir_args 'CPPFLAGS=$CPPFLAGS'],
185-
[libevent_happy="yes"], [libevent_happy="no"])
205+
MCA_opal_event_libevent2022_SUB_CONFIGURE([$event_args],
206+
[libevent_happy="yes"],
207+
[libevent_happy="no"])
186208
if test "$libevent_happy" = "no"; then
187209
AC_MSG_WARN([Event library failed to configure])
188210
AC_MSG_ERROR([Cannot continue])
@@ -200,26 +222,34 @@ AC_DEFUN([MCA_opal_event_libevent2022_BACKEND_CONFIG],[
200222
# the value in the generated libevent/config.h (NOT
201223
# libevent/include/event2/event-config.h!). Otherwise, set it to
202224
# 0.
203-
libevent_file=$libevent_basedir/libevent/config.h
204-
205-
# If we are not building the internal libevent, then indicate that
206-
# this component should not be built. NOTE: we still did all the
207-
# above configury so that all the proper GNU Autotools
208-
# infrastructure is setup properly (e.g., w.r.t. SUBDIRS=libevent in
209-
# this directory's Makefile.am, we still need the Autotools "make
210-
# distclean" infrastructure to work properly).
211-
212-
AS_IF([test "$with_libevent" != "internal" && test -n "$with_libevent" && test "$with_libevent" != "yes"],
213-
[AC_MSG_WARN([using an external libevent; disqualifying this component])
214-
libevent_happy=no],
215-
216-
[AS_IF([test "$libevent_happy" = "yes" && test -r $libevent_file],
217-
[OPAL_HAVE_WORKING_EVENTOPS=`grep HAVE_WORKING_EVENTOPS $libevent_file | awk '{print [$]3 }'`
218-
$1],
219-
[$2
220-
OPAL_HAVE_WORKING_EVENTOPS=0])
221-
]
222-
)
225+
libevent_file=$opal_event_libevent2022_basedir/libevent/config.h
226+
227+
AS_IF([test "$libevent_happy" = "yes" && test -r $libevent_file],
228+
[OPAL_HAVE_WORKING_EVENTOPS=`grep HAVE_WORKING_EVENTOPS $libevent_file | awk '{print [$]3 }'`
229+
$1],
230+
[$2
231+
OPAL_HAVE_WORKING_EVENTOPS=0])
223232

224233
OPAL_VAR_SCOPE_POP
225234
])
235+
236+
dnl Call configure in the embedded libevent.
237+
dnl
238+
dnl We still do this so that all the proper GNU Autotools
239+
dnl infrastructure is setup properly (e.g., w.r.t. SUBDIRS=libevent in
240+
dnl this directorys Makefile.am, we still need the Autotools "make
241+
dnl distclean" infrastructure to work properly).
242+
dnl
243+
dnl $1: extra configure arguments
244+
dnl $2: action on success
245+
dnl $3: action on failure
246+
dnl
247+
AC_DEFUN([MCA_opal_event_libevent2022_SUB_CONFIGURE],[
248+
# We define "random" to be "opal_random" so that Libevent will not
249+
# use random(3) internally (and potentially unexpectedly perturb
250+
# values returned by rand(3) to the application).
251+
252+
OPAL_CONFIG_SUBDIR([$opal_event_libevent2022_basedir/libevent],
253+
[$1 $opal_subdir_args 'CPPFLAGS=$CPPFLAGS'],
254+
[$2], [$3])
255+
])

0 commit comments

Comments
 (0)