shrext_cmds get passed literally into user code

Eric Gallager <[email protected]> Mon, 31 Jul 2023 19:18:18 -0400
Newsgroups gmane.comp.gnu.libtool.general
Message-ID <CAMfHzOtKpGtOb=_wer_B2FEWRUs1r=H6yTv-bY0-xgSJRgLHrg@mail.gmail.com>
I am on Darwin, where libtool sets shrext_cmds to `test .$module =
.yes && echo .so || echo .dylib`. In the project's configure.ac, there
is code that does this:

AC_DEFINE_UNQUOTED([SHARED_LIB_EXT],["${shrext_cmds}"],
                   [Extension of a shared library])dnl

This preprocessor macro, SHARED_LIB_EXT, then gets used in calls to
dlopen(), but unfortunately this leads to errors like this:

Impossible to load libscifunctions`test .$module = .yes && echo .so ||
echo .dylib` library:
dlopen(/Users/ericgallager/scilab/scilab/modules/functions/.libs/libscifunctions`test
.$module = .yes && echo .so || echo .dylib`, 10): image not found

As you can see, shrext_cmds have been passed as a string literal into
the code using it. Is there a way that I can get the variable to be
evaluated first before substituting it? i.e. I want the result of
running the command, not the literal string for the command itself.
Sorry if this is an extremely beginner-level question; all my
experience with shells and such is self-taught, and I never really
learned the basics properly.
Thanks,
Eric Gallager