]> git.ipfire.org Git - thirdparty/openssl.git/blob - Configurations/common.tmpl
Configure - Rename BASE to DEFAULTS and add a few inheritable BASEs
[thirdparty/openssl.git] / Configurations / common.tmpl
1 {- # -*- Mode: perl -*-
2
3 # A cache of objects for which a recipe has already been generated
4 my %cache;
5
6 # resolvedepends and reducedepends work in tandem to make sure
7 # there are no duplicate dependencies and that they are in the
8 # right order. This is especially used to sort the list of
9 # libraries that a build depends on.
10 sub resolvedepends {
11 my $thing = shift;
12 my @listsofar = @_; # to check if we're looping
13 my @list = @{$unified_info{depends}->{$thing}};
14 my @newlist = ();
15 if (scalar @list) {
16 foreach my $item (@list) {
17 # It's time to break off when the dependency list starts looping
18 next if grep { $_ eq $item } @listsofar;
19 push @newlist, $item, resolvedepends($item, @listsofar, $item);
20 }
21 }
22 @newlist;
23 }
24 sub reducedepends {
25 my @list = @_;
26 my @newlist = ();
27 while (@list) {
28 my $item = shift @list;
29 push @newlist, $item
30 unless grep { $item eq $_ } @list;
31 }
32 @newlist;
33 }
34
35 # doobj is responsible for producing all the recipes that build
36 # object files as well as dependency files.
37 sub doobj {
38 my $obj = shift;
39 return "" if $cache{$obj};
40 (my $obj_no_o = $obj) =~ s|\.o$||;
41 my $bin = shift;
42 my %opts = @_;
43 if (@{$unified_info{sources}->{$obj}}) {
44 $OUT .= src2obj(obj => $obj_no_o,
45 srcs => $unified_info{sources}->{$obj},
46 deps => [ reducedepends(resolvedepends($obj)) ],
47 incs => [ @{$unified_info{includes}->{$bin}},
48 @{$unified_info{includes}->{$obj}} ],
49 %opts);
50 }
51 $cache{$obj} = 1;
52 }
53
54 # dolib is responsible for building libraries. It will call
55 # libobj2shlib is shared libraries are produced, and obj2lib in all
56 # cases. It also makes sure all object files for the library are
57 # built.
58 sub dolib {
59 my $lib = shift;
60 return "" if $cache{$lib};
61 unless ($disabled{shared}) {
62 my %ordinals =
63 $unified_info{ordinals}->{$lib}
64 ? (ordinals => $unified_info{ordinals}->{$lib}) : ();
65 $OUT .= libobj2shlib(shlib => $unified_info{sharednames}->{$lib},
66 lib => $lib,
67 objs => [ map { (my $x = $_) =~ s|\.o$||; $x }
68 @{$unified_info{sources}->{$lib}} ],
69 deps => [ reducedepends(resolvedepends($lib)) ],
70 %ordinals);
71 }
72 $OUT .= obj2lib(lib => $lib,
73 objs => [ map { (my $x = $_) =~ s|\.o$||; $x }
74 @{$unified_info{sources}->{$lib}} ]);
75 map { doobj($_, $lib, intent => "lib") } @{$unified_info{sources}->{$lib}};
76 $cache{$lib} = 1;
77 }
78
79 # doengine is responsible for building engines. It will call
80 # obj2dso, and also makes sure all object files for the library
81 # are built.
82 sub doengine {
83 my $lib = shift;
84 return "" if $cache{$lib};
85 $OUT .= obj2dso(lib => $lib,
86 objs => [ map { (my $x = $_) =~ s|\.o$||; $x }
87 @{$unified_info{sources}->{$lib}} ],
88 deps => [ resolvedepends($lib) ]);
89 map { doobj($_, $lib, intent => "dso") } @{$unified_info{sources}->{$lib}};
90 $cache{$lib} = 1;
91 }
92
93 # dobin is responsible for building programs. It will call obj2bin,
94 # and also makes sure all object files for the library are built.
95 sub dobin {
96 my $bin = shift;
97 return "" if $cache{$bin};
98 my $deps = [ reducedepends(resolvedepends($bin)) ];
99 $OUT .= obj2bin(bin => $bin,
100 objs => [ map { (my $x = $_) =~ s|\.o$||; $x }
101 @{$unified_info{sources}->{$bin}} ],
102 deps => $deps);
103 map { doobj($_, $bin, intent => "bin") } @{$unified_info{sources}->{$bin}};
104 $cache{$bin} = 1;
105 }
106
107 # dobin is responsible for building scripts from templates. It will
108 # call in2script.
109 sub doscript {
110 my $script = shift;
111 return "" if $cache{$script};
112 $OUT .= in2script(script => $script,
113 sources => $unified_info{sources}->{$script});
114 $cache{$script} = 1;
115 }
116
117 # Build all known libraries, engines, programs and scripts.
118 # Everything else will be handled as a consequence.
119 map { dolib($_) } @{$unified_info{libraries}};
120 map { doengine($_) } @{$unified_info{engines}};
121 map { dobin($_) } @{$unified_info{programs}};
122 map { doscript($_) } @{$unified_info{scripts}};
123
124 # Finally, should there be any applicable BEGINRAW/ENDRAW sections,
125 # they are added here.
126 $OUT .= $_."\n" foreach(@{$unified_info{rawlines}});
127 -}