Now the compile and link functions support non-propagated target-specific
variables. If a variable is named like the target with a suffix
".EXTRA_FLAGS", it value is added to the compile/link command.
A non-propagated linker can be used too, defining a variable with the name
of the target with the suffix ".LINKER".
A very specific but reasonably useful pattern rule (similar to the doxygen
rule) is added to build sphinx based documentation. A few new variables are
added to control how the sphinx documentation is built. Those variables are
"monitored" to trigger a rebuild in a similar way C and C++ sources are
recompiled when compiler or compiler flags changes.
See the rule and variables comments for more details.
Following the "all", "install" and "doc", sub-makefiles can append to the
variable $(test) the rules they want to be executed when make has the
"test" target as a goal.
The (v)exec function removes the full directory component from the command
to execute. This can be a little confusing when running local scripts. This
patch applies the abbr function to the command instead.
Add a function to include sub-directory's Build.mak
Including a Build.mak in a sub-directory can be very error prone, since the
$S variable should be set to the relative path from $T before including the
Build.mak and restored afterwards.
The function include_subdirs is added to simplify this task, freeing the
user from doing all the dirty work and avoiding bugs.
The "otherproj" pkg-config file generation is moved to a subdirectory to
test how the new function works with deeply nested Build.mak.
Now Lib.mak handle a new $D directory, where generated documentation should
be built. A new "doc" phony rule is created to build all the documentation.
Makefiles can append targets to the $(doc) variable to be build when the
"doc" is used as a goal.
A very specific but reasonably useful pattern rule is added to build
doxygen based documentation. See the rule comment for more details.
The example sub-project "otherproj" now includes doxygen-generated
documentation as an example.
Change the name of the variable storing the root build path
The variable storing the root build path (where all the variants are built)
is named $D. Reserve this name for the documentation directory using $(VD)
instead.
Add a special variable for the full current makefile directory
The $C variable (which stores the path to the current makefile relative to
the top-level directory) is renamed to $S and $C now stores the full
(absolute) path to the current makefile.
The build system now support installing, supporting both $(prefix) and
$(DESTDIR) variables. A few helper functions are added to ease installation
and the $I variable is provided as the base directory where stuff should
be installed (i.e. $(DESTDIR)$(prefix)). The $(prefix) is passed to
compiled programs as a pre-processor define (PREFIX) and targets are
re-built when it changes.
Programs should "register" files to install adding them to the $(install)
variable (similar as they register targets to compile in the $(all)
variable).
A few common rules are included in Lib.mak to install binaries and
libraries. To install other type of files the rule should be provided by
the makefile writer (but a function is provided to make this easy).
The test project is updated to install binaries, libraries and headers.
When used from sub-directories, if the file isn't inside the project's
top-level directory, it yields a bogus pseudo-relative-absolute name.
This patch fixes that.
Move the code to detect flags changes to trigger a rebuild together,
allowing more accurate messages and adding new variables to the list of
variables to monitor for changes to trigger a rebuild.
Remove the $J variable, it was useless for now. Rename $I to the more
verbose $(INCLUDE_DIR) since it won't be used very often by the user
(makefile writer nor makefile user).
The include directory symlink is now handled per-project, allowing the
inclusion of sub-project headers more naturally (without requiring to
prefix the parent project name and allowing the sub-project to keep its
original include directory name). The $P variable is not needed anymore
because of this.
The makefiles functions changed a little to allow per-project include
directory making Lib.mak not include any other files; because of that the
"all" rule now uses the "secondary expansion" to calculate the
prerequisites (the $(all) variable has not been populated yet when the
"all" rule is defined).
The Toplevel.mak files are now guarded to avoid multiple inclusions. This
should be not a problem since now the Toplevel.mak should not be changed,
is like an extension to Lib.mak that the user shouldn't mdify unless
he is hacking the build system.
The subproj is now renamed to otherproj to illustrate how the sub-directory
where it is stored doesn't have to match the name of the sub-project.
The pre-compiled headers feature is a little broken for now because the
system includes detection is too weak to differentiate things real system
includes from things included from $(INCLUDE_DIR).
Make internal $V flag to store @ when pretty printing
Verbosity flag ($V variable) let the user decide if he want to see nice
small messages ($V empty) or the standard make output displaying the raw
commands as they are executed ($V non-empty).
Now the meaning of this flag is reversed (and stores "@" when non-empty)
to let the Makefile writer to easily silence commands dependending on the
verbosity flag. When writing a rule, just prepend $V to each action you
want to conditionally silence depending on the verbosity flag.
Make subprojects read the Lib.mak from the parent project
By moving the Config.mak inclusion to Toplevel.mak we can read the
configuration before anything else, letting the user to change the
top-level path ($T) for example, which can be useful to make the subproject
read the Lib.mak of the parent project for example.
To be able to do this, the top-level Build.mak is included in Lib.mak too,
because the $(all) variable should be populated before defining the "all"
target, so it can have $(all) as a prerequisite.
Initial import of the all mighty make based build system
This is a test/example of a nice make based build system that support
automatic dependencies, variants, separated build directory, automatic
generation of pre-compiled header, subproject embedding and some other
goodies.
The only important file is Lib.mak, all the rest is just an usage example
and/or test.