]> git.ipfire.org Git - thirdparty/openssl.git/blame - Configurations/README.design
Switch to MAJOR.MINOR.PATCH versioning and version 3.0.0-dev
[thirdparty/openssl.git] / Configurations / README.design
CommitLineData
f83133a5
RL
1Design document for the unified scheme data
2===========================================
3
4How are things connected?
5-------------------------
6
7The unified scheme takes all its data from the build.info files seen
8throughout the source tree. These files hold the minimum information
9needed to build end product files from diverse sources. See the
10section on build.info files below.
11
12From the information in build.info files, Configure builds up an
13information database as a hash table called %unified_info, which is
14stored in configdata.pm, found at the top of the build tree (which may
15or may not be the same as the source tree).
16
17Configurations/common.tmpl uses the data from %unified_info to
18generate the rules for building end product files as well as
19intermediary files with the help of a few functions found in the
20build-file templates. See the section on build-file templates further
21down for more information.
22
23build.info files
24----------------
25
26As mentioned earlier, build.info files are meant to hold the minimum
27information needed to build output files, and therefore only (with a
28few possible exceptions [1]) have information about end products (such
29as scripts, library files and programs) and source files (such as C
30files, C header files, assembler files, etc). Intermediate files such
b6453a68 31as object files are rarely directly referred to in build.info files (and
f83133a5 32when they are, it's always with the file name extension .o), they are
b6453a68 33inferred by Configure. By the same rule of minimalism, end product
f83133a5 34file name extensions (such as .so, .a, .exe, etc) are never mentioned
b6453a68 35in build.info. Their file name extensions will be inferred by the
f83133a5
RL
36build-file templates, adapted for the platform they are meant for (see
37sections on %unified_info and build-file templates further down).
38
39The variables PROGRAMS, LIBS, ENGINES and SCRIPTS are used to declare
52fef270
RL
40end products. There are variants for them with '_NO_INST' as suffix
41(PROGRAM_NO_INST etc) to specify end products that shouldn't get
42installed.
f83133a5 43
b96ab5e6
RL
44The variables SOURCE, DEPEND, INCLUDE and DEFINE are indexed by a
45produced file, and their values are the source used to produce that
46particular produced file, extra dependencies, include directories
47needed, or C macros to be defined.
f83133a5
RL
48
49All their values in all the build.info throughout the source tree are
50collected together and form a set of programs, libraries, engines and
51scripts to be produced, source files, dependencies, etc etc etc.
52
53Let's have a pretend example, a very limited contraption of OpenSSL,
54composed of the program 'apps/openssl', the libraries 'libssl' and
55'libcrypto', an engine 'engines/ossltest' and their sources and
56dependencies.
57
58 # build.info
59 LIBS=libcrypto libssl
f83133a5
RL
60 INCLUDE[libcrypto]=include
61 INCLUDE[libssl]=include
62 DEPEND[libssl]=libcrypto
63
64This is the top directory build.info file, and it tells us that two
d201dbc9
RL
65libraries are to be built, the include directory 'include/' shall be
66used throughout when building anything that will end up in each
67library, and that the library 'libssl' depend on the library
68'libcrypto' to function properly.
f83133a5
RL
69
70 # apps/build.info
71 PROGRAMS=openssl
72 SOURCE[openssl]=openssl.c
73 INCLUDE[openssl]=.. ../include
74 DEPEND[openssl]=../libssl
75
76This is the build.info file in 'apps/', one may notice that all file
77paths mentioned are relative to the directory the build.info file is
78located in. This one tells us that there's a program to be built
79called 'apps/openssl' (the file name extension will depend on the
80platform and is therefore not mentioned in the build.info file). It's
81built from one source file, 'apps/openssl.c', and building it requires
82the use of '.' and 'include' include directories (both are declared
83from the point of view of the 'apps/' directory), and that the program
84depends on the library 'libssl' to function properly.
85
86 # crypto/build.info
87 LIBS=../libcrypto
88 SOURCE[../libcrypto]=aes.c evp.c cversion.c
89 DEPEND[cversion.o]=buildinf.h
90
ae4c7450
RL
91 GENERATE[buildinf.h]=../util/mkbuildinf.pl "$(CC) $(CFLAGS)" "$(PLATFORM)"
92 DEPEND[buildinf.h]=../Makefile
2036fd50 93 DEPEND[../util/mkbuildinf.pl]=../util/Foo.pm
f83133a5
RL
94
95This is the build.info file in 'crypto', and it tells us a little more
96about what's needed to produce 'libcrypto'. LIBS is used again to
97declare that 'libcrypto' is to be produced. This declaration is
98really unnecessary as it's already mentioned in the top build.info
99file, but can make the info file easier to understand. This is to
100show that duplicate information isn't an issue.
101
102This build.info file informs us that 'libcrypto' is built from a few
103source files, 'crypto/aes.c', 'crypto/evp.c' and 'crypto/cversion.c'.
104It also shows us that building the object file inferred from
105'crypto/cversion.c' depends on 'crypto/buildinf.h'. Finally, it
e38bd948 106also shows the possibility to declare how some files are generated
2036fd50
RL
107using some script, in this case a perl script, and how such scripts
108can be declared to depend on other files, in this case a perl module.
f83133a5
RL
109
110Two things are worth an extra note:
111
b6453a68 112'DEPEND[cversion.o]' mentions an object file. DEPEND indexes is the
f83133a5
RL
113only location where it's valid to mention them
114
115Lines in 'BEGINRAW'..'ENDRAW' sections must always mention files as
116seen from the top directory, no exception.
117
118 # ssl/build.info
119 LIBS=../libssl
120 SOURCE[../libssl]=tls.c
121
122This is the build.info file in 'ssl/', and it tells us that the
123library 'libssl' is built from the source file 'ssl/tls.c'.
124
125 # engines/build.info
52fef270
RL
126 ENGINES=dasync
127 SOURCE[dasync]=e_dasync.c
128 DEPEND[dasync]=../libcrypto
129 INCLUDE[dasync]=../include
130
131 ENGINES_NO_INST=ossltest
132 SOURCE[ossltest]=e_ossltest.c
473a9547 133 DEPEND[ossltest]=../libcrypto.a
52fef270
RL
134 INCLUDE[ossltest]=../include
135
136This is the build.info file in 'engines/', telling us that two engines
137called 'engines/dasync' and 'engines/ossltest' shall be built, that
138dasync's source is 'engines/e_dasync.c' and ossltest's source is
f83133a5 139'engines/e_ossltest.c' and that the include directory 'include/' may
52fef270
RL
140be used when building anything that will be part of these engines.
141Also, both engines depend on the library 'libcrypto' to function
473a9547
RL
142properly. ossltest is explicitly linked with the static variant of
143the library 'libcrypto'. Finally, only dasync is being installed, as
144ossltest is only for internal testing.
f83133a5
RL
145
146When Configure digests these build.info files, the accumulated
147information comes down to this:
148
149 LIBS=libcrypto libssl
f83133a5
RL
150 SOURCE[libcrypto]=crypto/aes.c crypto/evp.c crypto/cversion.c
151 DEPEND[crypto/cversion.o]=crypto/buildinf.h
152 INCLUDE[libcrypto]=include
f83133a5
RL
153 SOURCE[libssl]=ssl/tls.c
154 INCLUDE[libssl]=include
155 DEPEND[libssl]=libcrypto
156
157 PROGRAMS=apps/openssl
158 SOURCE[apps/openssl]=apps/openssl.c
159 INCLUDE[apps/openssl]=. include
160 DEPEND[apps/openssl]=libssl
161
52fef270
RL
162 ENGINES=engines/dasync
163 SOURCE[engines/dasync]=engines/e_dasync.c
164 DEPEND[engines/dasync]=libcrypto
165 INCLUDE[engines/dasync]=include
166
167 ENGINES_NO_INST=engines/ossltest
e38bd948 168 SOURCE[engines/ossltest]=engines/e_ossltest.c
473a9547 169 DEPEND[engines/ossltest]=libcrypto.a
e38bd948 170 INCLUDE[engines/ossltest]=include
f83133a5 171
ae4c7450
RL
172 GENERATE[crypto/buildinf.h]=util/mkbuildinf.pl "$(CC) $(CFLAGS)" "$(PLATFORM)"
173 DEPEND[crypto/buildinf.h]=Makefile
2036fd50 174 DEPEND[util/mkbuildinf.pl]=util/Foo.pm
f83133a5
RL
175
176
177A few notes worth mentioning:
178
179LIBS may be used to declare routine libraries only.
180
181PROGRAMS may be used to declare programs only.
182
183ENGINES may be used to declare engines only.
184
d201dbc9
RL
185The indexes for SOURCE must only be end product files, such as
186libraries, programs or engines. The values of SOURCE variables must
187only be source files (possibly generated).
f83133a5 188
2036fd50
RL
189INCLUDE and DEPEND shows a relationship between different files
190(usually produced files) or between files and directories, such as a
191program depending on a library, or between an object file and some
192extra source file.
f83133a5
RL
193
194When Configure processes the build.info files, it will take it as
195truth without question, and will therefore perform very few checks.
196If the build tree is separate from the source tree, it will assume
197that all built files and up in the build directory and that all source
198files are to be found in the source tree, if they can be found there.
199Configure will assume that source files that can't be found in the
200source tree (such as 'crypto/bildinf.h' in the example above) are
201generated and will be found in the build tree.
202
203
204The %unified_info database
205--------------------------
206
207The information in all the build.info get digested by Configure and
208collected into the %unified_info database, divided into the following
209indexes:
210
211 depends => a hash table containing 'file' => [ 'dependency' ... ]
212 pairs. These are directly inferred from the DEPEND
213 variables in build.info files.
214
215 engines => a list of engines. These are directly inferred from
216 the ENGINES variable in build.info files.
217
e38bd948
RL
218 generate => a hash table containing 'file' => [ 'generator' ... ]
219 pairs. These are directly inferred from the GENERATE
220 variables in build.info files.
221
f83133a5
RL
222 includes => a hash table containing 'file' => [ 'include' ... ]
223 pairs. These are directly inferred from the INCLUDE
224 variables in build.info files.
225
52fef270
RL
226 install => a hash table containing 'type' => [ 'file' ... ] pairs.
227 The types are 'programs', 'libraries', 'engines' and
228 'scripts', and the array of files list the files of
229 that type that should be installed.
230
f83133a5
RL
231 libraries => a list of libraries. These are directly inferred from
232 the LIBS variable in build.info files.
233
f83133a5
RL
234 programs => a list of programs. These are directly inferred from
235 the PROGRAMS variable in build.info files.
236
237 rawlines => a list of build-file lines. These are a direct copy of
238 the BEGINRAW..ENDRAW lines in build.info files. Note:
239 only the BEGINRAW..ENDRAW section for the current
240 platform are copied, the rest are ignored.
241
242 scripts => a list of scripts. There are directly inferred from
243 the SCRIPTS variable in build.info files.
244
245 sources => a hash table containing 'file' => [ 'sourcefile' ... ]
246 pairs. These are indirectly inferred from the SOURCE
247 variables in build.info files. Object files are
248 mentioned in this hash table, with source files from
249 SOURCE variables, and AS source files for programs and
250 libraries.
251
2a08d1a0
RL
252 shared_sources =>
253 a hash table just like 'sources', but only as source
254 files (object files) for building shared libraries.
255
f83133a5
RL
256As an example, here is how the build.info files example from the
257section above would be digested into a %unified_info table:
258
259 our %unified_info = (
260 "depends" =>
261 {
262 "apps/openssl" =>
263 [
264 "libssl",
265 ],
e38bd948
RL
266 "crypto/buildinf.h" =>
267 [
268 "Makefile",
269 ],
f83133a5
RL
270 "crypto/cversion.o" =>
271 [
272 "crypto/buildinf.h",
273 ],
473a9547 274 "engines/dasync" =>
f83133a5
RL
275 [
276 "libcrypto",
277 ],
473a9547
RL
278 "engines/ossltest" =>
279 [
280 "libcrypto.a",
281 ],
f83133a5
RL
282 "libssl" =>
283 [
284 "libcrypto",
285 ],
2036fd50
RL
286 "util/mkbuildinf.pl" =>
287 [
288 "util/Foo.pm",
289 ],
f83133a5
RL
290 },
291 "engines" =>
292 [
52fef270 293 "engines/dasync",
e38bd948 294 "engines/ossltest",
f83133a5 295 ],
e38bd948
RL
296 "generate" =>
297 {
298 "crypto/buildinf.h" =>
299 [
300 "util/mkbuildinf.pl",
301 "\"\$(CC)",
302 "\$(CFLAGS)\"",
303 "\"$(PLATFORM)\"",
304 ],
305 },
f83133a5
RL
306 "includes" =>
307 {
308 "apps/openssl" =>
309 [
310 ".",
311 "include",
312 ],
e38bd948 313 "engines/ossltest" =>
f83133a5
RL
314 [
315 "include"
316 ],
317 "libcrypto" =>
318 [
319 "include",
320 ],
321 "libssl" =>
322 [
323 "include",
324 ],
2036fd50
RL
325 "util/mkbuildinf.pl" =>
326 [
327 "util",
328 ],
f83133a5 329 }
52fef270
RL
330 "install" =>
331 {
332 "engines" =>
333 [
334 "engines/dasync",
335 ],
336 "libraries" =>
337 [
338 "libcrypto",
339 "libssl",
340 ],
341 "programs" =>
342 [
343 "apps/openssl",
344 ],
345 },
f83133a5
RL
346 "libraries" =>
347 [
348 "libcrypto",
349 "libssl",
350 ],
f83133a5
RL
351 "programs" =>
352 [
353 "apps/openssl",
354 ],
355 "rawlines" =>
356 [
f83133a5
RL
357 ],
358 "sources" =>
359 {
360 "apps/openssl" =>
361 [
362 "apps/openssl.o",
363 ],
364 "apps/openssl.o" =>
365 [
366 "apps/openssl.c",
367 ],
368 "crypto/aes.o" =>
369 [
370 "crypto/aes.c",
371 ],
372 "crypto/cversion.o" =>
373 [
374 "crypto/cversion.c",
375 ],
376 "crypto/evp.o" =>
377 [
378 "crypto/evp.c",
379 ],
473a9547
RL
380 "engines/e_dasync.o" =>
381 [
382 "engines/e_dasync.c",
383 ],
384 "engines/dasync" =>
385 [
386 "engines/e_dasync.o",
387 ],
f83133a5
RL
388 "engines/e_ossltest.o" =>
389 [
390 "engines/e_ossltest.c",
391 ],
e38bd948 392 "engines/ossltest" =>
f83133a5
RL
393 [
394 "engines/e_ossltest.o",
395 ],
396 "libcrypto" =>
397 [
398 "crypto/aes.c",
399 "crypto/cversion.c",
400 "crypto/evp.c",
401 ],
402 "libssl" =>
403 [
404 "ssl/tls.c",
405 ],
406 "ssl/tls.o" =>
407 [
408 "ssl/tls.c",
409 ],
410 },
411 );
412
b6453a68 413As can be seen, everything in %unified_info is fairly simple suggest
f83133a5
RL
414of information. Still, it tells us that to build all programs, we
415must build 'apps/openssl', and to build the latter, we will need to
416build all its sources ('apps/openssl.o' in this case) and all the
417other things it depends on (such as 'libssl'). All those dependencies
418need to be built as well, using the same logic, so to build 'libssl',
419we need to build 'ssl/tls.o' as well as 'libcrypto', and to build the
420latter...
421
422
423Build-file templates
424--------------------
425
426Build-file templates are essentially build-files (such as Makefile on
427Unix) with perl code fragments mixed in. Those perl code fragment
428will generate all the configuration dependent data, including all the
429rules needed to build end product files and intermediary files alike.
430At a minimum, there must be a perl code fragment that defines a set of
431functions that are used to generates specific build-file rules, to
432build static libraries from object files, to build shared libraries
433from static libraries, to programs from object files and libraries,
434etc.
435
e38bd948
RL
436 generatesrc - function that produces build file lines to generate
437 a source file from some input.
438
439 It's called like this:
440
441 generatesrc(src => "PATH/TO/tobegenerated",
442 generator => [ "generatingfile", ... ]
2036fd50
RL
443 generator_incs => [ "INCL/PATH", ... ]
444 generator_deps => [ "dep1", ... ]
e38bd948
RL
445 incs => [ "INCL/PATH", ... ],
446 deps => [ "dep1", ... ],
447 intent => one of "libs", "dso", "bin" );
448
449 'src' has the name of the file to be generated.
450 'generator' is the command or part of command to
451 generate the file, of which the first item is
452 expected to be the file to generate from.
453 generatesrc() is expected to analyse and figure out
454 exactly how to apply that file and how to capture
2036fd50
RL
455 the result. 'generator_incs' and 'generator_deps'
456 are include directories and files that the generator
457 file itself depends on. 'incs' and 'deps' are
458 include directories and files that are used if $(CC)
459 is used as an intermediary step when generating the
460 end product (the file indicated by 'src'). 'intent'
461 indicates what the generated file is going to be
462 used for.
e38bd948 463
f83133a5
RL
464 src2obj - function that produces build file lines to build an
465 object file from source files and associated data.
466
467 It's called like this:
468
469 src2obj(obj => "PATH/TO/objectfile",
470 srcs => [ "PATH/TO/sourcefile", ... ],
471 deps => [ "dep1", ... ],
45502bfe
RL
472 incs => [ "INCL/PATH", ... ]
473 intent => one of "lib", "dso", "bin" );
f83133a5 474
aa343982
RL
475 'obj' has the intended object file with '.o'
476 extension, src2obj() is expected to change it to
477 something more suitable for the platform.
f83133a5
RL
478 'srcs' has the list of source files to build the
479 object file, with the first item being the source
480 file that directly corresponds to the object file.
45502bfe
RL
481 'deps' is a list of explicit dependencies. 'incs'
482 is a list of include file directories. Finally,
483 'intent' indicates what this object file is going
484 to be used for.
f83133a5
RL
485
486 obj2lib - function that produces build file lines to build a
487 static library file ("libfoo.a" in Unix terms) from
488 object files.
489
490 called like this:
491
492 obj2lib(lib => "PATH/TO/libfile",
493 objs => [ "PATH/TO/objectfile", ... ]);
494
495 'lib' has the intended library file name *without*
496 extension, obj2lib is expected to add that. 'objs'
aa343982 497 has the list of object files to build this library.
f83133a5 498
aa343982
RL
499 libobj2shlib - backward compatibility function that's used the
500 same way as obj2shlib (described next), and was
501 expected to build the shared library from the
502 corresponding static library when that was suitable.
503 NOTE: building a shared library from a static
504 library is now DEPRECATED, as they no longer share
505 object files. Attempting to do this will fail.
506
507 obj2shlib - function that produces build file lines to build a
f83133a5 508 shareable object library file ("libfoo.so" in Unix
aa343982 509 terms) from the corresponding object files.
f83133a5
RL
510
511 called like this:
512
aa343982
RL
513 obj2shlib(shlib => "PATH/TO/shlibfile",
514 lib => "PATH/TO/libfile",
515 objs => [ "PATH/TO/objectfile", ... ],
516 deps => [ "PATH/TO/otherlibfile", ... ]);
f83133a5 517
aa343982
RL
518 'lib' has the base (static) library file name
519 *without* extension. This is useful in case
520 supporting files are needed (such as import
521 libraries on Windows).
b6453a68 522 'shlib' has the corresponding shared library name
f83133a5
RL
523 *without* extension. 'deps' has the list of other
524 libraries (also *without* extension) this library
525 needs to be linked with. 'objs' has the list of
aa343982 526 object files to build this library.
f83133a5 527
aa343982
RL
528 obj2dso - function that produces build file lines to build a
529 dynamic shared object file from object files.
f83133a5
RL
530
531 called like this:
532
aa343982
RL
533 obj2dso(lib => "PATH/TO/libfile",
534 objs => [ "PATH/TO/objectfile", ... ],
535 deps => [ "PATH/TO/otherlibfile",
536 ... ]);
f83133a5 537
aa343982 538 This is almost the same as obj2shlib, but the
f83133a5 539 intent is to build a shareable library that can be
aa343982 540 loaded in runtime (a "plugin"...).
f83133a5
RL
541
542 obj2bin - function that produces build file lines to build an
543 executable file from object files.
544
545 called like this:
546
547 obj2bin(bin => "PATH/TO/binfile",
548 objs => [ "PATH/TO/objectfile", ... ],
549 deps => [ "PATH/TO/libfile", ... ]);
550
551 'bin' has the intended executable file name
552 *without* extension, obj2bin is expected to add
aa343982
RL
553 that. 'objs' has the list of object files to build
554 this library. 'deps' has the list of library files
555 (also *without* extension) that the programs needs
556 to be linked with.
f83133a5
RL
557
558 in2script - function that produces build file lines to build a
559 script file from some input.
560
561 called like this:
562
563 in2script(script => "PATH/TO/scriptfile",
564 sources => [ "PATH/TO/infile", ... ]);
565
566 'script' has the intended script file name.
567 'sources' has the list of source files to build the
568 resulting script from.
569
570Along with the build-file templates is the driving engine
571Configurations/common.tmpl, which looks through all the information in
572%unified_info and generates all the rulesets to build libraries,
573programs and all intermediate files, using the rule generating
574functions defined in the build-file template.
575
576As an example with the smaller build.info set we've seen as an
2036fd50 577example, producing the rules to build 'libcrypto' would result in the
f83133a5
RL
578following calls:
579
aa343982 580 # Note: obj2shlib will only be called if shared libraries are
f83133a5 581 # to be produced.
aa343982
RL
582 # Note 2: obj2shlib must convert the '.o' extension to whatever
583 # is suitable on the local platform.
584 obj2shlib(shlib => "libcrypto",
585 objs => [ "crypto/aes.o", "crypto/evp.o", "crypto/cversion.o" ],
586 deps => [ ]);
2036fd50
RL
587
588 obj2lib(lib => "libcrypto"
aa343982 589 objs => [ "crypto/aes.o", "crypto/evp.o", "crypto/cversion.o" ]);
f83133a5 590
aa343982 591 src2obj(obj => "crypto/aes.o"
2036fd50
RL
592 srcs => [ "crypto/aes.c" ],
593 deps => [ ],
594 incs => [ "include" ],
595 intent => "lib");
f83133a5 596
aa343982 597 src2obj(obj => "crypto/evp.o"
2036fd50 598 srcs => [ "crypto/evp.c" ],
f83133a5 599 deps => [ ],
e38bd948
RL
600 incs => [ "include" ],
601 intent => "lib");
f83133a5 602
aa343982 603 src2obj(obj => "crypto/cversion.o"
2036fd50
RL
604 srcs => [ "crypto/cversion.c" ],
605 deps => [ "crypto/buildinf.h" ],
606 incs => [ "include" ],
607 intent => "lib");
608
609 generatesrc(src => "crypto/buildinf.h",
610 generator => [ "util/mkbuildinf.pl", "\"$(CC)",
611 "$(CFLAGS)\"", "\"$(PLATFORM)\"" ],
612 generator_incs => [ "util" ],
613 generator_deps => [ "util/Foo.pm" ],
614 incs => [ ],
615 deps => [ ],
616 intent => "lib");
617
f83133a5
RL
618The returned strings from all those calls are then concatenated
619together and written to the resulting build-file.