Editing Documentation/Maemo 5 Developer Guide/GNU Build System

Warning: You are not logged in. Your IP address will be recorded in this page's edit history.

Warning: This page is 68 kilobytes long; some browsers may have problems editing pages approaching or longer than 32kb. Please consider breaking the page into smaller sections.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.
Latest revision Your text
Line 376: Line 376:
Variables work almost as they do inside regular UNIX command shells. They are a simple mechanism, by which a piece of text can be associated with a name that can be referenced later on in multiple places in the makefiles. Make variables are based on text replacement, just like shell variables are.
Variables work almost as they do inside regular UNIX command shells. They are a simple mechanism, by which a piece of text can be associated with a name that can be referenced later on in multiple places in the makefiles. Make variables are based on text replacement, just like shell variables are.
-
==== Variable Flavors ====
+
=== Variable Flavors ===
The variables that can be used in makefiles come in two basic styles or flavors.
The variables that can be used in makefiles come in two basic styles or flavors.
Line 386: Line 386:
Deciding on which flavor to use is important, when the evaluation of variable contents needs to be repeatable and fast. In these cases, simple variables are often the correct solution.
Deciding on which flavor to use is important, when the evaluation of variable contents needs to be repeatable and fast. In these cases, simple variables are often the correct solution.
-
===== Recursive Variables =====
+
=== Recursive Variables ===
Here are the rules for creating recursive variables:
Here are the rules for creating recursive variables:
Line 425: Line 425:
The CC variable is the standard variable to hold the name of the C compiler executable. GNU make comes preloaded with a list of tools that can be accessed in similar way (as will be shown with $(RM) shortly, but there are others). Most UNIX tools related to building software already have similar pre-defined variables in GNU make. Here one of them is overridden to demonstrate how it is done. Overriding variables like this is not recommended, because the user running make later might want to use some other compiler, and would have to edit the makefile to do so.
The CC variable is the standard variable to hold the name of the C compiler executable. GNU make comes preloaded with a list of tools that can be accessed in similar way (as will be shown with $(RM) shortly, but there are others). Most UNIX tools related to building software already have similar pre-defined variables in GNU make. Here one of them is overridden to demonstrate how it is done. Overriding variables like this is not recommended, because the user running make later might want to use some other compiler, and would have to edit the makefile to do so.
-
===== Simple Variables =====
+
=== Simple Variables ===
Suppose you have a makefile like this: [https://vcs.maemo.org/svn/maemoexamples/tags/maemo_5.0/simple-make-files/Makefile.6 simple-make-files/Makefile.6]
Suppose you have a makefile like this: [https://vcs.maemo.org/svn/maemoexamples/tags/maemo_5.0/simple-make-files/Makefile.6 simple-make-files/Makefile.6]
Line 474: Line 474:
The prepending operation can also be used with simple variables. Make will not change the type of variable on the left side of the += operator.
The prepending operation can also be used with simple variables. Make will not change the type of variable on the left side of the += operator.
-
===== Automatic Variables =====
+
=== Automatic Variables ===
There is a pre-defined set of variables inside make that can be used to avoid repetitive typing, when writing out the commands in a rule.
There is a pre-defined set of variables inside make that can be used to avoid repetitive typing, when writing out the commands in a rule.

Learn more about Contributing to the wiki.


Please note that all contributions to maemo.org wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see maemo.org wiki:Copyrights for details). Do not submit copyrighted work without permission!


Cancel | Editing help (opens in new window)

Templates used on this page: