Autotools 学习笔记

随便写了个hello程序练习:
hello/
|– Makefile.am
`– src
    |– Makefile.am
    `– main.c

几个文件的内容:

hello/Makefile.am:
SUBDIRS = src

hello/src/Makefile.am:

bin_PROGRAMS = hello
hello_SOURCES = main.c

hello/src/main.c:

#include <config.h>
#include <stdio.h>

int
main (void)
{
    puts ("hello, world\n");
    puts ("This is " PACKAGE_STRING ".");
    return 0;
}

hello/configure.in:
AC_PREREQ(2.61)
AC_INIT([hello],[0.1],[bug@report.com])
AM_INIT_AUTOMAKE([-Wall -Werror])
AC_CONFIG_SRCDIR([src/main.c])
AC_CONFIG_HEADER([config.h])
AC_PROG_CC
AC_CONFIG_FILES([Makefile
                 src/Makefile])
AC_OUTPUT

如果一步一步来:
1. autoscan
2. modify configure.scan
3. rename configure.scan to configure.in
4. aclocal
5. autoheader
6. autoupdate
7. touch NEWS README AUTHORS ChangeLog COPYING
8. automake –add-missing
9. autoconf

如果为了简单:
1. touch NEWS README AUTHORS ChangeLog COPYING
2. autoreconf –install

This entry was posted in GNU/Linux and tagged . Bookmark the permalink.

2 Responses to Autotools 学习笔记

  1. cocobear says:

    好麻烦啊

  2. dream1123 says:

    是啊,autotools 本来就挺麻烦的,不过我觉得为了能增加portable,还是值得的, :)

Leave a Reply

Your email address will not be published. Required fields are marked *