Add ZSTD compression support (RFC8478bis)
[openssl.git] / Configurations / 00-base-templates.conf
1 # -*- Mode: perl -*-
2 my %targets=(
3     DEFAULTS => {
4         template        => 1,
5
6         cflags          => "",
7         cppflags        => "",
8         lflags          => "",
9         defines         => [],
10         includes        => [],
11         lib_cflags      => "",
12         lib_cppflags    => "",
13         lib_defines     => [],
14         thread_scheme   => "(unknown)", # Assume we don't know
15         thread_defines  => [],
16
17         unistd          => "<unistd.h>",
18         shared_target   => "",
19         shared_cflag    => "",
20         shared_defines  => [],
21         shared_ldflag   => "",
22         shared_rcflag   => "",
23
24         #### Defaults for the benefit of the config targets who don't inherit
25         #### a BASE and assume Unix defaults
26         #### THESE WILL DISAPPEAR IN OpenSSL 1.2
27         build_scheme    => [ "unified", "unix" ],
28         build_file      => "Makefile",
29
30         AR              => "(unused)",
31         ARFLAGS         => "(unused)",
32         CC              => "cc",
33         HASHBANGPERL    => "/usr/bin/env perl",
34         RANLIB          => sub { which("$config{cross_compile_prefix}ranlib")
35                                      ? "ranlib" : "" },
36         RC              => "windres",
37
38         #### THESE WILL BE ENABLED IN OpenSSL 1.2
39         #HASHBANGPERL   => "PERL", # Only Unix actually cares
40     },
41
42     BASE_common => {
43         template        => 1,
44
45         enable          => [],
46         disable         => [],
47
48         defines         =>
49             sub {
50                 my @defs = ( 'OPENSSL_BUILDING_OPENSSL' );
51                 push @defs, "BROTLI" unless $disabled{brotli};
52                 push @defs, "BROTLI_SHARED" unless $disabled{"brotli-dynamic"};
53                 push @defs, "ZLIB" unless $disabled{zlib};
54                 push @defs, "ZLIB_SHARED" unless $disabled{"zlib-dynamic"};
55                 push @defs, "ZSTD" unless $disabled{zstd};
56                 push @defs, "ZSTD_SHARED" unless $disabled{"zstd-dynamic"};
57                 return [ @defs ];
58             },
59         includes        =>
60             sub {
61                 my @incs = ();
62                 push @incs, $withargs{brotli_include}
63                     if !$disabled{brotli} && $withargs{brotli_include};
64                 push @incs, $withargs{zlib_include}
65                     if !$disabled{zlib} && $withargs{zlib_include};
66                 push @incs, $withargs{zstd_include}
67                     if !$disabled{zstd} && $withargs{zstd_include};
68                 return [ @incs ];
69             },
70     },
71
72     BASE_unix => {
73         inherit_from    => [ "BASE_common" ],
74         template        => 1,
75
76         AR              => "ar",
77         ARFLAGS         => "qc",
78         CC              => "cc",
79         lflags          =>
80             sub {
81                 my @libs = ();
82                 push(@libs, "-L".$withargs{zlib_lib}) if $withargs{zlib_lib};
83                 push(@libs, "-L".$withargs{brotli_lib}) if $withargs{brotli_lib};
84                 push(@libs, "-L".$withargs{zstd_lib}) if $withargs{zstd_lib};
85                 return join(" ", @libs);
86             },
87         ex_libs         =>
88             sub {
89                 my @libs = ();
90                 push(@libs, "-lz") if !defined($disabled{zlib}) && defined($disabled{"zlib-dynamic"});
91                 if (!defined($disabled{brotli}) && defined($disabled{"brotli-dynamic"})) {
92                     push(@libs, "-lbrotlienc");
93                     push(@libs, "-lbrotlidec");
94                     push(@libs, "-lbrotlicommon");
95                     push(@libs, "-lm");
96                 }
97                 push(@libs, "-lzstd") if !defined($disabled{zstd}) && defined($disabled{"zstd-dynamic"});
98                 return join(" ", @libs);
99             },
100         HASHBANGPERL    => "/usr/bin/env perl", # Only Unix actually cares
101         RANLIB          => sub { which("$config{cross_compile_prefix}ranlib")
102                                      ? "ranlib" : "" },
103         RC              => "windres",
104
105         build_scheme    => [ "unified", "unix" ],
106         build_file      => "Makefile",
107
108         perl_platform   => 'Unix',
109     },
110
111     BASE_Windows => {
112         inherit_from    => [ "BASE_common" ],
113         template        => 1,
114
115         lib_defines      =>
116             sub {
117                 my @defs = ();
118                 unless ($disabled{"zlib-dynamic"}) {
119                     my $zlib = $withargs{zlib_lib} // "ZLIB1";
120                     push @defs, 'LIBZ=' . (quotify("perl", $zlib))[0];
121                 }
122                 return [ @defs ];
123             },
124         ex_libs         =>
125             sub {
126                 my @libs = ();
127                 unless ($disabled{zlib}) {
128                     if (defined($disabled{"zlib-dynamic"})) {
129                         push(@libs, $withargs{zlib_lib} // "ZLIB1");
130                     }
131                 }
132                 unless ($disabled{zstd}) {
133                     if (defined($disabled{"zstd-dynamic"})) {
134                         push(@libs, $withargs{zstd_lib} // "libzstd");
135                     }
136                 }
137                 unless ($disabled{brotli}) {
138                     if (defined($disabled{"brotli-dynamic"})) {
139                         my $path = "";
140                         if (defined($withargs{brotli_lib})) {
141                             $path = $withargs{brotli_lib} . "\\";
142                         }
143                         push(@libs, $path . "brotlicommon.lib");
144                         push(@libs, $path . "brotlidec.lib");
145                         push(@libs, $path . "brotlienc.lib");
146                     }
147                 }
148                 return join(" ", @libs);
149             },
150
151         MT              => "mt",
152         MTFLAGS         => "-nologo",
153         mtinflag        => "-manifest ",
154         mtoutflag       => "-outputresource:",
155
156         build_file      => "makefile",
157         build_scheme    => [ "unified", "windows" ],
158
159         perl_platform   => 'Windows',
160     },
161
162     BASE_VMS => {
163         inherit_from    => [ "BASE_common" ],
164         template        => 1,
165
166         includes        =>
167             add(sub {
168                     my @incs = ();
169                     # GNV$ZLIB_INCLUDE is the standard logical name for later
170                     # zlib incarnations.
171                     push @incs, 'GNV$ZLIB_INCLUDE:'
172                         if !$disabled{zlib} && !$withargs{zlib_include};
173                     return [ @incs ];
174                 }),
175
176         build_file       => "descrip.mms",
177         build_scheme     => [ "unified", "VMS" ],
178
179         perl_platform    => 'VMS',
180     },
181 );