使用autotools工具制作Makefile过程可能出现问题与解决方式

来源:互联网 发布:linux 更改文件夹权限 编辑:程序博客网 时间:2024/05/06 22:11
  1. 首先是新建一个目录,例如:#mkdir automake
  2. 然后就进入这个目录,并且建立一个.c文件。例如:#cd automake

vim hello.c 建立一个代码如下所示:

#include "stdio.h"int main(){        printf("hello,welcome to linux!");}

 

     3. 运行命令,#autoscan。然后就ls下就有如下文件autoscan.log  configure.scan  hello.

     如果现在直接运行命令:#aclocal  就会出现以下提示错误:  aclocal: `configure.ac' or `configure.in' is required
     出现这个错误原因是:缺少提示两个文件

    解决方式:就是把configure.scan改名为configure.in

    4.此刻如果运行#aclocal 会生产configure文件

    5. 运行 #autoconf 后会生产很多文件,但是缺少后缀为.m4文件,后面就会出错,无法编译出makefile相关文件

    原因:前面没有修改configure.in 文件内容或者依赖项

    解决问题就是修改configure内容:

原来内容如下所示:

#                                               -*- Autoconf -*-# Process this file with autoconf to produce a configure script.AC_PREREQ([2.63])AC_INIT([FULL-PACKAGE-NAME], [VERSION], [BUG-REPORT-ADDRESS])AC_CONFIG_SRCDIR([hello.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_OUTPUT

修改后内容:

#                                               -*- Autoconf -*-# Process this file with autoconf to produce a configure script.AC_PREREQ([2.63])AC_INIT(hello,1.0)AM_CONFIG_SRCDUR(hello, 1.0)AC_CONFIG_SRCDIR([hello.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