Difference between revisions of "User:Drcouzelis/GNU Build System"

From ArchWiki
Jump to navigation Jump to search
(Initial post, to be updated.)
(No difference)

Revision as of 20:03, 3 June 2016

Autotools uses a big long chain of applications and configuration files to help you build your project. It all begins with two files:

  • configure.ac
  • Makefile.am

The configure.ac file is used by the application autoconf. This file tells autoconf about what is needed to build your application - things like the name of the application and what compiler and libraries to use. Only one configure.ac file is needed, and it goes in the root directory of your source code tree.

The Makefile.am file is used by the application automake. The Makefile.am file tells automake how to build (or simply what to do with) the files that are in the directory. Each directory will have its own Makefile.am file, including the root directory.

In summary:

  • configure.ac -> autoconf
  • Makefile.am -> automake

Did you notice that the file extension for the AutoConf file is AC and that the file extension for the AutoMake file is AM? Cute, right?

Now, what do you put in those files?

The Makefile.am file is relatively simple. Here is an example of a project directory structure:


You would need two Makefile.am files:


 SUBDIRS = src


 bin_PROGRAMS = theapp
 theapp_SOURCES = resources.c theapp.c

Good news! As for the configure.ac file, autotools can help you create it. In the root directory of your project run the program autoscan. The autoscan program will look at your files and create a simple file called configure.scan for you to start with.

  • autoscan -> configure.scan

Just rename configure.scan to configure.ac.

Edit the configure.ac file. There are some nice easy to understand placeholders for you to fill in, such as "FULL-PACKAGE-NAME" and "VERSION".

  • [TODO HOW TO FILL IN Makefile.am]
  • [TODO HOW TO FILL IN configure.ac]

Now that you've prepared the configuration files it's time to let autotools to do some automating. Run "autoreconf --install" to run the autotools scripts. The "--install" command will install any missing files for you, such as the NEWS and README files.