关于automake 使用hello world例子。

A Small Hello World
In this section we recreate the amhello-1.0 package from scratch. The first subsection
shows how to call the Autotools to instantiate the GNU Build System, while the second
explains the meaning of the configure.ac and Makefile.am files read by the Autotools.

Creating amhello-1.0.tar.gz
Here is how we can recreate amhello-1.0.tar.gz from scratch. The package is simple
enough so that we will only need to write 5 files. (You may copy them from the final
amhello-1.0.tar.gz that is distributed with Automake if you do not want to write them.)
Create the following files in an empty directory.
src/main.c is the source file for the hello program. We store it in the src/ subdirectory, because later, when the package evolves, it will ease the addition of a man/
directory for man pages, a data/ directory for data files, etc.

~/amhello % cat src/main.c
#include <config.h>
#include <stdio.h>
int
main (void)
{
puts ("Hello World!");
Chapter 2: An Introduction to the Autotools 14
puts ("This is " PACKAGE_STRING ".");
return 0;
}

 


README contains some very limited documentation for our little package.

~/amhello % cat README
This is a demonstration package for GNU Automake.
Type ’info Automake’ to read the Automake manual.

 


Makefile.am and src/Makefile.am contain Automake instructions for these two directories.

~/amhello % cat src/Makefile.am
bin_PROGRAMS = hello
hello_SOURCES = main.c
~/amhello % cat Makefile.am
SUBDIRS = src
dist_doc_DATA = README

 


Finally, configure.ac contains Autoconf instructions to create the configure script.

~/amhello % cat configure.ac
AC_INIT([amhello], [1.0], [bug-automake@gnu.org])
AM_INIT_AUTOMAKE([-Wall -Werror foreign])
AC_PROG_CC
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_FILES([
Makefile
src/Makefile
])
AC_OUTPUT

 


Once you have these five files, it is time to run the Autotools to instantiate the build
system. Do this using the autoreconf command as follows:

~/amhello % autoreconf --install
configure.ac: installing ’./install-sh’
configure.ac: installing ’./missing’
configure.ac: installing ’./compile’
src/Makefile.am: installing ’./depcomp’

 


At this point the build system is complete.
In addition to the three scripts mentioned in its output, you can see that autoreconf
created four other files: configure, config.h.in, Makefile.in, and src/Makefile.in.
The latter three files are templates that will be adapted to the system by configure under
the names config.h, Makefile, and src/Makefile.

转载于:https://www.cnblogs.com/cooler/p/3217487.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值