目录html
详细介绍ios
准备工做:c++
3、实例ubuntu
2.操做步骤vim
(2)autoscanthis
(3)aclocalspa
autoscan: 扫描源代码以搜寻普通的可移植性问题,好比检查编译器,库,头文件等,生成文件configure.scan,它是configure.ac的一个雏形。
aclocal:根据已经安装的宏,用户定义宏和acinclude.m4文件中的宏将configure.ac文件所须要的宏集中定义到文件 aclocal.m4中。aclocal是一个perl 脚本程序,它的定义是:“aclocal - create aclocal.m4 by scanning configure.ac”
automake:将Makefile.am中定义的结构创建Makefile.in,而后configure脚本将生成的Makefile.in文件转换 为Makefile。若是在configure.ac中定义了一些特殊的宏,好比AC_PROG_LIBTOOL,它会调用libtoolize,不然它 会本身产生config.guess和config.sub
autoconf:将configure.ac中的宏展开,生成configure脚本。这个过程可能要用到aclocal.m4中定义的宏。
安装autoscan,
sudo apt-get install automake
个人文件是c++文件,这里建立一个hello.cpp文件,里面的内容以下:
#include <iostream> using namespace std; int main() { cout<<"hello word"<<endl; return 0; }
ubuntu@ubuntu:~/Documents/project/autotest$ sudo apt-get install automake^C automake包括:aclocal、automake等 autoconf包括:autoscan、autoconf等
将生成的configure.scan修改成configure.ac或configure.in,先修改configure.ac里面的内容,再进行aclocal的执行;
ubuntu@ubuntu:~/Documents/project/autotest$ vim configure.ac
这里尤为要注意下面红色的代码,须要填对
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
AC_INIT([hello], [1.0], [1583769112@qq.com])
AM_INIT_AUTOMAKE(hello,1.0)
AC_CONFIG_SRCDIR([hello.cpp])
AC_CONFIG_HEADERS([config.h])
# Checks for programs.
AC_PROG_CXX
# Checks for libraries.
# Checks for header files.
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_OUTPUT(Makefile)
下面就是执行aclocal
ubuntu@ubuntu:~/Documents/project/autotest$ aclocal
下面详细介绍 configure.ac 文件的参数的意义
此时能够看到已经生成了configure
autoheader生成了configure.h.in若是在configure.ac中定义了AC_CONFIG_HEADER,那么此文件就须要;
这里主要是修改Makefile.am文件
ubuntu@ubuntu:~/Documents/project/autotest$ vim Makefile.am ubuntu@ubuntu:~/Documents/project/autotest$ cat Makefile.am AUTOMAKE_OPTIONS=foreign bin_PROGRAMS=hello hello_SOURCES=hello.cpp
若是linux第一次使用automake这里容易出问题,以下出现了下面的问题:
configure.ac:7: installing './install-sh'
configure.ac:7: installing './missing'
其实这个经过这个命令automake --add-missing已经安装了,可是把错误打印了,给咱们的感受是仍是有错误,此时只须要在执行一遍该命令便可。
此步主要是为了生成Makefile.in,加上--add-missing参数后,会补全缺乏的脚本;
ubuntu@ubuntu:~/Documents/project/autotest$ ./configure ubuntu@ubuntu:~/Documents/project/autotest$ make ubuntu@ubuntu:~/Documents/project/autotest$ ./hello
和平时安装许多开源软件同样操做
ubuntu@ubuntu:~/Documents/project/autotest$ make dist
执行后会发现一个安装包,这时候发给别人,解压编译便可运行了。