Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 620
Harald Avatar asked Jul 24 '15 10:07

Harald


People also ask

What is m4 macro processor?

The m4 macro processor writes all redirected output to the temporary files in numerical order at the end of processing. The m4 macro processor discards the output if you redirect the output to a temporary file other than 0 through 9.

What is m4 files?

File written for m4, a Unix macro processor that is included with many Unix and Linux distributions; contains macros in addition to other text, but the macros are expanded when processed by m4; often used for setting up configuration files.

What is m4 Linux?

The m4 command is a macro processor used as a preprocessor for C and other languages. You can use it to process built-in macros or user-defined macros. Each File parameter is processed in order. If you do not specify a File parameter or if you specify the - (dash) as a file name, the m4 command reads standard input.


1 Answers

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.])
    ])
])
like image 95
ptomato Avatar answered Oct 08 '22 16:10

ptomato