亚洲好骚综合-亚洲黄色录像-亚洲黄色网址-亚洲黄色网址大全-99久久99久久-99久久99久久精品国产

您的位置:軟件測試 > 開源軟件測試 > 開源配置管理工具 > cvs
CVS、Automake與Autoconf簡介
作者:網絡轉載 發布時間:[ 2012/12/28 14:18:46 ] 推薦標簽:

1. 用 autoscan 產生一個 configure.in 的原型,執行autoscan 后會產生一個configure.scan 的文件,可以用它作為 configure.in文件的藍本。
 
% autoscan
% ls
configure.scan hello.c

2. 編輯 configure.scan文件,如下所示,?且改名為configure.in

dnl Process this file with Autoconf to produce a configure script.
AC_INIT(hello.c)
AM_INIT_AUTOMAKE(hello, 1.0)
dnl Checks for programs.
AC_PROG_CC
dnl Checks for libraries.
dnl Checks for header files.
dnl Checks for typedefs, structures, and compiler characteristics.
dnl Checks for library functions.
AC_OUTPUT(Makefile)

3. 執行 aclocal 和 Autoconf ,分?會產生 aclocal.m4 及 configure 兩個文件

% aclocal
% Autoconf
% ls
aclocal.m4 configure configure.in hello.c

4. 編輯 Makefile.am 文件,?容如下

AUTOMAKE_OPTIONS= foreign
bin_PROGRAMS= hello
hello_SOURCES= hello.c

5. 執行 Automake --add-missing ,Automake 會根據Makefile.am 文件產生一些文件,包含重要的Makefile.in

% Automake --add-missing
Automake: configure.in: installing `./install-sh'
Automake: configure.in: installing `./mkinstalldirs'
Automake: configure.in: installing `./missing'

6. 后執行 ./configure:

% ./configure
creating cache ./config.cache
checking for a BSD compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking whether make sets ${MAKE}... yes
checking for working aclocal... found
checking for working Autoconf... found
checking for working Automake... found
checking for working autoheader... found
checking for working makeinfo... found
checking for gcc... gcc
checking whether the C compiler (gcc ) works... yes
checking whether the C compiler (gcc ) is a cross-compiler... no
checking whether we are using GNU C... yes
checking whether gcc accepts -g... yes
updating cache ./config.cache
creating ./config.status
creating Makefile

$ ls
Makefile aclocal.m4 config.status hello.c mkinstalldirs
Makefile.am config.cache configure install-sh
Makefile.in config.log configure.in missing

?在你的目錄下已經產生了一個 Makefile 文件,輸入make指令可以編譯 hello.c 了!

% make
gcc -DPACKAGE="hello" -DVERSION="1.0" -I. -I. -g -O2 -c hello.c
gcc -g -O2 -o hello hello.o

你還可以試試 “make clean“,”make install“,”make dist“:
[root@localhost hello]# make clean
test -z "hello " || rm -f hello
rm -f *.o core *.core
[root@localhost hello]# make install
gcc -DPACKAGE="hello" -DVERSION="1.0" -I. -I. -g -O2 -c hello.c
gcc -g -O2 -o hello hello.o
make[1]: Entering directory `/home/joe/devel/hello'
/bin/sh ./mkinstalldirs /usr/local/bin
/usr/bin/install -c hello /usr/local/bin/hello
make[1]: Nothing to be done for `install-data-am'.
make[1]: Leaving directory `/home/joe/devel/hello'
[root@localhost hello]# make dist
rm -rf hello-1.0
mkdir hello-1.0
chmod 777 hello-1.0
here=`cd . && pwd`;
top_distdir=`cd hello-1.0 && pwd`;
distdir=`cd hello-1.0 && pwd`;
cd .
&& Automake --include-deps --build-dir=$here --srcdir-name=. --output-dir=$top_distdir --foreign Makefile
chmod -R a+r hello-1.0
GZIP=--best gtar chozf hello-1.0.tar.gz hello-1.0
rm -rf hello-1.0
一切工作得很好! 當然,在make install時由于需要向系統目錄拷貝文件,您需要有root權限。

更進一步
上述產生Makefile 的過程和以往自行編寫的方式非常不一樣,使用 Automake 只需用到一些已經定義好的宏可以了。我們把宏及目標 (target)寫在Makefile.am 文件內,Automake 讀入 Makefile.am 文件后會把這一串已經定義好的宏展開并產生相對應的
Makefile.in 文件,然后再由configure這個 shell script 根據 Makefile.in 產生合適的Makefile。
具體流程如下所示:
代碼 --> [autoscan*] --> [configure.scan] --> configure.in
configure.in --. .------> Autoconf* -----> configure
+---+
[aclocal.m4] --+ `---.
[acsite.m4] ---' |
+--> [autoheader*] -> [config.h.in]
[acconfig.h] ----. |
+-----'
[config.h.top] --+
[config.h.bot] --'

Makefile.am -- [Autoconf*] -------> Makefile.in

.-------------> config.cache
configure* ------------+-------------> config.log
|
[config.h.in] -. v .-> [config.h] -.
+--> config.status* -+ +--> make*
Makefile.in ---' `-> Makefile ---'

上圖表示在整個過程中要使用的文件及產生出來的文件,有星號 (*) 代表可執行文件。在此示例中可由 Autoconf 及 Automake 工具所產生的額外文件有 configure.scan、aclocal.m4、configure、Makefile.in,需要加入設置的有configure.in 及 Makefile.am。 開發者要書寫的文件集中為confiugre.in和Makefile.am,在minigui項目中,我們把一系列的命令集中到一個批處理文件中:autogen.sh:

#!/bin/sh
aclocal
autoheader
Automake --add-missing
Autoconf

只要執行該批處理文件,結合configure.in和Makefile.am,可以生成需要的Makefile了。

編輯 configure.in 文件
Autoconf 是用來產生 'configure'文件的工具。'configure' 是一個 shell script,它可以自動設定一些編譯參數使程序能夠條件編譯以符合各種不同平臺的Unix 系統。Autoconf會讀取configure.in 文件然后產生'configure' 這個 shell script。

configure.in 文件內容是一系列GNU m4 的宏,這些宏經Autoconf處理后會變成檢查系統特性的shell scripts。 configure.in文件中宏的順序并沒有特別的規定,但是每一個configure.in 文件必須在所有其它宏前加入 AC_INIT 宏,然后在所有其它宏的后加上 AC_OUTPUT宏。一般可先用 autoscan 掃描原始文件以產生一個 configure.scan 文件,再對 configure.scan 做些修改成 configure.in 文件。在例子中所用到的宏如下:

dnl
這個宏后面的內容不會被處理,可以視為注釋

AC_INIT(FILE)
該宏用來檢查源代碼所在路徑,autoscan 會自動產生,一般無須修改它。 

上一頁1234下一頁
軟件測試工具 | 聯系我們 | 投訴建議 | 誠聘英才 | 申請使用列表 | 網站地圖
滬ICP備07036474 2003-2017 版權所有 上海澤眾軟件科技有限公司 Shanghai ZeZhong Software Co.,Ltd
主站蜘蛛池模板: 亚洲欧美日韩中文综合在线不卡 | 在线天堂中文在线资源网 | 欧美日韩成人在线视频 | 日韩一区二区三区在线播放 | 午夜免费r级伦理片 | 夜夜橹 | 欧美成人综合 | 黄色三级视频在线观看 | 国产片一区二区三区 | 在线播放 你懂的 | 好吊色青青青国产在线播放 | 国产成人精品实拍在线 | 午夜在线观看免费视频 | 国产麻豆入在线观看 | 影音先锋欧美资源 | 在线观看免费视频黄 | 免费网站国产 | 福利视频精品 | 日韩欧美在线一级一中文字暮 | 色黄网 | 国产成人啪精品视频免费软件 | 国产成+人+亚洲+欧美+日韩 | 国产自产| 在线亚洲不卡 | 精品国产日韩亚洲一区在线 | 日韩永久免费进入2015 | 日本在线免费 | 亚洲视频精品在线观看 | 午夜国产小视频 | 成人久久久精品乱码一区二区三区 | 日本黄大片在线观看 | 极品精品国产超清自在线观看 | 久久久亚洲精品国产 | 日本三级欧美三级人妇英文 | 亚洲第一网站 | 欧美video巨大粗暴多人 | 一级毛片中国 | 国产精品高清一区二区三区不卡 | 香蕉视频老司机 | 国亚洲欧美日韩精品 | 精品400部自拍视频在线播放 |