

{"id":110421,"date":"2022-09-10T09:00:44","date_gmt":"2022-09-10T03:30:44","guid":{"rendered":"https:\/\/data-flair.training\/blogs\/?p=110421"},"modified":"2022-09-10T09:07:02","modified_gmt":"2022-09-10T03:37:02","slug":"makefile-in-linux","status":"publish","type":"post","link":"https:\/\/data-flair.training\/blogs\/makefile-in-linux\/","title":{"rendered":"Makefile in linux"},"content":{"rendered":"<p>By the end of this article, you will what linux makefile is, why it is used, look at the alternatives of makefile, version, and types of make, and only then go to the practical part.<\/p>\n<p>The fun part begins when we start looking at how to use a makefile. We will cover most of the ground as we discuss variables, conditional loops like if-else, functions like forereach function, call function, shell function and so many more coll topics. So let&#8217;s start!!!<\/p>\n<h3>What is a makefile and why do we use it?<\/h3>\n<p>Makefile is a command-line-based utility in Linux-based operating systems that helps us in deciding which part of gargantuan programs needs to be recompiled. It comes in handy when you want to run or update a task when certain files are updated.<\/p>\n<p>The make file tool requires a file that either goes by the name \u201cMakefile\u201d or \u201cmakefile\u201d with a set of tasks that need to be executed. Most open-source projects use \u2018make\u2019 to compile a final executable program which can later be installed by using \u201cmake install\u201d.<\/p>\n<p>In this tutorial, we will be prioritizing C and C++ as in the majority of the cases these programs are compiled as other languages have their own tools.<\/p>\n<h3>Are there alternatives to Make?<\/h3>\n<p>Of course, there are! Take C\/C++ for example, they have alternate build systems like Scons, CMake, Bazel, Ninja, and more. Other code editors like VS Code (Visual Studio Code) have their own in-built tools.<\/p>\n<p>Java also has its own tools, namely Ant, Maven, and Gradle. However, programming languages like Python, Ruby, and javascript don\u2019t require analog Makefiles.<\/p>\n<h3>Versions of Makefile<\/h3>\n<p>There are various implementations of Make, but don\u2019t worry, most of this tutorial will work on any version of Make. All the examples shown in this article work on all the versions 3 and 4. The version of Makefile I am using currently is 4.2.1.<\/p>\n<p>If you want to see the version of your Make, simply type the command \u201cmake -version\u201d in the terminal.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/version-of-makefile.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110619\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/version-of-makefile.webp\" alt=\"version of makefile\" width=\"780\" height=\"168\" \/><\/a><\/p>\n<h3>How does Make work?<\/h3>\n<p>The main goal of Makefile is to compile the files of your code that need to be compiled. It does this based on what files have changed. But when the files in the interpreted programming language change, nothing needs to be recompiled. You must keep in mind that when the program runs, the most recent version of the file is used.<\/p>\n<p>Here is a diagram showing the example dependency graph that you might build with Make. You must not that the file will get recompiled If any file&#8217;s dependencies change:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/06\/how-does-makefile-work.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110560\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/06\/how-does-makefile-work.webp\" alt=\"how does makefile work\" width=\"672\" height=\"351\" \/><\/a><\/p>\n<h3>Syntax of the makefile command in linux<\/h3>\n<p>Every MakeFile consists of a set of rules, and a rule looks like this:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">&lt;targets&gt;: &lt;prerequisite&gt;\r\n&lt;command&gt;\r\n&lt;command&gt;\r\n&lt;command&gt;<\/pre>\n<p>Let us take a closer look at the fields in the syntax of writing a rule:<\/p>\n<h4>1. &lt;targets&gt;<\/h4>\n<p>The targets are nothing but file names, separated by spaces. Mostly, there is only one per rule.<\/p>\n<h4>2. &lt;prerequisite&gt;<\/h4>\n<p>The prerequisite file is also file names, separated by spaces. However, you need to keep in mind that the files you specified need to exist before the commands for the target are run. Prerequisites are also called dependencies.<\/p>\n<h4>3. &lt;commands&gt;<\/h4>\n<p>The commands are a set of actions or a series of steps typically used to make the target(s). You must always bear in mind that commands always start with a tab character and not spaces. If at all you give spaces instead of a tab, make will fail.<\/p>\n<h3>Printing \u201cHello World\u201d<\/h3>\n<p>Before we jump into the action of Make, let us print the cliched \u201chello world\u201d statement to understand how to write make and execute them. First of all, you need to have \u201cMake\u201d installed in your system, if you don\u2019t you can simply use the command \u201csudo apt install make\u201d.<\/p>\n<p>We need a file to write the set of instructions right, well, there are countless ways of creating it, you can use, nano, vim, vi, gedit, cat and so many more, the only thing that is important is that the name of the file must either be \u201cMakefile\u201d or \u201cmakefile\u201d. Once you create the file, write the following piece of code in it:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-for-printing-Hello-world.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110621\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-for-printing-Hello-world.webp\" alt=\"code for printing Hello world\" width=\"350\" height=\"58\" \/><\/a><\/p>\n<p>Once you have written it, save and close it. To execute it, simply type the command \u201cmake\u201d in the terminal, and you will get the following output:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/printing-hello-world.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110622\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/printing-hello-world.webp\" alt=\"printing hello world\" width=\"652\" height=\"133\" \/><\/a><\/p>\n<h3>Beginner examples<\/h3>\n<p>Before we actually head-on and understand variables, conditionals, functions, and more, let us get our basics straight and understand how targets, prerequisites, and commands work by looking at some simple and small examples.<\/p>\n<p>Let us create a Makefile that has 3 separate rules, when you run \u201cmake blah\u201d in the terminal, it will build a program called \u201cblah\u201d in the following series of steps:<\/p>\n<p>1. Since make is given \u201cblah\u201d as the target, it searched for this target<\/p>\n<p>2. \u201cblah\u201d requires \u201cblah.o\u201d, so it searched for \u201cblah.o\u201d<\/p>\n<p>3. \u201cblah.o\u201d requires \u201cblah.c\u201d. co it searches for this target.<\/p>\n<p>4. However, \u201cblah.c\u201d has o dependencies, so it runs the \u201cecho\u201d command<\/p>\n<p>5. Then the \u201ccc -c\u201d command is run as all of the \u201cblah.o\u201d dependencies are finished<\/p>\n<p>6. Then the \u201ccc\u201d command as all of the \u201cblah\u201d dependencies are finished<\/p>\n<p>7. And voila! \u201cBlah\u201d is now a fully compiled C program.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/example-to-understanding-how-make-files-works.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110623\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/example-to-understanding-how-make-files-works.webp\" alt=\"example to understanding how make files works\" width=\"600\" height=\"228\" \/><\/a><\/p>\n<p>And here is the output, executed just like we anticipated!!<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-blah.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110624\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-blah.webp\" alt=\"output of blah\" width=\"608\" height=\"135\" \/><\/a><\/p>\n<p>Let us look at a few more examples before proceeding further.<\/p>\n<p>In the below-shown makefile, we only have a single target called \u201ca_file\u201d, so the default target is the first target, so the \u201ca_file\u201d will run.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/another-example-to-understanding-how-make-files-works.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110625\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/another-example-to-understanding-how-make-files-works.webp\" alt=\"another example to understanding how make files works\" width=\"522\" height=\"96\" \/><\/a><\/p>\n<p>And when we execute the Makefile, we will get the following output:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/prints-the-line-everytime.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110626\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/prints-the-line-everytime.webp\" alt=\"prints the line everytime\" width=\"488\" height=\"104\" \/><\/a><\/p>\n<p>In the below-shown makefile, all we did is add a touch command to create \u201ca_file\u201d.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/adding-touch-command-to-the-program.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110627\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/adding-touch-command-to-the-program.webp\" alt=\"adding touch command to the program\" width=\"562\" height=\"122\" \/><\/a><\/p>\n<p>And we get the output as expected nothing special, we also created the file \u201ca_file\u201d, which we can see by running the \u201cls\u201d command<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/creates-a-file-when-executed-the-first-time.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110628\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/creates-a-file-when-executed-the-first-time.webp\" alt=\"creates a file when executed the first time\" width=\"504\" height=\"175\" \/><\/a><\/p>\n<p>But the special part is when you run the program again, Make is clever enough to not create another \u201ca_file\u201d but tells you that it is already created and up to date!<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/updates-the-file-instead-of-creating-it-when-run-after-the-first-time.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110629\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/updates-the-file-instead-of-creating-it-when-run-after-the-first-time.webp\" alt=\"updates the file instead of creating it when run after the first time\" width=\"535\" height=\"85\" \/><\/a><\/p>\n<p>If we now make this program slightly more complex by depending the target \u201ca_file\u201d on \u201cb_file\u201d, the target will first look at its list of dependencies, and if any of them are older, it will first run the targets for those dependencies, and then run itself. However, the second time you execute this program, neither target will run because both targets exist.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-to-create-2-files.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110630\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-to-create-2-files.webp\" alt=\"code to create 2 files\" width=\"462\" height=\"208\" \/><\/a><\/p>\n<p>So in the command shown below, first the target \u201cb_file\u201d will run followed by \u201ca_file\u201d. Anagin you can check if the file \u201cb_file\u201d is successfully created or not by using the ls command.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/checking-if-program-created-2-files.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110631\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/checking-if-program-created-2-files.webp\" alt=\"checking if program created 2 files\" width=\"585\" height=\"229\" \/><\/a><\/p>\n<p>Now that we got the hang of how Makefiles work, and how the program executes, let us dive deeper and explore things like targste, variables, conditional statements, functions and more.<\/p>\n<h3>Targets<\/h3>\n<p>If you want to make multiple target and run all of them, you can simply make an all target<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-useing-targets.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110632\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-useing-targets.webp\" alt=\"code useing targets\" width=\"365\" height=\"290\" \/><\/a><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-targets.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110634\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-targets.webp\" alt=\"output of the code using targets\" width=\"488\" height=\"125\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h4>Multiple targets<\/h4>\n<p>When there are multiple targets for a rule, the commands will be run for each target specified. We can use the \u201c$@\u201d which is an automatic variable that contains the target name. Here is an example:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-mutiple-targets.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110635\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-mutiple-targets.webp\" alt=\"code using multiple targets\" width=\"232\" height=\"140\" \/><\/a><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-mutiple-targets.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110633\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-mutiple-targets.webp\" alt=\"output of the code using mutiple targets\" width=\"510\" height=\"146\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>Infact, the above shown program is the same as the program shown below:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/alternate-way-to-write-mutiple-targets.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110636\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/alternate-way-to-write-mutiple-targets.webp\" alt=\"alternate way to write mutiple targets\" width=\"270\" height=\"144\" \/><\/a><\/p>\n<p>And we even get the same output:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-mutiple-targets.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110633\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-mutiple-targets.webp\" alt=\"output of the code using mutiple targets\" width=\"510\" height=\"146\" \/><\/a><\/p>\n<h3>Variables<\/h3>\n<p>In Make variables can only be strings, they can\u2019t be integer, float. Booleans, etc, just plain strings. You typically use, \u201c:=\u201d but \u201c=\u201d also works. Let us look at an example to get a better understanding:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-showcasing-the-use-of-variables.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110637\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-showcasing-the-use-of-variables.webp\" alt=\"code showcasing the use of variables\" width=\"578\" height=\"340\" \/><\/a><\/p>\n<p>Here is the output of the program shown in the above screenshot:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-showcasing-the-use-of-variables.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110638\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-showcasing-the-use-of-variables.webp\" alt=\"output of the code showcasing the use of variables\" width=\"508\" height=\"170\" \/><\/a><\/p>\n<p>Reference variables on the other hand use \u201c${}\u201d or \u201c$()\u201d, here is an example<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-reference-variables.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110639\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-reference-variables.webp\" alt=\"code using reference variables\" width=\"278\" height=\"188\" \/><\/a><\/p>\n<p>And the output for the above shown code:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-reference-variables.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110641\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-reference-variables.webp\" alt=\"output of the code using reference variables\" width=\"485\" height=\"186\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<h3>Flavors and modification<\/h3>\n<p>In make, there are 2 flavor variables:<\/p>\n<ul>\n<li>= (recursive) &#8211; It only looks for the variables when the command is used<\/li>\n<li>:= (simply expanded) &#8211; only those defined so far get expanded<\/li>\n<\/ul>\n<p>Here is an examples using both the Recursive and simply expanded variables:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/another-example-of-a-code-using-reference-variables.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110643\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/another-example-of-a-code-using-reference-variables.webp\" alt=\"another example of a code using reference variables\" width=\"360\" height=\"296\" \/><\/a><\/p>\n<p>&nbsp;<\/p>\n<p>And the output of the code shown above:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-above-code-using-reference-variable-1.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110645\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-above-code-using-reference-variable-1.webp\" alt=\"output of the above code using reference variable\" width=\"495\" height=\"149\" \/><\/a><\/p>\n<p>The simply expanded variable allows you to append a variable as shown:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-the-simply-expanded-variable.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110642\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-the-simply-expanded-variable.webp\" alt=\"code using the simply expanded variable\" width=\"278\" height=\"166\" \/><\/a><\/p>\n<p>Here we appended \u201chello\u201d (as a variable) to \u201cthere\u201d as seen below:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-the-simply-expanded-variable.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110644\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-the-simply-expanded-variable.webp\" alt=\"output of the code using the simply expanded variable\" width=\"488\" height=\"100\" \/><\/a><\/p>\n<p>Another variable is \u201c?=\u201d, it only sets variables if they have not yet been set as shown in the below example:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-to-sets-variables-if-they-have-not-yet-been-set.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110646\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-to-sets-variables-if-they-have-not-yet-been-set.webp\" alt=\"code to sets variables if they have not yet been set\" width=\"302\" height=\"206\" \/><\/a><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-that-sets-variables-if-they-have-not-yet-been-set.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110647\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-that-sets-variables-if-they-have-not-yet-been-set.webp\" alt=\"output of the code that sets variables if they have not yet been set\" width=\"484\" height=\"154\" \/><\/a><\/p>\n<p>If you think of giving spaces to your variables, you can do so, However, Spaces at the end of a line are not stripped, but those at the start are. Therefore, if you want to give spaces in a proper and professional way, create a variables called \u201c$(nullstring)\u201d<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-the-nullstring-variable.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110648\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-the-nullstring-variable.webp\" alt=\"code using the nullstring variable\" width=\"778\" height=\"250\" \/><\/a><\/p>\n<p>As you can see in every place we put the null string variables we get a blank space in the output as shown below:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-the-nullstring-variable.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110648\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-the-nullstring-variable.webp\" alt=\"code using the nullstring variable\" width=\"778\" height=\"250\" \/><\/a> <a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-the-nullstring-variable.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110649\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-the-nullstring-variable.webp\" alt=\"output of the code using the nullstring variable\" width=\"530\" height=\"154\" \/><\/a><\/p>\n<p>If at all you are wondering what happens if we don\u2019t define a variable? The answer is that they will simply be an empty string.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-where-we-dont-define-a-variable.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110651\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-where-we-dont-define-a-variable.webp\" alt=\"code where we dont define a variable\" width=\"302\" height=\"94\" \/><\/a><\/p>\n<p>As you can see even though we used the variables \u201cnowhere\u201d, we did not define it, but it still acts as an empty string.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-empty-string.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110650\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-empty-string.webp\" alt=\"output of the code using empty string\" width=\"488\" height=\"105\" \/><\/a><\/p>\n<h4>Command-line arguments and override<\/h4>\n<p>You can actually override the variables that come from the command line by using override. Here is an example:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-showcasing-command-line-arguments-and-override.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110652\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-showcasing-command-line-arguments-and-override.webp\" alt=\"code showcasing command line arguments and override\" width=\"522\" height=\"208\" \/><\/a><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-showcasing-command-line-arguments-and-override.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110653\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-showcasing-command-line-arguments-and-override.webp\" alt=\"output of the code showcasing command line arguments and override\" width=\"490\" height=\"142\" \/><\/a><\/p>\n<h4>List of commands and \u201cdefine\u201d<\/h4>\n<p>\u201cDefine\u201d is actually just a list of commands, don\u2019t confuse it with a function. Here is an example:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-showcasing-how-define-works.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110654\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-showcasing-how-define-works.webp\" alt=\"code showcasing how define works\" width=\"780\" height=\"262\" \/><\/a><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-showcasing-how-define-works.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110655\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-showcasing-how-define-works.webp\" alt=\"output of the code showcasing how define works\" width=\"780\" height=\"129\" \/><\/a><\/p>\n<h4>Target specific variables<\/h4>\n<p>You can also assign variables for specific targets as shown below:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-target-specific-variables.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110656\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-target-specific-variables.webp\" alt=\"code using target specific variables\" width=\"502\" height=\"225\" \/><\/a><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-target-specific-variables.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110657\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-target-specific-variables.webp\" alt=\"output of the code using target specific variables\" width=\"508\" height=\"101\" \/><\/a><\/p>\n<h4>Pattern specific variables<\/h4>\n<p>Variables can also be set for specific patterns as shown below:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-pattern-specific-variables.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110658\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-pattern-specific-variables.webp\" alt=\"code using pattern specific variables\" width=\"490\" height=\"228\" \/><\/a><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-pattern-specific-variables.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110659\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-pattern-specific-variables.webp\" alt=\"output of the code using pattern specific variables\" width=\"496\" height=\"79\" \/><\/a><\/p>\n<h4>Automatic variables<\/h4>\n<p>There are many automatic variables that we can use in makefiles, but only a few showup.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-automatic-variables.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110660\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-automatic-variables.webp\" alt=\"code using automatic variables\" width=\"636\" height=\"462\" \/><\/a><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-automatic-variables.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110661\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-automatic-variables.webp\" alt=\"output of the code using automatic variables\" width=\"640\" height=\"312\" \/><\/a><\/p>\n<h3>Wildcards<\/h3>\n<p>In make files we can use either \u201c*\u201d or \u201c%\u201d as wildcards, but they mean entirely different things. Let&#8217;s look at the difference between th 2.<\/p>\n<h4>1. *<\/h4>\n<p>This wildcard searches your filesystem for matching filenames<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-the-astriesk-wildcard.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110662\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-the-astriesk-wildcard.webp\" alt=\"code using the astriesk wildcard\" width=\"758\" height=\"402\" \/><\/a><\/p>\n<h4>2. %<\/h4>\n<p>This wildcard is used for the following tasks:<\/p>\n<p>a. matches one or more characters in a string. This match is called the stem.<\/p>\n<p>b. takes the stem that was matched and replaces that in a string.<\/p>\n<p>c. used in rule definitions and in some specific functions.<\/p>\n<h3>Fancy rules<\/h3>\n<p>In Make files we have the following fancy rules<\/p>\n<p>1. Implicit rules<\/p>\n<p>2. Static pattern rules<\/p>\n<p>3. Static pattern rules and filter<\/p>\n<p>4. Pattern rules<\/p>\n<p>5. Double-colon Rules<\/p>\n<p>Let us look at each one in detail along with an example:<\/p>\n<h4>Implicit rules<\/h4>\n<p>When make is compiling c programs, it uses a automatic rules, make calls these \u201cimplicit rules\u201d here is a list of the Implicit rules:<\/p>\n<h4>Compiling a C program:<\/h4>\n<p>\u201cn.o\u201d is made automatically from \u201cn.c\u201d with a command of the form $(CC) -c $(CPPFLAGS) $(CFLAGS)<\/p>\n<h4>Compiling a C++ program<\/h4>\n<p>n.o is made automatically from n.cc or n.cpp with a command of the form $(CXX) -c $(CPPFLAGS) $(CXXFLAGS)<\/p>\n<h4>Linking a single object file<\/h4>\n<p>n is made automatically from n.o by running the command $(CC) $(LDFLAGS) n.o $(LOADLIBES) $(LDLIBS)<\/p>\n<p>Here is an example to build a C program without explicitly telling Make how to do the compilation:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/example-of-a-code-to-build-a-C-program-without-explicitly-telling-Make-how-to-do-the-compilation.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110663\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/example-of-a-code-to-build-a-C-program-without-explicitly-telling-Make-how-to-do-the-compilation.webp\" alt=\"example of a code to build a C program without explicitly telling Make how to do the compilation\" width=\"780\" height=\"226\" \/><\/a><\/p>\n<h4>Static pattern rules<\/h4>\n<p>Static [pattern rules is another way to write less in a Makefile!the syntax we use is shown below:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">targets...: target-pattern: prereq-patterns ...\r\ncommands<\/pre>\n<p>The basic idea is that the given target is matched by the target-pattern (through a % wildcard). Here is an example:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-static-pattern-rules.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110664\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-static-pattern-rules.webp\" alt=\"code using static pattern rules\" width=\"558\" height=\"332\" \/><\/a><\/p>\n<h4>Static pattern rules and filters<\/h4>\n<p>The filter can be used in static pattern rules to match the correct files. In the example shown below, I made up the .raw and .result extensions.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-static-pattern-rules-and-filters.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110665\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-static-pattern-rules-and-filters.webp\" alt=\"code using static pattern rules and filters\" width=\"478\" height=\"334\" \/><\/a><\/p>\n<h4>Pattern rules<\/h4>\n<p>Pattern rules are best used for<\/p>\n<p>1. Defining your own implicit rules<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-pattern-rules-for-defining-your-own-implicit-rules.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110666\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-pattern-rules-for-defining-your-own-implicit-rules.webp\" alt=\"code using pattern rules for defining your own implicit rules\" width=\"780\" height=\"115\" \/><\/a><\/p>\n<p>2. Used as a simpler form of static pattern rule.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-to-use-pattern-rules-as-a-simpler-form-of-static-pattern-rule.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110667\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-to-use-pattern-rules-as-a-simpler-form-of-static-pattern-rule.webp\" alt=\"code to use pattern rules as a simpler form of static pattern rule\" width=\"765\" height=\"140\" \/><\/a><\/p>\n<h4>Double &#8211; colon rules<\/h4>\n<p>Double colon rules are very seldom used. These rules allow multiple rules to be defined for the same target. You must be careful while using them and not get confused with single colons, as a warning would be printed and only the second set of commands would run.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-double-colon-rules.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110668\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-double-colon-rules.webp\" alt=\"code using double colon rules\" width=\"332\" height=\"212\" \/><\/a><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-double-colon-rules.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110669\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-double-colon-rules.webp\" alt=\"output of the code using double colon rules\" width=\"484\" height=\"145\" \/><\/a><\/p>\n<h3>Commands and execution<\/h3>\n<h4>Command echoing\/silencing<\/h4>\n<p>To stop a command from being printed, use the at the rate (@) symbol before the command. You can also run make with \u201c-s \u201cto add an at the rate symbol (@) before each line.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-showcasing-command-silencing.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110670\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-showcasing-command-silencing.webp\" alt=\"code showcasing command silencing\" width=\"622\" height=\"118\" \/><\/a><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-showcasing-command-silencing.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110671\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-showcasing-command-silencing.webp\" alt=\"output of the code showcasing command silencing\" width=\"508\" height=\"125\" \/><\/a><\/p>\n<h4>Command execution<\/h4>\n<p>Each command runs in a new shell<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-showcasing-command-execution.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110672\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-showcasing-command-execution.webp\" alt=\"code showcasing command execution\" width=\"780\" height=\"194\" \/><\/a><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-showcasing-command-execution.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110673\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-showcasing-command-execution.webp\" alt=\"output of the code showcasing command execution\" width=\"780\" height=\"216\" \/><\/a><\/p>\n<h4>Default shell<\/h4>\n<p>Speaking of shell, every makefile\u2019s default shell is the \/bin\/sh however, you can change this by using the variable \u201cSHELL\u201d at the beginning of the program as shown below:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-to-change-the-default-shell.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110674\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-to-change-the-default-shell.webp\" alt=\"code to change the default shell\" width=\"480\" height=\"154\" \/><\/a><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-to-change-the-default-shell.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110675\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-to-change-the-default-shell.webp\" alt=\"output of the code to change the default shell\" width=\"495\" height=\"100\" \/><\/a><\/p>\n<h4>Error handling<\/h4>\n<p>We handle different errors by using the following characters:<\/p>\n<h5>1. -k<\/h5>\n<p>We can use \u201c-k\u201d when running make to continue running even if it faces errors.<\/p>\n<h5>2. &#8211;<\/h5>\n<p>We can use \u201c-\u201d before a command to suppress the error<\/p>\n<h5>3. -i<\/h5>\n<p>We can use \u201c-i\u201d to make to have this happen for every command<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-to-handle-errors-by-using-the-option-i.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110676\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-to-handle-errors-by-using-the-option-i.webp\" alt=\"code to handle errors by using the option i\" width=\"780\" height=\"122\" \/><\/a><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-the-option-i-to-handle-errors.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110677\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-the-option-i-to-handle-errors.webp\" alt=\"output of the code using the option i to handle errors\" width=\"496\" height=\"79\" \/><\/a><\/p>\n<h4>Interrupting or Killing make<\/h4>\n<p>You can simply interrupt or kill make in the middle of something by pressing the key combination \u201cctrl\u201d + \u201cc\u201d. It will also delete the newer targets it just made.<\/p>\n<h4>Recursively using make<\/h4>\n<p>If you want to recursively call a makefile, use the special variable \u201c$(MAKE)\u201d instead of \u201cmake\u201d. Why? Because it will pass the make flag for you and won\u2019t affect itself by them. Here is an example:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/recursively-using-make.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110679\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/recursively-using-make.webp\" alt=\"recursively using make\" width=\"780\" height=\"224\" \/><\/a><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-recursively-using-make.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110680\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-recursively-using-make.webp\" alt=\"output of recursively using make\" width=\"780\" height=\"176\" \/><\/a><\/p>\n<h4>Using export for recursively calling a makefile<\/h4>\n<p>Another way to recursively call a makefile is by using export. The export directive takes a variable and makes it accessible to the command present in make, or most commonly called sub make commands.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-export-for-recursively-calling-a-makefile.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110678\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-export-for-recursively-calling-a-makefile.webp\" alt=\"code using export for recursively calling a makefile\" width=\"780\" height=\"424\" \/><\/a><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-export-for-recursively-calling-a-makefile.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110681\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-export-for-recursively-calling-a-makefile.webp\" alt=\"output of the code using export for recursively calling a makefile\" width=\"780\" height=\"299\" \/><\/a><\/p>\n<h3>If-else statement in Makefiles<\/h3>\n<p>We all know how the if-else statement works, the logic behind it is the same, the only thing that changes between various programming languages is the syntax. Let us look at one example to get a better idea of if-else statements in Makefiles:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-showcasing-the-use-of-if-else-statement.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110682\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-showcasing-the-use-of-if-else-statement.webp\" alt=\"code showcasing the use of if else statement\" width=\"475\" height=\"202\" \/><\/a><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-showcasing-the-use-of-if-else-statement.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110683\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-showcasing-the-use-of-if-else-statement.webp\" alt=\"output of the code showcasing the use of if else statement\" width=\"522\" height=\"98\" \/><\/a><\/p>\n<p>The above program checks if the string is \u201cDataFlair\u201d or not. Let us now use this conditional statement in a few examples.<\/p>\n<h4>Checking if a variable is empty or not<\/h4>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-to-check-if-a-variable-is-empty-or-not.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110684\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-to-check-if-a-variable-is-empty-or-not.webp\" alt=\"code to check if a variable is empty or not\" width=\"678\" height=\"272\" \/><\/a><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-to-check-if-a-variable-is-empty-or-not.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110685\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-to-check-if-a-variable-is-empty-or-not.webp\" alt=\"output of the code to check if a variable is empty or not\" width=\"538\" height=\"154\" \/><\/a><\/p>\n<h3>Functions in Makefiles<\/h3>\n<p>In make there are the following function:<\/p>\n<p>1. First functions<\/p>\n<p>2. String substitution<\/p>\n<p>3. Foreach function<\/p>\n<p>4. If function<\/p>\n<p>5. Call function<\/p>\n<p>6. Shell function<\/p>\n<p>Let us dive deeper and understand each one of them with the help of an example:<\/p>\n<h4>First functions<\/h4>\n<p>The primary purpose of functions is text processing, you can also make your own functions using the call built in function.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-first-functions.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110687\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-first-functions.webp\" alt=\"code using first functions\" width=\"758\" height=\"228\" \/><\/a><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-first-functions.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110688\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-first-functions.webp\" alt=\"output of the code using first functions\" width=\"756\" height=\"115\" \/><\/a><\/p>\n<h4>String substitution<\/h4>\n<p>The string substitution function finds whitespace separated word in the text that match pattern and replaces them with the replacement you specified.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-string-substitution.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110689\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-string-substitution.webp\" alt=\"code using string substitution\" width=\"780\" height=\"270\" \/><\/a><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-string-substitution.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110690\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-string-substitution.webp\" alt=\"output of the code using string substitution\" width=\"506\" height=\"192\" \/><\/a><\/p>\n<h4>Foreach function<\/h4>\n<p>The foreach function converts one list of words to another. It looks something like this:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">$(foreach var, &lt;list&gt;, &lt;text&gt;)<\/pre>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-foreach-function.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110691\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-foreach-function.webp\" alt=\"code using foreach function\" width=\"780\" height=\"186\" \/><\/a><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-foreach-function.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110692\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-foreach-function.webp\" alt=\"output of the code using foreach function\" width=\"515\" height=\"103\" \/><\/a><\/p>\n<h4>If function<\/h4>\n<p>The if function checks if the first argument is non-empty or empty. If at all the first argument is not empty, it runs the second argument, otherwise the third.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-the-if-function.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110693\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-the-if-function.webp\" alt=\"code using the if function\" width=\"514\" height=\"202\" \/><\/a><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-if-function.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110694\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-if-function.webp\" alt=\"output of the code using if function\" width=\"542\" height=\"110\" \/><\/a><\/p>\n<h4>Call function<\/h4>\n<p>As we glimpsed earlier, the inbuilt call function supports creating basic custom functions. It is you who defined the function just by creating a variable. You will have to use the parameters $(0), $(1), etc. The syntax you use to create your own function is:<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\">$(call &lt;variable&gt;, &lt;parameter&gt;, &lt;parameter&gt;)<\/pre>\n<h4><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-the-call-function.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110695\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-the-call-function.webp\" alt=\"code using the call function\" width=\"780\" height=\"122\" \/><\/a><\/h4>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-the-call-function.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110696\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-the-call-function.webp\" alt=\"output of the code using the call function\" width=\"780\" height=\"84\" \/><\/a><\/p>\n<h4>Shell function<\/h4>\n<p>The shell function calls the shell, but it replaces the newlines with spaces.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-the-shell-function.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110697\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-the-shell-function.webp\" alt=\"code using the shell function\" width=\"780\" height=\"86\" \/><\/a><\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-shell-function.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110698\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/output-of-the-code-using-shell-function.webp\" alt=\"output of the code using shell function\" width=\"780\" height=\"486\" \/><\/a><\/p>\n<h3>Bonus makefile features<\/h3>\n<p>Before we call it a day, let us look at some bonus features of makefile.<\/p>\n<h4>Multiline<\/h4>\n<p>The backslash (\\) gives us the ability to use multiple lines when the commands are too long. Here is an example:<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-the-mutiline-feature-of-makefile.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110699\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-the-mutiline-feature-of-makefile.webp\" alt=\"code using the multiline feature of makefile\" width=\"620\" height=\"120\" \/><\/a><\/p>\n<h4>.phony<\/h4>\n<p>We can add \u201c.PHONY\u201d to a target to prevent make from confusing the phony target with a file name. In the example shown below, if the file \u201cclean\u201d is created, make clean will still be run.<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-the-phony-feature-of-makefile.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110700\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-the-phony-feature-of-makefile.webp\" alt=\"code using the phony feature of makefile\" width=\"402\" height=\"296\" \/><\/a><\/p>\n<h4>.delete_on_error<\/h4>\n<p>Make stop running a rule if a command returns a nonzero exit status. This is where \u201c.delete_on_error\u201d comes in handy. It deletes the target of a rule if the rule fails in this manner. This happens for all targets, not just the one it is before like PHONY<\/p>\n<p><a href=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-the-delete-on-error-feature-of-makefile.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-110701\" src=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/08\/code-using-the-delete-on-error-feature-of-makefile.webp\" alt=\"code using the delete on error feature of makefile\" width=\"240\" height=\"276\" \/><\/a><\/p>\n<h3>Summary<\/h3>\n<p>We have now covered all of the basics and intermediate level practical commands related to make. As you have seen, makefile is a simple compiler of various programming languages.<\/p>\n<p>You have now learned what makefile is, why it is used, the alternatives of makefile, how makefile works, and the syntax. In the practical part we kicked of by printing \u201chello world\u201d and then going through a few beginner examples, we then went deep and understood things like targets, wildcats, variables, rules, commands and execution, if-else statement, functions and a few bonus features like PHONE, multiline and delete on error.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>By the end of this article, you will what linux makefile is, why it is used, look at the alternatives of makefile, version, and types of make, and only then go to the practical&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":110559,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[35],"tags":[27076,27077],"class_list":["post-110421","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux","tag-makefile-in-linux","tag-makefiles-command-in-linux"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.4 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Makefile in linux - DataFlair<\/title>\n<meta name=\"description\" content=\"Learn what linux makefile command is, why it is used, alternatives of makefile, version, &amp; types of make with examples.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/data-flair.training\/blogs\/makefile-in-linux\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Makefile in linux - DataFlair\" \/>\n<meta property=\"og:description\" content=\"Learn what linux makefile command is, why it is used, alternatives of makefile, version, &amp; types of make with examples.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/data-flair.training\/blogs\/makefile-in-linux\/\" \/>\n<meta property=\"og:site_name\" content=\"DataFlair\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/DataFlairWS\/\" \/>\n<meta property=\"article:published_time\" content=\"2022-09-10T03:30:44+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2022-09-10T03:37:02+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/06\/makefile-in-linux.webp\" \/>\n\t<meta property=\"og:image:width\" content=\"1200\" \/>\n\t<meta property=\"og:image:height\" content=\"628\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/webp\" \/>\n<meta name=\"author\" content=\"DataFlair Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:site\" content=\"@DataFlairWS\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"DataFlair Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"29 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Makefile in linux - DataFlair","description":"Learn what linux makefile command is, why it is used, alternatives of makefile, version, & types of make with examples.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/data-flair.training\/blogs\/makefile-in-linux\/","og_locale":"en_US","og_type":"article","og_title":"Makefile in linux - DataFlair","og_description":"Learn what linux makefile command is, why it is used, alternatives of makefile, version, & types of make with examples.","og_url":"https:\/\/data-flair.training\/blogs\/makefile-in-linux\/","og_site_name":"DataFlair","article_publisher":"https:\/\/www.facebook.com\/DataFlairWS\/","article_published_time":"2022-09-10T03:30:44+00:00","article_modified_time":"2022-09-10T03:37:02+00:00","og_image":[{"width":1200,"height":628,"url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/06\/makefile-in-linux.webp","type":"image\/webp"}],"author":"DataFlair Team","twitter_card":"summary_large_image","twitter_creator":"@DataFlairWS","twitter_site":"@DataFlairWS","twitter_misc":{"Written by":"DataFlair Team","Est. reading time":"29 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/data-flair.training\/blogs\/makefile-in-linux\/#article","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/makefile-in-linux\/"},"author":{"name":"DataFlair Team","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/b49855299264df5e27e3ec6c2cd9fde9"},"headline":"Makefile in linux","datePublished":"2022-09-10T03:30:44+00:00","dateModified":"2022-09-10T03:37:02+00:00","mainEntityOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/makefile-in-linux\/"},"wordCount":2725,"commentCount":0,"publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/makefile-in-linux\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/06\/makefile-in-linux.webp","keywords":["makefile in linux","makefiles command in linux"],"articleSection":["Linux Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/data-flair.training\/blogs\/makefile-in-linux\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/data-flair.training\/blogs\/makefile-in-linux\/","url":"https:\/\/data-flair.training\/blogs\/makefile-in-linux\/","name":"Makefile in linux - DataFlair","isPartOf":{"@id":"https:\/\/data-flair.training\/blogs\/#website"},"primaryImageOfPage":{"@id":"https:\/\/data-flair.training\/blogs\/makefile-in-linux\/#primaryimage"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/makefile-in-linux\/#primaryimage"},"thumbnailUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/06\/makefile-in-linux.webp","datePublished":"2022-09-10T03:30:44+00:00","dateModified":"2022-09-10T03:37:02+00:00","description":"Learn what linux makefile command is, why it is used, alternatives of makefile, version, & types of make with examples.","breadcrumb":{"@id":"https:\/\/data-flair.training\/blogs\/makefile-in-linux\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/data-flair.training\/blogs\/makefile-in-linux\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/makefile-in-linux\/#primaryimage","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/06\/makefile-in-linux.webp","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2022\/06\/makefile-in-linux.webp","width":1200,"height":628,"caption":"makefile in linux"},{"@type":"BreadcrumbList","@id":"https:\/\/data-flair.training\/blogs\/makefile-in-linux\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Blog Home","item":"https:\/\/data-flair.training\/blogs\/"},{"@type":"ListItem","position":2,"name":"Linux Tutorials","item":"https:\/\/data-flair.training\/blogs\/category\/linux\/"},{"@type":"ListItem","position":3,"name":"Makefile in linux"}]},{"@type":"WebSite","@id":"https:\/\/data-flair.training\/blogs\/#website","url":"https:\/\/data-flair.training\/blogs\/","name":"DataFlair","description":"Learn Today. Lead Tomorrow.","publisher":{"@id":"https:\/\/data-flair.training\/blogs\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/data-flair.training\/blogs\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/data-flair.training\/blogs\/#organization","name":"DataFlair","url":"https:\/\/data-flair.training\/blogs\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/","url":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","contentUrl":"https:\/\/data-flair.training\/blogs\/wp-content\/uploads\/sites\/2\/2016\/07\/Data-Flair.png","width":106,"height":48,"caption":"DataFlair"},"image":{"@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/DataFlairWS\/","https:\/\/x.com\/DataFlairWS","https:\/\/www.linkedin.com\/company\/dataflair-web-services-pvt-ltd\/","https:\/\/www.youtube.com\/user\/DataFlairWS"]},{"@type":"Person","@id":"https:\/\/data-flair.training\/blogs\/#\/schema\/person\/b49855299264df5e27e3ec6c2cd9fde9","name":"DataFlair Team","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/ef46b745ddad2fad690af626c6ef29b91809ad0a9f5ef398d07817d8cad042f5?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/ef46b745ddad2fad690af626c6ef29b91809ad0a9f5ef398d07817d8cad042f5?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/ef46b745ddad2fad690af626c6ef29b91809ad0a9f5ef398d07817d8cad042f5?s=96&d=mm&r=g","caption":"DataFlair Team"},"description":"DataFlair Team is a group of passionate educators and industry experts dedicated to providing high-quality online learning resources on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. With years of experience in the field, the team aims to simplify complex topics and help learners advance their careers. At DataFlair, we believe in empowering students and professionals with the knowledge and skills needed to thrive in today\u2019s fast-paced tech industry. Follow us for Free courses, expert insights, tutorials, and practical tips to boost your learning journey.","url":"https:\/\/data-flair.training\/blogs\/author\/datafbdad\/"}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/110421","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/comments?post=110421"}],"version-history":[{"count":5,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/110421\/revisions"}],"predecessor-version":[{"id":110702,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/posts\/110421\/revisions\/110702"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media\/110559"}],"wp:attachment":[{"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/media?parent=110421"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/categories?post=110421"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/data-flair.training\/blogs\/wp-json\/wp\/v2\/tags?post=110421"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}