Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linux: Create automatically C++ makefile from given source files

I have a project structure like that:

src/main.cpp
src/Folder/this.cpp
src/Folder/that.cpp
src/NewFolder/foo.cp
// etc.

In addition I need some libs so that I can link, e.g. lboost_system. How can I simply create a makefile with these given information? I read all the time about creating a makefile manually, CMake and so on but this is in my opinion way to complicated! Isn't there any tool where I can specify the following information:

Source folder: /home/bla/src/
Additional Libs: lboost_system
Compiler Flags: -std=c++0x (or whatever)

And a makefile is generated?! Is it really that hard?

like image 836
Anonymous Avatar asked Sep 28 '13 17:09

Anonymous


1 Answers

You can write a Makefile in a generic way - that is you won't have to specify each source file one by one. Have a look at http://www.puxan.com/Computers/Howto-write-generic-Makefiles, I did it quite a long time ago, so I don't remember details, but in the end adding *.cpp files does not (usually) require a Makefile change.

You can also have a look at automake (http://www.gnu.org/software/automake/manual/automake.html) which is some step ahead to bare cmake. It standardizes make goals and looks like make your life easier if you want to distribute your software as source files.

like image 166
Mariusz Lotko Avatar answered Oct 22 '22 01:10

Mariusz Lotko