[jack@localhost ~]$ wget https://github.com/chuanshanjia/ccpp/blob/master/frame.sh
[jack@localhost ccpp]$ ls
frame.sh
[jack@localhost ccpp]$ pwd
/home/jack/tool/ccpp
[jack@localhost ccpp]$ sh frame.sh autotools
configure.ac:6: installing `./install-sh'
configure.ac:6: installing `./missing'
...
[jack@localhost ccpp]$ ls
aclocal.m4 autom4te.cache ChangeLog config.h.in config.status configure.ac depcomp include install-sh Makefile.am missing README stamp-h1
AUTHORS autoscan.log config.h config.log configure COPYING frame.sh INSTALL Makefile Makefile.in NEWS src
清理:
[jack@localhost ccpp]$ sh frame.sh clear
[jack@localhost ccpp]$ ls
frame.sh
[jack@localhost ccpp]$
愉快的操作吧^_^
頭文件位置:
[jack@localhost ccpp]$ ls
aclocal.m4 autom4te.cache ChangeLog config.h.in config.status configure.ac depcomp include install-sh Makefile.am missing README stamp-h1
AUTHORS autoscan.log config.h config.log configure COPYING frame.sh INSTALL Makefile Makefile.in NEWS src
[jack@localhost ccpp]$ vim include/demo.h
main文件位置:
[jack@localhost ccpp]$ vim src/demo.cpp
編譯運行:
[jack@localhost ccpp]$ make
make all-am
make[1]: Entering directory `/home/jack/tool/ccpp'
g++ -DHAVE_CONFIG_H -I. -I/home/jack/tool/ccpp/include -I/home/jack/tool/ccpp/src/include -g -O2 -MT demo.o -MD -MP -MF .deps/demo.Tpo -c -o demo.o `test -f 'src/demo.cpp' || echo './'`src/demo.cpp
mv -f .deps/demo.Tpo .deps/demo.Po
g++ -g -O2 -o demo demo.o
make[1]: Leaving directory `/home/jack/tool/ccpp'
[jack@localhost ccpp]$ ./demo
hello,demo
[jack@localhost ccpp]$
以下內容可作為參考學習,幫助理解工具產生的過程,如非必要,可不進行閱讀。網上有很多類似內容,可以在百度搜索“autotools"就能看到整個過程。
工具准備(參考) autoscanaclocalautoheader automakeautoconfautomake
准備Makefile.am文件
INCLUDES=-I./include -I./src/include
UTOMAKE_OPTIONS=foreign
bin_PROGRAMS=test
test_SOURCES=src/test.cpp
使用智能化工具(參考)
autoscan
當我們利用autoscan工具生成confiugre.scan文件時,我們需要將confiugre.scan重命名為confiugre.ac文件。confiugre.in調用一系列autoconf宏來測試程序需要的或用到的特性是否存在,以及這些特性的功能。
具體使用如下:
[jack@localhost tool]$ autoscan
[jack@localhost tool]$ ls
autoscan.log configure.scan include src
[jack@localhost tool]$ mv configure.scan configure.ac
[jack@localhost tool]$ ls
autoscan.log configure.in include src[jack@localhost tool]$ vim configure.ac
修改點:
一氣呵成
aclocal
autoconf
autoheader
automake --add-missing
automake --add-missing
touch NEWS README AUTHORS ChangeLog
automake --add-missing
./configure
參考手冊 confiugre.in文件的一般布局:
AC_INIT
測試程序
測試函數庫
測試頭文件
測試類型定義
測試結構
測試編譯器特性
測試庫函數
測試系統調用
AC_OUTPUT
在Makefile.am中盡量使用相對路徑,系統預定義了兩個基本路徑:
推薦
本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系我们删除。