MechMK1
MechMK1

Reputation: 3378

In what order are autotools invoked to create a build system?

I'm trying to use autotools to create a build system for a C program. However, after reading info automake, I'm still very confused about the order of which tools are invoked by the developer.

Let's think about a very simple hello world application. In the root dir of the application there is simple src/hello.c and nothing else. What tools need to be called in what order to create configure and a Makefile?

I figured out by myself (partially reading doc, partially just trying) that autoscan comes first and generates a "sketch" of the configure.ac. Then autoheader appearently creates a header file (why?). Next autoconf finally creates the configure script, which will ultimately create a config.h.

However, I am still missing a Makefile which I believe is created by automake, but this requires a Makefile.am which I don't know how to generate. Is this file generated at all or hand-written by the developer?

Upvotes: 1

Views: 1197

Answers (2)

Gabi
Gabi

Reputation: 598

Your Makefile.am should look something like

bin_PROGRAMS = hello
AUTOMAKE_OPTIONS = foreign
hello_SOURCES = src/hello.c

Run automake and it will create a Makefile.in

Upvotes: 0

Brett Hale
Brett Hale

Reputation: 22318

The functionality of the autotools tends to blur at the edges. There's a decent flow chart describing the ordering here. The Makefile.am is typically hand-written. Many projects keep a simple shell script at the top-level of the source tree, i.e., autogen.sh or initgen.sh. The autogen.sh I use:

#! /bin/sh

case `uname` in Darwin*) glibtoolize --copy ;;
    *) libtoolize --copy ;; esac

aclocal -I m4 --install
autoheader
autoconf

automake --foreign --add-missing --force-missing --copy

This is still one of the best practical guides I've seen. I believe it's available in book form too.

Upvotes: 2

Related Questions