

So you can see that the make command first creates the dependencies and then the actual target. To compile the project, you can either simply use 'make' or can use the target 'all' with the make command. Now, let's have a look at some of the examples of make command usage in Linux. Now, suppose you make change to only one source file and you execute the make command again, it will only compile the object files corresponding to that source file, and hence will save a lot of time in compiling the final executable.Īnd here are the contents of the Makefile : all: test

Once the main dependencies are build, it then builds the main target (that was passed to the make command). If these dependencies are targets themselves, it scans the Makefile for these targets and builds their dependencies (if any), and then builds them. When the make command is executed for the very first time, it scans the Makefile to find the target (supplied to it) and then reads its dependencies.
#MAKE BASH SHELL FOR WINDOWS LOOK BETTER SERIES#
For more information, read our series of articles on how Makefiles work. These targets are usually specified in a file named 'Makefile', which also contains the associated action corresponding to the targets. In this article, we will discuss the internal working of the make command along with some practical examples.įor those who are unaware, the make command accepts targets as command line arguments. While it helps administrators in compiling and installing many open source utilities through the command line, programmers use it to manage the compilation of their large and complicated projects. The make command in Linux is one of the most frequently used commands by the system administrators and the programmers.
