Order under Linux C or C + + project development, Makefile is the necessary strength, but found handwriting is very troublesome. Baidu has a comake2 tool, used to automatically generate makefile tools, and in the outside of this wanted to find a similar tool, but found it difficult to do, only found a similar intelligent generation tool Autotools, but the operation is more troublesome, Ben "
one person to learn, we share "principle, Manually wrote a tool class to help yourself and everyone to generate a ready-made C or CPP framework. the code is relatively simple, I hope we can improve together. git path: https://github.com/chuanshanjia/ccpp/blob/master/frame.shgit description: https://github.com/chuanshanjia/ccpp/blob/master/README.md
I also want you to put forward more good ideas (such as name, function), we improve this tool together, please leave comments, I collected. How to use
Deployment:
[[email protected] ~]$ wget https://github.com/chuanshanjia/ccpp/blob/master/frame.sh[[email protected] ccpp]$ ls Frame.sh[[email protected] ccpp]$ pwd/home/jack/tool/ccpp[[email protected] ccpp]$ sh frame.sh autotoolsconfigure.ac:6 : Installing './install-sh ' configure.ac:6: Installing './missing ' ... [Email protected] ccpp]$ lsaclocal.m4 autom4te.cache ChangeLog config.h.in config.status Configure.ac depcomp include install-sh makefile.am missing README Stamp-h1authors autoscan.log config.h config.log Configure COPYING frame.sh INSTALL Makefile makefile.in NEWS src
Cleanup:
Let's have a pleasant operation ^_^
Header File Location:
[Email protected] ccpp]$ lsaclocal.m4 autom4te.cache ChangeLog config.h.in config.status Configure.ac depcomp include install-sh makefile.am missing README Stamp-h1authors autoscan.log config.h config.log Configure COPYING frame.sh INSTALL Makefile makefile.in NEWS
Main file Location:
[Email protected] ccpp]$ vim Src/demo.cpp
Compile run:
[Email protected] ccpp]$ Makemake all-ammake[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.cppmv-f. Deps/demo. Tpo. Deps/demo. pog++ -g-o2- o demo demo.o
The following can be used as reference learning to help understand the process that the tool produces, such as not necessary, to be read. There are many similar content on the Internet, you can search "Autotools" in Baidu to see the whole process.
Tool Preparation (Reference) Autoscanaclocalautoheader Automake
autoconf
Automake
Preparing the makefile.am file
using intelligent Tools (Reference)
AutoScan
When we use the AutoScan tool to generate the Confiugre.scan file, we need to rename the Confiugre.scan to Confiugre.ac file. Confiugre.in calls a series of autoconf macros to test for the existence of the required or used features of the program, and the functionality of those features.
The specific use is as follows:
[Email protected] tool]$ AutoScan [[email protected] tool]$ lsautoscan.log configure.scan include src[[ Email protected] tool]$ MV Configure.scan configure.ac
[[email protected] tool]$ ls
Modify point:
Coherent
Aclocalautoconfautoheaderautomake--add-missingautomake--add-missingtouch NEWS README AUTHORS Changelogautomake--add-missing./configure
Reference manual general layout of the Confiugre.in file:
Ac_init test program test function library test head file test type definition Test structure Test compiler feature test library function test system call Ac_output
Table 1makefile.am General Format table 2 global variables available in makefile.am
Using relative paths as much as possible in makefile.am, the system has predefined two basic paths:
Path variables available in table 3makefile.am Reference Documents 1, http://www.ibm.com/developerworks/cn/linux/l-makefile/2, Https://www.gnu.org/software/autoconf/manual/autoconf-2.61/html_node/Autoconf-Language.html#Autoconf-Language
Recommended
The
C + + Makefile automatic generation tool (Comake2,autotools,linux), hoping to make a little contribution to open source!