<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Makefile on soffensive blog</title><link>https://soffensive.github.io/tags/makefile/</link><description>Recent content in Makefile on soffensive blog</description><generator>Hugo</generator><language>en</language><lastBuildDate>Thu, 26 Dec 2024 05:35:00 -0700</lastBuildDate><atom:link href="https://soffensive.github.io/tags/makefile/index.xml" rel="self" type="application/rss+xml"/><item><title>make and makefile</title><link>https://soffensive.github.io/posts/various/2024-12-26-make-and-makefile-security/</link><pubDate>Thu, 26 Dec 2024 05:35:00 -0700</pubDate><guid>https://soffensive.github.io/posts/various/2024-12-26-make-and-makefile-security/</guid><description>&lt;p>I am a C/C++ newbie, but occassionally I have to compile or build projects. Since make (and Makefiles) are quite prevalent and sometimes they have to be adjusted due to potential errors, I had to learn more about them and want to share my learning publicly here.&lt;/p>
&lt;h3 id="building-blocks">Building Blocks&lt;/h3>
&lt;p>First of all, what are the involved building blocks of make and Makefiles?&lt;/p>
&lt;ul>
&lt;li>&lt;strong>make&lt;/strong>:
&lt;ul>
&lt;li>The GNU make utility. This is the executable that you actually run in order to execute a series of commands in order to modify files, typically compiling programs.&lt;/li>
&lt;li>If you run the program without specifying an explicit input file with the -f option, make will look for the makefiles GNUmakefile, makefile, and Makefile, in that order.&lt;/li>
&lt;li>make updates a target if it depends on prerequisite files that have been modified since the target was last modified, or if the target does not exist.&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>&lt;strong>makefile&lt;/strong>:
&lt;ul>
&lt;li>This is the input file for the make utility and consists of a series of instructions how to modify files.&lt;/li>
&lt;li>A makefile can contain one or more rules.&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>&lt;strong>rule&lt;/strong>:
&lt;ul>
&lt;li>A rule consists of one or more targets, prerequisites and commands.&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>&lt;strong>target&lt;/strong>:
&lt;ul>
&lt;li>A target is a file name and typically, there is only one per rule.&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>&lt;strong>prerequisite&lt;/strong>:
&lt;ul>
&lt;li>The prerequisites are file names, separated by spaces. These files need to exist before the commands for the target are run. These are also called dependencies.&lt;/li>
&lt;/ul>
&lt;/li>
&lt;li>&lt;strong>command&lt;/strong>:
&lt;ul>
&lt;li>The commands are a series of steps typically to make the target. They need to start with a tab character, not spaces.&lt;/li>
&lt;/ul>
&lt;/li>
&lt;/ul>
&lt;p>The general format of a &lt;code>Makefile&lt;/code> is as follows:&lt;/p></description></item></channel></rss>