一、相關軟件包
二、過程
1、相關軟件包(檢查是否安裝, fedora 下用yum install PROGRAMNAME)
1. GNU Automake
2. GNU Autoconf
3. GNU m4
4. perl
5. GNU Libtool (如果你需要產生 shared library)
2、過程
參照 http://www.ibm.com/developerworks/cn/linux/l-makefile/
首先進入 project 目錄,在該目錄下運行一系列命令,創建和修改幾個文件,就可以生成符合該平臺的Makefile文件,操作過程如下:
1) 運行autoscan命令:生成 autoscan.log configure.scan
2) 將configure.scan 文件重命名爲configure.in,並修改configure.in文件
其中要將AC_CONFIG_HEADER([config.h])修改爲:AC_CONFIG_HEADER(config.h), 並加入AM_INIT_AUTOMAKE(test,1.0)。由於我們的測試程序是基於多線程的程序,所以要加入AC_PROG_RANLIB,不然運行automake命令時會出錯。在AC_OUTPUT輸入要創建的Makefile文件名。(見上文鏈接)
3) 在project目錄下新建Makefile.am文件,並在src目錄下也新建Makefile.am文件(在所有的源文件目錄下都要建立)
//project 目錄下的Makefile.am文件內容
SUBDIRS=src
CURRENTPATH=`sh /bin/pwd`
INCLUDES=-I$(CURRENTPATH)/include
export INCLUDES//src目錄下的Makefile.am文件內容
noinst_PROGRAMS=ftools
ftools_SOURCES=main.c read_data_file.c
4) 在project目錄下新建NEWS、 README、 ChangeLog 、AUTHORS文件,(如:$touch NEWS)
5) 將/usr/share/automake-1.X/目錄下的depcomp和compile文件拷貝到本目錄下
6) 運行aclocal命令
% aclocal
//我的運行錯誤如下,去掉configure.in中有 AC_CONFIG_FILES 那一行就可以了
configure.in:26: error: `src/Makefile' is already registered with AC_CONFIG_FILES.
../../lib/autoconf/status.m4:290: AC_CONFIG_FILES is expanded from...
configure.in:26: the top level
autom4te: /usr/bin/m4 failed with exit status: 1
aclocal: autom4te failed with exit status: 1
% autoheader
% autoconf
8) 運行automake -a命令(先運行 automake --add-missing --copy)
9) 運行./confiugre腳本
autoconf automake使用小例http://blog.chinaunix.net/u2/72785/showart_1082331.html