使用automake 与 autoconf 自动生成 Makefile
来源:互联网 发布:中信淘宝信用卡怎么样 编辑:程序博客网 时间:2024/05/16 17:51
转自:http://blog.sina.com.cn/s/blog_50151e570100vgtk.html
刚开始的时候,一直在使用automake 和 autoconf生成Makefile,然后编译这个工具,一直想把自己了解的记录下来,今天做了个简单的实验,趁这个机会,把一些东西写在这里,并尽可能的说清楚这个工具的使用原理。
先从实验开始说
简单实验
编写一个简单的文件,autotest.c,内容如下:
#include <stdio.h>
int main(int argc,char** argv){
printf("If you look this print on your screen , it is work\n");
return 0;
}
1) 运行autoscan命令,这个命令会扫描你在当前目录下的源代码文件,然后会生成一个扫描的报告,这个报告会告诉你必要的配置,文件名为 :configure.scan。其实这个文件也没什么神秘的,它的大致应该如下:
# 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([config.h.in])
AC_CONFIG_HEADER([config.h])
# Checks for programs.
AC_PROG_CC
# Checks for libraries.
# FIXME: Replace `main' with a function in `-lpthread':
AC_CHECK_LIB([pthread], [main])
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_OUTPUT
有人把这个文件的内容总结为,
AC_INIT // 一定是以这个开头的