Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to include .m4 files in Autoconf?

Tags:

autoconf

I have downloaded a macro from Autoconf Archive, and I want to use it. What do I have to put in my configure.ac file to make use this macro?

like image 952
petersohn Avatar asked Mar 14 '11 12:03

petersohn


People also ask

How do I setup a script autoconf?

To create a configure script with Autoconf, you need to write an Autoconf input file configure.ac (or configure.in ) and run autoconf on it. If you write your own feature tests to supplement those that come with Autoconf, you might also write files called aclocal. m4 and acsite. m4 .

What is Autoconf m4?

Autoconf is an extensible package of M4 macros that produce shell scripts to automatically configure software source code packages. These scripts can adapt the packages to many kinds of UNIX-like systems without manual user intervention.

What is configure AC file?

The configure.ac file is used to create the ./configure script. It consists of a series of macros which are processed and expanded by autoconf . These macros can check for packages and libraries, handle --enable and --with switches, and generate various files.


2 Answers

You may want to add AC_CONFIG_MACRO_DIR to configure.ac to the directory where the macro is:

AC_CONFIG_MACRO_DIR([path/to/macros])

You'll need to invoke the macro somewhere in this file also.

and in Makefile.am you'll probably need to set up ACLOCAL_AMFLAGS (if you are using automake):

ACLOCAL_AMFLAGS         = -I path/to/macros

Then invoke autoreconf -fvi and you should be set.

like image 150
ldav1s Avatar answered Nov 17 '22 17:11

ldav1s


I had this exact same question, and it was harder to find an answer than I thought. It looked like AC_CONFIG_MACRO_DIR was what I wanted, but if you are not using libtoolize, it appears that AC_CONFIG_MACRO_DIR is useless at present.

If you're using automake, I think the answer above is right.

I'm not using automake, so the only way I've found is to use the m4_include macro to suck in each .m4 file individually. I found this approach here:

http://www.flameeyes.eu/autotools-mythbuster/autoconf/macros.html

Hope this helps. (Considering how long autoconf has been around, it boggles my mind somewhat that there's no built-in way to just specify a directory in the .ac file. Seems like it would be an awefully common use case. Oh, well.)

like image 20
Chris Avatar answered Nov 17 '22 18:11

Chris