Makefile: Difference between revisions

Added chapter for advanced techniques.
[unchecked revision][unchecked revision]
(→‎Basics: Added a word on := vs. =)
(Added chapter for advanced techniques.)
Line 187:
This is somewhat of an anticlimax in its "triviality". My test drivers need to link against the ''PDCLib'' itself, but that's already all. This is not really perfect; if ''any'' PDCLib function was touched (and, thus, pdclib.a updated), it recreates ''all'' test drivers, even when not necessary. Ah well, no Makefile ever is perfect, but I'd rather have too much compiled than missing a dependency.
 
= Advanced Techniques =
== A Final Word ==
 
== Conditional Evaluation ==
 
Sometimes it becomes useful to react on the existence or content of certain environment variables. For example, you might have to rely on the path to a certain framework being passed in FRAMEWORK_PATH. Perhaps the error message given by the compiler in case the variable is not set isn't that helpful, or it takes long until 'make' gets to the point where it actually detects the error.
 
Luckily, 'make' allows for conditional evaluation and manual error reporting, quite akin to the C preprocessor:
 
<pre>
ifndef FRAMEWORK_PATH
$(error FRAMEWORK_PATH is not set. Please set to the path where you installed "Framework".)
endif
 
ifneq ($(FRAMEWORK_PATH),/usr/lib/framework)
$(warning FRAMEWORK_PATH is set to $(FRAMEWORK_PATH), not /usr/lib/framework. Are you sure this is correct?)
endif
</pre>
 
== A Final Word ==
 
Hope this helps you in creating your own Makefile, and then forgetting about it (as you should, because 'make' should lessen your workload, not add more).
Line 194 ⟶ 212:
 
 
== See Also ==
 
=== External Links ===
* [http://www.xs4all.nl/~evbergen/nonrecursive-make.html Implementing non-recursive make] by Emile van Bergen<br />Further input on the subject of non-recursive, low-maintenance Makefile creation.
 
----
[[Category:Tutorials|Makefile]]
[[Category:Tools]]
448

edits