Skip to content

Commit 000f7e8

Browse files
committed
build: Use M4sh constructs to simplify opal_mca
There are a bunch of places where we were duplicating M4sh functionality, so convert the easy ones into directly using M4sh constructs. Signed-off-by: Brian Barrett <bbarrett@amazon.com>
1 parent 59bf4ee commit 000f7e8

File tree

1 file changed

+27
-45
lines changed

1 file changed

+27
-45
lines changed

config/opal_mca.m4

Lines changed: 27 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -103,12 +103,10 @@ AC_DEFUN([OPAL_MCA],[
103103
type=$item
104104
fi
105105
if test -z $comp ; then
106-
str="`echo DISABLE_${type}=1 | sed s/-/_/g`"
107-
eval $str
106+
AS_VAR_COPY([AS_TR_SH([DISABLE_$type])], [1])
108107
msg="$item $msg"
109108
else
110-
str="`echo DISABLE_${type}_${comp}=1 | sed s/-/_/g`"
111-
eval $str
109+
AS_VAR_COPY([AS_TR_SH([DISABLE_$type_$comp])], [1])
112110
msg="$item $msg"
113111
fi
114112
done
@@ -151,8 +149,7 @@ AC_DEFUN([OPAL_MCA],[
151149
AC_MSG_ERROR([*** The enable-mca-direct flag requires a
152150
*** list of type-component pairs. Invalid input detected.])
153151
else
154-
str="`echo DIRECT_$type=$comp | sed s/-/_/g`"
155-
eval $str
152+
AS_VAR_COPY([AS_TR_SH([DIRECT_$type])], [AS_TR_SH([$comp])])
156153
msg="$item $msg"
157154
fi
158155
done
@@ -187,8 +184,7 @@ AC_DEFUN([OPAL_MCA],[
187184
IFS="${IFS}$PATH_SEPARATOR,"
188185
msg=
189186
for item in $enable_mca_dso; do
190-
str="`echo DSO_$item=1 | sed s/-/_/g`"
191-
eval $str
187+
AS_VAR_COPY([AS_TR_SH([DSO_$item])], [1])
192188
msg="$item $msg"
193189
done
194190
IFS="$ifs_save"
@@ -216,8 +212,7 @@ AC_DEFUN([OPAL_MCA],[
216212
IFS="${IFS}$PATH_SEPARATOR,"
217213
msg=
218214
for item in $enable_mca_static; do
219-
str="`echo STATIC_$item=1 | sed s/-/_/g`"
220-
eval $str
215+
AS_VAR_COPY([AS_TR_SH([STATIC_$item])], [1])
221216
msg="$item $msg"
222217
done
223218
IFS="$ifs_save"
@@ -698,16 +693,10 @@ AC_DEFUN([MCA_CONFIGURE_ALL_CONFIG_COMPONENTS],[
698693
# NOTE: component_name may not be determined until runtime....
699694
AC_DEFUN([MCA_COMPONENT_COMPILE_MODE],[
700695
SHARED_FRAMEWORK="$DSO_$2"
701-
AS_LITERAL_IF([$3],
702-
[SHARED_COMPONENT="$DSO_$2_$3"],
703-
[str="SHARED_COMPONENT=\$DSO_$2_$3"
704-
eval $str])
696+
AS_VAR_COPY([SHARED_COMPONENT], [DSO_$2_$3])
705697
706698
STATIC_FRAMEWORK="$STATIC_$2"
707-
AS_LITERAL_IF([$3],
708-
[STATIC_COMPONENT="$STATIC_$2_$3"],
709-
[str="STATIC_COMPONENT=\$STATIC_$2_$3"
710-
eval $str])
699+
AS_VAR_COPY([STATIC_COMPONENT], [DSO_$2_$3])
711700
712701
# Look for the most specific specifier between static/dso. If
713702
# there is a tie (either neither or both specified), prefer
@@ -807,26 +796,25 @@ AC_MSG_ERROR([*** $2 component $3 was supposed to be direct-called, but
807796
fi
808797
fi
809798
810-
# if the component is building, add it's WRAPPER_EXTRA_LDFLAGS and
811-
# WRAPPER_EXTRA_LIBS. If the component doesn't specify it's
812-
# WRAPPER_EXTRA_LIBS and WRAPPER_EXTRA_LDFLAGS, try using LDFLAGS and LIBS if
813-
# component didn't have it's own configure script (in which case,
814-
# we know it didn't set LDFLAGS and LIBS because it can't) Don't
815-
# have to do this if the component is building dynamically,
816-
# because it will link against these (without a dependency from
817-
# libmpi.so to these flags)
818-
if test "$8" = "static"; then
819-
AS_LITERAL_IF([$3],
820-
[m4_foreach(flags, [LDFLAGS, LIBS],
821-
[AS_IF([test "$$2_$3_WRAPPER_EXTRA_]flags[" = ""],
822-
[OPAL_FLAGS_APPEND_UNIQ([mca_wrapper_extra_]m4_tolower(flags), [$$2_$3_]flags)],
823-
[OPAL_FLAGS_APPEND_UNIQ([mca_wrapper_extra_]m4_tolower(flags), [$$2_$3_WRAPPER_EXTRA_]flags)])
824-
])],
825-
[m4_foreach(flags, [LDFLAGS, LIBS],
826-
[[str="line=\$$2_$3_WRAPPER_EXTRA_]flags["]
827-
eval "$str"
828-
OPAL_FLAGS_APPEND_UNIQ([mca_wrapper_extra_]m4_tolower(flags), [$line])])])
829-
fi
799+
# If a component is building static, we need to provide LDFLAGS
800+
# and LIBS configuration to the wrapper compiler, so that it can
801+
# provide them for the final link of the application. Components
802+
# can explicitly set <framework>_<component>_WRAPPER_EXTRA_<flag>
803+
# for either LDFLAGS or LIBS, for cases where the component wants
804+
# to explicitly manage that behavior. If the full variable is not
805+
# defined, this macro will copy <framework>_<component>_<flag>
806+
# into the wrapper flags.
807+
AS_IF([test "$8" = "static"],
808+
[m4_foreach(flags, [LDFLAGS, LIBS],
809+
[AS_VAR_SET_IF([$2_$3_WRAPPER_EXTRA_]flags,
810+
[OPAL_FLAGS_APPEND_UNIQ([mca_wrapper_extra_]m4_tolower(flags), [$$2_$3_WRAPPER_EXTRA_]flags)],
811+
[OPAL_FLAGS_APPEND_UNIQ([mca_wrapper_extra_]m4_tolower(flags), [$$2_$3]_flags)])
812+
dnl yes, this is weird indenting, but the
813+
dnl combination of m4_foreach and AS_VAR_SET_IF
814+
dnl will result in the closing of one if and the
815+
dnl start of the next on the same line, resulting
816+
dnl in parse errors, if this is not here.
817+
])])
830818
831819
# if needed, copy over WRAPPER_EXTRA_CPPFLAGS. Since a configure script
832820
# component can never be used in a STOP_AT_FIRST framework, we
@@ -925,13 +913,7 @@ AC_DEFUN([MCA_COMPONENT_BUILD_CHECK],[
925913
926914
# if we were explicitly disabled, don't build :)
927915
AS_IF([test "$DISABLE_$2" = "1"], [want_component=0])
928-
AS_LITERAL_IF([$3],
929-
[AS_IF([test "$DISABLE_$2_$3" = "1"], [want_component=0])],
930-
[str="DISABLED_COMPONENT_CHECK=\$DISABLE_$2_$3"
931-
eval $str
932-
if test "$DISABLED_COMPONENT_CHECK" = "1" ; then
933-
want_component=0
934-
fi])
916+
AS_VAR_IF([DISABLE_$2_$3], [1], [want_component = 0])
935917
936918
AS_IF([test "$want_component" = "1"], [$4], [$5])
937919
])

0 commit comments

Comments
 (0)