How to detect if a m4 macro exists / can be called
Asked Answered
C

1

7

we're developing a software package that uses autotools (autoconf 2.69 and automake 1.13.3 to be precise). This package needs wxwidgets and this library provides its own m4 file to allow testing the installation of wxwidgets in the final installation system. wxwidgets has recently changed version from 2.8 to 3.0 and in this change they also changed the macro used to determine the availability (i.e. the macro changed from AM_PATH_WXCONFIG to WX_CONFIG_CHECK) as well as its parametrization. That also means that if we distribute the source code from our package and external developers want to rebuild the configure, then the configure.ac file should be aware of which of the two should be used.

So the question is: is there any chance for our package to check whether an m4 macro exists before executing it? If that's not possible, then should we include the m4 files from wxwidgets into our package?

Crochet answered 24/7, 2015 at 10:42 Comment(1)
Looks like autoconf 2.63 included m4_ifdef which may be useful here gnu.org/software/autoconf/manual/autoconf-2.63/html_node/…Crochet
E
4

As you suggested in your comment, use m4_ifdef:

m4_ifdef([AM_PATH_WXCONFIG], [
    AM_PATH_WXCONFIG(parameters)
], [
    m4_ifdef([WX_CONFIG_CHECK], [
        WX_CONFIG_CHECK(parameters)
    ], [
        AC_MSG_ERROR([You need to install the wxWidgets development package.])
    ])
])
Electrostatic answered 26/7, 2015 at 5:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.