Confirmed users
1,380
edits
m (→make-makefiles) |
mNo edit summary |
||
Line 1: | Line 1: | ||
= post #2 = | |||
== Build system tools: make-makefile == | |||
Build system tools: make-makefile x2 | |||
How the make-makefile tool is used to generate makefiles. | |||
>> Build system tools: make-makefile | |||
>> make-makefile will be automatically invoked while building whenever a Makefile does not exist beneath the object directory or a template (Makefile.in) is newer than a previously generated Makefile. | |||
When makefile generation is needed the tool will perform a few steps. | |||
1) gmake -f client.mk is invoked. During traversal if gmake detects one | |||
of two conditions for generation the tool will be invoked: | |||
o $(obj)/Makefile does not exist. | |||
o $(src)/Makefile.in is newer than $(obj)/Makefile. | |||
2) make-makefile is invoked with command line arguments, usually -d and -t. | |||
o -d relative path --depth from file to hierarchy root directory. | |||
Makefile: $(MOZ_OBJDIR), Makefile.in: $(TOPSRCDIR) | |||
o -t path to root of the development sandbox ~$(TOPSRCDIR) | |||
3) When invoked make-makefile is semi-aware of the directory hierarchy | |||
and will expect cwd for the shell to be $(MOZ_OBJDIR) or a subdir | |||
of it[1]. | |||
4) Step 1 - obtain values for depth, topsrcdir and objdir. | |||
o values can be passed on the command line | |||
o determined from the filesystem based on arguments or cwd | |||
o depth= can be set by the -d command line argument. Assignment of | |||
DEPTH=../.. specified within a given Makefile or arguments passed | |||
to MM. Failing this the tool will inspect Makefiles contained in | |||
a parent directory to obtain a value. | |||
5) Step 2 - Using cwd and arguments derive a path to the source template | |||
Makefile.in and target file Makefile. | |||
6) Step 3 - Slurp the source template Makefile.in. Perform value | |||
substitutions on tokens of the format @token@ | |||
gfx/Makefile.in | |||
=============== | |||
DEPTH = .. | |||
topsrcdir = @top_srcdir@ | |||
srcdir = @srcdir@ | |||
VPATH = @srcdir@ | |||
Note: common paths are derived internally by the tool for quick | |||
substitution. For all @${unknown}@ tokens make-makefile internally | |||
will spawn ./config.status to obtain values, create directories and | |||
who knows what else. Considerable overhead can be imposed by this | |||
step so avoid stray tokens whenever possible or code token expansion | |||
logic within MM to avoid the extra shell. | |||
7) Step 4 - update or preserve generated Makefile timestamps. If | |||
obj/Makefile does not exist create it. If the file exists compare | |||
generated content against the original and only update when modified. | |||
[1] - Use of hardcoded expectations can be altered by the --enhanced flag. | |||
This option and other new flags will be covered in a future post. | |||
[2] - Enhancement - modify make-makefile to parse and extract fully expanded | |||
values from config* to avoid invoking ./config.status for a subset of | |||
substitution tokens. | |||
= post #1 = | = post #1 = | ||
Line 15: | Line 78: | ||
<hr> | <hr> | ||
= Post # | = Post #x = | ||
<pre> | <pre> | ||
The make-makefile tool is normally invoked during recursive make traversal, indirectly launched by make -f client.mk calls. | The make-makefile tool is normally invoked during recursive make traversal, indirectly launched by make -f client.mk calls. |