linux自动编译工具automake说明

1.工具简单介绍

工具名称
用途
输入
输出
 说明
autoscan
扫描目录下文件
-
configure.scan

aclocal
生成aclocal.m4
configure.scan->configure.ac
并编辑configure.ac增加部分内容

configure.ac 一般增加AM_INIT_AUTOMAKE([helloworld],1.0) 为可选
automake
根据Makefile.am生成Makefile.in
Makefile.am(手动创建)
Makefile.in
一般使用增加选项--add-missing
autoconf
生成configure
configure.ac
aclocal.m4
configure


引用张旧图:
  图中configure.in更新为configure.ac

2.编译步骤

step1.手动创建源文件:
helloworld.c
#include <stdio.h>

int main(int argc, char** argv)
{
printf("Hello, Linux World!\n");
return 0;
}

step1.autoscan
自动生成 configure.scan
结果:
autoscan.log  configure.scan  helloworld.c

autoscan.log为空文件:
configure.scan
#                                               -*- 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([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_OUTPUT
step2.手动编辑configure.scan
#                                               -*- 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([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_OUTPUT

step3.执行aclocal
结果:
autom4te.cache  autoscan.log  configure.ac  helloworld.c

step4.手动创建Makefile.am
AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS= helloworld
helloworld _SOURCES= helloworld.c

step5.执行automake --add-missing
aclocal.m4  autom4te.cache  autoscan.log  configure.ac  depcomp  helloworld.c  install-sh  Makefile.am  Makefile.in  missing

step6.执行autoconf:
aclocal.m4  autom4te.cache  autoscan.log  configure  configure.ac  depcomp  helloworld.c  install-sh  Makefile.am  Makefile.in  missing

step7.执行./configure
aclocal.m4      autoscan.log  config.status  configure.ac  helloworld.c  Makefile     Makefile.in
autom4te.cache  config.log    configure      depcomp       install-sh    Makefile.am  missing

step8.执行make
aclocal.m4      autoscan.log  config.status  configure.ac  helloworld    helloworld.o  Makefile     Makefile.in
autom4te.cache  config.log    configure      depcomp       helloworld.c  install-sh    Makefile.am  missing

--end--

3.参考:

  • 整体说明:
自动生成 Makefile 的全过程详解  (比较老得,只能参考,了解原理)

  • autoconf-automake说明:

  • 报错解决:

  • 详细说明,涉及各种参数
gnu automake:


猜你喜欢

转载自blog.csdn.net/saturn254/article/details/80967783