autoconfig,automake 编译project

autoconfig,automake编译project

编辑文件:

helloworld.c

configure.ac

Makefile.am

创建过程:

autoscan; aclocal; autocconf; automake --add-missing; ./configure ; make

下面给出helloworld 的例子

  1. $cat helloworld.c
#include <stdio.h>
int main()
{
    printf("hello world\n");
    return 0;
}
  1. configure.ac 的编写

autoscan ;

cp configure.scan configure.ac ;

vim configure.ac

configure.ac 主要是定义一些宏
其中AM_INIT_AUTOMAKE是需要手动添加的

$cat configure.ac

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

AC_PREREQ([2.69])
AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS])
AC_CONFIG_SRCDIR([main.c])
AM_INIT_AUTOMAKE
#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

其中AM_INIT_AUTOMAKE, AC_CONFIG_FILES([Makefile])是手工添加的, 意思是configure 配置中要生成Makefile

  1. aclocal

aclocal; 是一个perl脚本, 以configure.ac 为输入,生成aclocal.m4 及autom4te.cache 目录

  1. autoconf

autoconf 是一个shell脚本, 它以configure.ac为输入, 输出configre 脚本文件.

  1. 编辑Makefile.am

cat Makefile.am

AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS=hello
hello_SOURCES=main.c
  1. 运行automake --addmissing

可以简单的写为: automake -a
添加一些必要的软链接,同时生成makefile.in

  1. 运行./configure 生成Makefile

  2. 执行make 生成执行文件

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值