linux 下通过源代码安装程序 ./configure 解释
来源:互联网 发布:johnny cash知乎 编辑:程序博客网 时间:2024/06/04 18:07
大家 都知道在 linux 通过源代码 安装程序
1. 下载源码
2.解压缩
3. 执行 ./configure
4. make
5 make install
make 命令 是对 makefile 文件 操作,make install 是安装命令,那么 ./configure 是 干什么呢?
./configure 其实 就是 生成 makefile 文件
生成 makefile 主要通过 autoscan,aclocal,automake,autoconf 命令 ,这些命令 属于 libtool 。
安装 libtool : yum install libtool -y;
转载自 :http://blog.sina.com.cn/s/blog_530e99a401013tqj.html
https://www.ibm.com/developerworks/cn/linux/l-makefile/
在本文中,将给大家介绍如何使用
编译一个简单的源文件main.c,需要自动生成一个makefile,以下是步骤:
第一步:
----------
在/root/project/main目录下创建一个文件main.c,其内容如下:
------------------------------------------------
#include
int main(int argc, char** argv)
{
printf("Hello, Auto Makefile!\n");
return 0;
}
------------------------------------------------
此时状态如下:
[root@localhost
/root/project/main
[root@localhost
main.c
[root@localhost
第二步:
----------
运行
此时状态如下:
[root@localhost
[root@localhost
autoscan.log configure.scan
[root@localhost
第三步:
----------
修改configure.scan的文件名为configure.in
查看configure.in的内容:
------------------------------------------------
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.61)
AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
AC_CONFIG_SRCDIR([main.c])
AC_CONFIG_HEADER([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:
# 确保使用的是足够新的Autoconf版本。如果用于创建configure的Autoconf的版
# 本比version 要早,就在标准错误输出打印一条错误消息并不会创建configure。
AC_PREREQ(2.61)
#
# 初始化,定义软件的基本信息,包括设置包的全称,版本号以及报告BUG时需要用的邮箱地址
#
AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
#
# 用来侦测所指定的源码文件是否存在,来确定源码目录的有效性
#
AC_CONFIG_SRCDIR([main.c])
#
# 用于生成config.h文件,以便autoheader使用
#
AC_CONFIG_HEADER([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.
#
# 创建输出文件。在`configure.in'的末尾调用本宏一次。
#
AC_OUTPUT
------------------------------------------------
修改动作:
1.修改AC_INIT里面的参数: AC_INIT(main,1.0, pgpxc@163.com)
2.添加宏AM_INIT_AUTOMAKE, 它是automake所必备的宏,也同前面一样,PACKAGE是所要产生软件套件的名称,VERSION是版本编号。
3.在AC_OUTPUT后添加输出文件Makefile
修改后的结果:
------------------------------------------------
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.61)
AC_INIT(main, 1.0, pgpxc@163.com)
AC_CONFIG_SRCDIR([main.c])
AC_CONFIG_HEADER([config.h])
AM_INIT_AUTOMAKE(main,1.0)
# 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([Makefile])
------------------------------------------------
第四步:
运行
此时的状态是:
[root@localhost
[root@localhost
aclocal.m4 autom4te.cache
[root@localhost
第五步:
运行
此时的状态是:
[root@localhost
[root@localhost
aclocal.m4 autoscan.log configure.in main.c
autom4te.cache
[root@localhost
第六步:
运行
此时的状态是:
[root@localhost
[root@localhost
aclocal.m4 autoscan.log configure configure.in~
autom4te.cache
[root@localhost
第七步:
下面即将运行
首先
创建一个
这个Makefile.am的内容如下:
------------------------------------------------
AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS=main
main_SOURCES=main.c
------------------------------------------------
下面对该脚本文件的对应项进行解释。
其中的AUTOMAKE_OPTIONS为设置automake的选项。由于GNU(在第1章中已经有所介绍)对自己发布的软件有严格的规范,比如 必须附 带许可证声明文件COPYING等,否则automake执行时会报错。automake提供了三种软件等级:foreign、gnu和gnits,让用 户选择采用,默认等级为gnu。在本例使用foreign等级,它只检测必须的文件。
bin_PROGRAMS定义要产生的执行文件名。如果要产生多个执行文件,每个文件名用空格隔开。
main_SOURCES定义“main”这个执行程序所需要的原始文件。如果”main”这个程序是由多个原始文件所产生的,则必须把它所用到的 所有原 始文件都列出来,并用空格隔开。例如:若目标体“main”需要“main.c”、“sunq.c”、“main.h”三个依赖文件,则定义 main_SOURCES=main.c sunq.c main.h。要注意的是,如果要定义多个执行文件,则对每个执行程序都要定义相应的file_SOURCES。
其次
使用automake对其生成“configure.in”文件,在这里使用选项“—adding-missing”可以让automake自动添加有一些必需的脚本文件。
运行后的状态是:
------------------------------------------------
[root@localhost
configure.in:8: installing `./missing'
configure.in:8: installing `./install-sh'
Makefile.am: installing `./depcomp'
[root@localhost
aclocal.m4 config.h.in configure.in~ main.c Makefile.in
autom4te.cache configure
autoscan.log configure.in
[root@localhost
------------------------------------------------
第八步
运行configure,在这一步中,通过运行自动配置设置文件configure,把Makefile.in变成了最终的Makefile。
运行的结果如下:
------------------------------------------------
[root@localhost
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: executing depfiles commands
[root@localhost
aclocal.m4 config.h.in configure.in main.c Makefile.in
autom4te.cache config.log configure.in~ Makefile
autoscan.log config.status
config.h
[root@localhost
------------------------------------------------
第九步
运行
此时的状态如下:
------------------------------------------------
[root@localhost
cd . && /bin/sh /root/project/main/missing --run aclocal-1.10
cd . && /bin/sh /root/project/main/missing --run automake-1.10 --foreign
cd . && /bin/sh /root/project/main/missing --run autoconf
/bin/sh ./config.status --recheck
running CONFIG_SHELL=/bin/sh /bin/sh ./configure --no-create --no-recursion
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking for gcc... gcc
checking for C compiler default output file name... a.out
checking whether the C compiler works... yes
checking whether we are cross compiling... no
checking for suffix of executables...
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for style of include used by make... GNU
checking dependency style of gcc... gcc3
configure: creating ./config.status
/bin/sh ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing depfiles commands
cd . && /bin/sh /root/project/main/missing --run autoheader
rm -f stamp-h1
touch config.h.in
make all-am
make[1]: Entering directory `/root/project/main'
gcc -DHAVE_CONFIG_H -I. -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o main.c
mv -f .deps/main.Tpo .deps/main.Po
gcc -g -O2 -o main main.o
cd . && /bin/sh ./config.status config.h
config.status: creating config.h
config.status: config.h is unchanged
make[1]: Leaving directory `/root/project/main'
[root@localhost
aclocal.m4 autoscan.log config.h.in config.status configure.in depcomp
autom4te.cache config.h config.log configure configure.in~ install-sh main.c Makefile Makefile.am~ missing
[root@localhost
------------------------------------------------
第十步
运行生成的文件 main:
------------------------------------------------
[root@localhost
Hello, Auto Makefile!
[root@localhost
------------------------------------------------
我用的是ubuntu
- linux 下通过源代码安装程序 ./configure 解释
- linux下通过源代码包编译安装程序
- Linux下通过源码编译安装程序(configure/make/make install的作用 )
- Linux下通过源码编译安装程序
- Linux下通过源码编译安装程序
- Linux configure 参数解释
- Linux configure 参数解释
- Linux configure 参数解释
- Linux configure 参数解释
- Linux configure参数解释
- linux configure参数解释
- linux configure 参数解释
- Linux configure 参数解释
- Linux configure 参数解释
- Linux configure 参数解释
- Linux configure 参数解释
- Linux configure 参数解释
- Linux configure 参数解释
- RCNN学习笔记(3):Spatial Pyramid Pooling in Deep Convolutional Networks for Visual Recognition(SPP-net)
- easyui需要的数据,后台怎样封装
- .Net WebSocket学习之旅(二)Signalr
- 关于Java方法参数的传递问题
- C#学习笔记:GDI图形高级编程(1)——如何将图形画到控件上
- linux 下通过源代码安装程序 ./configure 解释
- fastjson解析null值处理 null的属性不显示
- Data guard、双机热备、RAC
- 极光推送
- 基于maven的spring+springMvc+MyBatis+Dubbo架构的搭建
- Java中配置连接池
- app升级策略
- opencv3.0 批量读取图片并裁剪到指定大小
- 安卓学习笔记---Android检测网络状态,判断当前网络是否可用