Autotools學習

Autotools  工具集使用

1,autoscan

2,   aclocal

3,  autoconf

4, [autoheader]

5, automake


官方幫助文檔

http://www.gnu.org/software/autoconf/manual/autoconf.html#Automake

automake 流程圖

Files used in preparing a software package for distribution, when usingjust Autoconf:

     your source files --> [autoscan*] --> [configure.scan] --> configure.ac
     
     configure.ac --.
                    |   .------> autoconf* -----> configure
     [aclocal.m4] --+---+
                    |   `-----> [autoheader*] --> [config.h.in]
     [acsite.m4] ---'
     
     Makefile.in

Additionally, if you use Automake, the following additional productionscome into play:

     [acinclude.m4] --.
                      |
     [local macros] --+--> aclocal* --> aclocal.m4
                      |
     configure.ac ----'
     
     configure.ac --.
                    +--> automake* --> Makefile.in
     Makefile.am ---'

Files used in configuring a software package:

                            .-------------> [config.cache]
     configure* ------------+-------------> config.log
                            |
     [config.h.in] -.       v            .-> [config.h] -.
                    +--> config.status* -+               +--> make*
     Makefile.in ---'                    `-> Makefile ---'


第一步:

               建立hello.c 源文件

#include<stdio.h>
int main ()
{
        printf("hello automake");
        return 0;
}

在當前目錄執行autoscan生成autoscan.log 和configure.scan兩個文件,編輯configure.scan文件,將configure.scan 改名configure.ac

編輯該文件修改文件如下:

AC_PREREQ([2.68])
AC_INIT(hello,1.0,[email protected])
AC_CONFIG_SRCDIR([hello.c])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE(hello,1.0)
# Checks for programs.
AC_PROG_CC

# Checks for libraries.

# Checks for header files.

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.

AC_OUTPUT(Makefile)

AM_INIT_AUTOMAKE參數必須添加不然接下來會報錯。

第二步

執行aclocal 生成 aclocal.m4 文件

執行 autoheader 生成 config.h.in


第三步

新建文件 Makefile.am 填入

bin_PROGRAMS = hello
hello_SOURCES = hello.c

在文檔可以找到詳細解釋


執行 automake --add-missing 生成 Makefile.in

執行 autoconf  生成 configure

執行 ./configure 生成 Makefile


接下來執行make install 安裝你但程序。

執行 make dist 生成hello-1.0.tar.gz 發佈包 完成。








發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章