- 论坛徽章:
- 0
|
自动编译工具AutoTools使用测试
1.检查系统必装工具包(保证可用)automake,autoconf,aclocal,autoheader,libtool,m4,perl
2.mkdir test && vi test/test.c
输入测试代码:
#include
int main(int argc,char **argv)
{
printf("GNU AutoTools Test.The test works well if you see this
message.");
return 0;
}
3.$autoscan
生成如下文件:
autoscan.log configure.scan test.c
4.$mv configure.scan configure.in && vi configure.in
源文件如下:
# -*-Autoconf-*-
#Process this file with autoconf to produce a configure script.
AC_PREREQ(2.57)
AC_INIT(FULL-PACKAGE-NAME,VERSION,BUG-REPORT-ADDRESS)
AC_CONFIG_SRCDIR([test.c])
AC_CONFIG_HEADER([config.h])
#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
修改如下:
# -*-Autoconf-*-
#Process this file with autoconf to produce a configure script.
AC_PREREQ(2.57)
AC_INIT(test.c,1.0,creatory@mail.com)
AM_INIT_AUTOMAKE(test,1.0)
AC_CONFIG_SRCDIR([test.c])
AC_CONFIG_HEADER([config.h])
#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)
5.$aclocal && autoheader && autoconf
生成文件如下:
aclocal.m4 autoscan.log configure test.c autom4te.cache config.h.in configure.in
6.$vi Makefile.am
新建文件内容如下:
AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS=test
test_SOURCES=test.c
7.$automake --add-missing
至此配置完毕
先用./configure进行检测配置
再用make dist打包为test-1.0.tar.gz即可发行.
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u1/56374/showart_1851725.html |
|