linux 源码编译 ./configure 的配置和用法
阅读目录
- 1. linux从源码编译到安装软件的3个步骤
- 2. ./configure 的配置和用法
- 基本配置
- 配置安装目录
- 微调安装目录
- 配置程序名称
- 配置系统类型
- 配置可选特性
- 配置包选项
- 配置编译环境变量
- 3. 综合示例
1. linux从源码编译到安装软件的3个步骤
./configure
make
make install
1)./configure:
configure是一个脚本,一般由Autoconf工具生成,它会检验当前的系统环境,看是否满足安装软件所必需的条件:比如当前系统是否支持待安装软件,是否已经安装软件依赖等。configure脚本最后会生成一个Makefile文件。
2)make
make是一个命令,它使用第1步得到的Makefile文件,如果只有"make"命令,而没有指明"目标",一般情况下是编译源码。
3)make install
make install表示运行"目标为install的make命令",即将编译后的结果复制到相应目录中。
2. ./configure 的配置和用法
每个configure脚本可配置参数都是不同的,具体可通过以下命令来查看:
./configure --help
下面以编译gdb-7.12.tar.gz为例,执行./configure --help
mayue6@Cpl-Ezviz-General-14-173:~/bulidspace/gdb-7.12-01/gdb-7.12/gdb$ ./configure --help
`configure' configures this package to adapt to many kinds of systems.Usage: ./configure [OPTION]... [VAR=VALUE]...To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE. See below for descriptions of some of the useful variables.Defaults for the options are specified in brackets.Configuration:-h, --help display this help and exit--help=short display options specific to this package--help=recursive display the short help of all the included packages-V, --version display version information and exit-q, --quiet, --silent do not print `checking...' messages--cache-file=FILE cache test results in FILE [disabled]-C, --config-cache alias for `--cache-file=config.cache'-n, --no-create do not create output files--srcdir=DIR find the sources in DIR [configure dir or `..']Installation directories:--prefix=PREFIX install architecture-independent files in PREFIX[/usr/local]--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX[PREFIX]By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc. You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.For better control, use the options below.Fine tuning of the installation directories:--bindir=DIR user executables [EPREFIX/bin]--sbindir=DIR system admin executables [EPREFIX/sbin]--libexecdir=DIR program executables [EPREFIX/libexec]--sysconfdir=DIR read-only single-machine data [PREFIX/etc]--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]--localstatedir=DIR modifiable single-machine data [PREFIX/var]--libdir=DIR object code libraries [EPREFIX/lib]--includedir=DIR C header files [PREFIX/include]--oldincludedir=DIR C header files for non-gcc [/usr/include]--datarootdir=DIR read-only arch.-independent data root [PREFIX/share]--datadir=DIR read-only architecture-independent data [DATAROOTDIR]--infodir=DIR info documentation [DATAROOTDIR/info]--localedir=DIR locale-dependent data [DATAROOTDIR/locale]--mandir=DIR man documentation [DATAROOTDIR/man]--docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE]--htmldir=DIR html documentation [DOCDIR]--dvidir=DIR dvi documentation [DOCDIR]--pdfdir=DIR pdf documentation [DOCDIR]--psdir=DIR ps documentation [DOCDIR]Program names:--program-prefix=PREFIX prepend PREFIX to installed program names--program-suffix=SUFFIX append SUFFIX to installed program names--program-transform-name=PROGRAM run sed PROGRAM on installed program namesX features:--x-includes=DIR X include files are in DIR--x-libraries=DIR X library files are in DIRSystem types:--build=BUILD configure for building on BUILD [guessed]--host=HOST cross-compile to build programs to run on HOST [BUILD]--target=TARGET configure for building compilers for TARGET [HOST]Optional Features:--disable-option-checking ignore unrecognized --enable/--with options--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)--enable-FEATURE[=ARG] include FEATURE [ARG=yes]--enable-maintainer-mode enable make rules and dependencies not useful(and sometimes confusing) to the casual installer--enable-plugins Enable support for plugins--disable-largefile omit support for large files--disable-build-with-cxxbuild with C compiler instead of C++ compiler--enable-targets=TARGETSalternative target configurations--enable-64-bit-bfd 64-bit support (on hosts with narrower word sizes)--disable-gdbcli disable command-line interface (CLI)--disable-gdbmi disable machine-interface (MI)--enable-tui enable full-screen terminal user interface (TUI)--enable-gdbtk enable gdbtk graphical user interface (GUI)--enable-profiling enable profiling of GDB--disable-rpath do not hardcode runtime library paths--enable-libmcheck Try linking with -lmcheck if available--enable-werror treat compile warnings as errors--enable-build-warnings enable build-time compiler warnings if gcc is used--enable-gdb-build-warningsenable GDB specific build-time compiler warnings ifgcc is used--enable-sim link gdb with simulator--enable-multi-ice build the multi-ice-gdb-server--enable-gdbserver automatically build gdbserver (yes/no/auto, defaultis auto)Optional Packages:--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)--with-separate-debug-dir=PATHlook for global separate debug info in this path[LIBDIR/debug]--with-gdb-datadir=PATH look for global separate data files in this path[DATADIR/gdb]--with-relocated-sources=PATHautomatically relocate this path for source files--with-auto-load-dir=PATHdirectories from which to load auto-loaded scripts[$debugdir:$datadir/auto-load]--with-auto-load-safe-path=PATHdirectories safe to hold auto-loaded files[--with-auto-load-dir]--without-auto-load-safe-pathdo not restrict auto-loaded files locations--with-libunwind-ia64 use libunwind frame unwinding for ia64 targets--with-curses use the curses library instead of the termcaplibrary--with-pkgversion=PKG Use PKG in the version string in place of "GDB"--with-bugurl=URL Direct users to URL to report a bug--with-system-zlib use installed libz--with-gnu-ld assume the C compiler uses GNU ld default=no--with-libiconv-prefix[=DIR] search for libiconv in DIR/include and DIR/lib--without-libiconv-prefix don't search for libiconv in includedir and libdir--with-iconv-bin=PATH specify where to find the iconv program--with-system-readline use installed readline library--with-jit-reader-dir=PATHdirectory to load the JIT readers from--with-expat include expat support (auto/yes/no)--with-libexpat-prefix[=DIR] search for libexpat in DIR/include and DIR/lib--without-libexpat-prefix don't search for libexpat in includedir and libdir--with-python[=PYTHON] include python support(auto/yes/no/<python-program>)--with-guile[=GUILE] include guile support(auto/yes/no/<guile-version>/<pkg-config-program>)--with-intel-pt include Intel Processor Trace support (auto/yes/no)--with-libipt-prefix[=DIR] search for libipt in DIR/include and DIR/lib--without-libipt-prefix don't search for libipt in includedir and libdir--without-included-regexdon't use included regex; this is the default onsystems with version 2 of the GNU C library (usewith caution on other system)--with-sysroot[=DIR] search for usr/lib et al within DIR--with-system-gdbinit=PATHautomatically load a system-wide gdbinit file--with-lzma support lzma compression (auto/yes/no)--with-liblzma-prefix[=DIR] search for liblzma in DIR/include and DIR/lib--without-liblzma-prefix don't search for liblzma in includedir and libdir--with-tcl directory containing tcl configuration (tclConfig.sh)--with-tk directory containing tk configuration (tkConfig.sh)--with-x use the X Window System--with-babeltrace include babeltrace support (auto/yes/no)--with-libbabeltrace-prefix[=DIR] search for libbabeltrace in DIR/include and DIR/lib--without-libbabeltrace-prefix don't search for libbabeltrace in includedir and libdirSome influential environment variables:CC C compiler commandCFLAGS C compiler flagsLDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in anonstandard directory <lib dir>LIBS libraries to pass to the linker, e.g. -l<library>CPPFLAGS C/C++/Objective C preprocessor flags, e.g. -I<include dir> ifyou have headers in a nonstandard directory <include dir>CXX C++ compiler commandCXXFLAGS C++ compiler flagsCPP C preprocessorMAKEINFO Parent configure detects if it is of sufficient version.MAKEINFOFLAGSParameters for MAKEINFO.YACC The `Yet Another C Compiler' implementation to use. Defaults tothe first program found out of: `bison -y', `byacc', `yacc'.YFLAGS The list of arguments that will be passed by default to $YACC.This script will default YFLAGS to the empty string to avoid adefault value of `-d' given by some make applications.XMKMF Path to xmkmf, Makefile generator for X Window SystemUse these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.Report bugs to the package provider.
基本配置
Configuration:-h, --help display this help and exit……
-h 或 --help
输出帮助信息。即使是有经验的用户也偶尔需要使用使用’–help’选项,因为一个复杂的项目会包含附加的选项。例如,GCC包里的’configure’脚本就包含了允许你控制是否生成和在GCC中使用GNU汇编器的选项。
-V 或 --version
打印用来产生’configure’脚本的Autoconf的版本号。
配置安装目录
Installation directories:--prefix=PREFIX install architecture-independent files in PREFIX[/usr/local]--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX[PREFIX]
--prefix=PREFIX
指定程序包的安装目录,示例./configure --prefix="$PWD/install"
--exec-prefix=EPREFIX
与’–prefix’选项类似,但是他是用来设置结构倚赖的文件的安装位置.编译好的’emacs’二进制文件就是这样一个文件.如果没有设置这个选项的话,默认使用的选项值将被设为和’–prefix’选项值一样.
微调安装目录
Fine tuning of the installation directories:--bindir=DIR user executables [EPREFIX/bin]--sbindir=DIR system admin executables [EPREFIX/sbin]……
--bindir=DIR
指定二进制文件的安装位置,这里的二进制文件定义为可以被用户直接执行的程序。
--sbindir=DIR
指定超级二进制文件的安装位置.这是一些通常只能由超级用户执行的程序。
--libexecdir=DIR
指定可执行支持文件的安装位置。与二进制文件相反,这些文件从来不直接由用户执行,但是可以被上面提到的二进制文件所执行。
--datadir=DIR
指定通用数据文件的安装位置。
--libdir=DIR
指定库文件的安装位置。
--includedir=DIR
指定为除GCC外编译器安装的C头文件的安装位置。
--infodir=DIR
指定Info格式文档的安装位置.Info是被GNU工程所使用的文档格式。
--mandir=DIR
指定手册页的安装位置。
--srcdir=DIR
这个选项对安装没有作用,他会告诉’configure’源码的位置。一般来说不用指定此选项,因为’configure’脚本一般和源码文件在同一个目录下。
配置程序名称
Program names:--program-prefix=PREFIX prepend PREFIX to installed program names--program-suffix=SUFFIX append SUFFIX to installed program names--program-transform-name=PROGRAM run sed PROGRAM on installed program names
--program-prefix=my
在生成的可执行文件前加前缀my,例如,使用’–program-prefix=g’来configure一个名为’tar’的程序将会使安装的程序被命名为’gtar’。当和其他的安装选项一起使用时,这个选项只有当他被`Makefile.in’文件使用时才会工作。
--program-suffix=suffix
在生成的可执行文件上加后缀suffix。
--program-transform-name=program
将可执行文件的名字设置为program,例如,假设生成的默认可执行文件的名字为hello,执行
./configure --program-prefix=test- && make && make install
则生成名字为test-hello的可执行文件。
配置系统类型
System types:--build=BUILD configure for building on BUILD [guessed]--host=HOST cross-compile to build programs to run on HOST [BUILD]--target=TARGET configure for building compilers for TARGET [HOST]
--build=BUILD
指定软件包安装的系统平台。如果没有指定,默认值将是’–host’选项的值。
--host=HOST
指定软件运行的系统平台。如果没有指定。将会运行`config.guess’来检测。
--target=GARGET
指定软件面向(target to)的系统平台。这主要在程序语言工具如编译器和汇编器上下文中起作用。如果没有指定,默认将使用’–host’选项的值。
示例:
./configure --target=mipsel-linux --host=mipsel-linux
详细用法参考:https://blog.csdn.net/mayue_web/article/details/103987915
配置可选特性
Optional Features:--disable-option-checking ignore unrecognized --enable/--with options……
--enable-werror
将编译警告视为错误。
配置包选项
Optional Packages:--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)……
–with-PACKAGE[=ARG]
在自由软件社区里,有使用已有软件包和库的优秀传统。当用’configure’来配置一个源码树时,可以提供其他已经安装的软件包的信息。例如,倚赖于Tcl和Tk的BLT器件工具包。要配置BLT,可能需要给’configure’提供一些关于我们把Tcl和Tk装的何处的信息:
./configure --with-tcl=/usr/local --with-tk=/usr/local
‘–with-PACKAGE=no’与下面将提到的’–without-PACKAGE’是同义的。
--without-PACKAGE
有时候你可能不想让你的软件包与系统已有的软件包交互。例如,你可能不想让你的新编译器使用GNU ld。通过使用这个选项可以做到这一点:
./configure --without-gnu-ld
配置编译环境变量
Some influential environment variables:CC C compiler commandCFLAGS C compiler flags……
CC=
.c文件的编译命令,示例CC=/usr/bin/mipsel-linux-gcc
CFLAGS=
.c文件的编译选项,示例CFLAGS="-g -O2 -I/home/mayue/bulidspace/termcap-1.3.1/install/include"
LDFLAGS=
链接选项,示例LDFLAGS="-L/home/mayue/bulidspace/termcap-1.3.1/install/lib"
LIBS=
链接库,示例LIBS="-lpthread"
CPPFLAGS=
C/C++文件预处理选项,示例
CXX=
c++文件的编译命令,示例CXX=/usr/bin/mipsel-linux-g++
CXXFLAGS=
c++文件的编译选项,示例
CPP=
C预处理器,示例
3. 综合示例
示例1:
./configure CC=/usr/bin/mipsel-linux-gcc --host=mipsel-linux --target=mipsel-linux --program-prefix=mipsel-linux --prefix=/home/mayue/bulidspace/termcap-1.3.1/install
示例2:
./configure CC=/usr/bin/mipsel-linux-gcc --enable-static CFLAGS="-g -O2 -I/home/mayue/bulidspace/termcap-1.3.1/install/include" LDFLAGS="-L/home/mayue/bulidspace/termcap-1.3.1/install/lib" --prefix=/home/mayue/bulidspace/gdb-7.6.1/install/mipsel --target=mipsel-linux --host=mipsel-linux --program-prefix=mipsel-linux-
示例3
./configure --host=x86_64-linux-gnu --target=mipsel-linux --prefix="$PWD/install"
参考资料
https://jingyan.baidu.com/article/86112f1382da1e27379787ed.html
https://blog.csdn.net/dslztx/article/details/49079303
https://www.cnblogs.com/zl-graduate/articles/6600742.html
https://www.jianshu.com/p/0d64954eb9bc
linux 源码编译 ./configure 的配置和用法相关推荐
- linux源码编译安装apache( httpd-2.4.53)处理服务器支持 TLS Client-initiated 重协商攻击(CVE-2011-1473)
linux源码编译安装apache 首先我们需要下载相关的依赖包 apr.apr-util.pcre 下载地址 http://archive.apache.org/dist/apr/apr-1.7.0 ...
- linux源码编译-安装postgresql数据库(中标麒麟+龙芯CPU)
linux源码编译-安装postgresql数据库(中标麒麟+龙芯CPU) 一.查看yum源中pgsql版本 二.安装readline-devel 三.下载pgsql库的源码 四.解压下载的源码.co ...
- Linux源码编译(一):从头文件说起
Linux源码编译(一):从头文件说起 2013-04-10 14:37:24 分类: LINUX 在Linux体系结构章节中,主要让大家对Linux结构层次有一定的了解,没有过多的长篇大论,力求简结 ...
- Linux源码编译-编译哪些设备树
Linux源码编译-编译哪些设备树 Fang XS. 1452512966@qq.com 如果有错误,希望被指出 编译内核过程中编译了那些设备树文件 编译源码前都会make xxxdefconfig ...
- CentOS 7上源码编译安装和配置LNMP Web+phpMyAdmin服务器环境
什么是LNMP? LNMP(别名LEMP)是指由Linux, Nginx, MySQL/MariaDB, PHP/Perl/Python组合成的动态Web应用程序和服务器,它是一组Web应用程序的基础 ...
- Linux 源码编译安装过程-以安装XZ解压为例
一.描述 Linux安装软件一般有两种安装方式:安装包安装和源码安装. 1.安装包安装.安装包安装比较简单,例如采用apt-get install +软件名 命令,安装 deb 包的 Linux 操 ...
- Spark入门教程(二)Spark2.2源码编译及安装配置
Spark2.2源码下载 点此进入官网下载地址: 下载Spark spark官网下载截图 //下载好后用传输工具传输到我们的linux上并解压缩 tar -zxvf spark-2.2.0.tgz 源 ...
- MySQL5.7.17源码编译安装与配置
一.下载MySQL源码 官网: http://www.mysql.com 下载下来的文件为:mysql-boost-5.7.17.tar.gz 二.解压源码,准备环境 [root@server1 so ...
- Linux源码编译安装步骤及命令
源码编译安装过程 RPM包:rpm -ivh yum install 源码包----开发工具---->可以执行的程序----->运行安装 • 主要优点 – 获得软件的最新版,及时修复bug ...
最新文章
- 编程以外积累: 如何给项目生成类似VS2008的说明文档
- linux ip -o,linux IP 命令使用举例
- 达摩java_JAVA面向对象
- 单片机编程遇到'DATA' SEGMENT TOO LARGE怎么解决?
- 小师妹学IO系列文章集合-附PDF下载
- Mysql-my-innodb-heavy-4G.cnf配置文件注解
- Knapsack Cryptosystem【折半+查找】
- cocos2dx 屏幕适配
- Python: 自定义类对象序列化为Json串
- 19.Linux/Unix 系统编程手册(上) -- 监控文件事件
- STL---vector的内存分配策略
- 考不上本科是智商问题,这话有错吗?
- illustrative visualization思考
- Android之解决太大太多图片造成的oom
- Linux系统GCC常用命令和GCC编译过程描述
- windows server 2012 r2 *** 服务器搭建
- 计算机网络与通讯教案,计算机网络技术教案.docx
- CentOS 安装Kerberos服务
- C语言如何做出简易贪食蛇
- php三元运算符要多个赋值,php中三元运算符用法
热门文章
- HTML期末大作业: 学生个人网页设计作品 学生个人网页模板 简单个人主页成品 个人网页制作 HTML学生个人网站作业设计代做...
- K-SVD简述——字典学习,稀疏编码
- Wattagio for Mac(Mac电池管理软件)v1.12.11
- 小程序 底部按钮兼容 iPhone X(解决底部横杠遮挡问题)
- 【Soul】用户运营策略分析报告
- 刚发布!新型病毒下,程序员可在家免费学习了!
- 灰鸽子--木马、后门实验
- 再聊聊Linux IO
- 怎么把.txt转换成html,怎么把txt转换成HTML
- C#学习笔记之匿名方法