1 Design document for the unified scheme data
2 ===========================================
4 How are things connected?
5 -------------------------
7 The unified scheme takes all its data from the build.info files seen
8 throughout the source tree. These files hold the minimum information
9 needed to build end product files from diverse sources. See the
10 section on build.info files below.
12 From the information in build.info files, Configure builds up an
13 information database as a hash table called %unified_info, which is
14 stored in configdata.pm, found at the top of the build tree (which may
15 or may not be the same as the source tree).
17 Configurations/common.tmpl uses the data from %unified_info to
18 generate the rules for building end product files as well as
19 intermediary files with the help of a few functions found in the
20 build-file templates. See the section on build-file templates further
21 down for more information.
26 As mentioned earlier, build.info files are meant to hold the minimum
27 information needed to build output files, and therefore only (with a
28 few possible exceptions [1]) have information about end products (such
29 as scripts, library files and programs) and source files (such as C
30 files, C header files, assembler files, etc). Intermediate files such
31 as object files are rarely directly referred to in build.info files (and
32 when they are, it's always with the file name extension .o), they are
33 inferred by Configure. By the same rule of minimalism, end product
34 file name extensions (such as .so, .a, .exe, etc) are never mentioned
35 in build.info. Their file name extensions will be inferred by the
36 build-file templates, adapted for the platform they are meant for (see
37 sections on %unified_info and build-file templates further down).
39 The variables PROGRAMS, LIBS, ENGINES and SCRIPTS are used to declare
42 The variables SOURCE, DEPEND, INCLUDE and ORDINALS are indexed by a
43 produced file, and their values are the source used to produce that
44 particular produced file, extra dependencies, include directories
45 needed, and ordinal files (explained further below.
47 All their values in all the build.info throughout the source tree are
48 collected together and form a set of programs, libraries, engines and
49 scripts to be produced, source files, dependencies, etc etc etc.
51 Let's have a pretend example, a very limited contraption of OpenSSL,
52 composed of the program 'apps/openssl', the libraries 'libssl' and
53 'libcrypto', an engine 'engines/ossltest' and their sources and
58 ORDINALS[libcrypto]=crypto
60 INCLUDE[libcrypto]=include
61 INCLUDE[libssl]=include
62 DEPEND[libssl]=libcrypto
64 This is the top directory build.info file, and it tells us that two
65 libraries are to be built, there are some ordinals to be used to
66 declare what symbols in those libraries are seen as public, the
67 include directory 'include/' shall be used throughout when building
68 anything that will end up in each library, and that the library
69 'libssl' depend on the library 'libcrypto' to function properly.
73 SOURCE[openssl]=openssl.c
74 INCLUDE[openssl]=.. ../include
75 DEPEND[openssl]=../libssl
77 This is the build.info file in 'apps/', one may notice that all file
78 paths mentioned are relative to the directory the build.info file is
79 located in. This one tells us that there's a program to be built
80 called 'apps/openssl' (the file name extension will depend on the
81 platform and is therefore not mentioned in the build.info file). It's
82 built from one source file, 'apps/openssl.c', and building it requires
83 the use of '.' and 'include' include directories (both are declared
84 from the point of view of the 'apps/' directory), and that the program
85 depends on the library 'libssl' to function properly.
89 SOURCE[../libcrypto]=aes.c evp.c cversion.c
90 DEPEND[cversion.o]=buildinf.h
92 GENERATE[buildinf.h]=../util/mkbuildinf.pl "$(CC) $(CFLAGS)" "$(PLATFORM)"
93 DEPEND[buildinf.h]=../Makefile
95 This is the build.info file in 'crypto', and it tells us a little more
96 about what's needed to produce 'libcrypto'. LIBS is used again to
97 declare that 'libcrypto' is to be produced. This declaration is
98 really unnecessary as it's already mentioned in the top build.info
99 file, but can make the info file easier to understand. This is to
100 show that duplicate information isn't an issue.
102 This build.info file informs us that 'libcrypto' is built from a few
103 source files, 'crypto/aes.c', 'crypto/evp.c' and 'crypto/cversion.c'.
104 It also shows us that building the object file inferred from
105 'crypto/cversion.c' depends on 'crypto/buildinf.h'. Finally, it
106 also shows the possibility to include raw build-file statements in a
107 build.info file, in this case showing how 'buildinf.h' is built on
108 Unix-like operating systems.
110 Two things are worth an extra note:
112 'DEPEND[cversion.o]' mentions an object file. DEPEND indexes is the
113 only location where it's valid to mention them
115 Lines in 'BEGINRAW'..'ENDRAW' sections must always mention files as
116 seen from the top directory, no exception.
120 SOURCE[../libssl]=tls.c
122 This is the build.info file in 'ssl/', and it tells us that the
123 library 'libssl' is built from the source file 'ssl/tls.c'.
127 SOURCE[libossltest]=e_ossltest.c
128 DEPEND[libossltest]=../libcrypto
129 INCLUDE[libossltest]=../include
131 This is the build.info file in 'engines/', telling us that an engine
132 called 'engines/libossltest' shall be built, that it's source is
133 'engines/e_ossltest.c' and that the include directory 'include/' may
134 be used when building anything that will be part of this engine.
135 Finally, the engine 'engines/libossltest' depends on the library
136 'libcrypto' to function properly.
138 When Configure digests these build.info files, the accumulated
139 information comes down to this:
141 LIBS=libcrypto libssl
142 ORDINALS[libcrypto]=crypto
143 SOURCE[libcrypto]=crypto/aes.c crypto/evp.c crypto/cversion.c
144 DEPEND[crypto/cversion.o]=crypto/buildinf.h
145 INCLUDE[libcrypto]=include
147 SOURCE[libssl]=ssl/tls.c
148 INCLUDE[libssl]=include
149 DEPEND[libssl]=libcrypto
151 PROGRAMS=apps/openssl
152 SOURCE[apps/openssl]=apps/openssl.c
153 INCLUDE[apps/openssl]=. include
154 DEPEND[apps/openssl]=libssl
156 ENGINES=engines/libossltest
157 SOURCE[engines/libossltest]=engines/e_ossltest.c
158 DEPEND[engines/libossltest]=libcrypto
159 INCLUDE[engines/libossltest]=include
161 GENERATE[crypto/buildinf.h]=util/mkbuildinf.pl "$(CC) $(CFLAGS)" "$(PLATFORM)"
162 DEPEND[crypto/buildinf.h]=Makefile
165 A few notes worth mentioning:
167 LIBS may be used to declare routine libraries only.
169 PROGRAMS may be used to declare programs only.
171 ENGINES may be used to declare engines only.
173 The indexes for SOURCE, INCLUDE and ORDINALS must only be end product
174 files, such as libraries, programs or engines. The values of SOURCE
175 variables must only be source files (possibly generated)
177 DEPEND shows a relationship between different produced files, such
178 as a program depending on a library, or between an object file and
179 some extra source file.
181 When Configure processes the build.info files, it will take it as
182 truth without question, and will therefore perform very few checks.
183 If the build tree is separate from the source tree, it will assume
184 that all built files and up in the build directory and that all source
185 files are to be found in the source tree, if they can be found there.
186 Configure will assume that source files that can't be found in the
187 source tree (such as 'crypto/bildinf.h' in the example above) are
188 generated and will be found in the build tree.
191 The %unified_info database
192 --------------------------
194 The information in all the build.info get digested by Configure and
195 collected into the %unified_info database, divided into the following
198 depends => a hash table containing 'file' => [ 'dependency' ... ]
199 pairs. These are directly inferred from the DEPEND
200 variables in build.info files.
202 engines => a list of engines. These are directly inferred from
203 the ENGINES variable in build.info files.
205 includes => a hash table containing 'file' => [ 'include' ... ]
206 pairs. These are directly inferred from the INCLUDE
207 variables in build.info files.
209 libraries => a list of libraries. These are directly inferred from
210 the LIBS variable in build.info files.
212 ordinals => a hash table containing 'file' => [ 'word', 'ordfile' ]
213 pairs. 'file' and 'word' are directly inferred from
214 the ORDINALS variables in build.info files, while the
215 file 'ofile' comes from internal knowledge in
218 programs => a list of programs. These are directly inferred from
219 the PROGRAMS variable in build.info files.
221 rawlines => a list of build-file lines. These are a direct copy of
222 the BEGINRAW..ENDRAW lines in build.info files. Note:
223 only the BEGINRAW..ENDRAW section for the current
224 platform are copied, the rest are ignored.
226 scripts => a list of scripts. There are directly inferred from
227 the SCRIPTS variable in build.info files.
229 sources => a hash table containing 'file' => [ 'sourcefile' ... ]
230 pairs. These are indirectly inferred from the SOURCE
231 variables in build.info files. Object files are
232 mentioned in this hash table, with source files from
233 SOURCE variables, and AS source files for programs and
236 As an example, here is how the build.info files example from the
237 section above would be digested into a %unified_info table:
239 our %unified_info = (
246 "crypto/cversion.o" =>
250 "engines/libossltest" =>
261 "engines/libossltest",
270 "engines/libossltest" =>
293 "util/libcrypto.num",
307 "crypto/buildinf.h : Makefile",
308 " perl util/mkbuildinf.h \"\$(CC) \$(CFLAGS)\" \"\$(PLATFORM)\" \\"
309 " > crypto/buildinf.h"
325 "crypto/cversion.o" =>
333 "engines/e_ossltest.o" =>
335 "engines/e_ossltest.c",
337 "engines/libossltest" =>
339 "engines/e_ossltest.o",
358 As can be seen, everything in %unified_info is fairly simple suggest
359 of information. Still, it tells us that to build all programs, we
360 must build 'apps/openssl', and to build the latter, we will need to
361 build all its sources ('apps/openssl.o' in this case) and all the
362 other things it depends on (such as 'libssl'). All those dependencies
363 need to be built as well, using the same logic, so to build 'libssl',
364 we need to build 'ssl/tls.o' as well as 'libcrypto', and to build the
371 Build-file templates are essentially build-files (such as Makefile on
372 Unix) with perl code fragments mixed in. Those perl code fragment
373 will generate all the configuration dependent data, including all the
374 rules needed to build end product files and intermediary files alike.
375 At a minimum, there must be a perl code fragment that defines a set of
376 functions that are used to generates specific build-file rules, to
377 build static libraries from object files, to build shared libraries
378 from static libraries, to programs from object files and libraries,
381 src2obj - function that produces build file lines to build an
382 object file from source files and associated data.
384 It's called like this:
386 src2obj(obj => "PATH/TO/objectfile",
387 srcs => [ "PATH/TO/sourcefile", ... ],
388 deps => [ "dep1", ... ],
389 incs => [ "INCL/PATH", ... ]
390 intent => one of "lib", "dso", "bin" );
392 'obj' has the intended object file *without*
393 extension, src2obj() is expected to add that.
394 'srcs' has the list of source files to build the
395 object file, with the first item being the source
396 file that directly corresponds to the object file.
397 'deps' is a list of explicit dependencies. 'incs'
398 is a list of include file directories. Finally,
399 'intent' indicates what this object file is going
402 obj2lib - function that produces build file lines to build a
403 static library file ("libfoo.a" in Unix terms) from
408 obj2lib(lib => "PATH/TO/libfile",
409 objs => [ "PATH/TO/objectfile", ... ]);
411 'lib' has the intended library file name *without*
412 extension, obj2lib is expected to add that. 'objs'
413 has the list of object files (also *without*
414 extension) to build this library.
416 libobj2shlib - function that produces build file lines to build a
417 shareable object library file ("libfoo.so" in Unix
418 terms) from the corresponding static library file
423 libobj2shlib(shlib => "PATH/TO/shlibfile",
424 lib => "PATH/TO/libfile",
425 objs => [ "PATH/TO/objectfile", ... ],
426 deps => [ "PATH/TO/otherlibfile", ... ],
427 ordinals => [ "word", "/PATH/TO/ordfile" ]);
429 'lib' has the intended library file name *without*
430 extension, libobj2shlib is expected to add that.
431 'shlib' has the corresponding shared library name
432 *without* extension. 'deps' has the list of other
433 libraries (also *without* extension) this library
434 needs to be linked with. 'objs' has the list of
435 object files (also *without* extension) to build
436 this library. 'ordinals' MAY be present, and when
437 it is, its value is an array where the word is
438 "crypto" or "ssl" and the file is one of the ordinal
439 files util/libcrypto.num or util/libssl.num in the
442 This function has a choice; it can use the
443 corresponding static library as input to make the
444 shared library, or the list of object files.
446 obj2dynlib - function that produces build file lines to build a
447 dynamically loadable library file ("libfoo.so" on
448 Unix) from object files.
452 obj2dynlib(lib => "PATH/TO/libfile",
453 objs => [ "PATH/TO/objectfile", ... ],
454 deps => [ "PATH/TO/otherlibfile",
457 This is almost the same as libobj2shlib, but the
458 intent is to build a shareable library that can be
459 loaded in runtime (a "plugin"...). The differences
460 are subtle, one of the most visible ones is that the
461 resulting shareable library is produced from object
464 obj2bin - function that produces build file lines to build an
465 executable file from object files.
469 obj2bin(bin => "PATH/TO/binfile",
470 objs => [ "PATH/TO/objectfile", ... ],
471 deps => [ "PATH/TO/libfile", ... ]);
473 'bin' has the intended executable file name
474 *without* extension, obj2bin is expected to add
475 that. 'objs' has the list of object files (also
476 *without* extension) to build this library. 'deps'
477 has the list of library files (also *without*
478 extension) that the programs needs to be linked
481 in2script - function that produces build file lines to build a
482 script file from some input.
486 in2script(script => "PATH/TO/scriptfile",
487 sources => [ "PATH/TO/infile", ... ]);
489 'script' has the intended script file name.
490 'sources' has the list of source files to build the
491 resulting script from.
493 Along with the build-file templates is the driving engine
494 Configurations/common.tmpl, which looks through all the information in
495 %unified_info and generates all the rulesets to build libraries,
496 programs and all intermediate files, using the rule generating
497 functions defined in the build-file template.
499 As an example with the smaller build.info set we've seen as an
500 example, producing the rules to build 'libssl' would result in the
503 # Note: libobj2shlib will only be called if shared libraries are
505 # Note 2: libobj2shlib gets both the name of the static library
506 # and the names of all the object files that go into it. It's up
507 # to the implementation to decide which to use as input.
508 libobj2shlib(shlib => "libssl",
510 objs => [ "ssl/tls.o" ],
511 deps => [ "libcrypto" ]
512 ordinals => [ "ssl", "util/libssl.num" ]);
514 obj2lib(lib => "libssl"
515 objs => [ "ssl/tls.o" ]);
517 # Note 3: common.tmpl peals off the ".o" extension, as the
518 # platform at hand may have a different one.
519 src2obj(obj => "ssl/tls"
520 srcs => [ "ssl/tls.c" ],
522 incs => [ "include" ]);
524 src2dep(obj => "ssl/tls"
525 srcs => [ "ssl/tls.c" ],
526 incs => [ "include" ]);
528 The returned strings from all those calls are then concatenated
529 together and written to the resulting build-file.