日期:2014-05-16  浏览次数:20550 次

Linux下Makefile的automake生成

******************helloworld.c*********************************/
#include <stdio.h>

int main(void)
{
?? printf("hello kenter!\n");
?? return 0;
}
***************************************************************/


1.首先运行autoscan扫描源代码,生成configure.scan文件
2.重命名configure.scan文件位configure.in文件,并修改

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

AC_PREREQ([2.64])
AC_INIT([hello], [1.0], [kenter1643@gmail.com])
AM_INIT_AUTOMAKE(hello,1.0)
AC_CONFIG_SRCDIR([helloworld.c])
AC_CONFIG_HEADERS([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
/****************************************************************/

3.运行aclocal生存aclocal.m4文件
4.运行autoconf
5.运行autoheader
6.新建Makefile.am文件,编辑

/******************configure.in*********************************/
AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS=hello
hello_SOURCES=helloworld.c
/***************************************************************/

7.运行automake --add-missing生存configure文件
8.运行./configure
9.运行make
10.运行make install
11.测试输入hello输出hello kenter!表示成功