|
前言GNU autotools 是一系列編程工具,可以輔助產(chǎn)生 Makefile,方便編譯整個工程項目。它是自由軟件基金會發(fā)起的GNU計劃的其中一項,作為GNU建構(gòu)系統(tǒng)的一部分。autotools 所產(chǎn)生的 Makefile 符合GNU編程標準。
使用過開源 C/C++ 項目的同學(xué)們都知道,標準的編譯過程已經(jīng)變成了簡單的三部曲:configure/make/make install, 使用起來很方便,不像平時自己寫代碼,要手寫一堆復(fù)雜的 Makefile,而且換個編譯環(huán)境,Makefile 還需要修改。
Makefile 帶來的最大好處就是 “自動化編譯”,一但編輯好文件,只需要一個 make 命令,整個工程完全自動編譯,極大的提高了軟件開發(fā)的效率。
如果工程項目比較小,那么可以直接手動編輯該文件;不過一但工程項目比較大時,手動維護將變得極其復(fù)雜,為此,就可以使用 Autotools 或者 CMake 生成 Makefile 文件。本文主要講解 Autotools 生成Makefile 的方法。
一、Autotools構(gòu)成首先安裝autoTools工具集,Centos下可以使用如下命令在線安裝:
yum install autoconf automake libtool
autotools包含以下工具:
aclocal:perl 腳本程序,根據(jù)已經(jīng)安裝的宏、用戶定義宏和acinclude.m4文件中的宏將configure.ac文件所需要的宏集中定義到文件 aclocal.m4中;autoscan:autoconf的輔助命令,掃描源代碼以搜尋普通的可移植性問題,比如檢查編譯器、庫、頭文件等,生成configure.scan,最終生成 configure.ac;autoheader: autoconf的輔助命令,用于生成configure的模板頭文件config.h.in;autoconf:基于configure.ac生成configure,需依賴 m4;automake:基于Makefile.am和configure.ac生成Makefile,需依賴perl。libtool:創(chuàng)建和使用可移植的共享(動態(tài)鏈接)庫。二、構(gòu)建流程使用Autotools生成Makefile的流程總結(jié)如下:在源代碼的頂層目錄下執(zhí)行 autoscan 命令生成 configure.scan 文件。將 configure.scan 文件改名為 configure.ac(或configure.in),并對其默認配置進行修改。執(zhí)行 aclocal、autoconf、autoheader 三個命令,分別生成 aclocal.m4、configure 、config.h.in文件。在每個目錄下創(chuàng)建一個名為 Makefile.am 的文件,并輸入相應(yīng)的內(nèi)容。執(zhí)行 automake --add-missing,它根據(jù) Makefile.am 文件,生成 Makefile.in。(ps 此步驟只能在 aclocal、autoconf之后)執(zhí)行 ./configure 腳本文件,它根據(jù) Makefile.in 文件,生成最終的 Makefile 文件。生成 Makefile 之后,執(zhí)行make編譯工程并且生成可執(zhí)行程序。
[/ol]根據(jù)上述流程,整理autotools自動構(gòu)建流程圖如下:
ueweu0mf2gv6407611505.jpg (169 KB, 下載次數(shù): 0)
下載附件
保存到相冊
ueweu0mf2gv6407611505.jpg
2024-11-22 06:41 上傳
看到這里,你可能只是對于使用 autotools 創(chuàng)建 Makefile 的步驟有了一個模糊的認識,正所謂:“實踐才是檢驗真理的唯一標準”,接下來讓我們從實際的例子入手帶你領(lǐng)略一下autotools 的精妙之處。
三、Autotools編譯各類型文件首先,創(chuàng)建/tmp/myproject目錄,我們用它來存放各種編譯場景下的main程序及相關(guān)依賴文件。
mkdir -p /tmp/myproject
cd /tmp/myproject
mkdir src
mkdir include
創(chuàng)建C源文件供后續(xù)各編譯場景下使用,具體如下:
main.c源文件:
#include
#include"include/math.h"
int main()
{
int a = 10;
int b = 20;
printf("max=%d
", max(a, b));
printf("min=%d
", min(a, b));
}
math.h頭文件:
#pragma once
#ifndef MATH_H
#define MATH_H
int max(int x, int y);
int min(int x, int y);
#endif // !MATH_H
math.c源文件:
int max(int x, int y)
{
return x > y ? x : y;
}
int min(int x, int y)
{
return x 1、編譯可執(zhí)行程序(未依賴任何庫文件)(1)生成 configure.scan我們使用 autoscan 命令來幫助我們根據(jù)目錄下的源代碼生成一個configure.scan文件,它可以作為進一步生成 configure的 configure.ac 文件的模板。
[root@localhost myproject]# tree
.
├── include
│ └── math.h
└── src
├── main.c
└── math.c
2 directories, 3 files
[root@localhost myproject]# autoscan
[root@localhost myproject]# tree
.
├── autoscan.log
├── configure.scan
├── include
│ └── math.h
└── src
├── main.c
└── math.c
2 directories, 5 files
執(zhí)行后在myproject目錄下會生成一個文件:configure.scan,我們可以拿它作為configure.in (早期使用.in后綴) 或者 configure.ac的藍本。
(2)修改configure.ac當(dāng)利用autoscan工具生成confiugre.scan文件時,configure.scan其實是一個模板文件,我們需要將文件confiugre.scan重命名為confiugre.ac。confiugre.ac調(diào)用一系列autoconf宏來測試程序需要的或用到的特性是否存在,以及這些特性的功能。
下面我們就來目睹一下confiugre.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([src/main.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
每個configure.scan文件都是以AC_INIT開頭,以AC_OUTPUT結(jié)束。我們不難從文件中看出confiugre.ac文件的一般布局:
AC_INIT
測試程序
測試函數(shù)庫
測試頭文件
測試類型定義
測試結(jié)構(gòu)
測試編譯器特性
測試庫函數(shù)
測試系統(tǒng)調(diào)用
AC_OUTPUT
上面的調(diào)用次序只是建議性質(zhì)的,但我們還是強烈建議不要隨意改變對宏調(diào)用的次序。
configure.ac 標簽說明:
標簽說明AC_PREREQ確定autoconf版本,它是在AC_INIT前唯一使用的宏AC_INIT定義軟件名稱,版本號,郵箱AM_INIT_AUTOMAKE必須要的,參數(shù)為軟件名和版本號AC_CONFIG_SRCDIR該宏用來偵測所指定的源碼文件是否存在,來確定源碼有效性AC_CONFIG_HEADER該宏用來生成config.h文件,以便autoheader命令使用AC_PROG_CC指定編譯器,默認GCCAC_CONFIG_FILE生成相應(yīng)的Makefile文件,不同目錄下通過空格分隔AC_OUTPUT用來設(shè)定configure所要產(chǎn)生的文件,如果是makefile,config會把它檢查出來的結(jié)果帶入makefile.in文件,產(chǎn)生合適的makefile,如果只有一個Makefile, 也可改為AC_OUTPUT([Makefile])現(xiàn)在開始重命名該文件:
[root@localhost myproject]# mv configure.scan configure.ac
同時修改重命名后的configure.ac文件,修改后的結(jié)果如下:
# -*- 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_INIT(main, 1.0, linux106587@126.com) #新增一句描述,這里main是我源程序main.c的名字
AM_INIT_AUTOMAKE(main, 1.0) #新增一句,后面aclocal用到的
AC_CONFIG_SRCDIR([src/main.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
(3)生成 configure執(zhí)行命令aclocal和autoconf,分別會產(chǎn)生aclocal.m4及configure兩個文件:
# 執(zhí)行aclocal,生成文件如下所示
[root@localhost myproject]# aclocal
[root@localhost myproject]# tree
.
├── aclocal.m4
├── autom4te.cache
│ ├── output.0
│ ├── requests
│ └── traces.0
├── autoscan.log
├── configure.ac
├── include
│ └── math.h
└── src
├── main.c
└── math.c
3 directories, 9 files
# 執(zhí)行autoconf,生成文件如下:
[root@localhost myproject]# autoconf
[root@localhost myproject]# tree
.
├── aclocal.m4
├── autom4te.cache
│ ├── output.0
│ ├── output.1
│ ├── requests
│ ├── traces.0
│ └── traces.1
├── autoscan.log
├── configure
├── configure.ac
├── include
│ └── math.h
└── src
├── main.c
└── math.c
3 directories, 12 files
(4)生成config.h.in執(zhí)行 autoheader,掃描configure.ac(configure.in)、acconfig.h(如果存在),生成config.h.in宏定義文件,里面主要是根據(jù)configure.ac中某些特定宏(如AC_DEFINE)生成的#define和#undefine宏,configure在將根據(jù)實際的探測結(jié)果決定這些宏是否定義。
[root@localhost myproject]# autoheader
[root@localhost myproject]# tree
.
├── aclocal.m4
├── autom4te.cache
│ ├── output.0
│ ├── output.1
│ ├── requests
│ ├── traces.0
│ └── traces.1
├── autoscan.log
├── config.h.in
├── configure
├── configure.ac
├── include
│ └── math.h
└── src
├── main.c
└── math.c
3 directories, 13 files
(5)創(chuàng)建 Makefile.amMakefile.am 是一種比Makefile更高層次的規(guī)則。只需指定要生成什么目標,它由什么源文件生成,要安裝到什么目錄等構(gòu)成。
圖一列出了可執(zhí)行文件、靜態(tài)庫、頭文件和數(shù)據(jù)文件,四種書寫Makefile.am文件的一般格式。
eum410mq40s6407611605.png (38.57 KB, 下載次數(shù): 0)
下載附件
保存到相冊
eum410mq40s6407611605.png
2024-11-22 06:41 上傳
對于可執(zhí)行文件和靜態(tài)庫類型,如果只想編譯,不想安裝到系統(tǒng)中,可以用 noinst_PROGRAMS 代替 bin_PROGRAMS,noinst_LIBRARIES 代替 lib_LIBRARIES。
Makefile.am 還提供了一些全局變量供所有的目標體使用:
變量含義INCLUDES鏈接時所需要的頭文件LDADD鏈接時所需要的庫文件LDFLAGS鏈接時所需要的庫文件選項標志EXTRA_DIST源程序和一些默認的文件將自動打入.tar.gz包,其它文件若要進入.tar.gz包可以用這種辦法,比如配置文件、數(shù)據(jù)文件等等SUBDIRS在處理當(dāng)前目錄之前要遞歸處理指定的子目錄在 Makefile.am 中盡量使用相對路徑,系統(tǒng)預(yù)定義了兩個基本路徑:
路徑變量含義$(top_srcdir)工程最頂層目錄,用于引用源程序$(top_builddir)定義了生成目標文件最上層目錄,用于引用.o等編譯出來的目標文件新建Makefile.am文件,命令:
[root@localhost myproject]# vim Makefile.am
[root@localhost myproject]# cat Makefile.am
AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS=main
main_SOURCES=src/main.c src/math.c
include_HEADERS=include/math.h
其中的AUTOMAKE_OPTIONS為設(shè)置automake的選項。由于GNU對自己發(fā)布的軟件有嚴格的規(guī)范,比如必須附帶許可證聲明文件COPYING等,否則automake執(zhí)行時會報錯。automake提供了三種軟件等級:foreign、gnu和gnits,讓用戶選擇采用,默認等級為gnu。在本例使用foreign等級,它只檢測必須的文件。
執(zhí)行automake --add-missing會根據(jù)你寫的Makefile.am來自動生成Makefile.in。
Makefile.am中定義的宏和目標,會指導(dǎo)automake生成指定的代碼。例如,宏bin_PROGRAMS將導(dǎo)致編譯和連接的目標被生成。automake會根據(jù)Makefile.am文件產(chǎn)生一些文件,包含最重要的Makefile.in。
[root@localhost myproject]# automake --add-missing
configure.ac:7: warning: AM_INIT_AUTOMAKE: two- and three-arguments forms are deprecated. For more info, see:
configure.ac:7: https://www.gnu.org/software/automake/manual/automake.html#Modernize-AM_005fINIT_005fAUTOMAKE-invocation
configure.ac:12: installing './compile'
configure.ac:7: installing './install-sh'
configure.ac:7: installing './missing'
Makefile.am:3: warning: source file 'src/main.c' is in a subdirectory,
Makefile.am:3: but option 'subdir-objects' is disabled
automake: warning: possible forward-incompatibility.
automake: At least a source file is in a subdirectory, but the 'subdir-objects'
automake: automake option hasn't been enabled. For now, the corresponding output
automake: object file(s) will be placed in the top-level directory. However,
automake: this behaviour will change in future Automake versions: they will
automake: unconditionally cause object files to be placed in the same subdirectory
automake: of the corresponding sources.
automake: You are advised to start using 'subdir-objects' option throughout your
automake: project, to avoid future incompatibilities.
Makefile.am:3: warning: source file 'src/math.c' is in a subdirectory,
Makefile.am:3: but option 'subdir-objects' is disabled
Makefile.am: installing './depcomp'
[root@localhost myproject]#
[root@localhost myproject]# tree
.
├── aclocal.m4
├── autom4te.cache
│ ├── output.0
│ ├── output.1
│ ├── requests
│ ├── traces.0
│ └── traces.1
├── autoscan.log
├── compile -> /usr/share/automake-1.16/compile
├── config.h.in
├── configure
├── configure.ac
├── depcomp -> /usr/share/automake-1.16/depcomp
├── include
│ └── math.h
├── install-sh -> /usr/share/automake-1.16/install-sh
├── Makefile.am
├── Makefile.in
├── missing -> /usr/share/automake-1.16/missing
└── src
├── main.c
└── math.c
3 directories, 19 files
(6)生成Makefile執(zhí)行 configure 腳本文件,它根據(jù) Makefile.in 文件,生成最終的 Makefile 文件。
[root@localhost myproject]# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
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 whether gcc understands -c and -o together... yes
checking whether make supports the include directive... yes (GNU style)
checking dependency style of gcc... gcc3
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating config.h
config.status: executing depfiles commands
[root@localhost myproject]# tree
.
├── aclocal.m4
├── autom4te.cache
│ ├── output.0
│ ├── output.1
│ ├── requests
│ ├── traces.0
│ └── traces.1
├── autoscan.log
├── compile -> /usr/share/automake-1.16/compile
├── config.h
├── config.h.in
├── config.log
├── config.status
├── configure
├── configure.ac
├── depcomp -> /usr/share/automake-1.16/depcomp
├── include
│ └── math.h
├── install-sh -> /usr/share/automake-1.16/install-sh
├── Makefile
├── Makefile.am
├── Makefile.in
├── missing -> /usr/share/automake-1.16/missing
├── src
│ ├── main.c
│ └── math.c
└── stamp-h1
3 directories, 24 files
(7)make編譯工程生成 Makefile 之后,執(zhí)行make編譯工程并且生成可執(zhí)行程序。
[root@localhost myproject]# make
make all-am
make[1]: Entering directory '/tmp/myproject'
gcc -DHAVE_CONFIG_H -I. -g -O2 -MT main.o -MD -MP -MF .deps/main.Tpo -c -o main.o `test -f 'src/main.c' || echo './'`src/main.c
mv -f .deps/main.Tpo .deps/main.Po
gcc -DHAVE_CONFIG_H -I. -g -O2 -MT math.o -MD -MP -MF .deps/math.Tpo -c -o math.o `test -f 'src/math.c' || echo './'`src/math.c
mv -f .deps/math.Tpo .deps/math.Po
gcc -g -O2 -o main main.o math.o
make[1]: Leaving directory '/tmp/myproject'
[root@localhost myproject]#
[root@localhost myproject]# ls -l
total 352
-rw-r--r-- 1 root root 41888 Jul 28 13:21 aclocal.m4
drwxr-xr-x 2 root root 86 Jul 28 13:42 autom4te.cache
-rw-r--r-- 1 root root 0 Jul 28 13:05 autoscan.log
lrwxrwxrwx 1 root root 32 Jul 28 13:42 compile -> /usr/share/automake-1.16/compile
-rw-r--r-- 1 root root 761 Jul 28 13:44 config.h
-rw-r--r-- 1 root root 625 Jul 28 13:27 config.h.in
-rw-r--r-- 1 root root 9015 Jul 28 13:44 config.log
-rwxr-xr-x 1 root root 32345 Jul 28 13:44 config.status
-rwxr-xr-x 1 root root 145845 Jul 28 13:24 configure
-rw-r--r-- 1 root root 671 Jul 28 13:21 configure.ac
lrwxrwxrwx 1 root root 32 Jul 28 13:42 depcomp -> /usr/share/automake-1.16/depcomp
drwxr-xr-x 2 root root 20 Jul 28 10:59 include
lrwxrwxrwx 1 root root 35 Jul 28 13:42 install-sh -> /usr/share/automake-1.16/install-sh
-rwxr-xr-x 1 root root 21416 Jul 28 13:46 main
-rw-r--r-- 1 root root 6672 Jul 28 13:46 main.o
-rw-r--r-- 1 root root 28783 Jul 28 13:44 Makefile
-rw-r--r-- 1 root root 109 Jul 28 13:38 Makefile.am
-rw-r--r-- 1 root root 29860 Jul 28 13:42 Makefile.in
-rw-r--r-- 1 root root 2784 Jul 28 13:46 math.o
lrwxrwxrwx 1 root root 32 Jul 28 13:42 missing -> /usr/share/automake-1.16/missing
drwxr-xr-x 2 root root 34 Jul 28 11:17 src
-rw-r--r-- 1 root root 23 Jul 28 13:44 stamp-h1
(8)運行驗證運行生成的main可執(zhí)行程序,執(zhí)行成功,結(jié)果如下:
[root@localhost myproject]# ./main
max=20
min=10
2、編譯可執(zhí)行程序(依賴靜態(tài)庫文件)上一節(jié)中所有源文件都在同一個目錄下,但在比較大的項目中,很少將所有文件放在一個目錄下的。下面將針對這種情況做個簡單介紹。
多級目錄結(jié)構(gòu)的軟件,一般是單個程序、庫文件或模塊放在各自的目錄中。automake要求每個目錄都有自己的Makefile.am文件來編譯各自目錄 下的代碼。在頂級的目錄中,有一個Makefile.am文件,該文件通過SUBDIRS指明了這個目錄下有多少個直接下級目錄的代碼需要編譯。下級目錄的Makefile.am也指明自己需要編譯的下級目錄。通過這樣的層層遞歸,從而完成多級目錄結(jié)構(gòu)的編譯。
本節(jié)使用上述創(chuàng)建的C源文件及相關(guān)目錄,并新建lib 目錄,查看各目錄下的結(jié)構(gòu):
[root@localhost myproject]# mkdir lib
[root@localhost myproject]# tree
.
├── include
│ └── math.h
├── lib
│ └── math.c
└── src
└── main.c
3 directories, 3 files
(1)生成configure.scan在項目頂級目錄執(zhí)行autoscan命令生成configure.scan文件,執(zhí)行命令后項目目錄內(nèi)生成如下文件:
[root@localhost myproject]# ls
autoscan.log configure.scan include lib src
(2)修改configure.ac將生成的configure.scan文件改名成configure.ac (早期使用configure.in現(xiàn)在常用configure.ac),查看configure.ac內(nèi)容如下:
[root@localhost myproject]# mv configure.scan configure.ac
[root@localhost myproject]# cat configure.ac
# -*- 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([src/main.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
修改configure.ac文件內(nèi)容如下:
[root@localhost myproject]# vi configure.ac
[root@localhost myproject]# cat configure.ac
# -*- 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_INIT(main, 1.0, linux106587@126.com)
AC_CONFIG_SRCDIR([src/main.c])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE(main, 1.0)
AC_PROG_RANLIB #使用了靜態(tài)庫編譯,需要此宏的定義
# 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 src/Makefile lib/Makefile)
(3)生成 configure然后執(zhí)行命令aclocal和autoconf,分別會產(chǎn)生aclocal.m4及configure兩個文件:
[root@localhost myproject]# ls
aclocal.m4 autom4te.cache autoscan.log configure.ac include lib src
[root@localhost myproject]# ls
aclocal.m4 autom4te.cache autoscan.log configure configure.ac include lib src
(4)生成config.h.in執(zhí)行 autoheader,生成config.h.in宏定義文件。
[root@localhost myproject]# ls
aclocal.m4 autom4te.cache autoscan.log config.h.in configure configure.ac include lib src
(5)創(chuàng)建 Makefile.am頂級目錄下創(chuàng)建Makefile.am并編輯內(nèi)容如下:
[root@localhost myproject]# vi Makefile.am
[root@localhost myproject]# cat Makefile.am
AUTOMAKE_OPTIONS=foreign
SUBDIRS= lib src #表示本目錄的直接下級目錄需要編譯
#注意:順序不能反,按照調(diào)用順序來寫。
src目錄下創(chuàng)建Makefile.am文件
[root@localhost src]# cat Makefile.am
AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS=main #本目錄的文件編譯成可執(zhí)行文件main
main_SOURCES=main.c
main_LDADD=$(top_srcdir)/lib/libmath.a
INCLUDES=-I$(top_srcdir)/include/
main_LDADD 指定main 程序需要的庫文件INCLUDES 指定需要的頭文件
lib目錄下創(chuàng)建Makefile.am文件
[root@localhost lib]# cat Makefile.am
AUTOMAKE_OPTIONS=foreign
noinst_LIBRARIES=libmath.a
libmath_a_SOURCES=math.c
INCLUDES=-I$(top_srcdir)/include/
(6)生成Makefile.in[root@localhost myproject]# automake --add-missing
configure.ac:9: warning: AM_INIT_AUTOMAKE: two- and three-arguments forms are deprecated. For more info, see:
configure.ac:9: https://www.gnu.org/software/automake/manual/automake.html#Modernize-AM_005fINIT_005fAUTOMAKE-invocation
configure.ac:13: installing './compile'
configure.ac:9: installing './install-sh'
configure.ac:9: installing './missing'
lib/Makefile.am:7: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
lib/Makefile.am: installing './depcomp'
src/Makefile.am:9: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
[root@localhost myproject]#
[root@localhost myproject]# ls
aclocal.m4 autoscan.log config.h.in configure.ac include lib Makefile.in src
autom4te.cache compile configure depcomp install-sh Makefile.am missing
(7)生成Makefile[root@localhost myproject]# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for ranlib... ranlib
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
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 whether gcc understands -c and -o together... yes
checking whether make supports the include directive... yes (GNU style)
checking dependency style of gcc... gcc3
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating lib/Makefile
config.status: creating config.h
config.status: executing depfiles commands
[root@localhost myproject]# ls
aclocal.m4 autoscan.log config.h config.log configure depcomp install-sh Makefile Makefile.in src
autom4te.cache compile config.h.in config.status configure.ac include lib Makefile.am missing stamp-h1
(8)編譯運行[root@localhost myproject]# make
make all-recursive
make[1]: Entering directory '/tmp/myproject'
Making all in lib
make[2]: Entering directory '/tmp/myproject/lib'
gcc -DHAVE_CONFIG_H -I. -I.. -I../include/ -g -O2 -MT math.o -MD -MP -MF .deps/math.Tpo -c -o math.o math.c
mv -f .deps/math.Tpo .deps/math.Po
rm -f libmath.a
ar cru libmath.a math.o
ranlib libmath.a
make[2]: Leaving directory '/tmp/myproject/lib'
Making all in src
make[2]: Entering directory '/tmp/myproject/src'
gcc -DHAVE_CONFIG_H -I. -I.. -I../include/ -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 ../lib/libmath.a
make[2]: Leaving directory '/tmp/myproject/src'
make[2]: Entering directory '/tmp/myproject'
make[2]: Leaving directory '/tmp/myproject'
make[1]: Leaving directory '/tmp/myproject'
[root@localhost myproject]# tree
.
├── aclocal.m4
├── autom4te.cache
│ ├── output.0
│ ├── output.1
│ ├── requests
│ ├── traces.0
│ └── traces.1
├── autoscan.log
├── compile -> /usr/share/automake-1.16/compile
├── config.h
├── config.h.in
├── config.log
├── config.status
├── configure
├── configure.ac
├── depcomp -> /usr/share/automake-1.16/depcomp
├── include
│ └── math.h
├── install-sh -> /usr/share/automake-1.16/install-sh
├── lib
│ ├── libmath.a
│ ├── Makefile
│ ├── Makefile.am
│ ├── Makefile.in
│ ├── math.c
│ └── math.o
├── Makefile
├── Makefile.am
├── Makefile.in
├── missing -> /usr/share/automake-1.16/missing
├── src
│ ├── main
│ ├── main.c
│ ├── main.o
│ ├── Makefile
│ ├── Makefile.am
│ └── Makefile.in
└── stamp-h1
4 directories, 34 files
[root@localhost src]# ./main
max=20
min=10
[root@localhost myproject]# make install
Making install in lib
make[1]: Entering directory '/tmp/myproject/lib'
make[2]: Entering directory '/tmp/myproject/lib'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/tmp/myproject/lib'
make[1]: Leaving directory '/tmp/myproject/lib'
Making install in src
make[1]: Entering directory '/tmp/myproject/src'
make[2]: Entering directory '/tmp/myproject/src'
/usr/bin/mkdir -p '/usr/local/bin'
/usr/bin/install -c main '/usr/local/bin'
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/tmp/myproject/src'
make[1]: Leaving directory '/tmp/myproject/src'
make[1]: Entering directory '/tmp/myproject'
make[2]: Entering directory '/tmp/myproject'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/tmp/myproject'
make[1]: Leaving directory '/tmp/myproject'
[root@localhost myproject]# which main
/usr/local/bin/main
[root@localhost ~]# main
max=20
min=10
3、編譯可執(zhí)行程序(依賴動態(tài)庫文件)本節(jié)使用上述創(chuàng)建的C源文件并新創(chuàng)建相關(guān)目錄,查看各目錄下的結(jié)構(gòu)。
[root@localhost 85]# tree
.
├── include
│ └── math.h
├── lib
│ └── math.c
└── src
└── main.c
3 directories, 3 files
(1)生成configure.scan在項目頂級目錄執(zhí)行autoscan命令生成configure.scan文件,執(zhí)行命令后項目目錄內(nèi)生成如下文件:
[root@localhost 85]# autoscan
[root@localhost 85]# ls
autoscan.log configure.scan include lib src
(2)修改configure.ac將生成的configure.scan文件改名成configure.ac (早期使用configure.in現(xiàn)在常用configure.ac), 修改configure.ac文件內(nèi)容如下:
[root@localhost 85]# mv configure.scan configure.ac
[root@localhost 85]# vi configure.ac
[root@localhost 85]# cat configure.ac
# -*- 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_INIT(main, 1.0, linux106587@126.com)
AC_CONFIG_SRCDIR([src/main.c])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE(main, 1.0)
AC_PROG_LIBTOOL #使用了動態(tài)庫編譯,需要此宏的定義
# 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 src/Makefile lib/Makefile)
(3)生成 configure然后執(zhí)行命令aclocal、autoheader 和autoconf,分別會產(chǎn)生aclocal.m4、config.h.in及configure等文件:
[root@localhost 85]# aclocal
[root@localhost 85]# ls
aclocal.m4 autom4te.cache autoscan.log configure.ac include lib src
[root@localhost 85]# autoheader
[root@localhost 85]# ls -l
total 376
-rw-r--r-- 1 root root 372261 Aug 5 04:17 aclocal.m4
drwxr-xr-x 2 root root 86 Aug 5 04:18 autom4te.cache
-rw-r--r-- 1 root root 0 Aug 5 04:15 autoscan.log
-rw-r--r-- 1 root root 1611 Aug 5 04:18 config.h.in
-rw-r--r-- 1 root root 656 Aug 5 04:17 configure.ac
drwxr-xr-x 2 root root 20 Aug 5 04:02 include
drwxr-xr-x 3 root root 52 Aug 5 04:14 lib
drwxr-xr-x 3 root root 52 Aug 5 04:15 src
[root@localhost 85]#
[root@localhost 85]# autoconf
[root@localhost 85]# ls -l
total 812
-rw-r--r-- 1 root root 372261 Aug 5 04:17 aclocal.m4
drwxr-xr-x 2 root root 86 Aug 5 04:18 autom4te.cache
-rw-r--r-- 1 root root 0 Aug 5 04:15 autoscan.log
-rw-r--r-- 1 root root 1611 Aug 5 04:18 config.h.in
-rwxr-xr-x 1 root root 446104 Aug 5 04:18 configure
-rw-r--r-- 1 root root 656 Aug 5 04:17 configure.ac
drwxr-xr-x 2 root root 20 Aug 5 04:02 include
drwxr-xr-x 3 root root 52 Aug 5 04:14 lib
drwxr-xr-x 3 root root 52 Aug 5 04:15 src
(4)libtoolize配置執(zhí)行l(wèi)ibtoolize -f -c命令,使用共享庫必須要執(zhí)行。
[root@localhost 85]# libtoolize -f -c
libtoolize: putting auxiliary files in '.'.
libtoolize: copying file './ltmain.sh'
libtoolize: Consider adding 'AC_CONFIG_MACRO_DIRS([m4])' to configure.ac,
libtoolize: and rerunning libtoolize and aclocal.
libtoolize: Consider adding '-I m4' to ACLOCAL_AMFLAGS in Makefile.am.
(5)創(chuàng)建 Makefile.am頂級目錄下創(chuàng)建Makefile.am并編輯內(nèi)容如下:
[root@localhost 85]# vi Makefile.am
[root@localhost 85]# cat Makefile.am
AUTOMAKE_OPTIONS=foreign
SUBDIRS=lib src #表示本目錄的直接下級目錄需要編譯
#注意:順序不能反,按照調(diào)用順序來寫。
src目錄下創(chuàng)建Makefile.am文件
[root@localhost src]# cat Makefile.am
AUTOMAKE_OPTIONS=foreign
bin_PROGRAMS=main #本目錄的文件編譯成可執(zhí)行文件main
main_SOURCES=main.c
main_LDADD=$(top_srcdir)/lib/libmath.la
INCLUDES=-I$(top_srcdir)/include/
main_LDADD 指定main 程序需要的庫文件INCLUDES 指定需要的頭文件
lib目錄下創(chuàng)建Makefile.am文件
[root@localhost lib]# cat Makefile.am
AUTOMAKE_OPTIONS=foreign
lib_LTLIBRARIES=libmath.la
libmath_la_SOURCES=math.c
INCLUDES=-I$(top_srcdir)/include/
(6)生成Makefile.in[root@localhost 85]# automake --add-missing
configure.ac:9: warning: AM_INIT_AUTOMAKE: two- and three-arguments forms are deprecated. For more info, see:
configure.ac:9: https://www.gnu.org/software/automake/manual/automake.html#Modernize-AM_005fINIT_005fAUTOMAKE-invocation
configure.ac:10: installing './compile'
configure.ac:10: installing './config.guess'
configure.ac:10: installing './config.sub'
configure.ac:9: installing './install-sh'
configure.ac:9: installing './missing'
lib/Makefile.am:7: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
lib/Makefile.am: installing './depcomp'
src/Makefile.am:9: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')
(7)生成Makefile[root@localhost 85]# ./configure
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking how to print strings... printf
checking whether make supports the include directive... yes (GNU style)
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
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 whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-pc-linux-gnu file names to x86_64-pc-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /usr/bin/dd
checking how to truncate binary pipes... /usr/bin/dd bs=4096 count=1
checking for mt... no
checking if : is a manifest tool... no
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking whether gcc understands -c and -o together... (cached) yes
checking dependency style of gcc... (cached) gcc3
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating lib/Makefile
config.status: creating config.h
config.status: executing depfiles commands
config.status: executing libtool commands
[root@localhost 85]#
[root@nj-localhost]# ls -l
total 1728
-rw-r--r-- 1 root root 372261 Aug 5 04:17 aclocal.m4
drwxr-xr-x 2 root root 86 Aug 5 04:19 autom4te.cache
-rw-r--r-- 1 root root 0 Aug 5 04:15 autoscan.log
lrwxrwxrwx 1 root root 32 Aug 5 04:19 compile -> /usr/share/automake-1.16/compile
lrwxrwxrwx 1 root root 37 Aug 5 04:19 config.guess -> /usr/share/automake-1.16/config.guess
-rw-r--r-- 1 root root 1790 Aug 5 04:19 config.h
-rw-r--r-- 1 root root 1611 Aug 5 04:18 config.h.in
-rw-r--r-- 1 root root 23404 Aug 5 04:19 config.log
-rwxr-xr-x 1 root root 57443 Aug 5 04:19 config.status
lrwxrwxrwx 1 root root 35 Aug 5 04:19 config.sub -> /usr/share/automake-1.16/config.sub
-rwxr-xr-x 1 root root 446104 Aug 5 04:18 configure
-rw-r--r-- 1 root root 656 Aug 5 04:17 configure.ac
lrwxrwxrwx 1 root root 32 Aug 5 04:19 depcomp -> /usr/share/automake-1.16/depcomp
drwxr-xr-x 2 root root 20 Aug 5 04:02 include
lrwxrwxrwx 1 root root 35 Aug 5 04:19 install-sh -> /usr/share/automake-1.16/install-sh
drwxr-xr-x 3 root root 87 Aug 5 04:19 lib
-rwxr-xr-x 1 root root 339146 Aug 5 04:19 libtool
-rw-r--r-- 1 root root 324152 Aug 5 04:18 ltmain.sh
-rw-r--r-- 1 root root 25193 Aug 5 04:19 Makefile
-rw-r--r-- 1 root root 150 Aug 5 04:15 Makefile.am
-rw-r--r-- 1 root root 25308 Aug 5 04:19 Makefile.in
lrwxrwxrwx 1 root root 32 Aug 5 04:19 missing -> /usr/share/automake-1.16/missing
drwxr-xr-x 3 root root 87 Aug 5 04:19 src
-rw-r--r-- 1 root root 23 Aug 5 04:19 stamp-h1
(8)編譯安裝[root@localhost 85]# make
make all-recursive
make[1]: Entering directory '/tmp/85'
Making all in lib
make[2]: Entering directory '/tmp/85/lib'
/bin/sh ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -I../include/ -g -O2 -MT math.lo -MD -MP -MF .deps/math.Tpo -c -o math.lo math.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -I../include/ -g -O2 -MT math.lo -MD -MP -MF .deps/math.Tpo -c math.c -fPIC -DPIC -o .libs/math.o
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -I../include/ -g -O2 -MT math.lo -MD -MP -MF .deps/math.Tpo -c math.c -o math.o >/dev/null 2>&1
mv -f .deps/math.Tpo .deps/math.Plo
/bin/sh ../libtool --tag=CC --mode=link gcc -g -O2 -o libmath.la -rpath /usr/local/lib math.lo
libtool: link: gcc -shared -fPIC -DPIC .libs/math.o -g -O2 -Wl,-soname -Wl,libmath.so.0 -o .libs/libmath.so.0.0.0
libtool: link: (cd ".libs" && rm -f "libmath.so.0" && ln -s "libmath.so.0.0.0" "libmath.so.0")
libtool: link: (cd ".libs" && rm -f "libmath.so" && ln -s "libmath.so.0.0.0" "libmath.so")
libtool: link: ar cru .libs/libmath.a math.o
libtool: link: ranlib .libs/libmath.a
libtool: link: ( cd ".libs" && rm -f "libmath.la" && ln -s "../libmath.la" "libmath.la" )
make[2]: Leaving directory '/tmp/85/lib'
Making all in src
make[2]: Entering directory '/tmp/85/src'
gcc -DHAVE_CONFIG_H -I. -I.. -I../include/ -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
/bin/sh ../libtool --tag=CC --mode=link gcc -g -O2 -o main main.o ../lib/libmath.la
libtool: link: gcc -g -O2 -o .libs/main main.o ../lib/.libs/libmath.so -Wl,-rpath -Wl,/usr/local/lib
make[2]: Leaving directory '/tmp/85/src'
make[2]: Entering directory '/tmp/85'
make[2]: Leaving directory '/tmp/85'
make[1]: Leaving directory '/tmp/85'
[root@localhost 85]#
[root@localhost 85]# tree
.
├── aclocal.m4
├── autom4te.cache
│ ├── output.0
│ ├── output.1
│ ├── requests
│ ├── traces.0
│ └── traces.1
├── autoscan.log
├── compile -> /usr/share/automake-1.16/compile
├── config.guess -> /usr/share/automake-1.16/config.guess
├── config.h
├── config.h.in
├── config.log
├── config.status
├── config.sub -> /usr/share/automake-1.16/config.sub
├── configure
├── configure.ac
├── depcomp -> /usr/share/automake-1.16/depcomp
├── include
│ └── math.h
├── install-sh -> /usr/share/automake-1.16/install-sh
├── lib
│ ├── libmath.la
│ ├── Makefile
│ ├── Makefile.am
│ ├── Makefile.in
│ ├── math.c
│ ├── math.lo
│ └── math.o
├── libtool
├── ltmain.sh
├── Makefile
├── Makefile.am
├── Makefile.in
├── missing -> /usr/share/automake-1.16/missing
├── src
│ ├── main
│ ├── main.c
│ ├── main.o
│ ├── Makefile
│ ├── Makefile.am
│ └── Makefile.in
└── stamp-h1
4 directories, 39 files
[root@localhost src]# ./main
max=20
min=10
[root@localhost 85]# make install
Making install in lib
make[1]: Entering directory '/tmp/85/lib'
make[2]: Entering directory '/tmp/85/lib'
/usr/bin/mkdir -p '/usr/local/lib'
/bin/sh ../libtool --mode=install /usr/bin/install -c libmath.la '/usr/local/lib'
libtool: install: /usr/bin/install -c .libs/libmath.so.0.0.0 /usr/local/lib/libmath.so.0.0.0
libtool: install: (cd /usr/local/lib && { ln -s -f libmath.so.0.0.0 libmath.so.0 || { rm -f libmath.so.0 && ln -s libmath.so.0.0.0 libmath.so.0; }; })
libtool: install: (cd /usr/local/lib && { ln -s -f libmath.so.0.0.0 libmath.so || { rm -f libmath.so && ln -s libmath.so.0.0.0 libmath.so; }; })
libtool: install: /usr/bin/install -c .libs/libmath.lai /usr/local/lib/libmath.la
libtool: install: /usr/bin/install -c .libs/libmath.a /usr/local/lib/libmath.a
libtool: install: chmod 644 /usr/local/lib/libmath.a
libtool: install: ranlib /usr/local/lib/libmath.a
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/opt/netronome/bin:/root/bin:/sbin" ldconfig -n /usr/local/lib
----------------------------------------------------------------------
Libraries have been installed in:
/usr/local/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the 'LD_RUN_PATH' environment variable
during linking
- use the '-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to '/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/tmp/85/lib'
make[1]: Leaving directory '/tmp/85/lib'
Making install in src
make[1]: Entering directory '/tmp/85/src'
make[2]: Entering directory '/tmp/85/src'
/usr/bin/mkdir -p '/usr/local/bin'
/bin/sh ../libtool --mode=install /usr/bin/install -c main '/usr/local/bin'
libtool: install: /usr/bin/install -c .libs/main /usr/local/bin/main
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/tmp/85/src'
make[1]: Leaving directory '/tmp/85/src'
make[1]: Entering directory '/tmp/85'
make[2]: Entering directory '/tmp/85'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/tmp/85'
make[1]: Leaving directory '/tmp/85'
[root@localhost 85]#
[root@localhost 85]# which main
/usr/local/bin/main
[root@localhost 85]# ls -l /usr/local/bin/main
-rwxr-xr-x 1 root root 20968 Aug 5 10:33 /usr/local/bin/main
[root@localhost 85]# ls -l /usr/local/lib/ | grep libmath.la
-rwxr-xr-x 1 root root 916 Aug 5 10:33 libmath.la
如果沒有指定安裝路徑,make install 會將可執(zhí)行程序以及庫文件安裝到默認路徑下,可執(zhí)行文件默認放在/usr/local/bin/,庫文件默認放在/usr/local/lib,配置文件默認放在/usr/local/etc,其它的資源文件放在/usr/local/share,比較分散。如果不想安裝在默認路徑,而想自行指定安裝路徑,則可以通過執(zhí)行configure 時指定--prefix,這里--prefix選項表示配置安裝的路徑。為了便于集中管理某個軟件的各種文件,可以配置如:./configure --prefix=/usr/local,則會把所有資源文件放在/usr/local的路徑中,就不會分散了。
[root@localhost 85]# make clean
Making clean in lib
make[1]: Entering directory '/tmp/85/lib'
test -z "libmath.la" || rm -f libmath.la
rm -f ./so_locations
rm -rf .libs _libs
rm -f *.o
rm -f *.lo
make[1]: Leaving directory '/tmp/85/lib'
Making clean in src
make[1]: Entering directory '/tmp/85/src'
rm -f main
rm -rf .libs _libs
rm -f *.o
rm -f *.lo
make[1]: Leaving directory '/tmp/85/src'
make[1]: Entering directory '/tmp/85'
rm -rf .libs _libs
rm -f *.lo
make[1]: Leaving directory '/tmp/85'
[root@localhost 85]# tree
.
├── aclocal.m4
├── autom4te.cache
│ ├── output.0
│ ├── output.1
│ ├── requests
│ ├── traces.0
│ └── traces.1
├── autoscan.log
├── compile -> /usr/share/automake-1.16/compile
├── config.guess -> /usr/share/automake-1.16/config.guess
├── config.h
├── config.h.in
├── config.log
├── config.status
├── config.sub -> /usr/share/automake-1.16/config.sub
├── configure
├── configure.ac
├── depcomp -> /usr/share/automake-1.16/depcomp
├── include
│ └── math.h
├── install-sh -> /usr/share/automake-1.16/install-sh
├── lib
│ ├── Makefile
│ ├── Makefile.am
│ ├── Makefile.in
│ └── math.c
├── libtool
├── ltmain.sh
├── Makefile
├── Makefile.am
├── Makefile.in
├── missing -> /usr/share/automake-1.16/missing
├── src
│ ├── main.c
│ ├── Makefile
│ ├── Makefile.am
│ └── Makefile.in
└── stamp-h1
4 directories, 34 files
[root@localhost 85]# ./configure --prefix=$PWD/_install
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /usr/bin/mkdir -p
checking for gawk... gawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking how to print strings... printf
checking whether make supports the include directive... yes (GNU style)
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
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 whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking for a sed that does not truncate output... /usr/bin/sed
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking for fgrep... /usr/bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-pc-linux-gnu file names to x86_64-pc-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /usr/bin/dd
checking how to truncate binary pipes... /usr/bin/dd bs=4096 count=1
checking for mt... no
checking if : is a manifest tool... no
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... no
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking whether gcc understands -c and -o together... (cached) yes
checking dependency style of gcc... (cached) gcc3
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating src/Makefile
config.status: creating lib/Makefile
config.status: creating config.h
config.status: config.h is unchanged
config.status: executing depfiles commands
config.status: executing libtool commands
[root@localhost 85]# ls -l
total 1728
-rw-r--r-- 1 root root 372261 Aug 5 04:17 aclocal.m4
drwxr-xr-x 2 root root 86 Aug 5 04:19 autom4te.cache
-rw-r--r-- 1 root root 0 Aug 5 04:15 autoscan.log
lrwxrwxrwx 1 root root 32 Aug 5 04:19 compile -> /usr/share/automake-1.16/compile
lrwxrwxrwx 1 root root 37 Aug 5 04:19 config.guess -> /usr/share/automake-1.16/config.guess
-rw-r--r-- 1 root root 1790 Aug 5 04:19 config.h
-rw-r--r-- 1 root root 1611 Aug 5 04:18 config.h.in
-rw-r--r-- 1 root root 23522 Aug 5 04:22 config.log
-rwxr-xr-x 1 root root 57504 Aug 5 04:22 config.status
lrwxrwxrwx 1 root root 35 Aug 5 04:19 config.sub -> /usr/share/automake-1.16/config.sub
-rwxr-xr-x 1 root root 446104 Aug 5 04:18 configure
-rw-r--r-- 1 root root 656 Aug 5 04:17 configure.ac
lrwxrwxrwx 1 root root 32 Aug 5 04:19 depcomp -> /usr/share/automake-1.16/depcomp
drwxr-xr-x 2 root root 20 Aug 5 04:02 include
lrwxrwxrwx 1 root root 35 Aug 5 04:19 install-sh -> /usr/share/automake-1.16/install-sh
drwxr-xr-x 3 root root 87 Aug 5 04:22 lib
-rwxr-xr-x 1 root root 339146 Aug 5 04:22 libtool
-rw-r--r-- 1 root root 324152 Aug 5 04:18 ltmain.sh
-rw-r--r-- 1 root root 25199 Aug 5 04:22 Makefile
-rw-r--r-- 1 root root 150 Aug 5 04:15 Makefile.am
-rw-r--r-- 1 root root 25308 Aug 5 04:19 Makefile.in
lrwxrwxrwx 1 root root 32 Aug 5 04:19 missing -> /usr/share/automake-1.16/missing
drwxr-xr-x 3 root root 87 Aug 5 04:22 src
-rw-r--r-- 1 root root 23 Aug 5 04:22 stamp-h1
[root@localhost 85]# make
make all-recursive
make[1]: Entering directory '/tmp/85'
Making all in lib
make[2]: Entering directory '/tmp/85/lib'
/bin/sh ../libtool --tag=CC --mode=compile gcc -DHAVE_CONFIG_H -I. -I.. -I../include/ -g -O2 -MT math.lo -MD -MP -MF .deps/math.Tpo -c -o math.lo math.c
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -I../include/ -g -O2 -MT math.lo -MD -MP -MF .deps/math.Tpo -c math.c -fPIC -DPIC -o .libs/math.o
libtool: compile: gcc -DHAVE_CONFIG_H -I. -I.. -I../include/ -g -O2 -MT math.lo -MD -MP -MF .deps/math.Tpo -c math.c -o math.o >/dev/null 2>&1
mv -f .deps/math.Tpo .deps/math.Plo
/bin/sh ../libtool --tag=CC --mode=link gcc -g -O2 -o libmath.la -rpath /tmp/85/_install/lib math.lo
libtool: link: gcc -shared -fPIC -DPIC .libs/math.o -g -O2 -Wl,-soname -Wl,libmath.so.0 -o .libs/libmath.so.0.0.0
libtool: link: (cd ".libs" && rm -f "libmath.so.0" && ln -s "libmath.so.0.0.0" "libmath.so.0")
libtool: link: (cd ".libs" && rm -f "libmath.so" && ln -s "libmath.so.0.0.0" "libmath.so")
libtool: link: ar cru .libs/libmath.a math.o
libtool: link: ranlib .libs/libmath.a
libtool: link: ( cd ".libs" && rm -f "libmath.la" && ln -s "../libmath.la" "libmath.la" )
make[2]: Leaving directory '/tmp/85/lib'
Making all in src
make[2]: Entering directory '/tmp/85/src'
gcc -DHAVE_CONFIG_H -I. -I.. -I../include/ -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
/bin/sh ../libtool --tag=CC --mode=link gcc -g -O2 -o main main.o ../lib/libmath.la
libtool: link: gcc -g -O2 -o .libs/main main.o ../lib/.libs/libmath.so -Wl,-rpath -Wl,/tmp/85/_install/lib
make[2]: Leaving directory '/tmp/85/src'
make[2]: Entering directory '/tmp/85'
make[2]: Leaving directory '/tmp/85'
make[1]: Leaving directory '/tmp/85'
[root@localhost 85]# ls -l
total 1728
-rw-r--r-- 1 root root 372261 Aug 5 04:17 aclocal.m4
drwxr-xr-x 2 root root 86 Aug 5 04:19 autom4te.cache
-rw-r--r-- 1 root root 0 Aug 5 04:15 autoscan.log
lrwxrwxrwx 1 root root 32 Aug 5 04:19 compile -> /usr/share/automake-1.16/compile
lrwxrwxrwx 1 root root 37 Aug 5 04:19 config.guess -> /usr/share/automake-1.16/config.guess
-rw-r--r-- 1 root root 1790 Aug 5 04:19 config.h
-rw-r--r-- 1 root root 1611 Aug 5 04:18 config.h.in
-rw-r--r-- 1 root root 23522 Aug 5 04:22 config.log
-rwxr-xr-x 1 root root 57504 Aug 5 04:22 config.status
lrwxrwxrwx 1 root root 35 Aug 5 04:19 config.sub -> /usr/share/automake-1.16/config.sub
-rwxr-xr-x 1 root root 446104 Aug 5 04:18 configure
-rw-r--r-- 1 root root 656 Aug 5 04:17 configure.ac
lrwxrwxrwx 1 root root 32 Aug 5 04:19 depcomp -> /usr/share/automake-1.16/depcomp
drwxr-xr-x 2 root root 20 Aug 5 04:02 include
lrwxrwxrwx 1 root root 35 Aug 5 04:19 install-sh -> /usr/share/automake-1.16/install-sh
drwxr-xr-x 4 root root 147 Aug 5 04:22 lib
-rwxr-xr-x 1 root root 339146 Aug 5 04:22 libtool
-rw-r--r-- 1 root root 324152 Aug 5 04:18 ltmain.sh
-rw-r--r-- 1 root root 25199 Aug 5 04:22 Makefile
-rw-r--r-- 1 root root 150 Aug 5 04:15 Makefile.am
-rw-r--r-- 1 root root 25308 Aug 5 04:19 Makefile.in
lrwxrwxrwx 1 root root 32 Aug 5 04:19 missing -> /usr/share/automake-1.16/missing
drwxr-xr-x 4 root root 126 Aug 5 04:22 src
-rw-r--r-- 1 root root 23 Aug 5 04:22 stamp-h1
[root@localhost 85]# make install
Making install in lib
make[1]: Entering directory '/tmp/85/lib'
make[2]: Entering directory '/tmp/85/lib'
/usr/bin/mkdir -p '/tmp/85/_install/lib'
/bin/sh ../libtool --mode=install /usr/bin/install -c libmath.la '/tmp/85/_install/lib'
libtool: install: /usr/bin/install -c .libs/libmath.so.0.0.0 /tmp/85/_install/lib/libmath.so.0.0.0
libtool: install: (cd /tmp/85/_install/lib && { ln -s -f libmath.so.0.0.0 libmath.so.0 || { rm -f libmath.so.0 && ln -s libmath.so.0.0.0 libmath.so.0; }; })
libtool: install: (cd /tmp/85/_install/lib && { ln -s -f libmath.so.0.0.0 libmath.so || { rm -f libmath.so && ln -s libmath.so.0.0.0 libmath.so; }; })
libtool: install: /usr/bin/install -c .libs/libmath.lai /tmp/85/_install/lib/libmath.la
libtool: install: /usr/bin/install -c .libs/libmath.a /tmp/85/_install/lib/libmath.a
libtool: install: chmod 644 /tmp/85/_install/lib/libmath.a
libtool: install: ranlib /tmp/85/_install/lib/libmath.a
libtool: finish: PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/opt/netronome/bin:/root/bin:/sbin" ldconfig -n /tmp/85/_install/lib
----------------------------------------------------------------------
Libraries have been installed in:
/tmp/85/_install/lib
If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the '-LLIBDIR'
flag during linking and do at least one of the following:
- add LIBDIR to the 'LD_LIBRARY_PATH' environment variable
during execution
- add LIBDIR to the 'LD_RUN_PATH' environment variable
during linking
- use the '-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to '/etc/ld.so.conf'
See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/tmp/85/lib'
make[1]: Leaving directory '/tmp/85/lib'
Making install in src
make[1]: Entering directory '/tmp/85/src'
make[2]: Entering directory '/tmp/85/src'
/usr/bin/mkdir -p '/tmp/85/_install/bin'
/bin/sh ../libtool --mode=install /usr/bin/install -c main '/tmp/85/_install/bin'
libtool: install: /usr/bin/install -c .libs/main /tmp/85/_install/bin/main
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/tmp/85/src'
make[1]: Leaving directory '/tmp/85/src'
make[1]: Entering directory '/tmp/85'
make[2]: Entering directory '/tmp/85'
make[2]: Nothing to be done for 'install-exec-am'.
make[2]: Nothing to be done for 'install-data-am'.
make[2]: Leaving directory '/tmp/85'
make[1]: Leaving directory '/tmp/85'
[root@localhost 85]# which main
/usr/local/bin/main
[root@localhost 85]# ls -l /usr/local/bin/main
-rwxr-xr-x 1 root root 21424 Aug 3 04:16 /usr/local/bin/main
[root@localhost 85]# ls
aclocal.m4 compile config.h.in config.sub depcomp install-sh ltmain.sh Makefile.in stamp-h1
autom4te.cache config.guess config.log configure include lib Makefile missing
autoscan.log config.h config.status configure.ac _install libtool Makefile.am src
[root@localhost 85]# cd _install/
[root@localhost _install]# tree .
.
├── bin
│ └── main
└── lib
├── libmath.a
├── libmath.la
├── libmath.so -> libmath.so.0.0.0
├── libmath.so.0 -> libmath.so.0.0.0
└── libmath.so.0.0.0
2 directories, 6 files
[root@localhost 85]# ls
aclocal.m4 compile config.h.in config.sub depcomp install-sh ltmain.sh Makefile.in stamp-h1
autom4te.cache config.guess config.log configure include lib Makefile missing
autoscan.log config.h config.status configure.ac _install libtool Makefile.am src
這里我們通過--prefix選項將可執(zhí)行文件和庫文件安裝到自定義路徑_install。通過make install編譯安裝過后,我們發(fā)現(xiàn)在_install路徑下確實含有編譯生成的可執(zhí)行程序以及動態(tài)庫文件。
另外,在確?蓤(zhí)行程序運行正常后,我們也可以通過命令make dist將項目源文件整體打包發(fā)布,極其方便。
[root@localhost 85]# make dist
make dist-gzip am__post_remove_distdir='@:'
make[1]: Entering directory '/tmp/85'
make distdir-am
make[2]: Entering directory '/tmp/85'
if test -d "main-1.0"; then find "main-1.0" -type d ! -perm -200 -exec chmod u+w {} ';' && rm -rf "main-1.0" || { sleep 5 && rm -rf "main-1.0"; }; else :; fi
test -d "main-1.0" || mkdir "main-1.0"
(cd lib && make top_distdir=../main-1.0 distdir=../main-1.0/lib \
am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)
make[3]: Entering directory '/tmp/85/lib'
make distdir-am
make[4]: Entering directory '/tmp/85/lib'
make[4]: Leaving directory '/tmp/85/lib'
make[3]: Leaving directory '/tmp/85/lib'
(cd src && make top_distdir=../main-1.0 distdir=../main-1.0/src \
am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)
make[3]: Entering directory '/tmp/85/src'
make distdir-am
make[4]: Entering directory '/tmp/85/src'
make[4]: Leaving directory '/tmp/85/src'
make[3]: Leaving directory '/tmp/85/src'
test -n "" \
|| find "main-1.0" -type d ! -perm -755 \
-exec chmod u+rwx,go+rx {} \; -o \
! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
! -type d ! -perm -400 -exec chmod a+r {} \; -o \
! -type d ! -perm -444 -exec /bin/sh /tmp/85/install-sh -c -m a+r {} {} \; \
|| chmod -R a+r "main-1.0"
make[2]: Leaving directory '/tmp/85'
tardir=main-1.0 && ${TAR-tar} chof - "$tardir" | eval GZIP= gzip --best -c >main-1.0.tar.gz
make[1]: Leaving directory '/tmp/85'
if test -d "main-1.0"; then find "main-1.0" -type d ! -perm -200 -exec chmod u+w {} ';' && rm -rf "main-1.0" || { sleep 5 && rm -rf "main-1.0"; }; else :; fi
[root@localhost 85]# ls -l
total 1936
-rw-r--r-- 1 root root 372261 Aug 5 04:17 aclocal.m4
drwxr-xr-x 2 root root 86 Aug 5 04:19 autom4te.cache
-rw-r--r-- 1 root root 0 Aug 5 04:15 autoscan.log
lrwxrwxrwx 1 root root 32 Aug 5 04:19 compile -> /usr/share/automake-1.16/compile
lrwxrwxrwx 1 root root 37 Aug 5 04:19 config.guess -> /usr/share/automake-1.16/config.guess
-rw-r--r-- 1 root root 1790 Aug 5 04:19 config.h
-rw-r--r-- 1 root root 1611 Aug 5 04:18 config.h.in
-rw-r--r-- 1 root root 23522 Aug 5 10:48 config.log
-rwxr-xr-x 1 root root 57504 Aug 5 10:48 config.status
lrwxrwxrwx 1 root root 35 Aug 5 04:19 config.sub -> /usr/share/automake-1.16/config.sub
-rwxr-xr-x 1 root root 446104 Aug 5 04:18 configure
-rw-r--r-- 1 root root 656 Aug 5 04:17 configure.ac
lrwxrwxrwx 1 root root 32 Aug 5 04:19 depcomp -> /usr/share/automake-1.16/depcomp
drwxr-xr-x 2 root root 20 Aug 5 04:02 include
drwxr-xr-x 4 root root 28 Aug 5 04:25 _install
lrwxrwxrwx 1 root root 35 Aug 5 04:19 install-sh -> /usr/share/automake-1.16/install-sh
drwxr-xr-x 4 root root 147 Aug 5 10:49 lib
-rwxr-xr-x 1 root root 339146 Aug 5 10:48 libtool
-rw-r--r-- 1 root root 324152 Aug 5 04:18 ltmain.sh
-rw-r--r-- 1 root root 331481 Aug 5 13:03 main-1.0.tar.gz
-rw-r--r-- 1 root root 25199 Aug 5 10:48 Makefile
-rw-r--r-- 1 root root 150 Aug 5 04:15 Makefile.am
-rw-r--r-- 1 root root 25308 Aug 5 04:19 Makefile.in
lrwxrwxrwx 1 root root 32 Aug 5 04:19 missing -> /usr/share/automake-1.16/missing
drwxr-xr-x 4 root root 126 Aug 5 10:49 src
-rw-r--r-- 1 root root 23 Aug 5 10:48 stamp-h1
[root@nj-localhost]# cp main-1.0.tar.gz ../
[root@nj-raclocalhostcd ..
[root@nj-rack02localhostr -zxvf main-1.0.tar.gz
main-1.0/
main-1.0/Makefile.am
main-1.0/configure
main-1.0/configure.ac
main-1.0/aclocal.m4
main-1.0/Makefile.in
main-1.0/config.h.in
main-1.0/compile
main-1.0/config.guess
main-1.0/config.sub
main-1.0/install-sh
main-1.0/ltmain.sh
main-1.0/missing
main-1.0/lib/
main-1.0/lib/Makefile.am
main-1.0/lib/Makefile.in
main-1.0/lib/math.c
main-1.0/depcomp
main-1.0/src/
main-1.0/src/Makefile.am
main-1.0/src/Makefile.in
main-1.0/src/main.c
[root@localhostlocalhost
total 384
drwxr-xr-x 2 root root 20 Jul 28 09:01 717
drwxr-xr-x 2 root root 23 Jul 28 09:01 722
drwxr-xr-x 5 root root 4096 Jul 28 08:49 724
drwxr-xr-x 2 root root 6 Jul 17 13:36 77
drwxr-xr-x 8 root root 4096 Aug 5 13:03 85
drwxr-xr-x 6 root root 137 Aug 1 14:57 example
-rw-r--r-- 1 root root 12510 Jul 28 03:53 gcc_micro
drwxr-xr-x 4 root root 4096 Aug 5 13:03 main-1.0
-rw-r--r-- 1 root root 331481 Aug 5 13:03 main-1.0.tar.gz
-rw-r--r-- 1 root root 252 Jul 24 13:43 Makefile
drwxr-xr-x 7 root root 4096 Aug 5 04:02 myproject
drwx------ 3 root root 17 Jun 8 15:34 systemd-private-ef1fd2fdd12d442c8b6a8d3d0cdc1c54-chronyd.service-BS2qcS
-rwxr-xr-x 1 root root 18096 Jul 27 02:48 test
-rw-r--r-- 1 root root 162 Jul 27 02:48 test.c
[root@nj-localhostlocalhost1.0/
[root@nj-raclocalhostlocalhostocal.m4 config.guess config.sub configure.ac install-sh ltmain.sh Makefile.in src
compile config.h.in configure depcomp lib Makefile.am missing
[root@nj-rack02localhostlocalhost─ aclocal.m4
├── compile
├── config.guess
├── config.h.in
├── config.sub
├── configure
├── configure.ac
├── depcomp
├── install-sh
├── lib
│ ├── Makefile.am
│ ├── Makefile.in
│ └── math.c
├── ltmain.sh
├── Makefile.am
├── Makefile.in
├── missing
└── src
├── main.c
├── Makefile.am
└── Makefile.in
2 directories, 19 files
四、總結(jié)本文從Autotools工具的構(gòu)成、構(gòu)建工程項目流程、以及實戰(zhàn)構(gòu)建各類程序三個方面,簡單的介紹了Autotools工具的原理和使用方法,為我們在日常學(xué)習(xí)和工作中構(gòu)建復(fù)雜的工程項目提供一定的參考,姑且作為拋磚引玉之作。但是由于篇幅所限,無法在一篇文章中將Autotools工具的方方面面都詳細的總結(jié)出來,后續(xù)小編會陸續(xù)推出針對Autotools工具的一些細節(jié)內(nèi)容總結(jié)的推文,敬請期待。
end
一口Linux
關(guān)注,回復(fù)【1024】海量Linux資料贈送
精彩文章合集
文章推薦
?【專輯】ARM?【專輯】粉絲問答?【專輯】所有原創(chuàng)?【專輯】linux入門?【專輯】計算機網(wǎng)絡(luò)?【專輯】Linux驅(qū)動?【干貨】嵌入式驅(qū)動工程師學(xué)習(xí)路線?【干貨】Linux嵌入式所有知識點-思維導(dǎo)圖 |
|