Makefile : Basic to Advance in 5 steps in Linux
RAJ PRAJAPATI
Senior Tech Lead – Future Industry Leader | Automotive R&D | C++ & Linux Expert | Strategic Leader Driving Innovation | Strategic Decision-Maker & Team Leader | Driving Innovation & High-Impact Deliveries |
Makefile : Basic to Advance in Linux
1 Program 5 Makefile, Learn Make on your Tips
Makefile is a program building tool which runs on Unix, Linux, and their flavors used for compiling the programs and preparing the executable.
Consider a case where you have one 5 file to compile. You can use g++/gcc to compile all the 5 file, but what if the no of files reaches to 1000 or more ? Then you do not have time to compile each and every file, also it seems very difficult to do so.
Hence, to simpler this task "make" utility is used present in Linux, Unix and its flavours like Ubuntu, Fadora etc . Working on Makefile itself is a challenge.
You can find the learning resource from GNU at https://www.gnu.org/software/make/manual/make.pdf
But practical implementation of it explains better. Here is the program written in C++ for Calculator that will add, subtract, divide and multiply. In this program focus is not on the program (that you can write anyways) but on the Makefile.
Git Repository : https://github.com/rajatmelavr/Makefile
Here in this repository, you can do many enhancements on Makefile, but it is kept as simple as possible so that you can understand each and every steps of Makefile. Code is not touched in any commit, just Makefile is update. Compare the Makefiles and see the differences. Download the code and try experimenting on it to have good control on Makefile.
Any enhancement in the Makefile is invited, as much as you contribute, more you learn.