<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://aznot.com/index.php?action=history&amp;feed=atom&amp;title=Linux%2Fmake</id>
	<title>Linux/make - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://aznot.com/index.php?action=history&amp;feed=atom&amp;title=Linux%2Fmake"/>
	<link rel="alternate" type="text/html" href="https://aznot.com/index.php?title=Linux/make&amp;action=history"/>
	<updated>2026-05-07T03:46:46Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.41.0</generator>
	<entry>
		<id>https://aznot.com/index.php?title=Linux/make&amp;diff=6309&amp;oldid=prev</id>
		<title>Kenneth: /* change directory */</title>
		<link rel="alternate" type="text/html" href="https://aznot.com/index.php?title=Linux/make&amp;diff=6309&amp;oldid=prev"/>
		<updated>2023-06-30T03:22:12Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;change directory&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;== make ==&lt;br /&gt;
&lt;br /&gt;
The principal domain, of &amp;#039;make&amp;#039;, is C programming.  Many sites also use &amp;#039;make&amp;#039; for software installation, document formatting, and cleaning out temporary files.&lt;br /&gt;
&lt;br /&gt;
Make file uses backward-chaining to process a Makefile (description file).&lt;br /&gt;
&lt;br /&gt;
== GNU Make Documentation ==&lt;br /&gt;
&lt;br /&gt;
[http://www.gnu.org/software/make/manual/make.html GNU Make Documentation]&lt;br /&gt;
&lt;br /&gt;
== Tutorials ==&lt;br /&gt;
&lt;br /&gt;
* [http://www.opussoftware.com/tutorial/TutMakefile.htm Tutorial - Makefile]&lt;br /&gt;
&lt;br /&gt;
== Books ==&lt;br /&gt;
&lt;br /&gt;
Managing Projects with GNU Make, 3rd Edition - O&amp;#039;Reilly Media - http://oreilly.com/catalog/make3/book/index.csp&lt;br /&gt;
&lt;br /&gt;
PDF - http://it-ebooks.info/book/383/&lt;br /&gt;
* http://filepi.com/i/v5Ta6Dc&lt;br /&gt;
&lt;br /&gt;
== usage ==&lt;br /&gt;
&lt;br /&gt;
 make [target(s)]&lt;br /&gt;
&lt;br /&gt;
 make -f mymakefile [target(s)]&lt;br /&gt;
&lt;br /&gt;
== validation ==&lt;br /&gt;
&lt;br /&gt;
Check the tabs in description file:&lt;br /&gt;
 cat -v -t -e makefile&lt;br /&gt;
&lt;br /&gt;
== file name ==&lt;br /&gt;
&lt;br /&gt;
To specify make description file name: &amp;#039;&amp;#039;make -f filename&amp;#039;&amp;#039;.&lt;br /&gt;
&lt;br /&gt;
When GNU Make is run, with no arguments, it will look for one of the following configuration files, in the current working directory: (in priority order, is also directory sort order)&lt;br /&gt;
# &amp;#039;&amp;#039;GNUmakefile&amp;#039;&amp;#039;&lt;br /&gt;
# &amp;#039;&amp;#039;makefile&amp;#039;&amp;#039;&lt;br /&gt;
# &amp;#039;&amp;#039;Makefile&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;If no -f option is present, make will look for the makefiles GNUmakefile, makefile, and Makefile, in that order.&amp;quot; (make man page)&lt;br /&gt;
&lt;br /&gt;
-&lt;br /&gt;
&lt;br /&gt;
&amp;quot;This file is normally named makefile or Makefile. As a convention, GNU programs named their makefile, Makefile, because it is easy to see (if you do &amp;quot;ls&amp;quot; then this file is usually always on the top of the list). If you give it another name, just make sure you include option -f to make command in order to let it know that you use it.&amp;quot; [http://linuxgazette.net/issue83/heriyanto.html]&lt;br /&gt;
&lt;br /&gt;
== Layout ==&lt;br /&gt;
&lt;br /&gt;
Makefile layout:&lt;br /&gt;
* dependency line / rule line (targets:dependencies)&lt;br /&gt;
* command lines (tab command)&lt;br /&gt;
* comments (# comment)&lt;br /&gt;
&lt;br /&gt;
Lines can be wrapped using the &amp;#039;\&amp;#039; character at the end of a line.&lt;br /&gt;
&lt;br /&gt;
A Makefile is composed of rules.  The rules are composed of targets, dependencies (prerequisites) and system commands.  The first target in the Makefile is the default target.&lt;br /&gt;
&lt;br /&gt;
A Makefile rule is composed of:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
target(s) : dependencies&lt;br /&gt;
[tab] system commands&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Examples:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Linking object files&lt;br /&gt;
sample: main.o example.o&lt;br /&gt;
	cc -o sample main.o example.o&lt;br /&gt;
	echo sample: make complete&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Compiling source files&lt;br /&gt;
main.o: main.c main.h&lt;br /&gt;
	cc -c main.c&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
example.o: example.c defs.h&lt;br /&gt;
	cc -c example.c&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
new_Spec new_impt : menus hash store&lt;br /&gt;
 date &amp;gt;&amp;gt; $@&lt;br /&gt;
 ls $? &amp;gt;&amp;gt; $@&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== targets ==&lt;br /&gt;
&lt;br /&gt;
 target : dependency&lt;br /&gt;
&lt;br /&gt;
 target target2 : dependency dependency2&lt;br /&gt;
&lt;br /&gt;
Able to reuse target with multiple colons:&lt;br /&gt;
 target :: dependency1&lt;br /&gt;
 target :: dependency2&lt;br /&gt;
&lt;br /&gt;
== Logic ==&lt;br /&gt;
&lt;br /&gt;
A target is considered &amp;quot;up to date&amp;quot; if an identically named file exists and is newer than its dependencies.&lt;br /&gt;
&lt;br /&gt;
Make works backwards, starting with the target of the first rule in the file. In our example, that&amp;#039;s sample. Make checks the dependencies for sample -- main.o and example.o -- to see if they have rules. If they do, it recursively checks their rules. &lt;br /&gt;
&lt;br /&gt;
Make walks down the recursion chain until it finds a target that has no dependencies, or whose dependencies have no rules. Once it hits one of those, it walks back up its recursion chain and runs commands as necessary. It creates a recursion chain for every prerequisite it encounters that has a rule.&lt;br /&gt;
&lt;br /&gt;
Make can run the dependencies in any order. The important part of this sequence is that it runs recursively backwards from the first target (or the target named in the command parameters), and tests only the rules that it encounters in the dependencies chain.&lt;br /&gt;
&lt;br /&gt;
Make aborts compilation if it receives an error. This is usually useful behavior -- it lets you correct compiler-detected problems during a compile-and-test cycle. The option -i tells Make to ignore errors.&lt;br /&gt;
&lt;br /&gt;
make will check the last modification date of target against the last modification date of all the dependencies files that follow it. If none of these things have changed, then it won&amp;#039;t recompile the target.&lt;br /&gt;
&lt;br /&gt;
== Default Target ==&lt;br /&gt;
&lt;br /&gt;
The default target is the first target found.&lt;br /&gt;
&lt;br /&gt;
== Phony Target ==&lt;br /&gt;
&lt;br /&gt;
A phony target is a fake filename. It is just a name for commands that will be executed when you give an explicit request. There are two reasons for using phony target : to avoid conflicts with a file with the same name, and to enhance the makefile performance.&lt;br /&gt;
&lt;br /&gt;
If you write a rule whose command will not create a target file, those commands will be executed every time the target is remade. For example:&lt;br /&gt;
&lt;br /&gt;
 clean:&lt;br /&gt;
 	rm *.o temp&lt;br /&gt;
&lt;br /&gt;
Because the command rm will not create a file named clean, that file will never exist. Command rm will always be executed every time you called make clean, because make assume that the clean file is always new.&lt;br /&gt;
&lt;br /&gt;
The above target will stop working if a file named clean exists in the current directory. Because it does not require dependencies, file clean will be considered up-to-date, and the command &amp;#039;rm *.o temp&amp;#039; will not be executed. To resolve this problem, you can explicitly declare a target as phony, using special target command .PHONY. For example :&lt;br /&gt;
&lt;br /&gt;
 .PHONY : clean&lt;br /&gt;
&lt;br /&gt;
In the makefile above, if we give instruction make clean from the command-line, the command &amp;#039;rm *.o temp&amp;#039; will always be run, whether or not a file named clean exists in the current directory. &lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
.PHONY : all test1 test2&lt;br /&gt;
&lt;br /&gt;
all: test1 test2&lt;br /&gt;
&lt;br /&gt;
test1:&lt;br /&gt;
        cd test1 ; tar -cf ../test1.tar *&lt;br /&gt;
&lt;br /&gt;
test2:&lt;br /&gt;
        cd test2 ; tar -cf ../test2.tar *&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Target name.  To reference from within a command use &amp;#039;$@&amp;#039;&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
test1:&lt;br /&gt;
        cd $@ ; tar -cf ../$@.tar *&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Source: [http://linuxgazette.net/issue83/heriyanto.html Creating Makefiles: A Mini Tutorial LG #83]&lt;br /&gt;
&lt;br /&gt;
== Wildcard Target ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# make all&lt;br /&gt;
all:&lt;br /&gt;
	echo %@  # &amp;quot;all&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# make test&lt;br /&gt;
%:&lt;br /&gt;
	echo %@  # &amp;quot;test&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# make test.txt&lt;br /&gt;
%.txt:&lt;br /&gt;
	echo %@  # &amp;quot;test&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# make all&lt;br /&gt;
# output: &amp;quot;first&amp;quot; &amp;quot;second&amp;quot;&lt;br /&gt;
.PHONY: all first second&lt;br /&gt;
TARGETS=first second&lt;br /&gt;
&lt;br /&gt;
all: $(TARGETS)&lt;br /&gt;
&lt;br /&gt;
$(TARGETS):&lt;br /&gt;
	@echo $@&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Ignore Error ==&lt;br /&gt;
&lt;br /&gt;
Start a line with &amp;#039;-&amp;#039; to continue even on error:&lt;br /&gt;
 -command_that_fails&lt;br /&gt;
&lt;br /&gt;
== Comments ==&lt;br /&gt;
&lt;br /&gt;
Comments are start with a &amp;#039;#&amp;#039;:&lt;br /&gt;
 # This is a comment&lt;br /&gt;
&lt;br /&gt;
End of line comment:&lt;br /&gt;
    some makefile statement # a comment &lt;br /&gt;
&lt;br /&gt;
Comments and Continued Makefile Lines:&lt;br /&gt;
 line_one \&lt;br /&gt;
 line_two # more_line_two \&lt;br /&gt;
 line_three &lt;br /&gt;
&lt;br /&gt;
is the same as:&lt;br /&gt;
    line_one line_two line_three &lt;br /&gt;
&lt;br /&gt;
Source: http://www.opussoftware.com/tutorial/TutMakefile.htm&lt;br /&gt;
&lt;br /&gt;
== Hide Command ==&lt;br /&gt;
&lt;br /&gt;
The &amp;#039;@&amp;#039; character will hide the command name, but show command output.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
usage:&lt;br /&gt;
	@echo &amp;quot;This is the usage&amp;quot;&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== macros ==&lt;br /&gt;
&lt;br /&gt;
macro definitions:&lt;br /&gt;
 name = string&lt;br /&gt;
 name=string&lt;br /&gt;
 name = some strings&lt;br /&gt;
 name =    # set to null string, not &amp;quot;undefied&amp;quot;&lt;br /&gt;
 name = &amp;quot;some strings&amp;quot;  # &amp;quot; will be included in output&lt;br /&gt;
&lt;br /&gt;
macro usage:&lt;br /&gt;
 $(name)&lt;br /&gt;
 ${name}&lt;br /&gt;
 $A  # optional only with single character macros (or special character macros)&lt;br /&gt;
&lt;br /&gt;
Define from command line:&lt;br /&gt;
 make DIR=/path&lt;br /&gt;
 export DIR=path ; make  # shell environment form&lt;br /&gt;
 DIR=path make  # shell environment form&lt;br /&gt;
&lt;br /&gt;
Macro assignment priority order:&lt;br /&gt;
# Internal (default) definitions of &amp;#039;make&amp;#039;&lt;br /&gt;
# Current shell environment variables (including those preceding &amp;#039;make&amp;#039; command)&lt;br /&gt;
# Description file macro definitions&lt;br /&gt;
# Macros specified on &amp;#039;make&amp;#039; command line&lt;br /&gt;
&lt;br /&gt;
Can swap priority 2 and 3 with &amp;#039;&amp;#039;make -e&amp;#039;&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Tips:&lt;br /&gt;
* Macro names, by convention, are in uppercase.&lt;br /&gt;
* If macro referred to without defining, will be null string.  Never will get an undefined error.&lt;br /&gt;
* Order of macros is unimportant, will be evaluated when used&lt;br /&gt;
* Macros cannot be redefined, once defined (unless doing a recursive make)&lt;br /&gt;
* Can display all predefined macros with &amp;#039;&amp;#039;make -p&amp;#039;&amp;#039; (and there are a lot)&lt;br /&gt;
* Shell/environment variables are available as macros&lt;br /&gt;
&lt;br /&gt;
-&lt;br /&gt;
&lt;br /&gt;
String substitution: (limitation: end of macro only - like extensions)&lt;br /&gt;
 ls ${SRCS:.c=.o}  # src.c to src.o&lt;br /&gt;
&lt;br /&gt;
-&lt;br /&gt;
&lt;br /&gt;
Internal macros:&lt;br /&gt;
 $@ - current target (command line only)&lt;br /&gt;
 $? - prerequisites that are newer than target (command line only)&lt;br /&gt;
 $$@ - current target (dependency line only)&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
new_Spec new_impt : menus hash store&lt;br /&gt;
	date &amp;gt;&amp;gt; $@&lt;br /&gt;
	ls $? &amp;gt;&amp;gt; $@&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
 docmk : $$@.c  # evaluates to: docmk : docmk.c&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
C_OBJS = main.o iodat.o dorun.o&lt;br /&gt;
${C_OBJS} : $${@:.o=.c}&lt;br /&gt;
	${CC} -c $?&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Variables or Macros ==&lt;br /&gt;
&lt;br /&gt;
Certain versions of Make call variables &amp;quot;macros&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Make variables are different from shell variables.&lt;br /&gt;
&lt;br /&gt;
Make&amp;#039;s variables are defined and set in the header portion before targets are defined.&lt;br /&gt;
&lt;br /&gt;
Set a Make variable:&lt;br /&gt;
 MYVAR = one two three  # recursively expanded variable&lt;br /&gt;
 MYVAR := one two three  # simply expanded variables&lt;br /&gt;
&lt;br /&gt;
Use a Make variable:&lt;br /&gt;
 # Using variable with another variable&lt;br /&gt;
 ANOTHER_MYVAR=$(MYVAR) four&lt;br /&gt;
&lt;br /&gt;
 # Using variable from target&lt;br /&gt;
 all:&lt;br /&gt;
 	echo $(MYVAR)&lt;br /&gt;
 	echo ${MYVAR}&lt;br /&gt;
&lt;br /&gt;
Setting make variables from environment variables:&lt;br /&gt;
 DESTDIR ?= /usr/local&lt;br /&gt;
&lt;br /&gt;
An environment variable can also be passed to the Makefile by not defining the variable in the Makefile.  If it is not set in the environment, the variable will default to empty.&lt;br /&gt;
&lt;br /&gt;
Passing environment variable to pass to Makefile:&lt;br /&gt;
 $ DESTDIR=&amp;quot;/bin&amp;quot; make&lt;br /&gt;
 $ export DESTDIR=&amp;quot;/bin&amp;quot; ; make&lt;br /&gt;
&lt;br /&gt;
 DESTDIR=&amp;quot;/bin&amp;quot; make&lt;br /&gt;
&lt;br /&gt;
Append variable (will also append to the environment variables)&lt;br /&gt;
 CFLAGS += -g -Wall&lt;br /&gt;
&lt;br /&gt;
Substitution:&lt;br /&gt;
 foo := a.o b.o c.o&lt;br /&gt;
 bar := $(foo:.o=.c)&lt;br /&gt;
 # sets &amp;#039;bar&amp;#039; to &amp;#039;a.c b.c c.c&amp;#039;&lt;br /&gt;
&lt;br /&gt;
Make variable example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# I am a variable&lt;br /&gt;
CC=g++&lt;br /&gt;
CFLAGS=-c -Wall&lt;br /&gt;
&lt;br /&gt;
main.o: main.cpp&lt;br /&gt;
	$(CC) $(CFLAGS) main.cpp&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Redefining Macros from the command line:&lt;br /&gt;
 make CFLAGS=–ms&lt;br /&gt;
 make &amp;quot;CFLAGS=-ms -z -p&amp;quot;&lt;br /&gt;
&lt;br /&gt;
=== Macro Shell Assignment ===&lt;br /&gt;
&lt;br /&gt;
$(shell) is a special function in gmake that runs an external command and captures the output for use in the makefile. For example, you could get the current working directory like this:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
CWD:=$(shell pwd)&lt;br /&gt;
all:&lt;br /&gt;
	@echo This makefile lives in $(CWD).&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note, make sure to use &amp;quot;:=&amp;quot; or it will be reevaluated in each new section, unless that is what you want&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
DATE=$(warning Invoking shell)$(shell date)&lt;br /&gt;
all: first&lt;br /&gt;
	@echo ${DATE}&lt;br /&gt;
&lt;br /&gt;
first:&lt;br /&gt;
	@echo ${DATE}&lt;br /&gt;
        sleep 3&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
References:&lt;br /&gt;
* Development Cloud Solutions | Electric Cloud - http://www.electric-cloud.com/blog/2009/03/23/makefile-performance-shell/&lt;br /&gt;
&lt;br /&gt;
=== Macro Functions ===&lt;br /&gt;
&lt;br /&gt;
 $(dir names...)         # Extracts the directory-part of each file name in names.&lt;br /&gt;
 $(basename names...)    # Extracts all but the suffix of each file name in names.&lt;br /&gt;
 $(addprefix prefix,names...)    # The argument names is regarded as a series of names, separated by whitespace; prefix is used as a unit.&lt;br /&gt;
&lt;br /&gt;
File Name Functions - GNU `make&amp;#039; - https://www.gnu.org/software/make/manual/html_node/File-Name-Functions.html&lt;br /&gt;
&lt;br /&gt;
=== Warn on Undefined ===&lt;br /&gt;
&lt;br /&gt;
Warn on undefined variables:&lt;br /&gt;
 --warn-undefined-variables&lt;br /&gt;
&lt;br /&gt;
== Warning ==&lt;br /&gt;
&lt;br /&gt;
Display warning macro:&lt;br /&gt;
 $(warning This is a warning)&lt;br /&gt;
&lt;br /&gt;
== Shell Variables ==&lt;br /&gt;
&lt;br /&gt;
Shell variables in Makefiles&lt;br /&gt;
&lt;br /&gt;
There may come a time you need to use shell scripting complicated enough to require shell vars in a Makefile but make has issues since $ is the prefix for Make vars too, to escape the $, just use $$, so this:&lt;br /&gt;
 for e in * ; do echo $e ; done&lt;br /&gt;
becomes:&lt;br /&gt;
 for e in * ; do echo $$e ; done&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Another method is to embed within a bash command: [http://www.netbsd.org/docs/pkgsrc/makefile.html]&lt;br /&gt;
 /bin/sh -c &amp;#039;i=&amp;quot;test&amp;quot; ; echo $$i&amp;#039;&lt;br /&gt;
&lt;br /&gt;
== Multiple Combined Commands ==&lt;br /&gt;
&lt;br /&gt;
Each line runs in it&amp;#039;s own shell.  If you would like to chain several commands together (usually to get to shell variables):&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
	line_one \&lt;br /&gt;
	line_two # more_line_two \&lt;br /&gt;
	line_three &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
%.pem:&lt;br /&gt;
        umask 77 ; \&lt;br /&gt;
        PEM1=`/bin/mktemp /tmp/openssl.XXXXXX` ; \&lt;br /&gt;
        PEM2=`/bin/mktemp /tmp/openssl.XXXXXX` ; \&lt;br /&gt;
        /usr/bin/openssl req $(UTF8) -newkey rsa:1024 -keyout $$PEM1 -nodes -x509 -days 365 -out $$PEM2 -set_serial $(SERIAL) ; \&lt;br /&gt;
        cat $$PEM1 &amp;gt;  $@ ; \&lt;br /&gt;
        echo &amp;quot;&amp;quot;    &amp;gt;&amp;gt; $@ ; \&lt;br /&gt;
        cat $$PEM2 &amp;gt;&amp;gt; $@ ; \&lt;br /&gt;
        $(RM) $$PEM1 $$PEM2&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== change directory ==&lt;br /&gt;
&lt;br /&gt;
How do you change directories in a makefile, run a command and then change back? First off, all the commands that you want to run for that situation must be on the same line, because make executes each line with a new shell&lt;br /&gt;
&lt;br /&gt;
 foo:&lt;br /&gt;
     cd /bin; stat ls; cd -&lt;br /&gt;
&lt;br /&gt;
Source: http://crawlicious.com/wp/2009/06/11/make-change-dir/&lt;br /&gt;
&lt;br /&gt;
== Include Other Makefiles ==&lt;br /&gt;
&lt;br /&gt;
 include filenames...&lt;br /&gt;
&lt;br /&gt;
ref: https://www.gnu.org/software/make/manual/html_node/Include.html&lt;br /&gt;
&lt;br /&gt;
== Info and Error Output ==&lt;br /&gt;
&lt;br /&gt;
Info message:&lt;br /&gt;
 $(info [message])&lt;br /&gt;
&lt;br /&gt;
Error message:&lt;br /&gt;
 $(error [message])&lt;br /&gt;
&lt;br /&gt;
Example:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
HELLO=hello world&lt;br /&gt;
all:&lt;br /&gt;
        $(info hi $(HELLO))&lt;br /&gt;
        $(error this is a test)&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Conditionals ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
USERID=$(shell id -u)&lt;br /&gt;
&lt;br /&gt;
all:&lt;br /&gt;
	$(info User Id is $(USERID))&lt;br /&gt;
ifeq ($(USERID),0)&lt;br /&gt;
	$(info Running as root... OK)&lt;br /&gt;
else&lt;br /&gt;
	$(error You must be root to execute this command)&lt;br /&gt;
endif&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Source: [http://www.linuxquestions.org/questions/linux-software-2/makefile-conditional-does-not-work-785572/]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
If file1 does not exist then $(wildcard file1) will evaluate to an empty string:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
ifeq ($(wildcard file1),) &lt;br /&gt;
    CLEAN_SRC =&lt;br /&gt;
else &lt;br /&gt;
    CLEAN_SRC = *.h file3&lt;br /&gt;
endif&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Source: http://stackoverflow.com/questions/1077676/how-to-conditional-set-up-a-makefile-variable-by-testing-if-a-file-exists&lt;br /&gt;
&lt;br /&gt;
References:&lt;br /&gt;
* http://www.chemie.fu-berlin.de/chemnet/use/info/make/make_7.html&lt;br /&gt;
* http://www.gnu.org/software/autoconf/manual/make/Conditional-Syntax.html&lt;br /&gt;
&lt;br /&gt;
== Suffixes ==&lt;br /&gt;
&lt;br /&gt;
Define new default behavior for targets&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
.SUFFIXES : .txt .rst&lt;br /&gt;
&lt;br /&gt;
.txt.rst :&lt;br /&gt;
    cat $&amp;lt; &amp;gt; $@&lt;br /&gt;
    # cat test.txt &amp;gt; test.rst&lt;br /&gt;
    # or cat $@ &amp;gt; $*.rst&lt;br /&gt;
&lt;br /&gt;
manual : test.rst&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* $&amp;lt; evaluates to prerequisite that triggered the rule (test.txt)&lt;br /&gt;
* $* evaluates to target minus suffix&lt;br /&gt;
* $@ evaluates to target&lt;br /&gt;
&lt;br /&gt;
== Example Make Files ==&lt;br /&gt;
&lt;br /&gt;
See [[Linux/make/Examples]]&lt;br /&gt;
&lt;br /&gt;
Postfix main.cf Makefile:&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
# Kenneth&lt;br /&gt;
&lt;br /&gt;
.PHONY : aliases&lt;br /&gt;
.PHONY : clean&lt;br /&gt;
&lt;br /&gt;
MAIN-FILES = main.cf.original main.cf.kenneth&lt;br /&gt;
&lt;br /&gt;
all: main.cf aliases&lt;br /&gt;
&lt;br /&gt;
clean:&lt;br /&gt;
        # CLEANING FILES&lt;br /&gt;
        #&lt;br /&gt;
        rm -f main.cf&lt;br /&gt;
        #&lt;br /&gt;
&lt;br /&gt;
main.cf: $(MAIN-FILES)&lt;br /&gt;
        # REBUILDING MAIN.CF...&lt;br /&gt;
        #&lt;br /&gt;
        cat main.cf.original main.cf.kenneth &amp;gt; main.cf&lt;br /&gt;
        #&lt;br /&gt;
&lt;br /&gt;
aliases:&lt;br /&gt;
        # REBUILDING ALIASES...&lt;br /&gt;
        #&lt;br /&gt;
        newaliases&lt;br /&gt;
        #&lt;br /&gt;
&lt;br /&gt;
$(MAIN-FILES):&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Examples ==&lt;br /&gt;
&lt;br /&gt;
== Reference ==&lt;br /&gt;
&lt;br /&gt;
* [http://pragmatic.oreilly.com/pub/a/linux/2002/01/31/make_intro.html Introduction to Make | O&amp;#039;Reilly Media]&lt;br /&gt;
* [http://www.wlug.org.nz/MakefileHowto Makefile Howto - Waikato Linux Users Group]&lt;br /&gt;
* [http://mrbook.org/tutorials/make/ Makefile Tutorial by Example]&lt;br /&gt;
* [http://linuxgazette.net/issue83/heriyanto.html Creating Makefiles: A Mini Tutorial LG #83]&lt;br /&gt;
&lt;br /&gt;
== keywords ==&lt;br /&gt;
&lt;br /&gt;
[[Category:Linux]]&lt;br /&gt;
[[Category:make]]&lt;/div&gt;</summary>
		<author><name>Kenneth</name></author>
	</entry>
</feed>