Confused about configure script and Makefile.in

In order to really understand the autotools utilities you have to remember where they come from: they come from an open source world where there are (a) developers who are working from a source code repository (CVS, Git, etc.) and creating a tar file or similar containing source code and putting that tar file up on a download site, and (b) end-users who are getting the source code tar file, compiling that source code on their system and using the resulting binary. Obviously the folks in group (a) also compile the code and use the resulting binary, but the folks in group (b) don't have or need, often, all the tools for development that the folks in group (a) need.

So the use of the tools is geared towards this split, where the people in group (b) don't have access to autoconf, automake, etc.

When using autoconf, people generally check in the configure.ac file (input to autoconf) into source control but do not check in the output of autoconf, the configure script (some projects do check in the configure script of course: it's up to you).

When using automake, people generally check in the Makefile.am file (input to automake) but do not check in the output of automake: Makefile.in.

The configure script basically looks at your system for various optional elements that the package may or may not need, where they can be found, etc. Once it finds this information, it can use it to convert various XXX.in files (typically, but not solely, Makefile.in) into XXX files (for example, Makefile).

So the steps generally go like this: write configure.ac and Makefile.am and check them in. To build the project from source code control checkout, run autoconf to generate configure from configure.ac. Run automake to generate Makefile.in from Makefile.am. Run configure to generate Makefile from Makefile.in. Run make to build the product.

When you want to release the source code (if you're developing an open source product that makes source code releases) you run autoconf and automake, then bundle up the source code with the configure and Makefile.in files, so that people building your source code release just need make and a compiler and don't need any autotools.

Because the order of running autoconf and automake (and libtool if you use it) can be tricky there are scripts like autogen.sh and autoreconf, etc. which are checked into source control to be used by developers building from source control, but these are not needed/used by people building from the source code release tar file etc.

Autoconf and automake are often used together but you can use autoconf without automake, if you want to write your own Makefile.in.


For this error:

config.status: error: cannot find input file: `somedir/Makefile.in'

In the directory where the configure.ac is located in the Makefile.am add a line with the subdirectory somedir

SUBDIRS = somedir

Inside somedir put a Makefile.am with all the description. then run automaker --add-missing

A better description can be found in 7.1 Recursing subdirectories automake manual. https://www.gnu.org/software/automake/manual/automake.html