关于GNU Build System的大致介绍:
GNU Build System on Wiki
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
<pre name="code" class="plain">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], [xxx@yyy.com])
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.
本文详细介绍了如何使用GNUBuildSystem创建可移植包的过程,包括创建源代码目录结构、配置Makefile.am文件、运行相关自动化工具等步骤。
397

被折叠的 条评论
为什么被折叠?



