How to include .m4 files in Autoconf?

前端 未结 5 866
孤街浪徒
孤街浪徒 2021-02-05 04:46

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?

相关标签:
5条回答
  • 2021-02-05 05:14

    As an alternative to Idav1s' solution (which is absolutely correct), you can install the macro in a location where aclocal will find it (use aclocal --print to see where aclocal is looking for .m4 files). Each approach has pros and cons. If you install the .m4 files in $(aclocal --print), you can use the macro in all of your projects without doing anything else. The primary drawback is that each developer who works on the project will have to install the macro on their box, and that requires each developer to have a reasonable understanding of the autotools.

    0 讨论(0)
  • 2021-02-05 05:20

    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.)

    0 讨论(0)
  • 2021-02-05 05:23

    I have this issue as well, and just fixed it. My environment is: CentOS 6.4, M4 1.4.17 , autoconf 2.69, libtool 2.4, automake 1.14

    Here are the steps I used.

    add m4 as AC_CONFIG_MACRO_DIR to your configure.ac
    rm aclocal.m4  if it exists
    mkdir m4       if it does not exist
    # copy some dummy files into the folder 
    # or some versions of autoconf  won't work   
    autoreconf -i --install    
    
    0 讨论(0)
  • 2021-02-05 05:25

    Isn't it enough to just save the m4 macro in certain directory and run autoreconf with the -I option:

    autoreconf -i -I/path/to/your/m4/file
    

    Or did I misunderstand you and do you want to integrate it permanently, without the person running autoreconf to worry about downloading the m4 file?

    0 讨论(0)
  • 2021-02-05 05:29

    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.

    0 讨论(0)
提交回复
热议问题