Search code examples
autotoolscc

Autoconf complains of undefined macro, suggests m4_pattern_allow? what's going on?


I've done a lot of C and some C++ programming, but never used autotools before (I was doing this so long ago, the tools were not yet available to me). Anyway, I'm on Xubuntu 20.04, and I'm following a tutorial at https://earthly.dev/blog/autoconf/ and I've created this configure.ac

AC_INIT([helloworld], [0.1], [[email protected]])
AM_INIT_AUTOMAKE
AC_PROG_CC
AC_CONFIG_FILES([Makefile])
AC_OUTPUT

which seems to agree with the tutorial, and I did aclocal okay but when I try to do autoconf I get

configure: error: cannot find install-sh, install.sh, or shtool in "." "./.." "./../.."

I have no idea why this comes up, and while I can guess in general, I don't know specifically what those install things are, or why configure seems to think I need them.


Solution

  • I don't much care for some of the details of the article you linked. Generally speaking, one should not run the individual autotools manually (aclocal, autoconf, etc.), and a recommendation to routinely do so undermines the recommender's credibility with me. Use autoreconf instead. It determines which of the individual autotools to run, and runs them all in the correct order. Most of the time, that's all you need to do.

    For a new or newly autotooled project, however, or if you otherwise get messages such as you report about scripts and tools being missing, add the --install option to your autoreconf run. In that case, I tend to also use the --force option for good measure, though often it's unnecessary:

    autoreconf --install --force
    

    The --install part will ensure that all the helper scripts needed for the Autotools components you are presently using are installed in the project source tree, and the --force option will replace any that are already there.

    NOTE: If you plan to use AC_CONFIG_AUX_DIR in your configure.ac then it is convenient to put it in before running autoreconf --install, because it affects where the helper scripts will be put.