Creating a Make Template using GNU make
Recursive use of make systems is not very well looked at. But then it has some
advantages. I have taken the advantages, and created a structure that addresses
several, if not most, disadvantages:
-
It will automatically find all directories to be included in the build, with a
possibility to specify dependencies between directories
-
It will automatically find all sources to be included in the build
-
It supports the use of source code generators like lex, yacc or IDL
-
It will automatically determine the dependencies between source files
-
The Makefiles in each source directory are mostly one- or two-liners, the
complexity is encapsulated in centralized make-includes
-
It will walk the source tree just once
-
If supported by your platform, you may use the parallel-build options GNU Make
offers
-
It will store the objects in architecture/variant dependent directories
-
It will run on Windows XP or later with CMD, Windows/Cygwin with bash, and Linux/Unix
-
It will work with GNU Make version 3.79.1 or upwards
Of course, most automatic functions can also be overridden.
This project has been implemented successfully in at least three different sites.
And now I started to document the system in such a way, that interested readers
can follow the various steps and intricacies.
The documentation will grow step by step, with each step building on the
previous one. And for each step, I will provide the full test-environment
demonstrating the features.
And here's what I've been creating so far:
-
The descriptive document
(Version 005, 300k PDF) containing an extensive explanation of what, how and
why.
-
001Traverse.zip (7k) - The
first instalment in a ZIP container, with all files, and directories. This
instalment automatically traverses the source tree, while recognizing and
observing dependencies between directories.
-
002Objects.zip (8k) - The second
instalment creates and traverses the objects' tree instead, while taking
Makefiles from the source tree.
-
003Sources.zip (19k) - The third
instalment creates object files (pretends to, using "touch", for now)
in the intermediates' tree.
-
004Compilation.zip (19k) -
The fourth instalment really creates objects using GCC, contains a 'clean'
target and shows a few tricks.
-
005Differentiate.zip (24k) -
The fifth instalment differentiates between Windows and Linux, bash and CMD.EXE,
and GCC and Visual Studio, as examples. Compilation is possible with each of the
choices, and compilation variants are held separately, supporting multiple
variants using one source tree. Further choices as to platform, compiler and/or
shell are possible, if not supported out of the box. The Makefile is split into
several files, in order not to lose the overview and enable reuse.
What else do you need?
If you need GNU make (the Cygwin environment provides its own version. Others
don't necessarily, but many Linux distribtions offer GNU Make at least as an
option), go to the make homepage at http://www.gnu.org/software/make/make.html.
You may have to build GNU make yourself.
For information on Cygwin, go to their main site, http://www.cygwin.com/, download and execute
the "setup.exe" (Look for "Install or update now!"), and make sure to
install the development tools (Category 'Devel') 'make' 3.81 or newer, and GCC,
as well as 'coreutils' and 'bash', both in the category 'Base', installed by
default. Later we may add more, when the projects grows.
And, finally (for now), you might need a utility called 'touch'. In many Unix/Linux
variants it belongs to a standard installation, only for Windows this is not the
case. Later we'll possibly create a windows version ourselves, for now I refer
to a CodeProject site, http://www.codeproject.com/KB/applications/touch_win.aspx
(registration required, freeware with source code).
www.bezem.de:
© 1999 – 2024 by Johan Bezem, all rights reserved.
This page was last updated on Monday, 2018-07-23 06:28.
|