views:

15

answers:

1

In using the m4_ax_python_module.m4 macro in configure.ac (AX_PYTHON_MODULE), one can know at configure time if a given module is installed. It takes two arguments, the module name, and second argument which if not empty, will lead to an exit, useful when the module is a must-have.

In the case where you don't want a fatal exit, how do you test in configure.ac which modules were found or not? They output "yes" or "no" when configure is run, but that's all I've found so far. Basically If I have these lines in configure.ac:

EDIT: added square brackets around module names

AX_PYTHON_MODULE([json],[])
AX_PYTHON_MODULE([simplejson],[])

How do I test which of the two modules were found?

See http://www.gnu.org/software/autoconf-archive/ax_python_module.html#ax_python_module for documentation about this macro.

+1  A: 

Ok the best solution I've found so far was:

EDIT: using AS_IF instead of just if test

AS_IF([test "x${HAVE_PYMOD_JSON}" = "xno"], 
    AS_IF([test "x${HAVE_PYMOD_SIMPLEJSON}" = "xno"],
        [AC_MSG_ERROR([Requires one of json or simplejson])]))

What through me off was in the macro, the AS_TR_CPP transforms its arguments into #define style macros, i.e. all upper case.

tmatth
+1, but consider using AS_IF instead of raw "if test", and properly quote your invocation: AX_PYTHON_MODULE([json],[]).
William Pursell
thanks @William Pursell, i edited my initial answer
tmatth