快速使用automake

1.hello.c

#include <stdio.h>  
#include <sys/time.h>  
#include <time.h>  
  
#include "config.h"  
double get_epoch()  
{  
    double sec;  
  
    #ifdef HAVE_GETTIMEOFDAY  
        struct timeval tv;  
        gettimeofday(&tv, NULL);  
        sec = tv.tv_sec;  
        sec += tv.tv_usec / 1000000.0;  
    #else  
        sec = time(NULL);  
    #endif  
  
    return sec;  
}  
  
int main(int argc, char* argv[])  
{  
    printf("%f\n", get_epoch());  
  
    return 0;  
}  


2.编写Makefile.am

AUTOMAKE_OPTIONS = foreign   
INCLUDES=
bin_PROGRAMS = hello  
hello_SOURCES=gettime.c
hello_CFLAGS=-Wall -g
hello_LDADD=

3. autoscan之后生成configre.scan重命名为configure.in伙configure.ac,之后修改文件加上AM_INIT_AUTOMAKE(hello,1.1)。

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

AC_PREREQ([2.66])
AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS])
AC_CONFIG_SRCDIR([gettime.c])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE(hello,1.1)
# Checks for programs.
AC_PROG_CC

# Checks for libraries.

# Checks for header files.
AC_CHECK_HEADERS([sys/time.h])

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.
AC_CHECK_FUNCS([gettimeofday])

AC_CONFIG_FILES([Makefile])
AC_OUTPUT

4.acloacl

5.autoconf

6.autoheader

7.automake --add-missing

8.../configure

9.make

10.运行hellio


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

会飞的幸运儿

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值