标签:
[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"就能看到整个过程。
准备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
AC_INIT 测试程序 测试函数库 测试头文件 测试类型定义 测试结构 测试编译器特性 测试库函数 测试系统调用 AC_OUTPUT
在Makefile.am中尽量使用相对路径,系统预定义了两个基本路径:
C/C++ makefile自动生成工具(comake2,autotools,linux),希望能为开源做点微薄的贡献!
标签:
原文地址:http://www.cnblogs.com/baochuan/p/5243227.html