设为首页 加入收藏

TOP

Linux C一个Autotools的最简单例子
2014-11-24 01:25:46 来源: 作者: 【 】 浏览:2
Tags:Linux 一个 Autotools 简单 例子

1、准备:
需要工具autoscan aclocal autoheader automake autoconf make 等工具.
2、测试程序编写:
建立目录:mkdir include src
编写程序:include/str.h


#include
int str(char *string);


编写程序:src/str.c


#include "str.h"
//print string
int str(char *string){
printf("\n----PRINT STRING----\n\"%s\"\n",string);
return 0;
}


//interface of this program
int main(int argc , char **argv){
char str_read[1024];
printf("Please INPUT something end by [ENTER]\n");
scanf("%s",str_read);
return str(str_read );
}


3、生成configure.ac
configure.ac是automake的输入文件,所以必须先生成该文件。
执行命令:


[root@localhost str]# ls
include src
[root@localhost str]# autoscan
autom4te: configure.ac: no such file or directory
autoscan: /usr/bin/autom4te failed with exit status: 1
[root@localhost str]# ls
autoscan.log configure.scan include src
[root@localhost str]# cp configure.scan configure.ac


修改 configure.ac


# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.


AC_PREREQ(2.59)
AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
AC_CONFIG_SRCDIR([include/str.h])
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


修改


AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)



AC_INIT(str,0.0.1, [bug@sounos.org])


FULL-PACKAGE-NAME 为程序名称,VERSION为当前版本, BUG-REPORT-ADDRESS为bug汇报地址
添加AM_INIT_AUTOMAKE
添加AC_CONFIG_FILES([Makefile])


# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.


AC_PREREQ(2.59)
#AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
AC_INIT(str, 0.0.1, [bug@sounos.org])
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([include/str.h])
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_CONFIG_FILES([Makefile])
AC_OUTPUT


4、执行aclocal


】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇在Linux下C/C++的Regular Express.. 下一篇Java 7将向细颗粒并行化发展

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: