GNU Build System

关于GNU Build System的大致介绍: GNU Build System on Wiki

GNU Build的standard targets (e.g. install/clean):   GNU make standard targets

Automake的详细描述:Automake


下面是一个使用GNU Build System创建portable package的过程例子。

Create a portable package
=================

See  Automake man docs to learn more about the format of Makefile.am and GNU build systems.

Create a source tree like below
------------------------------------
.
|-- Makefile.am
|-- scripts
|   |-- Makefile.am
|   `-- hello.sh
`-- src
    |-- Makefile.am
    `-- main.c
$ cat Makefile.am
AUTOMAKE_OPTIONS = foreign
SUBDIRS = src scripts
$ cat scripts/Makefile.am
bin_SCRIPTS = hello.sh
$ cat scripts/hello.sh
#!/bin/bash
echo "hello"
$ cat src/Makefile.am
CFLAGS = -Wall -O2
LDFLAGS = -lpthread

bin_PROGRAMS = main

main_SOURCES = main.c

 
   
Run autoscan
---------------
Autoscan scans the source files and Makefile.am, it does:
1. check which libraries are required
2. check which header files are required
Move the generated configure.scan to configure.ac and add the following lines after AC_INIT (also revise AC_INIT).
AC_INIT([hello], [0.1], [[email protected]])
AM_INIT_AUTOMAKE(hello, 0.1)

Run aclocal
-------------

It generates aclocal.m4 and autom4te.cache from configure.ac

Run autoheader
------------------

It generates config.h.in from configure.ac

Run automake
----------------

$ automake --add-missing
It generates Makefile.in from Makefile.am and config.h.in

RUn autoconf
---------------

It generates script @configure from autom4te.cache?

Compile the program
------------------------

$./configure && make
When running ./configure, config.status is generated. Actually ./configure invokes config.status to generate Makefile, so you can run config.status to re-create Makefiles.

你可能感兴趣的:(GNU Build System)