使用autotool工具自动生成 Makefile

  1. 1、准备  
  2.     $ cd /tmp  
  3.     $ mkdir hello  
  4.     $ mkdir src  
  5.     $ cd src  
  6.     $ vim hello.c  
  7.         #include <stdio.h>  
  8.   
  9.         int main(int argc, char *argv[])  
  10.         {  
  11.             printf("Hello, World!\n");  
  12.       
  13.             return 0;  
  14.         }  
  15.           
  16.     $ vim Makefile.am  
  17.         AUTOMAKE_OPTIONS=foreign  
  18.         AM_CFLAGS =\  
  19.                    -Wall\  
  20.                    -g  
  21.   
  22.         bin_PROGRAMS = hello  
  23.         hello_SOURCES = hello.c  
  24.           
  25.     $ cd /tmp/hello  
  26.     $ vim Makefile.am  
  27.         AUTOMAKE_OPTIONS=foreign  
  28.         SUBDIRS=src  
  29.       
  30. 2、autoscan  
  31.     $ autoscan  
  32.     $ mv configure.scan configure.in  
  33.     modify configure.in  
  34.         #                                               -*- Autoconf -*-  
  35.         # Process this file with autoconf to produce a configure script.  
  36.   
  37.         AC_PREREQ([2.67])  
  38.         AC_INIT([hello], [1.0], [sunsea1026@gmail.com])  
  39.         AC_CONFIG_SRCDIR([src/hello.c])  
  40.         AC_CONFIG_HEADERS([config.h])  
  41.         AM_INIT_AUTOMAKE(hello, 1.0)  
  42.   
  43.         # Checks for programs.  
  44.         AC_PROG_CC  
  45.   
  46.         # Checks for libraries.  
  47.   
  48.         # Checks for header files.  
  49.   
  50.         # Checks for typedefs, structures, and compiler characteristics.  
  51.   
  52.         # Checks for library functions.  
  53.   
  54.         AC_CONFIG_FILES([Makefile  
  55.                         src/Makefile])  
  56.         AC_OUTPUT  
  57.           
  58. 3、aclocal  
  59.     $ aclocal  
  60.       
  61. 4、autoconf  
  62.     $ autoconf  
  63.       
  64. 5、autoheader  
  65.     $ autoheader  
  66.   
  67. 6、automake  
  68.     $ automake --add-missing  
  69.   
  70. 7、./configure  
  71.     $ ./configure  
  72.   
  73. 8、make  
  74.     $ make  
  75.   
  76. 9、run  
  77.     $ ./src/hello 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值