Configuration: move the handling of zlib_include to config files
[openssl.git] / Configurations / 10-main.conf
1 ## -*- mode: perl; -*-
2 ## Standard openssl configuration targets.
3
4 # Helper functions for the Windows configs
5 my $vc_win64a_info = {};
6 sub vc_win64a_info {
7     unless (%$vc_win64a_info) {
8         if (`nasm -v 2>NUL` =~ /NASM version ([0-9]+\.[0-9]+)/ && $1 >= 2.0) {
9             $vc_win64a_info = { as        => "nasm",
10                                 asflags   => "-f win64 -DNEAR -Ox -g",
11                                 asoutflag => "-o" };
12         } elsif ($disabled{asm}) {
13             $vc_win64a_info = { as        => "ml64",
14                                 asflags   => "/c /Cp /Cx /Zi",
15                                 asoutflag => "/Fo" };
16         } else {
17             $die->("NASM not found - please read INSTALL and NOTES.WIN for further details\n");
18             $vc_win64a_info = { as        => "{unknown}",
19                                 asflags   => "",
20                                 asoutflag => "" };
21         }
22     }
23     return $vc_win64a_info;
24 }
25
26 my $vc_win32_info = {};
27 sub vc_win32_info {
28     unless (%$vc_win32_info) {
29         my $ver=`nasm -v 2>NUL`;
30         my $vew=`nasmw -v 2>NUL`;
31         if ($ver ne "" || $vew ne "") {
32             $vc_win32_info = { as        => $ver ge $vew ? "nasm" : "nasmw",
33                                asflags   => "-f win32",
34                                asoutflag => "-o",
35                                perlasm_scheme => "win32n" };
36         } elsif ($disabled{asm}) {
37             $vc_win32_info = { as        => "ml",
38                                asflags   => "/nologo /Cp /coff /c /Cx /Zi",
39                                asoutflag => "/Fo",
40                                perlasm_scheme => "win32" };
41         } else {
42             $die->("NASM not found - please read INSTALL and NOTES.WIN for further details\n");
43             $vc_win32_info = { as        => "{unknown}",
44                                asflags   => "",
45                                asoutflag => "",
46                                perlasm_scheme => "win32" };
47         }
48     }
49     return $vc_win32_info;
50 }
51
52 my $vc_wince_info = {};
53 sub vc_wince_info {
54     unless (%$vc_wince_info) {
55         # sanity check
56         $die->('%OSVERSION% is not defined') if (!defined(env('OSVERSION')));
57         $die->('%PLATFORM% is not defined')  if (!defined(env('PLATFORM')));
58         $die->('%TARGETCPU% is not defined') if (!defined(env('TARGETCPU')));
59
60         #
61         # Idea behind this is to mimic flags set by eVC++ IDE...
62         #
63         my $wcevers = env('OSVERSION');                     # WCENNN
64         my $wcevernum;
65         my $wceverdotnum;
66         if ($wcevers =~ /^WCE([1-9])([0-9]{2})$/) {
67             $wcevernum = "$1$2";
68             $wceverdotnum = "$1.$2";
69         } else {
70             $die->('%OSVERSION% value is insane');
71             $wcevernum = "{unknown}";
72             $wceverdotnum = "{unknown}";
73         }
74         my $wcecdefs = "-D_WIN32_WCE=$wcevernum -DUNDER_CE=$wcevernum"; # -D_WIN32_WCE=NNN
75         my $wcelflag = "/subsystem:windowsce,$wceverdotnum";        # ...,N.NN
76
77         my $wceplatf =  env('PLATFORM');
78
79         $wceplatf =~ tr/a-z0-9 /A-Z0-9_/;
80         $wcecdefs .= " -DWCE_PLATFORM_$wceplatf";
81
82         my $wcetgt = env('TARGETCPU');                      # just shorter name...
83       SWITCH: for($wcetgt) {
84           /^X86/        && do { $wcecdefs.=" -Dx86 -D_X86_ -D_i386_ -Di_386_";
85                                 $wcelflag.=" /machine:X86";     last; };
86           /^ARMV4[IT]/  && do { $wcecdefs.=" -DARM -D_ARM_ -D$wcetgt";
87                                 $wcecdefs.=" -DTHUMB -D_THUMB_" if($wcetgt=~/T$/);
88                                 $wcecdefs.=" -QRarch4T -QRinterwork-return";
89                                 $wcelflag.=" /machine:THUMB";   last; };
90           /^ARM/        && do { $wcecdefs.=" -DARM -D_ARM_ -D$wcetgt";
91                                 $wcelflag.=" /machine:ARM";     last; };
92           /^MIPSIV/     && do { $wcecdefs.=" -DMIPS -D_MIPS_ -DR4000 -D$wcetgt";
93                                 $wcecdefs.=" -D_MIPS64 -QMmips4 -QMn32";
94                                 $wcelflag.=" /machine:MIPSFPU"; last; };
95           /^MIPS16/     && do { $wcecdefs.=" -DMIPS -D_MIPS_ -DR4000 -D$wcetgt";
96                                 $wcecdefs.=" -DMIPSII -QMmips16";
97                                 $wcelflag.=" /machine:MIPS16";  last; };
98           /^MIPSII/     && do { $wcecdefs.=" -DMIPS -D_MIPS_ -DR4000 -D$wcetgt";
99                                 $wcecdefs.=" -QMmips2";
100                                 $wcelflag.=" /machine:MIPS";    last; };
101           /^R4[0-9]{3}/ && do { $wcecdefs.=" -DMIPS -D_MIPS_ -DR4000";
102                                 $wcelflag.=" /machine:MIPS";    last; };
103           /^SH[0-9]/    && do { $wcecdefs.=" -D$wcetgt -D_${wcetgt}_ -DSHx";
104                                 $wcecdefs.=" -Qsh4" if ($wcetgt =~ /^SH4/);
105                                 $wcelflag.=" /machine:$wcetgt"; last; };
106           { $wcecdefs.=" -D$wcetgt -D_${wcetgt}_";
107             $wcelflag.=" /machine:$wcetgt";                     last; };
108       }
109
110         $vc_wince_info = { cppflags => $wcecdefs,
111                            lflags => $wcelflag };
112     }
113     return $vc_wince_info;
114 }
115
116 # Helper functions for the VMS configs
117 my $vms_info = {};
118 sub vms_info {
119     unless (%$vms_info) {
120         my $pointer_size = shift;
121         my $pointer_size_str = $pointer_size == 0 ? "" : "$pointer_size";
122
123         $vms_info->{disable_warns} = [ ];
124         $vms_info->{pointer_size} = $pointer_size_str;
125         if ($pointer_size == 64) {
126             `PIPE CC /NOCROSS_REFERENCE /NOLIST /NOOBJECT /WARNINGS = DISABLE = ( MAYLOSEDATA3, EMPTYFILE ) NL: 2> NL:`;
127             if ($? == 0) {
128                 push @{$vms_info->{disable_warns}}, "MAYLOSEDATA3";
129             }
130         }
131
132         unless ($disabled{zlib}) {
133             my $default_zlib = 'GNV$LIBZSHR' . $pointer_size_str;
134             if (defined($disabled{"zlib-dynamic"})) {
135                 $vms_info->{zlib} = $withargs{zlib_lib} || "$default_zlib/SHARE";
136             } else {
137                 $vms_info->{def_zlib} = $withargs{zlib_lib} || $default_zlib;
138                 # In case the --with-zlib-lib value contains something like
139                 # /SHARE or /LIB or so at the end, remove it.
140                 $vms_info->{def_zlib} =~ s|/.*$||g;
141             }
142         }
143     }
144     return $vms_info;
145 }
146
147 my %targets = (
148
149 #### Basic configs that should work on any 32-bit box
150     "gcc" => {
151         inherit_from     => [ "BASE_unix" ],
152         cc               => "gcc",
153         cflags           => picker(debug   => "-O0 -g",
154                                    release => "-O3"),
155         thread_scheme    => "(unknown)",
156         bn_ops           => "BN_LLONG",
157     },
158     "cc" => {
159         inherit_from     => [ "BASE_unix" ],
160         cc               => "cc",
161         cflags           => "-O",
162         thread_scheme    => "(unknown)",
163     },
164
165 #### VOS Configurations
166     "vos-gcc" => {
167         inherit_from     => [ "BASE_unix" ],
168         cc               => "gcc",
169         cflags           => picker(default => "-Wall",
170                                    debug   => "-O0 -g",
171                                    release => "-O3"),
172         cppflags         => "-D_POSIX_C_SOURCE=200112L -D_BSD -D_VOS_EXTENDED_NAMES -DB_ENDIAN",
173         thread_scheme    => "(unknown)",
174         sys_id           => "VOS",
175         lflags           => add("-Wl,-map"),
176         bn_ops           => "BN_LLONG",
177         shared_extension => ".so",
178     },
179
180 #### Solaris configurations
181     "solaris-common" => {
182         inherit_from     => [ "BASE_unix" ],
183         template         => 1,
184         cppflags         => "-DFILIO_H",
185         ex_libs          => add("-lsocket -lnsl -ldl"),
186         dso_scheme       => "dlfcn",
187         thread_scheme    => "pthreads",
188         shared_target    => "solaris-shared",
189         shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
190     },
191 #### Solaris x86 with GNU C setups
192     "solaris-x86-gcc" => {
193         # NB. GNU C has to be configured to use GNU assembler, and not
194         # /usr/ccs/bin/as. Failure to comply will result in compile
195         # failures [at least] in 32-bit build.
196         inherit_from     => [ "solaris-common", asm("x86_elf_asm") ],
197         cc               => "gcc",
198         cflags           => add_before(picker(default => "-Wall",
199                                               debug   => "-O0 -g",
200                                               release => "-O3 -fomit-frame-pointer"),
201                                        threads("-pthread")),
202         cppflags         => add("-DL_ENDIAN"),
203         ex_libs          => add(threads("-pthread")),
204         bn_ops           => "BN_LLONG",
205         shared_cflag     => "-fPIC",
206         shared_ldflag    => "-shared -static-libgcc",
207     },
208     "solaris64-x86_64-gcc" => {
209         # -shared -static-libgcc might appear controversial, but modules
210         # taken from static libgcc do not have relocations and linking
211         # them into our shared objects doesn't have any negative side
212         # effects. On the contrary, doing so makes it possible to use
213         # gcc shared build with Sun C. Given that gcc generates faster
214         # code [thanks to inline assembler], I would actually recommend
215         # to consider using gcc shared build even with vendor compiler:-)
216         #                        -- <appro@openssl.org>
217         inherit_from     => [ "solaris-common", asm("x86_64_asm") ],
218         cc               => "gcc",
219         cflags           => add_before(picker(default => "-m64 -Wall",
220                                               debug   => "-O0 -g",
221                                               release => "-O3"),
222                                        threads("-pthread")),
223         cppflags         => add("-DL_ENDIAN"),
224         ex_libs          => add(threads("-pthread")),
225         bn_ops           => "SIXTY_FOUR_BIT_LONG",
226         perlasm_scheme   => "elf",
227         shared_cflag     => "-fPIC",
228         shared_ldflag    => "-shared -static-libgcc",
229         multilib         => "/64",
230     },
231
232 #### Solaris x86 with Sun C setups
233     # There used to be solaris-x86-cc target, but it was removed,
234     # primarily because vendor assembler can't assemble our modules
235     # with -KPIC flag. As result it, assembly support, was not even
236     # available as option. But its lack means lack of side-channel
237     # resistant code, which is incompatible with security by todays
238     # standards. Fortunately gcc is readily available prepackaged
239     # option, which we can firmly point at...
240     #
241     # On related note, solaris64-x86_64-cc target won't compile code
242     # paths utilizing AVX and post-Haswell instruction extensions.
243     # Consider switching to solaris64-x86_64-gcc even here...
244     #
245     "solaris64-x86_64-cc" => {
246         inherit_from     => [ "solaris-common", asm("x86_64_asm") ],
247         cc               => "cc",
248         cflags           => add_before(picker(default => "-xarch=generic64 -xstrconst -Xa",
249                                               debug   => "-g",
250                                               release => "-xO5 -xdepend -xbuiltin")),
251         cppflags         => add("-DL_ENDIAN", threads("-D_REENTRANT")),
252         thread_scheme    => "pthreads",
253         lflags           => add(threads("-mt")),
254         ex_libs          => add(threads("-lpthread")),
255         bn_ops           => "SIXTY_FOUR_BIT_LONG",
256         perlasm_scheme   => "elf",
257         shared_cflag     => "-KPIC",
258         shared_ldflag    => "-G -dy -z text",
259         multilib         => "/64",
260     },
261
262 #### SPARC Solaris with GNU C setups
263     "solaris-sparcv7-gcc" => {
264         inherit_from     => [ "solaris-common" ],
265         cc               => "gcc",
266         cflags           => add_before(picker(default => "-Wall",
267                                               debug   => "-O0 -g",
268                                               release => "-O3"),
269                                        threads("-pthread")),
270         cppflags         => add("-DB_ENDIAN -DBN_DIV2W"),
271         ex_libs          => add(threads("-pthread")),
272         bn_ops           => "BN_LLONG RC4_CHAR",
273         shared_cflag     => "-fPIC",
274         shared_ldflag    => "-shared",
275     },
276     "solaris-sparcv8-gcc" => {
277         inherit_from     => [ "solaris-sparcv7-gcc", asm("sparcv8_asm") ],
278         cflags           => add_before("-mcpu=v8"),
279     },
280     "solaris-sparcv9-gcc" => {
281         # -m32 should be safe to add as long as driver recognizes
282         # -mcpu=ultrasparc
283         inherit_from     => [ "solaris-sparcv7-gcc", asm("sparcv9_asm") ],
284         cflags           => add_before("-m32 -mcpu=ultrasparc"),
285     },
286     "solaris64-sparcv9-gcc" => {
287         inherit_from     => [ "solaris-sparcv9-gcc" ],
288         cflags           => sub { my $f=join(" ",@_); $f =~ s/\-m32/-m64/; $f; },
289         bn_ops           => "BN_LLONG RC4_CHAR",
290         multilib         => "/64",
291     },
292
293 #### SPARC Solaris with Sun C setups
294 # SC4.0 doesn't pass 'make test', upgrade to SC5.0 or SC4.2.
295 # SC4.2 is ok, better than gcc even on bn as long as you tell it -xarch=v8
296 # SC5.0 note: Compiler common patch 107357-01 or later is required!
297     "solaris-sparcv7-cc" => {
298         inherit_from     => [ "solaris-common" ],
299         cc               => "cc",
300         cflags           => add_before(picker(default => "-xstrconst -Xa",
301                                               debug   => "-g",
302                                               release => "-xO5 -xdepend")),
303         cppflags         => add("-DB_ENDIAN -DBN_DIV2W",
304                                 threads("-D_REENTRANT")),
305         lflags           => add(threads("-mt")),
306         ex_libs          => add(threads("-lpthread")),
307         bn_ops           => "BN_LLONG RC4_CHAR",
308         shared_cflag     => "-KPIC",
309         shared_ldflag    => "-G -dy -z text",
310     },
311 ####
312     "solaris-sparcv8-cc" => {
313         inherit_from     => [ "solaris-sparcv7-cc", asm("sparcv8_asm") ],
314         cflags           => add_before("-xarch=v8"),
315     },
316     "solaris-sparcv9-cc" => {
317         inherit_from     => [ "solaris-sparcv7-cc", asm("sparcv9_asm") ],
318         cflags           => add_before("-xarch=v8plus"),
319     },
320     "solaris64-sparcv9-cc" => {
321         inherit_from     => [ "solaris-sparcv7-cc", asm("sparcv9_asm") ],
322         cflags           => add_before("-xarch=v9"),
323         bn_ops           => "BN_LLONG RC4_CHAR",
324         multilib         => "/64",
325     },
326
327 #### IRIX 6.x configs
328 # Only N32 and N64 ABIs are supported.
329     "irix-mips3-gcc" => {
330         inherit_from     => [ "BASE_unix", asm("mips64_asm") ],
331         cc               => "gcc",
332         cflags           => combine(picker(default => "-mabi=n32",
333                                            debug   => "-g -O0",
334                                            release => "-O3")),
335         cppflags         => combine("-DB_ENDIAN -DBN_DIV3W",
336                                     threads("-D_SGI_MP_SOURCE")),
337         ex_libs          => add(threads("-lpthread")),
338         bn_ops           => "RC4_CHAR SIXTY_FOUR_BIT",
339         thread_scheme    => "pthreads",
340         perlasm_scheme   => "n32",
341         dso_scheme       => "dlfcn",
342         shared_target    => "irix-shared",
343         shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
344         multilib         => "32",
345     },
346     "irix-mips3-cc" => {
347         inherit_from     => [ "BASE_unix", asm("mips64_asm") ],
348         cc               => "cc",
349         cflags           => combine(picker(default => "-n32 -mips3 -use_readonly_const -G0 -rdata_shared",
350                                            debug   => "-g -O0",
351                                            release => "-O2")),
352         cppflags         => combine("-DB_ENDIAN -DBN_DIV3W",
353                                     threads("-D_SGI_MP_SOURCE")),
354         ex_libs          => add(threads("-lpthread")),
355         bn_ops           => "RC4_CHAR SIXTY_FOUR_BIT",
356         thread_scheme    => "pthreads",
357         perlasm_scheme   => "n32",
358         dso_scheme       => "dlfcn",
359         shared_target    => "irix-shared",
360         shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
361         multilib         => "32",
362     },
363     # N64 ABI builds.
364     "irix64-mips4-gcc" => {
365         inherit_from     => [ "BASE_unix", asm("mips64_asm") ],
366         cc               => "gcc",
367         cflags           => combine(picker(default => "-mabi=64 -mips4",
368                                            debug   => "-g -O0",
369                                            release => "-O3")),
370         cppflags         => combine("-DB_ENDIAN -DBN_DIV3W",
371                                     threads("-D_SGI_MP_SOURCE")),
372         ex_libs          => add(threads("-lpthread")),
373         bn_ops           => "RC4_CHAR SIXTY_FOUR_BIT_LONG",
374         thread_scheme    => "pthreads",
375         perlasm_scheme   => "64",
376         dso_scheme       => "dlfcn",
377         shared_target    => "irix-shared",
378         shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
379         multilib         => "64",
380     },
381     "irix64-mips4-cc" => {
382         inherit_from     => [ "BASE_unix", asm("mips64_asm") ],
383         cc               => "cc",
384         cflags           => combine(picker(default => "-64 -mips4 -use_readonly_const -G0 -rdata_shared",
385                                            debug   => "-g -O0",
386                                            release => "-O2")),
387         cppflags         => combine("-DB_ENDIAN -DBN_DIV3W",
388                                     threads("-D_SGI_MP_SOURCE")),
389         ex_libs          => add(threads("-lpthread")),
390         bn_ops           => "RC4_CHAR SIXTY_FOUR_BIT_LONG",
391         thread_scheme    => "pthreads",
392         perlasm_scheme   => "64",
393         dso_scheme       => "dlfcn",
394         shared_target    => "irix-shared",
395         shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
396         multilib         => "64",
397     },
398
399 #### Unified HP-UX ANSI C configs.
400 # Special notes:
401 # - Originally we were optimizing at +O4 level. It should be noted
402 #   that the only difference between +O3 and +O4 is global inter-
403 #   procedural analysis. As it has to be performed during the link
404 #   stage the compiler leaves behind certain pseudo-code in lib*.a
405 #   which might be release or even patch level specific. Generating
406 #   the machine code for and analyzing the *whole* program appears
407 #   to be *extremely* memory demanding while the performance gain is
408 #   actually questionable. The situation is intensified by the default
409 #   HP-UX data set size limit (infamous 'maxdsiz' tunable) of 64MB
410 #   which is way too low for +O4. In other words, doesn't +O3 make
411 #   more sense?
412 # - Keep in mind that the HP compiler by default generates code
413 #   suitable for execution on the host you're currently compiling at.
414 #   If the toolkit is meant to be used on various PA-RISC processors
415 #   consider './Configure hpux-parisc-[g]cc +DAportable'.
416 # - -DMD32_XARRAY triggers workaround for compiler bug we ran into in
417 #   32-bit message digests. (For the moment of this writing) HP C
418 #   doesn't seem to "digest" too many local variables (they make "him"
419 #   chew forever:-). For more details look-up MD32_XARRAY comment in
420 #   crypto/sha/sha_lcl.h.
421 # - originally there were 32-bit hpux-parisc2-* targets. They were
422 #   scrapped, because a) they were not interchangeable with other 32-bit
423 #   targets; b) performance-critical 32-bit assembly modules implement
424 #   even PA-RISC 2.0-specific code paths, which are chosen at run-time,
425 #   thus adequate performance is provided even with PA-RISC 1.1 build.
426     "hpux-parisc-gcc" => {
427         inherit_from     => [ "BASE_unix" ],
428         cc               => "gcc",
429         cflags           => combine(picker(debug   => "-O0 -g",
430                                            release => "-O3"),
431                                     threads("-pthread")),
432         cppflags         => "-DB_ENDIAN -DBN_DIV2W",
433         ex_libs          => add("-Wl,+s -ldld", threads("-pthread")),
434         bn_ops           => "BN_LLONG",
435         thread_scheme    => "pthreads",
436         dso_scheme       => "dl",
437         shared_target    => "hpux-shared",
438         shared_cflag     => "-fPIC",
439         shared_ldflag    => "-shared",
440         shared_extension => ".sl.\$(SHLIB_VERSION_NUMBER)",
441     },
442     "hpux-parisc1_1-gcc" => {
443         inherit_from     => [ "hpux-parisc-gcc", asm("parisc11_asm") ],
444         multilib         => "/pa1.1",
445     },
446     "hpux64-parisc2-gcc" => {
447         inherit_from     => [ "BASE_unix", asm("parisc20_64_asm") ],
448         cc               => "gcc",
449         cflags           => combine(picker(debug   => "-O0 -g",
450                                            release => "-O3")),
451         cppflags         => combine("-DB_ENDIAN", threads("-D_REENTRANT")),
452         ex_libs          => add("-ldl"),
453         bn_ops           => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
454         thread_scheme    => "pthreads",
455         dso_scheme       => "dlfcn",
456         shared_target    => "hpux-shared",
457         shared_cflag     => "-fpic",
458         shared_ldflag    => "-shared",
459         shared_extension => ".sl.\$(SHLIB_VERSION_NUMBER)",
460         multilib         => "/pa20_64",
461     },
462
463     # More attempts at unified 10.X and 11.X targets for HP C compiler.
464     "hpux-parisc-cc" => {
465         inherit_from     => [ "BASE_unix" ],
466         cc               => "cc",
467         cflags           => combine(picker(default => "+Optrs_strongly_typed -Ae +ESlit",
468                                            debug   => "+O0 +d -g",
469                                            release => "+O3")),
470         cppflags         => combine("-DB_ENDIAN -DBN_DIV2W -DMD32_XARRAY",
471                                     threads("-D_REENTRANT")),
472         ex_libs          => add("-Wl,+s -ldld",threads("-lpthread")),
473         bn_ops           => "RC4_CHAR",
474         thread_scheme    => "pthreads",
475         dso_scheme       => "dl",
476         shared_target    => "hpux-shared",
477         shared_cflag     => "+Z",
478         shared_ldflag    => "-b",
479         shared_extension => ".sl.\$(SHLIB_VERSION_NUMBER)",
480     },
481     "hpux-parisc1_1-cc" => {
482         inherit_from     => [ "hpux-parisc-cc", asm("parisc11_asm") ],
483         cflags           => add_before("+DA1.1"),
484         multilib         => "/pa1.1",
485     },
486     "hpux64-parisc2-cc" => {
487         inherit_from     => [ "BASE_unix", asm("parisc20_64_asm") ],
488         cc               => "cc",
489         cflags           => combine(picker(default => "+DD64 +Optrs_strongly_typed -Ae +ESlit",
490                                            debug   => "+O0 +d -g",
491                                            release => "+O3")),
492         cppflags         => combine("-DB_ENDIAN -DMD32_XARRAY",
493                                     threads("-D_REENTRANT")),
494         ex_libs          => add("-ldl",threads("-lpthread")),
495         bn_ops           => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
496         thread_scheme    => "pthreads",
497         dso_scheme       => "dlfcn",
498         shared_target    => "hpux-shared",
499         shared_cflag     => "+Z",
500         shared_ldflag    => "-b",
501         shared_extension => ".sl.\$(SHLIB_VERSION_NUMBER)",
502         multilib         => "/pa20_64",
503     },
504
505     # HP/UX IA-64 targets
506     "hpux-ia64-cc" => {
507         inherit_from     => [ "BASE_unix", asm("ia64_asm") ],
508         cc               => "cc",
509         cflags           => combine(picker(default => "-Ae +DD32 +Olit=all -z",
510                                            debug   => "+O0 +d -g",
511                                            release => "+O2")),
512         cppflags         => combine("-DB_ENDIAN", threads("-D_REENTRANT")),
513         ex_libs          => add("-ldl",threads("-lpthread")),
514         bn_ops           => "SIXTY_FOUR_BIT",
515         thread_scheme    => "pthreads",
516         dso_scheme       => "dlfcn",
517         shared_target    => "hpux-shared",
518         shared_cflag     => "+Z",
519         shared_ldflag    => "-b",
520         shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
521         multilib         => "/hpux32",
522     },
523     "hpux64-ia64-cc" => {
524         inherit_from     => [ "BASE_unix", asm("ia64_asm") ],
525         cc               => "cc",
526         cflags           => combine(picker(default => "-Ae +DD64 +Olit=all -z",
527                                            debug   => "+O0 +d -g",
528                                            release => "+O3")),
529         cppflags         => combine("-DB_ENDIAN", threads("-D_REENTRANT")),
530         ex_libs          => add("-ldl", threads("-lpthread")),
531         bn_ops           => "SIXTY_FOUR_BIT_LONG",
532         thread_scheme    => "pthreads",
533         dso_scheme       => "dlfcn",
534         shared_target    => "hpux-shared",
535         shared_cflag     => "+Z",
536         shared_ldflag    => "-b",
537         shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
538         multilib         => "/hpux64",
539     },
540     # GCC builds...
541     "hpux-ia64-gcc" => {
542         inherit_from     => [ "BASE_unix", asm("ia64_asm") ],
543         cc               => "gcc",
544         cflags           => combine(picker(debug   => "-O0 -g",
545                                            release => "-O3"),
546                                     threads("-pthread")),
547         cppflags         => "-DB_ENDIAN",
548         ex_libs          => add("-ldl", threads("-pthread")),
549         bn_ops           => "SIXTY_FOUR_BIT",
550         thread_scheme    => "pthreads",
551         dso_scheme       => "dlfcn",
552         shared_target    => "hpux-shared",
553         shared_cflag     => "-fpic",
554         shared_ldflag    => "-shared",
555         shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
556         multilib         => "/hpux32",
557     },
558     "hpux64-ia64-gcc" => {
559         inherit_from     => [ "BASE_unix", asm("ia64_asm") ],
560         cc               => "gcc",
561         cflags           => combine(picker(default => "-mlp64",
562                                            debug   => "-O0 -g",
563                                            release => "-O3"),
564                                     threads("-pthread")),
565         cppflags         => "-DB_ENDIAN",
566         ex_libs          => add("-ldl", threads("-pthread")),
567         bn_ops           => "SIXTY_FOUR_BIT_LONG",
568         thread_scheme    => "pthreads",
569         dso_scheme       => "dlfcn",
570         shared_target    => "hpux-shared",
571         shared_cflag     => "-fpic",
572         shared_ldflag    => "-shared",
573         shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
574         multilib         => "/hpux64",
575     },
576
577 #### HP MPE/iX http://jazz.external.hp.com/src/openssl/
578     "MPE/iX-gcc" => {
579         inherit_from     => [ "BASE_unix" ],
580         cc               => "gcc",
581         cflags           => "-O3",
582         cppflags         => "-D_ENDIAN -DBN_DIV2W -D_POSIX_SOURCE -D_SOCKET_SOURCE",
583         includes         => add("/SYSLOG/PUB"),
584         sys_id           => "MPE",
585         lflags           => add("-L/SYSLOG/PUB"),
586         ex_libs          => add("-lsyslog -lsocket -lcurses"),
587         thread_scheme    => "(unknown)",
588         bn_ops           => "BN_LLONG",
589     },
590
591 #### DEC Alpha Tru64 targets. Tru64 is marketing name for OSF/1 version 4
592 #### and forward. In reality 'uname -s' still returns "OSF1". Originally
593 #### there were even osf1-* configs targeting prior versions provided,
594 #### but not anymore...
595     "tru64-alpha-gcc" => {
596         inherit_from     => [ "BASE_unix", asm("alpha_asm") ],
597         cc               => "gcc",
598         cflags           => combine("-std=c9x -O3", threads("-pthread")),
599         cppflags         => "-D_XOPEN_SOURCE=500 -D_OSF_SOURCE",
600         ex_libs          => add("-lrt", threads("-pthread")), # for mlock(2)
601         bn_ops           => "SIXTY_FOUR_BIT_LONG",
602         thread_scheme    => "pthreads",
603         dso_scheme       => "dlfcn",
604         shared_target    => "alpha-osf1-shared",
605         shared_extension => ".so",
606     },
607     "tru64-alpha-cc" => {
608         inherit_from     => [ "BASE_unix", asm("alpha_asm") ],
609         cc               => "cc",
610         cflags           => combine("-std1 -tune host -fast -readonly_strings",
611                                     threads("-pthread")),
612         cppflags         => "-D_XOPEN_SOURCE=500 -D_OSF_SOURCE",
613         ex_libs          => add("-lrt", threads("-pthread")), # for mlock(2)
614         bn_ops           => "SIXTY_FOUR_BIT_LONG",
615         thread_scheme    => "pthreads",
616         dso_scheme       => "dlfcn",
617         shared_target    => "alpha-osf1-shared",
618         shared_ldflag    => "-msym",
619         shared_extension => ".so",
620     },
621
622 ####
623 #### Variety of LINUX:-)
624 ####
625 # *-generic* is endian-neutral target, but ./config is free to
626 # throw in -D[BL]_ENDIAN, whichever appropriate...
627     "linux-generic32" => {
628         inherit_from     => [ "BASE_unix" ],
629         cc               => "gcc",
630         cxx              => "g++",
631         cflags           => combine(picker(default => "-Wall",
632                                            debug   => "-O0 -g",
633                                            release => "-O3"),
634                                     threads("-pthread")),
635         cxxflags         => combine(picker(default => "-std=c++11 -Wall",
636                                            debug   => "-O0 -g",
637                                            release => "-O3"),
638                                     threads("-pthread")),
639         cppflags         => "-DOPENSSL_USE_NODELETE",
640         ex_libs          => add("-ldl", threads("-pthread")),
641         bn_ops           => "BN_LLONG RC4_CHAR",
642         thread_scheme    => "pthreads",
643         dso_scheme       => "dlfcn",
644         shared_target    => "linux-shared",
645         shared_cflag     => "-fPIC",
646         shared_ldflag    => "-Wl,-znodelete",
647         shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
648     },
649     "linux-generic64" => {
650         inherit_from     => [ "linux-generic32" ],
651         bn_ops           => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
652     },
653
654     "linux-ppc" => {
655         inherit_from     => [ "linux-generic32", asm("ppc32_asm") ],
656         perlasm_scheme   => "linux32",
657     },
658     "linux-ppc64" => {
659         inherit_from     => [ "linux-generic64", asm("ppc64_asm") ],
660         cflags           => add("-m64"),
661         cppflags         => add("-DB_ENDIAN"),
662         perlasm_scheme   => "linux64",
663         multilib         => "64",
664     },
665     "linux-ppc64le" => {
666         inherit_from     => [ "linux-generic64", asm("ppc64_asm") ],
667         cflags           => add("-m64"),
668         cppflags         => add("-DL_ENDIAN"),
669         perlasm_scheme   => "linux64le",
670     },
671
672     "linux-armv4" => {
673         ################################################################
674         # Note that -march is not among compiler options in linux-armv4
675         # target description. Not specifying one is intentional to give
676         # you choice to:
677         #
678         # a) rely on your compiler default by not specifying one;
679         # b) specify your target platform explicitly for optimal
680         # performance, e.g. -march=armv6 or -march=armv7-a;
681         # c) build "universal" binary that targets *range* of platforms
682         # by specifying minimum and maximum supported architecture;
683         #
684         # As for c) option. It actually makes no sense to specify
685         # maximum to be less than ARMv7, because it's the least
686         # requirement for run-time switch between platform-specific
687         # code paths. And without run-time switch performance would be
688         # equivalent to one for minimum. Secondly, there are some
689         # natural limitations that you'd have to accept and respect.
690         # Most notably you can *not* build "universal" binary for
691         # big-endian platform. This is because ARMv7 processor always
692         # picks instructions in little-endian order. Another similar
693         # limitation is that -mthumb can't "cross" -march=armv6t2
694         # boundary, because that's where it became Thumb-2. Well, this
695         # limitation is a bit artificial, because it's not really
696         # impossible, but it's deemed too tricky to support. And of
697         # course you have to be sure that your binutils are actually
698         # up to the task of handling maximum target platform. With all
699         # this in mind here is an example of how to configure
700         # "universal" build:
701         #
702         # ./Configure linux-armv4 -march=armv6 -D__ARM_MAX_ARCH__=8
703         #
704         inherit_from     => [ "linux-generic32", asm("armv4_asm") ],
705         perlasm_scheme   => "linux32",
706     },
707     "linux-aarch64" => {
708         inherit_from     => [ "linux-generic64", asm("aarch64_asm") ],
709         perlasm_scheme   => "linux64",
710     },
711     "linux-arm64ilp32" => {  # https://wiki.linaro.org/Platform/arm64-ilp32
712         inherit_from     => [ "linux-generic32", asm("aarch64_asm") ],
713         cflags           => add("-mabi=ilp32"),
714         bn_ops           => "SIXTY_FOUR_BIT RC4_CHAR",
715         perlasm_scheme   => "linux64",
716     },
717
718     "linux-mips32" => {
719         # Configure script adds minimally required -march for assembly
720         # support, if no -march was specified at command line.
721         inherit_from     => [ "linux-generic32", asm("mips32_asm") ],
722         cflags           => add("-mabi=32"),
723         cppflags         => add("-DBN_DIV3W"),
724         perlasm_scheme   => "o32",
725     },
726     # mips32 and mips64 below refer to contemporary MIPS Architecture
727     # specifications, MIPS32 and MIPS64, rather than to kernel bitness.
728     "linux-mips64" => {
729         inherit_from     => [ "linux-generic32", asm("mips64_asm") ],
730         cflags           => add("-mabi=n32"),
731         cppflags         => add("-DBN_DIV3W"),
732         bn_ops           => "SIXTY_FOUR_BIT RC4_CHAR",
733         perlasm_scheme   => "n32",
734         multilib         => "32",
735     },
736     "linux64-mips64" => {
737         inherit_from     => [ "linux-generic64", asm("mips64_asm") ],
738         cflags           => add("-mabi=64"),
739         cppflags         => add("-DBN_DIV3W"),
740         perlasm_scheme   => "64",
741         multilib         => "64",
742     },
743
744     #### IA-32 targets...
745     #### These two targets are a bit aged and are to be used on older Linux
746     #### machines where gcc doesn't understand -m32 and -m64
747     "linux-elf" => {
748         inherit_from     => [ "linux-generic32", asm("x86_elf_asm") ],
749         cflags           => add(picker(release => "-fomit-frame-pointer")),
750         cppflags         => add("-DL_ENDIAN"),
751         bn_ops           => "BN_LLONG",
752     },
753     "linux-aout" => {
754         inherit_from     => [ "BASE_unix", asm("x86_asm") ],
755         cc               => "gcc",
756         cflags           => add(picker(default => "-Wall",
757                                        debug   => "-O0 -g",
758                                        release => "-O3 -fomit-frame-pointer")),
759         cppflags         => add("-DL_ENDIAN"),
760         bn_ops           => "BN_LLONG",
761         thread_scheme    => "(unknown)",
762         perlasm_scheme   => "a.out",
763     },
764
765     #### X86 / X86_64 targets
766     "linux-x86" => {
767         inherit_from     => [ "linux-generic32", asm("x86_asm") ],
768         cflags           => add(picker(default => "-m32",
769                                        release => "-fomit-frame-pointer")),
770         cppflags         => add("-DL_ENDIAN"),
771         bn_ops           => "BN_LLONG",
772         perlasm_scheme   => "elf",
773     },
774     "linux-x86-clang" => {
775         inherit_from     => [ "linux-x86" ],
776         cc               => "clang",
777         cxx              => "clang++",
778         cflags           => add("-Wextra"),
779     },
780     "linux-x86_64" => {
781         inherit_from     => [ "linux-generic64", asm("x86_64_asm") ],
782         cflags           => add("-m64"),
783         cppflags         => add("-DL_ENDIAN"),
784         bn_ops           => "SIXTY_FOUR_BIT_LONG",
785         perlasm_scheme   => "elf",
786         multilib         => "64",
787     },
788     "linux-x86_64-clang" => {
789         inherit_from     => [ "linux-x86_64" ],
790         cc               => "clang",
791         cxx              => "clang++",
792         cflags           => add("-Wextra"),
793     },
794     "linux-x32" => {
795         inherit_from     => [ "linux-generic32", asm("x86_64_asm") ],
796         cflags           => add("-mx32"),
797         cppflags         => add("-DL_ENDIAN"),
798         bn_ops           => "SIXTY_FOUR_BIT",
799         perlasm_scheme   => "elf32",
800         multilib         => "x32",
801     },
802
803     "linux-ia64" => {
804         inherit_from     => [ "linux-generic64", asm("ia64_asm") ],
805         bn_ops           => "SIXTY_FOUR_BIT_LONG",
806     },
807
808     "linux64-s390x" => {
809         inherit_from     => [ "linux-generic64", asm("s390x_asm") ],
810         cflags           => add("-m64"),
811         cppflags         => add("-DB_ENDIAN"),
812         perlasm_scheme   => "64",
813         multilib         => "64",
814     },
815     "linux32-s390x" => {
816         #### So called "highgprs" target for z/Architecture CPUs
817         # "Highgprs" is kernel feature first implemented in Linux
818         # 2.6.32, see /proc/cpuinfo. The idea is to preserve most
819         # significant bits of general purpose registers not only
820         # upon 32-bit process context switch, but even on
821         # asynchronous signal delivery to such process. This makes
822         # it possible to deploy 64-bit instructions even in legacy
823         # application context and achieve better [or should we say
824         # adequate] performance. The build is binary compatible with
825         # linux-generic32, and the idea is to be able to install the
826         # resulting libcrypto.so alongside generic one, e.g. as
827         # /lib/highgprs/libcrypto.so.x.y, for ldconfig and run-time
828         # linker to autodiscover. Unfortunately it doesn't work just
829         # yet, because of couple of bugs in glibc
830         # sysdeps/s390/dl-procinfo.c affecting ldconfig and ld.so.1...
831         #
832         inherit_from     => [ "linux-generic32", asm("s390x_asm") ],
833         cflags           => add("-m31 -Wa,-mzarch"),
834         cppflags         => add("-DB_ENDIAN"),
835         bn_asm_src       => sub { my $r=join(" ",@_); $r=~s|asm/s390x\.S|bn_asm.c|; $r; },
836         perlasm_scheme   => "31",
837         multilib         => "/highgprs",
838     },
839
840     #### SPARC Linux setups
841     "linux-sparcv8" => {
842         inherit_from     => [ "linux-generic32", asm("sparcv8_asm") ],
843         cflags           => add("-mcpu=v8"),
844         cppflags         => add("-DB_ENDIAN -DBN_DIV2W"),
845     },
846     "linux-sparcv9" => {
847         # it's a real mess with -mcpu=ultrasparc option under Linux,
848         # but -Wa,-Av8plus should do the trick no matter what.
849         inherit_from     => [ "linux-generic32", asm("sparcv9_asm") ],
850         cflags           => add("-m32 -mcpu=ultrasparc -Wa,-Av8plus"),
851         cppflags         => add("-DB_ENDIAN -DBN_DIV2W"),
852     },
853     "linux64-sparcv9" => {
854         # GCC 3.1 is a requirement
855         inherit_from     => [ "linux-generic64", asm("sparcv9_asm") ],
856         cflags           => add("-m64 -mcpu=ultrasparc"),
857         cppflags         => add("-DB_ENDIAN"),
858         bn_ops           => "BN_LLONG RC4_CHAR",
859         multilib         => "64",
860     },
861
862     "linux-alpha-gcc" => {
863         inherit_from     => [ "linux-generic64", asm("alpha_asm") ],
864         cppflags         => add("-DL_ENDIAN"),
865         bn_ops           => "SIXTY_FOUR_BIT_LONG",
866     },
867     "linux-c64xplus" => {
868         inherit_from     => [ "BASE_unix" ],
869         # TI_CGT_C6000_7.3.x is a requirement
870         cc               => "cl6x",
871         cflags           => "--linux -ea=.s -eo=.o -mv6400+ -o2 -ox -ms -pden",
872         cppflags         => combine("-DOPENSSL_SMALL_FOOTPRINT",
873                                     threads("-D_REENTRANT")),
874         bn_ops           => "BN_LLONG",
875         cpuid_asm_src    => "c64xpluscpuid.s",
876         bn_asm_src       => "asm/bn-c64xplus.asm c64xplus-gf2m.s",
877         aes_asm_src      => "aes-c64xplus.s aes_cbc.c aes-ctr.fake",
878         sha1_asm_src     => "sha1-c64xplus.s sha256-c64xplus.s sha512-c64xplus.s",
879         rc4_asm_src      => "rc4-c64xplus.s",
880         modes_asm_src    => "ghash-c64xplus.s",
881         chacha_asm_src   => "chacha-c64xplus.s",
882         poly1305_asm_src => "poly1305-c64xplus.s",
883         thread_scheme    => "pthreads",
884         perlasm_scheme   => "void",
885         dso_scheme       => "dlfcn",
886         shared_target    => "linux-shared",
887         shared_cflag     => "--pic",
888         shared_ldflag    => add("-z --sysv --shared"),
889         shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
890         ranlib           => "true",
891     },
892
893 #### Android: linux-* but without pointers to headers and libs.
894     #
895     # It takes pair of prior-set environment variables to make it work:
896     #
897     # CROSS_SYSROOT=/some/where/android-ndk-<ver>/platforms/android-<apiver>/arch-<arch>
898     # CROSS_COMPILE=<prefix>
899     #
900     # As well as PATH adjusted to cover ${CROSS_COMPILE}gcc and company.
901     # For example to compile for ICS and ARM with NDK 10d, you'd:
902     #
903     # ANDROID_NDK=/some/where/android-ndk-10d
904     # CROSS_SYSROOT=$ANDROID_NDK/platforms/android-14/arch-arm
905     # CROSS_COMPILE=arm-linux-androideabi-
906     # PATH=$ANDROID_NDK/toolchains/arm-linux-androideabi-4.8/prebuild/linux-x86_64/bin
907     #
908     "android" => {
909         inherit_from     => [ "linux-generic32" ],
910         # Special note about unconditional -fPIC and -pie. The underlying
911         # reason is that Lollipop refuses to run non-PIE. But what about
912         # older systems and NDKs? -fPIC was never problem, so the only
913         # concern is -pie. Older toolchains, e.g. r4, appear to handle it
914         # and binaries turn mostly functional. "Mostly" means that oldest
915         # Androids, such as Froyo, fail to handle executable, but newer
916         # systems are perfectly capable of executing binaries targeting
917         # Froyo. Keep in mind that in the nutshell Android builds are
918         # about JNI, i.e. shared libraries, not applications.
919         cflags           => add(picker(default => "-mandroid -fPIC --sysroot=\$(CROSS_SYSROOT) -Wa,--noexecstack")),
920         bin_cflags       => "-pie",
921     },
922     "android-x86" => {
923         inherit_from     => [ "android", asm("x86_asm") ],
924         cflags           => add(picker(release => "-fomit-frame-pointer")),
925         bn_ops           => "BN_LLONG",
926         perlasm_scheme   => "android",
927     },
928     ################################################################
929     # Contemporary Android applications can provide multiple JNI
930     # providers in .apk, targeting multiple architectures. Among
931     # them there is "place" for two ARM flavours: generic eabi and
932     # armv7-a/hard-float. However, it should be noted that OpenSSL's
933     # ability to engage NEON is not constrained by ABI choice, nor
934     # is your ability to call OpenSSL from your application code
935     # compiled with floating-point ABI other than default 'soft'.
936     # [Latter thanks to __attribute__((pcs("aapcs"))) declaration.]
937     # This means that choice of ARM libraries you provide in .apk
938     # is driven by application needs. For example if application
939     # itself benefits from NEON or is floating-point intensive, then
940     # it might be appropriate to provide both libraries. Otherwise
941     # just generic eabi would do. But in latter case it would be
942     # appropriate to
943     #
944     #   ./Configure android-armeabi -D__ARM_MAX_ARCH__=8
945     #
946     # in order to build "universal" binary and allow OpenSSL take
947     # advantage of NEON when it's available.
948     #
949     "android-armeabi" => {
950         inherit_from     => [ "android", asm("armv4_asm") ],
951     },
952     "android-mips" => {
953         inherit_from     => [ "android", asm("mips32_asm") ],
954         perlasm_scheme   => "o32",
955     },
956
957     "android64" => {
958         inherit_from     => [ "linux-generic64" ],
959         cflags           => add(picker(default => "-mandroid -fPIC --sysroot=\$(CROSS_SYSROOT) -Wa,--noexecstack")),
960         bin_cflags       => "-pie",
961     },
962     "android64-aarch64" => {
963         inherit_from     => [ "android64", asm("aarch64_asm") ],
964         perlasm_scheme   => "linux64",
965     },
966     "android64-x86_64" => {
967         inherit_from     => [ "android64", asm("x86_64_asm") ],
968         perlasm_scheme   => "elf",
969     },
970     "android64-mips64" => {
971         ############################################################
972         # You are more than likely have to specify target processor
973         # on ./Configure command line. Trouble is that toolchain's
974         # default is MIPS64r6 (at least in r10d), but there are no
975         # such processors around (or they are too rare to spot one).
976         # Actual problem is that MIPS64r6 is binary incompatible
977         # with previous MIPS ISA versions, in sense that unlike
978         # prior versions original MIPS binary code will fail.
979         #
980         inherit_from     => [ "android64", asm("mips64_asm") ],
981         perlasm_scheme   => "64",
982     },
983
984 #### *BSD
985     "BSD-generic32" => {
986         # As for thread cflag. Idea is to maintain "collective" set of
987         # flags, which would cover all BSD flavors. -pthread applies
988         # to them all, but is treated differently. OpenBSD expands is
989         # as -D_POSIX_THREAD -lc_r, which is sufficient. FreeBSD 4.x
990         # expands it as -lc_r, which has to be accompanied by explicit
991         # -D_THREAD_SAFE and sometimes -D_REENTRANT. FreeBSD 5.x
992         # expands it as -lc_r, which seems to be sufficient?
993         inherit_from     => [ "BASE_unix" ],
994         cc               => "cc",
995         cflags           => combine(picker(default => "-Wall",
996                                            debug   => "-O0 -g",
997                                            release => "-O3"),
998                                     threads("-pthread")),
999         cppflags         => threads("-D_THREAD_SAFE -D_REENTRANT"),
1000         ex_libs          => add(threads("-pthread")),
1001         enable           => add("devcryptoeng"),
1002         bn_ops           => "BN_LLONG",
1003         thread_scheme    => "pthreads",
1004         dso_scheme       => "dlfcn",
1005         shared_target    => "bsd-gcc-shared",
1006         shared_cflag     => "-fPIC",
1007         shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
1008     },
1009     "BSD-generic64" => {
1010         inherit_from     => [ "BSD-generic32" ],
1011         bn_ops           => "SIXTY_FOUR_BIT_LONG",
1012     },
1013
1014     "BSD-x86" => {
1015         inherit_from     => [ "BSD-generic32", asm("x86_asm") ],
1016         cflags           => add(picker(release => "-fomit-frame-pointer")),
1017         cppflags         => add("-DL_ENDIAN"),
1018         bn_ops           => "BN_LLONG",
1019         shared_target    => "bsd-shared",
1020         perlasm_scheme   => "a.out",
1021     },
1022     "BSD-x86-elf" => {
1023         inherit_from     => [ "BSD-x86" ],
1024         perlasm_scheme   => "elf",
1025     },
1026
1027     "BSD-sparcv8" => {
1028         inherit_from     => [ "BSD-generic32", asm("sparcv8_asm") ],
1029         cflags           => add("-mcpu=v8"),
1030         cppflags         => add("-DB_ENDIAN"),
1031     },
1032     "BSD-sparc64" => {
1033         # -DMD32_REG_T=int doesn't actually belong in sparc64 target, it
1034         # simply *happens* to work around a compiler bug in gcc 3.3.3,
1035         # triggered by RIPEMD160 code.
1036         inherit_from     => [ "BSD-generic64", asm("sparcv9_asm") ],
1037         cppflags         => add("-DB_ENDIAN -DMD32_REG_T=int"),
1038         bn_ops           => "BN_LLONG",
1039     },
1040
1041     "BSD-ia64" => {
1042         inherit_from     => [ "BSD-generic64", asm("ia64_asm") ],
1043         cppflags         => add("-DL_ENDIAN"),
1044         bn_ops           => "SIXTY_FOUR_BIT_LONG",
1045     },
1046
1047     "BSD-x86_64" => {
1048         inherit_from     => [ "BSD-generic64", asm("x86_64_asm") ],
1049         cppflags         => add("-DL_ENDIAN"),
1050         bn_ops           => "SIXTY_FOUR_BIT_LONG",
1051         perlasm_scheme   => "elf",
1052     },
1053
1054     "bsdi-elf-gcc" => {
1055         inherit_from     => [ "BASE_unix", asm("x86_elf_asm") ],
1056         cc               => "gcc",
1057         cflags           => "-fomit-frame-pointer -O3 -Wall",
1058         cppflags         => "-DPERL5 -DL_ENDIAN",
1059         ex_libs          => add("-ldl"),
1060         bn_ops           => "BN_LLONG",
1061         thread_scheme    => "(unknown)",
1062         dso_scheme       => "dlfcn",
1063         shared_target    => "bsd-gcc-shared",
1064         shared_cflag     => "-fPIC",
1065         shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
1066     },
1067
1068     "nextstep" => {
1069         inherit_from     => [ "BASE_unix" ],
1070         cc               => "cc",
1071         cflags           => "-O -Wall",
1072         unistd           => "<libc.h>",
1073         bn_ops           => "BN_LLONG",
1074         thread_scheme    => "(unknown)",
1075     },
1076     "nextstep3.3" => {
1077         inherit_from     => [ "BASE_unix" ],
1078         cc               => "cc",
1079         cflags           => "-O3 -Wall",
1080         unistd           => "<libc.h>",
1081         bn_ops           => "BN_LLONG",
1082         thread_scheme    => "(unknown)",
1083     },
1084
1085 # QNX
1086     "qnx4" => {
1087         inherit_from     => [ "BASE_unix" ],
1088         cc               => "cc",
1089         cflags           => "",
1090         cppflags         => "-DL_ENDIAN -DTERMIO",
1091         thread_scheme    => "(unknown)",
1092     },
1093     "QNX6" => {
1094         inherit_from     => [ "BASE_unix" ],
1095         cc               => "gcc",
1096         ex_libs          => add("-lsocket"),
1097         dso_scheme       => "dlfcn",
1098         shared_target    => "bsd-gcc-shared",
1099         shared_cflag     => "-fPIC",
1100         shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
1101     },
1102     "QNX6-i386" => {
1103         inherit_from     => [ "BASE_unix", asm("x86_elf_asm") ],
1104         cc               => "gcc",
1105         cflags           => "-O2 -Wall",
1106         cppflags         => "-DL_ENDIAN",
1107         ex_libs          => add("-lsocket"),
1108         dso_scheme       => "dlfcn",
1109         shared_target    => "bsd-gcc-shared",
1110         shared_cflag     => "-fPIC",
1111         shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
1112     },
1113
1114 #### SCO/Caldera targets.
1115 #
1116 # Originally we had like unixware-*, unixware-*-pentium, unixware-*-p6, etc.
1117 # Now we only have blended unixware-* as it's the only one used by ./config.
1118 # If you want to optimize for particular microarchitecture, bypass ./config
1119 # and './Configure unixware-7 -Kpentium_pro' or whatever appropriate.
1120 # Note that not all targets include assembler support. Mostly because of
1121 # lack of motivation to support out-of-date platforms with out-of-date
1122 # compiler drivers and assemblers.
1123 #
1124 # UnixWare 2.0x fails destest with -O.
1125     "unixware-2.0" => {
1126         inherit_from     => [ "BASE_unix" ],
1127         cc               => "cc",
1128         cflags           => combine(threads("-Kthread")),
1129         cppflags         => "-DFILIO_H -DNO_STRINGS_H",
1130         ex_libs          => add("-lsocket -lnsl -lresolv -lx"),
1131         thread_scheme    => "uithreads",
1132     },
1133     "unixware-2.1" => {
1134         inherit_from     => [ "BASE_unix" ],
1135         cc               => "cc",
1136         cflags           => combine("-O", threads("-Kthread")),
1137         cppflags         => "-DFILIO_H",
1138         ex_libs          => add("-lsocket -lnsl -lresolv -lx"),
1139         thread_scheme    => "uithreads",
1140     },
1141     "unixware-7" => {
1142         inherit_from     => [ "BASE_unix", asm("x86_elf_asm") ],
1143         cc               => "cc",
1144         cflags           => combine("-O -Kalloca", threads("-Kthread")),
1145         cppflags         => "-DFILIO_H",
1146         ex_libs          => add("-lsocket -lnsl"),
1147         thread_scheme    => "uithreads",
1148         bn_ops           => "BN_LLONG",
1149         perlasm_scheme   => "elf-1",
1150         dso_scheme       => "dlfcn",
1151         shared_target    => "svr5-shared",
1152         shared_cflag     => "-Kpic",
1153         shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
1154     },
1155     "unixware-7-gcc" => {
1156         inherit_from     => [ "BASE_unix", asm("x86_elf_asm") ],
1157         cc               => "gcc",
1158         cflags           => combine("-O3 -fomit-frame-pointer -Wall"),
1159         cppflags         => add("-DL_ENDIAN -DFILIO_H",
1160                                 threads("-D_REENTRANT")),
1161         ex_libs          => add("-lsocket -lnsl"),
1162         bn_ops           => "BN_LLONG",
1163         thread_scheme    => "pthreads",
1164         perlasm_scheme   => "elf-1",
1165         dso_scheme       => "dlfcn",
1166         shared_target    => "gnu-shared",
1167         shared_cflag     => "-fPIC",
1168         shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
1169     },
1170 # SCO 5 - Ben Laurie says the -O breaks the SCO cc.
1171     "sco5-cc" => {
1172         inherit_from     => [ "BASE_unix", asm("x86_elf_asm") ],
1173         cc               => "cc",
1174         cflags           => "-belf",
1175         ex_libs          => add("-lsocket -lnsl"),
1176         thread_scheme    => "(unknown)",
1177         perlasm_scheme   => "elf-1",
1178         dso_scheme       => "dlfcn",
1179         shared_target    => "svr3-shared",
1180         shared_cflag     => "-Kpic",
1181         shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
1182     },
1183     "sco5-gcc" => {
1184         inherit_from     => [ "BASE_unix", asm("x86_elf_asm") ],
1185         cc               => "gcc",
1186         cflags           => "-O3 -fomit-frame-pointer",
1187         ex_libs          => add("-lsocket -lnsl"),
1188         bn_ops           => "BN_LLONG",
1189         thread_scheme    => "(unknown)",
1190         perlasm_scheme   => "elf-1",
1191         dso_scheme       => "dlfcn",
1192         shared_target    => "svr3-shared",
1193         shared_cflag     => "-fPIC",
1194         shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
1195     },
1196
1197 #### IBM's AIX.
1198     # Below targets assume AIX >=5. Caveat lector. If you are accustomed
1199     # to control compilation "bitness" by setting $OBJECT_MODE environment
1200     # variable, then you should know that in OpenSSL case it's considered
1201     # only in ./config. Once configured, build procedure remains "deaf" to
1202     # current value of $OBJECT_MODE.
1203     "aix-gcc" => {
1204         inherit_from     => [ "BASE_unix", asm("ppc32_asm") ],
1205         cc               => "gcc",
1206         cflags           => combine(picker(debug   => "-O0 -g",
1207                                            release => "-O"),
1208                                     threads("-pthread")),
1209         cppflags         => "-DB_ENDIAN",
1210         ex_libs          => add(threads("-pthread")),
1211         sys_id           => "AIX",
1212         bn_ops           => "BN_LLONG RC4_CHAR",
1213         thread_scheme    => "pthreads",
1214         perlasm_scheme   => "aix32",
1215         dso_scheme       => "dlfcn",
1216         shared_target    => "aix-shared",
1217         shared_ldflag    => "-shared -static-libgcc -Wl,-G",
1218         shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
1219         arflags          => "-X32",
1220     },
1221     "aix64-gcc" => {
1222         inherit_from     => [ "BASE_unix", asm("ppc64_asm") ],
1223         cc               => "gcc",
1224         cflags           => combine(picker(default => "-maix64",
1225                                            debug   => "-O0 -g",
1226                                            release => "-O"),
1227                                     threads("-pthread")),
1228         cppflags         => "-DB_ENDIAN",
1229         ex_libs          => add(threads("-pthread")),
1230         sys_id           => "AIX",
1231         bn_ops           => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
1232         thread_scheme    => "pthreads",
1233         perlasm_scheme   => "aix64",
1234         dso_scheme       => "dlfcn",
1235         shared_target    => "aix-shared",
1236         shared_ldflag    => "-shared -static-libgcc -Wl,-G",
1237         shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
1238         arflags          => "-X64",
1239     },
1240     "aix-cc" => {
1241         inherit_from     => [ "BASE_unix", asm("ppc32_asm") ],
1242         cc               => "cc",
1243         cflags           => combine(picker(default => "-q32 -qmaxmem=16384 -qro -qroconst",
1244                                            debug   => "-O0 -g",
1245                                            release => "-O"),
1246                                     threads("-qthreaded")),
1247         cppflags         => combine("-DB_ENDIAN", threads("-D_THREAD_SAFE")),
1248         sys_id           => "AIX",
1249         bn_ops           => "BN_LLONG RC4_CHAR",
1250         thread_scheme    => "pthreads",
1251         ex_libs          => threads("-lpthreads"),
1252         perlasm_scheme   => "aix32",
1253         dso_scheme       => "dlfcn",
1254         shared_target    => "aix-shared",
1255         shared_ldflag    => "-G",
1256         shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
1257         arflags          => "-X 32",
1258     },
1259     "aix64-cc" => {
1260         inherit_from     => [ "BASE_unix", asm("ppc64_asm") ],
1261         cc               => "cc",
1262         cflags           => combine(picker(default => "-q64 -qmaxmem=16384 -qro -qroconst",
1263                                            debug   => "-O0 -g",
1264                                            release => "-O"),
1265                                     threads("-qthreaded")),
1266         cppflags         => combine("-DB_ENDIAN", threads("-D_THREAD_SAFE")),
1267         sys_id           => "AIX",
1268         bn_ops           => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
1269         thread_scheme    => "pthreads",
1270         ex_libs          => threads("-lpthreads"),
1271         perlasm_scheme   => "aix64",
1272         dso_scheme       => "dlfcn",
1273         shared_target    => "aix-shared",
1274         shared_ldflag    => "-G",
1275         shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
1276         arflags          => "-X 64",
1277     },
1278
1279 # SIEMENS BS2000/OSD: an EBCDIC-based mainframe
1280     "BS2000-OSD" => {
1281         inherit_from     => [ "BASE_unix" ],
1282         cc               => "c89",
1283         cflags           => "-O -XLLML -XLLMK -XL",
1284         cppflags         => "-DB_ENDIAN -DCHARSET_EBCDIC",
1285         ex_libs          => add("-lsocket -lnsl"),
1286         bn_ops           => "THIRTY_TWO_BIT RC4_CHAR",
1287         thread_scheme    => "(unknown)",
1288     },
1289
1290 #### Visual C targets
1291 #
1292 # Win64 targets, WIN64I denotes IA-64 and WIN64A - AMD64
1293 #
1294 # Note about -wd4090, disable warning C4090. This warning returns false
1295 # positives in some situations. Disabling it altogether masks both
1296 # legitimate and false cases, but as we compile on multiple platforms,
1297 # we rely on other compilers to catch legitimate cases.
1298 #
1299 # Also note that we force threads no matter what.  Configuring "no-threads"
1300 # is ignored.
1301     "VC-common" => {
1302         inherit_from     => [ "BASE_Windows" ],
1303         template         => 1,
1304         cc               => "cl",
1305         cflags           => "-W3 -wd4090 -Gs0 -GF -Gy -nologo",
1306         defines          => add("OPENSSL_SYS_WIN32", "WIN32_LEAN_AND_MEAN",
1307                                 "L_ENDIAN", "_CRT_SECURE_NO_DEPRECATE",
1308                                 "_WINSOCK_DEPRECATED_NO_WARNINGS",
1309                                 sub { my @defs = ();
1310                                       unless ($disabled{"zlib-dynamic"}) {
1311                                           my $zlib =
1312                                               $withargs{zlib_lib} // "ZLIB1";
1313                                           push @defs,
1314                                               quotify("perl",
1315                                                       'LIBZ="' . $zlib . '"');
1316                                       }
1317                                       return [ @defs ];
1318                                   }),
1319         coutflag         => "/Fo",
1320         lib_cflags       => add("/Zi /Fdossl_static"),
1321         dso_cflags       => "/Zi /Fddso",
1322         bin_cflags       => "/Zi /Fdapp",
1323         lflags           => add("/debug"),
1324         shared_ldflag    => "/dll",
1325         shared_target    => "win-shared", # meaningless except it gives Configure a hint
1326         thread_scheme    => "winthreads",
1327         dso_scheme       => "win32",
1328         apps_aux_src     => add("win32_init.c"),
1329     },
1330     "VC-noCE-common" => {
1331         inherit_from     => [ "VC-common" ],
1332         template         => 1,
1333         cflags           => add(picker(debug   =>
1334                                        sub {
1335                                            ($disabled{shared} ? "" : "/MDd")
1336                                                ." /Od";
1337                                        },
1338                                        release =>
1339                                        sub {
1340                                            ($disabled{shared} ? "" : "/MD")
1341                                                ." /O2";
1342                                        })),
1343         defines          => add(picker(default => [ "UNICODE", "_UNICODE" ],
1344                                        debug   => [ "DEBUG", "_DEBUG" ])),
1345         lib_cflags       => add(sub { $disabled{shared} ? "/MT /Zl" : () }),
1346         # Following might/should appears controversial, i.e. defining
1347         # /MDd without evaluating $disabled{shared}. It works in
1348         # non-shared build because static library is compiled with /Zl
1349         # and bares no reference to specific RTL. And it works in
1350         # shared build because multiple /MDd options are not prohibited.
1351         # But why /MDd in static build? Well, basically this is just a
1352         # reference point, which allows to catch eventual errors that
1353         # would prevent those who want to wrap OpenSSL into own .DLL.
1354         # Why not /MD in release build then? Well, some are likely to
1355         # prefer [non-debug] openssl.exe to be free from Micorosoft RTL
1356         # redistributable.
1357         bin_cflags       => add(picker(debug   => "/MDd",
1358                                        release => sub { $disabled{shared} ? "/MT" : () },
1359                                       )),
1360         bin_lflags       => add("/subsystem:console /opt:ref"),
1361         ex_libs          => add(sub {
1362             my @ex_libs = ();
1363             push @ex_libs, 'ws2_32.lib' unless $disabled{sock};
1364             push @ex_libs, 'gdi32.lib advapi32.lib crypt32.lib user32.lib';
1365             return join(" ", @ex_libs);
1366         }),
1367     },
1368     "VC-WIN64-common" => {
1369         inherit_from     => [ "VC-noCE-common" ],
1370         template         => 1,
1371         ex_libs          => add(sub {
1372             my @ex_libs = ();
1373             push @ex_libs, 'bufferoverflowu.lib' if (`cl 2>&1` =~ /14\.00\.4[0-9]{4}\./);
1374             return join(" ", @_, @ex_libs);
1375         }),
1376         bn_ops           => "SIXTY_FOUR_BIT EXPORT_VAR_AS_FN",
1377         build_scheme     => add("VC-W64", { separator => undef }),
1378     },
1379     "VC-WIN64I" => {
1380         inherit_from     => [ "VC-WIN64-common", asm("ia64_asm"),
1381                               sub { $disabled{shared} ? () : "ia64_uplink" } ],
1382         as               => "ias",
1383         asflags          => "-d debug",
1384         asoutflag        => "-o",
1385         sys_id           => "WIN64I",
1386         bn_asm_src       => sub { return undef unless @_;
1387                                   my $r=join(" ",@_); $r=~s|bn-ia64.s|bn_asm.c|; $r; },
1388         perlasm_scheme   => "ias",
1389         multilib         => "-ia64",
1390     },
1391     "VC-WIN64A" => {
1392         inherit_from     => [ "VC-WIN64-common", asm("x86_64_asm"),
1393                               sub { $disabled{shared} ? () : "x86_64_uplink" } ],
1394         as               => sub { vc_win64a_info()->{as} },
1395         asflags          => sub { vc_win64a_info()->{asflags} },
1396         asoutflag        => sub { vc_win64a_info()->{asoutflag} },
1397         sys_id           => "WIN64A",
1398         bn_asm_src       => sub { return undef unless @_;
1399                                   my $r=join(" ",@_); $r=~s|asm/x86_64-gcc|bn_asm|; $r; },
1400         perlasm_scheme   => "auto",
1401         multilib         => "-x64",
1402     },
1403     "VC-WIN32" => {
1404         # x86 Win32 target defaults to ANSI API, if you want UNICODE,
1405         # configure with 'perl Configure VC-WIN32 -DUNICODE -D_UNICODE'
1406         inherit_from     => [ "VC-noCE-common", asm("x86_asm"),
1407                               sub { $disabled{shared} ? () : "uplink_common" } ],
1408         cflags           => add("-WX"),
1409         as               => sub { vc_win32_info()->{as} },
1410         asflags          => sub { vc_win32_info()->{asflags} },
1411         asoutflag        => sub { vc_win32_info()->{asoutflag} },
1412         ex_libs          => add(sub {
1413             my @ex_libs = ();
1414             # WIN32 UNICODE build gets linked with unicows.lib for
1415             # backward compatibility with Win9x.
1416             push @ex_libs, 'unicows.lib'
1417                 if (grep { $_ eq "UNICODE" } @{$user{CPPDEFINES}});
1418             return join(" ", @ex_libs, @_);
1419         }),
1420         sys_id           => "WIN32",
1421         bn_ops           => "BN_LLONG EXPORT_VAR_AS_FN",
1422         perlasm_scheme   => sub { vc_win32_info()->{perlasm_scheme} },
1423         build_scheme     => add("VC-W32", { separator => undef }),
1424     },
1425     "VC-CE" => {
1426         inherit_from     => [ "VC-common" ],
1427         as               => "ml",
1428         asflags          => "/nologo /Cp /coff /c /Cx /Zi",
1429         asoutflag        => "/Fo",
1430         cc               => "cl",
1431         cflags           =>
1432             picker(default =>
1433                    combine('/W3 /WX /GF /Gy /nologo',
1434                            sub { vc_wince_info()->{cflags}; },
1435                            sub { `cl 2>&1` =~ /Version ([0-9]+)\./ && $1>=14
1436                                      ? ($disabled{shared} ? " /MT" : " /MD")
1437                                      : " /MC"; }),
1438                    debug   => "/Od",
1439                    release => "/O1i"),
1440         cppflags         => sub { vc_wince_info()->{cppflags}; },
1441         defines          =>
1442             picker(default => [ "UNICODE", "_UNICODE", "OPENSSL_SYS_WINCE",
1443                                 "WIN32_LEAN_AND_MEAN", "L_ENDIAN", "DSO_WIN32",
1444                                 "NO_CHMOD", "OPENSSL_SMALL_FOOTPRINT" ],
1445                    debug   => [ "DEBUG", "_DEBUG" ]),
1446         includes         =>
1447             add(combine(sub { defined(env('WCECOMPAT'))
1448                               ? '$(WCECOMPAT)/include' : (); },
1449                         sub { defined(env('PORTSDK_LIBPATH'))
1450                                   ? '$(PORTSDK_LIBPATH)/../../include'
1451                                   : (); })),
1452         lflags           => add(combine("/nologo /opt:ref",
1453                                         sub { vc_wince_info()->{lflags}; },
1454                                         sub { defined(env('PORTSDK_LIBPATH'))
1455                                                   ? "/entry:mainCRTstartup" : (); })),
1456         sys_id           => "WINCE",
1457         bn_ops           => "BN_LLONG EXPORT_VAR_AS_FN",
1458         ex_libs          => add(sub {
1459             my @ex_libs = ();
1460             push @ex_libs, 'ws2.lib' unless $disabled{sock};
1461             push @ex_libs, 'crypt32.lib';
1462             if (defined(env('WCECOMPAT'))) {
1463                 my $x = '$(WCECOMPAT)/lib';
1464                 if (-f "$x/env('TARGETCPU')/wcecompatex.lib") {
1465                     $x .= '/$(TARGETCPU)/wcecompatex.lib';
1466                 } else {
1467                     $x .= '/wcecompatex.lib';
1468                 }
1469                 push @ex_libs, $x;
1470             }
1471             push @ex_libs, '$(PORTSDK_LIBPATH)/portlib.lib'
1472                 if (defined(env('PORTSDK_LIBPATH')));
1473             push @ex_libs, ' /nodefaultlib coredll.lib corelibc.lib'
1474                 if (env('TARGETCPU') eq "X86");
1475             return @ex_libs;
1476         }),
1477         build_scheme     => add("VC-WCE", { separator => undef }),
1478     },
1479
1480 #### MinGW
1481     "mingw" => {
1482         inherit_from     => [ "BASE_unix", asm("x86_asm"),
1483                               sub { $disabled{shared} ? () : "x86_uplink" } ],
1484         cc               => "gcc",
1485         cflags           => picker(default => "-m32 -Wall",
1486                                    debug   => "-g -O0",
1487                                    release => "-O3 -fomit-frame-pointer"),
1488         cppflags         => combine("-DL_ENDIAN -DWIN32_LEAN_AND_MEAN",
1489                                     "-DUNICODE -D_UNICODE", threads("-D_MT")),
1490         sys_id           => "MINGW32",
1491         ex_libs          => add("-lws2_32 -lgdi32 -lcrypt32"),
1492         bn_ops           => "BN_LLONG EXPORT_VAR_AS_FN",
1493         thread_scheme    => "winthreads",
1494         perlasm_scheme   => "coff",
1495         dso_scheme       => "win32",
1496         shared_target    => "mingw-shared",
1497         shared_cppflags  => add("_WINDLL"),
1498         shared_ldflag    => "-static-libgcc",
1499         shared_rcflag    => "--target=pe-i386",
1500         shared_extension => ".dll",
1501         multilib         => "",
1502         apps_aux_src     => add("win32_init.c"),
1503     },
1504     "mingw64" => {
1505         # As for OPENSSL_USE_APPLINK. Applink makes it possible to use
1506         # .dll compiled with one compiler with application compiled with
1507         # another compiler. It's possible to engage Applink support in
1508         # mingw64 build, but it's not done, because till mingw64
1509         # supports structured exception handling, one can't seriously
1510         # consider its binaries for using with non-mingw64 run-time
1511         # environment. And as mingw64 is always consistent with itself,
1512         # Applink is never engaged and can as well be omitted.
1513         inherit_from     => [ "BASE_unix", asm("x86_64_asm") ],
1514         cc               => "gcc",
1515         cflags           => picker(default => "-m64 -Wall",
1516                                    debug   => "-g -O0",
1517                                    release => "-O3"),
1518         cppflags         => combine("-DL_ENDIAN -DWIN32_LEAN_AND_MEAN",
1519                                     "-DUNICODE -D_UNICODE", threads("-D_MT")),
1520         sys_id           => "MINGW64",
1521         ex_libs          => add("-lws2_32 -lgdi32 -lcrypt32"),
1522         bn_ops           => "SIXTY_FOUR_BIT EXPORT_VAR_AS_FN",
1523         thread_scheme    => "winthreads",
1524         perlasm_scheme   => "mingw64",
1525         dso_scheme       => "win32",
1526         shared_target    => "mingw-shared",
1527         shared_cppflags  => add("_WINDLL"),
1528         shared_ldflag    => "-static-libgcc",
1529         shared_rcflag    => "--target=pe-x86-64",
1530         shared_extension => ".dll",
1531         multilib         => "64",
1532         apps_aux_src     => add("win32_init.c"),
1533     },
1534
1535 #### UEFI
1536     "UEFI" => {
1537         inherit_from     => [ "BASE_unix" ],
1538         cc               => "cc",
1539         cflags           => "-O",
1540         cppflags         => "-DL_ENDIAN",
1541         sys_id           => "UEFI",
1542     },
1543
1544 #### UWIN
1545     "UWIN" => {
1546         inherit_from     => [ "BASE_unix" ],
1547         cc               => "cc",
1548         cflags           => "-O -Wall",
1549         cppflags         => "-DTERMIOS -DL_ENDIAN",
1550         sys_id           => "UWIN",
1551         bn_ops           => "BN_LLONG",
1552         dso_scheme       => "win32",
1553     },
1554
1555 #### Cygwin
1556     "Cygwin-x86" => {
1557         inherit_from     => [ "BASE_unix", asm("x86_asm") ],
1558         cc               => "gcc",
1559         cflags           => picker(default => "-Wall",
1560                                    debug   => "-g -O0",
1561                                    release => "-O3 -fomit-frame-pointer"),
1562         cppflags         => "-DTERMIOS -DL_ENDIAN",
1563         sys_id           => "CYGWIN",
1564         bn_ops           => "BN_LLONG",
1565         thread_scheme    => "pthread",
1566         perlasm_scheme   => "coff",
1567         dso_scheme       => "dlfcn",
1568         shared_target    => "cygwin-shared",
1569         shared_cppflags  => "-D_WINDLL",
1570         shared_extension => ".dll",
1571     },
1572     "Cygwin-x86_64" => {
1573         inherit_from     => [ "BASE_unix", asm("x86_64_asm") ],
1574         cc               => "gcc",
1575         cflags           => picker(default => "-Wall",
1576                                    debug   => "-g -O0",
1577                                    release => "-O3"),
1578         cppflags         => "-DTERMIOS -DL_ENDIAN",
1579         sys_id           => "CYGWIN",
1580         bn_ops           => "SIXTY_FOUR_BIT_LONG",
1581         thread_scheme    => "pthread",
1582         perlasm_scheme   => "mingw64",
1583         dso_scheme       => "dlfcn",
1584         shared_target    => "cygwin-shared",
1585         shared_cppflags  => "-D_WINDLL",
1586         shared_extension => ".dll",
1587     },
1588     # Backward compatibility for those using this target
1589     "Cygwin" => {
1590         inherit_from     => [ "Cygwin-x86" ]
1591     },
1592     # In case someone constructs the Cygwin target name themself
1593     "Cygwin-i386" => {
1594         inherit_from     => [ "Cygwin-x86" ]
1595     },
1596     "Cygwin-i486" => {
1597         inherit_from     => [ "Cygwin-x86" ]
1598     },
1599     "Cygwin-i586" => {
1600         inherit_from     => [ "Cygwin-x86" ]
1601     },
1602     "Cygwin-i686" => {
1603         inherit_from     => [ "Cygwin-x86" ]
1604     },
1605
1606 ##### MacOS X (a.k.a. Darwin) setup
1607     "darwin-common" => {
1608         inherit_from     => [ "BASE_unix" ],
1609         template         => 1,
1610         cc               => "cc",
1611         cflags           => picker(default => "",
1612                                    debug   => "-g -O0",
1613                                    release => "-O3"),
1614         cppflags         => threads("-D_REENTRANT"),
1615         sys_id           => "MACOSX",
1616         plib_lflags      => "-Wl,-search_paths_first",
1617         bn_ops           => "BN_LLONG RC4_CHAR",
1618         thread_scheme    => "pthreads",
1619         perlasm_scheme   => "osx32",
1620         dso_scheme       => "dlfcn",
1621         ranlib           => "ranlib -c",
1622         shared_target    => "darwin-shared",
1623         shared_cflag     => "-fPIC",
1624         shared_extension => ".\$(SHLIB_VERSION_NUMBER).dylib",
1625     },
1626     # Option "freeze" such as -std=gnu9x can't negatively interfere
1627     # with future defaults for below two targets, because MacOS X
1628     # for PPC has no future, it was discontinued by vendor in 2009.
1629     "darwin-ppc-cc" => {
1630         inherit_from     => [ "darwin-common", asm("ppc32_asm") ],
1631         cflags           => add("-arch ppc -std=gnu9x -Wa,-force_cpusubtype_ALL"),
1632         cppflags         => add("-DB_ENDIAN"),
1633         perlasm_scheme   => "osx32",
1634     },
1635     "darwin64-ppc-cc" => {
1636         inherit_from     => [ "darwin-common", asm("ppc64_asm") ],
1637         cflags           => add("-arch ppc64 -std=gnu9x"),
1638         cppflags         => add("-DB_ENDIAN"),
1639         bn_ops           => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
1640         perlasm_scheme   => "osx64",
1641     },
1642     "darwin-i386-cc" => {
1643         inherit_from     => [ "darwin-common", asm("x86_asm") ],
1644         cflags           => add(picker(default => "-arch i386",
1645                                        release => "-fomit-frame-pointer")),
1646         cppflags         => add("-DL_ENDIAN"),
1647         bn_ops           => "BN_LLONG RC4_INT",
1648         perlasm_scheme   => "macosx",
1649     },
1650     "darwin64-x86_64-cc" => {
1651         inherit_from     => [ "darwin-common", asm("x86_64_asm") ],
1652         cflags           => add("-arch x86_64 -Wall"),
1653         cppflags         => add("-DL_ENDIAN"),
1654         bn_ops           => "SIXTY_FOUR_BIT_LONG",
1655         perlasm_scheme   => "macosx",
1656     },
1657
1658 #### iPhoneOS/iOS
1659 #
1660 # It takes three prior-set environment variables to make it work:
1661 #
1662 # CROSS_COMPILE=/where/toolchain/is/usr/bin/ [note ending slash]
1663 # CROSS_TOP=/where/SDKs/are
1664 # CROSS_SDK=iPhoneOSx.y.sdk
1665 #
1666 # Exact paths vary with Xcode releases, but for couple of last ones
1667 # they would look like this:
1668 #
1669 # CROSS_COMPILE=`xcode-select --print-path`/Toolchains/XcodeDefault.xctoolchain/usr/bin/
1670 # CROSS_TOP=`xcode-select --print-path`/Platforms/iPhoneOS.platform/Developer
1671 # CROSS_SDK=iPhoneOS.sdk
1672 #
1673     "iphoneos-cross" => {
1674         inherit_from     => [ "darwin-common" ],
1675         cflags           => add("-isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK) -fno-common"),
1676         sys_id           => "iOS",
1677     },
1678     "ios-cross" => {
1679         inherit_from     => [ "darwin-common", asm("armv4_asm") ],
1680         # It should be possible to go below iOS 6 and even add -arch armv6,
1681         # thus targeting iPhone pre-3GS, but it's assumed to be irrelevant
1682         # at this point.
1683         cflags           => add("-arch armv7 -mios-version-min=6.0.0 -isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK) -fno-common"),
1684         sys_id           => "iOS",
1685         perlasm_scheme   => "ios32",
1686     },
1687     "ios64-cross" => {
1688         inherit_from     => [ "darwin-common", asm("aarch64_asm") ],
1689         cflags           => add("-arch arm64 -mios-version-min=7.0.0 -isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK) -fno-common"),
1690         sys_id           => "iOS",
1691         bn_ops           => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
1692         perlasm_scheme   => "ios64",
1693     },
1694
1695 ##### GNU Hurd
1696     "hurd-x86" => {
1697         inherit_from     => [ "BASE_unix" ],
1698         inherit_from     => [ asm("x86_elf_asm") ],
1699         cc               => "gcc",
1700         cflags           => combine("-O3 -fomit-frame-pointer -Wall",
1701                                     threads("-pthread")),
1702         cppflags         => "-DL_ENDIAN",
1703         ex_libs          => add("-ldl", threads("-pthread")),
1704         bn_ops           => "BN_LLONG",
1705         thread_scheme    => "pthreads",
1706         dso_scheme       => "dlfcn",
1707         shared_target    => "linux-shared",
1708         shared_cflag     => "-fPIC",
1709         shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
1710     },
1711
1712 ##### VxWorks for various targets
1713     "vxworks-ppc60x" => {
1714         inherit_from     => [ "BASE_unix" ],
1715         cc               => "ccppc",
1716         cflags           => "-mrtp -mhard-float -mstrict-align -fno-implicit-fp -O2 -fstrength-reduce -fno-builtin -fno-strict-aliasing -Wall",
1717         cppflags         => combine("-D_REENTRANT -DPPC32_fp60x -DCPU=PPC32",
1718                                     "_DTOOL_FAMILY=gnu -DTOOL=gnu",
1719                                     "-I\$(WIND_BASE)/target/usr/h",
1720                                     "-I\$(WIND_BASE)/target/usr/h/wrn/coreip"),
1721         sys_id           => "VXWORKS",
1722         lflags           => add("-L \$(WIND_BASE)/target/usr/lib/ppc/PPC32/common"),
1723         ex_libs          => add("-Wl,--defsym,__wrs_rtp_base=0xe0000000"),
1724     },
1725     "vxworks-ppcgen" => {
1726         inherit_from     => [ "BASE_unix" ],
1727         cc               => "ccppc",
1728         cflags           => "-mrtp -msoft-float -mstrict-align -O1 -fno-builtin -fno-strict-aliasing -Wall",
1729         cppflags         => combine("-D_REENTRANT -DPPC32 -DCPU=PPC32",
1730                                     "-DTOOL_FAMILY=gnu -DTOOL=gnu",
1731                                     "-I\$(WIND_BASE)/target/usr/h",
1732                                     "-I\$(WIND_BASE)/target/usr/h/wrn/coreip"),
1733         sys_id           => "VXWORKS",
1734         lflags           => add("-L \$(WIND_BASE)/target/usr/lib/ppc/PPC32/sfcommon"),
1735         ex_libs          => add("-Wl,--defsym,__wrs_rtp_base=0xe0000000"),
1736     },
1737     "vxworks-ppc405" => {
1738         inherit_from     => [ "BASE_unix" ],
1739         cc               => "ccppc",
1740         cflags           => "-g -msoft-float -mlongcall",
1741         cppflags         => combine("-D_REENTRANT -DPPC32 -DCPU=PPC405",
1742                                     "-DTOOL_FAMILY=gnu -DTOOL=gnu",
1743                                     "-I\$(WIND_BASE)/target/h"),
1744         sys_id           => "VXWORKS",
1745         lflags           => add("-r"),
1746     },
1747     "vxworks-ppc750" => {
1748         inherit_from     => [ "BASE_unix" ],
1749         cc               => "ccppc",
1750         cflags           => "-ansi -nostdinc -fvolatile -fno-builtin -fno-for-scope -fsigned-char -Wall -msoft-float -mlongcall \$(DEBUG_FLAG)",
1751         cppflags         => combine("-DPPC750 -D_REENTRANT -DCPU=PPC604",
1752                                     "-I\$(WIND_BASE)/target/h"),
1753         sys_id           => "VXWORKS",
1754         lflags           => add("-r"),
1755     },
1756     "vxworks-ppc750-debug" => {
1757         inherit_from     => [ "BASE_unix" ],
1758         cc               => "ccppc",
1759         cflags           => "-ansi -nostdinc -fvolatile -fno-builtin -fno-for-scope -fsigned-char -Wall -msoft-float -mlongcall -g",
1760         cppflags         => combine("-DPPC750 -D_REENTRANT -DCPU=PPC604",
1761                                     "-DPEDANTIC -DDEBUG",
1762                                     "-I\$(WIND_BASE)/target/h"),
1763         sys_id           => "VXWORKS",
1764         lflags           => add("-r"),
1765     },
1766     "vxworks-ppc860" => {
1767         inherit_from     => [ "BASE_unix" ],
1768         cc               => "ccppc",
1769         cflags           => "-nostdinc -msoft-float",
1770         cppflags         => combine("-DCPU=PPC860 -DNO_STRINGS_H",
1771                                     "-I\$(WIND_BASE)/target/h"),
1772         sys_id           => "VXWORKS",
1773         lflags           => add("-r"),
1774     },
1775     "vxworks-simlinux" => {
1776         inherit_from     => [ "BASE_unix" ],
1777         cc               => "ccpentium",
1778         cflags           => "-B\$(WIND_BASE)/host/\$(WIND_HOST_TYPE)/lib/gcc-lib/ -fno-builtin -fno-defer-pop",
1779         cppflags         => combine("-D_VSB_CONFIG_FILE=\"\$(WIND_BASE)/target/lib/h/config/vsbConfig.h\"",
1780                                     "-DL_ENDIAN -DCPU=SIMLINUX -DNO_STRINGS_H",
1781                                     "-DTOOL_FAMILY=gnu -DTOOL=gnu",
1782                                     "-DOPENSSL_NO_HW_PADLOCK",
1783                                     "-I\$(WIND_BASE)/target/h",
1784                                     "-I\$(WIND_BASE)/target/h/wrn/coreip"),
1785         sys_id           => "VXWORKS",
1786         lflags           => add("-r"),
1787         ranlib           => "ranlibpentium",
1788     },
1789     "vxworks-mips" => {
1790         inherit_from     => [ "BASE_unix", asm("mips32_asm") ],
1791         cc               => "ccmips",
1792         cflags           => "-mrtp -mips2 -O -G 0 -B\$(WIND_BASE)/host/\$(WIND_HOST_TYPE)/lib/gcc-lib/ -msoft-float -mno-branch-likely -fno-builtin -fno-defer-pop",
1793         cppflags         => combine("-D_VSB_CONFIG_FILE=\"\$(WIND_BASE)/target/lib/h/config/vsbConfig.h\"",
1794                                     "-DCPU=MIPS32 -DNO_STRINGS_H",
1795                                     "-DTOOL_FAMILY=gnu -DTOOL=gnu",
1796                                     "-DOPENSSL_NO_HW_PADLOCK",
1797                                     threads("-D_REENTRANT"),
1798                                     "-I\$(WIND_BASE)/target/h",
1799                                     "-I\$(WIND_BASE)/target/h/wrn/coreip"),
1800         sys_id           => "VXWORKS",
1801         lflags           => add("-L \$(WIND_BASE)/target/usr/lib/mips/MIPSI32/sfcommon"),
1802         ex_libs          => add("-Wl,--defsym,__wrs_rtp_base=0xe0000000"),
1803         thread_scheme    => "pthreads",
1804         perlasm_scheme   => "o32",
1805         ranlib           => "ranlibmips",
1806     },
1807
1808 #### uClinux
1809     "uClinux-dist" => {
1810         inherit_from     => [ "BASE_unix" ],
1811         cc               => sub { env('CC') },
1812         cppflags         => threads("-D_REENTRANT"),
1813         ex_libs          => add("\$(LDLIBS)"),
1814         bn_ops           => "BN_LLONG",
1815         thread_scheme    => "pthreads",
1816         dso_scheme       => sub { env('LIBSSL_dlfcn') },
1817         shared_target    => "linux-shared",
1818         shared_cflag     => "-fPIC",
1819         shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
1820         ranlib           => sub { env('RANLIB') },
1821     },
1822     "uClinux-dist64" => {
1823         inherit_from     => [ "BASE_unix" ],
1824         cc               => sub { env('CC') },
1825         cppflags         => threads("-D_REENTRANT"),
1826         ex_libs          => add("\$(LDLIBS)"),
1827         bn_ops           => "SIXTY_FOUR_BIT_LONG",
1828         thread_scheme    => "pthreads",
1829         dso_scheme       => sub { env('LIBSSL_dlfcn') },
1830         shared_target    => "linux-shared",
1831         shared_cflag     => "-fPIC",
1832         shared_extension => ".so.\$(SHLIB_VERSION_NUMBER)",
1833         ranlib           => sub { env('RANLIB') },
1834     },
1835
1836     ##### VMS
1837     "vms-generic" => {
1838         inherit_from     => [ "BASE_VMS" ],
1839         template         => 1,
1840         cc               => "CC/DECC",
1841         cflags           => picker(default => "/STANDARD=(ISOC94,RELAXED)/NOLIST/PREFIX=ALL",
1842                                    debug   => "/NOOPTIMIZE/DEBUG",
1843                                    release => "/OPTIMIZE/NODEBUG"),
1844         defines          => add("OPENSSL_USE_NODELETE"),
1845         lflags           => picker(default => "/MAP='F\$PARSE(\".MAP\",\"\$\@\")'",
1846                                    debug   => "/DEBUG/TRACEBACK",
1847                                    release => "/NODEBUG/NOTRACEBACK"),
1848         lib_cflags       => add("/NAMES=(AS_IS,SHORTENED)/EXTERN_MODEL=STRICT_REFDEF"),
1849         # no_inst_lib_cflags is used instead of lib_cflags by descrip.mms.tmpl
1850         # for object files belonging to selected internal libraries
1851         no_inst_lib_cflags => "",
1852         shared_target    => "vms-shared",
1853         dso_scheme       => "vms",
1854         thread_scheme    => "pthreads",
1855
1856         apps_aux_src     => "vms_term_sock.c",
1857         apps_init_src    => "vms_decc_init.c",
1858     },
1859
1860     "vms-alpha" => {
1861         inherit_from     => [ "vms-generic" ],
1862         cflags           => add(sub { my @warnings =
1863                                           @{vms_info(0)->{disable_warns}};
1864                                       @warnings
1865                                           ? "/WARNINGS=DISABLE=(".join(",",@warnings).")" : (); }),
1866         defines          =>
1867                     add(sub {
1868                             return vms_info(0)->{def_zlib}
1869                                 ? "LIBZ=\"\"\"".vms_info(0)->{def_zlib}."\"\"\"" : ();
1870                             }),
1871         ex_libs          => add(sub { return vms_info(0)->{zlib} || (); }),
1872         pointer_size     => sub { return vms_info(0)->{pointer_size} },
1873         #as               => "???",
1874         #debug_aflags     => "/NOOPTIMIZE/DEBUG",
1875         #release_aflags   => "/OPTIMIZE/NODEBUG",
1876         bn_opts          => "SIXTY_FOUR_BIT RC4_INT",
1877     },
1878     "vms-alpha-p32" => {
1879         inherit_from     => [ "vms-generic" ],
1880         cflags           =>
1881             add("/POINTER_SIZE=32",
1882                 sub { my @warnings =
1883                           @{vms_info(32)->{disable_warns}};
1884                       @warnings
1885                           ? "/WARNINGS=DISABLE=(".join(",",@warnings).")" : ();
1886                 } ),
1887         defines          =>
1888                     add(sub {
1889                             return vms_info(32)->{def_zlib}
1890                                 ? "LIBZ=\"\"\"".vms_info(32)->{def_zlib}."\"\"\"" : ();
1891                             }),
1892         ex_libs          => add(sub { return vms_info(32)->{zlib} || (); }),
1893         pointer_size     => sub { return vms_info(32)->{pointer_size} },
1894     },
1895     "vms-alpha-p64" => {
1896         inherit_from     => [ "vms-generic" ],
1897         cflags           =>
1898             add("/POINTER_SIZE=64=ARGV",
1899                 sub { my @warnings =
1900                           @{vms_info(64)->{disable_warns}};
1901                       @warnings
1902                           ? "/WARNINGS=DISABLE=(".join(",",@warnings).")" : ();
1903                 } ),
1904         defines          =>
1905                     add(sub {
1906                             return vms_info(64)->{def_zlib}
1907                                 ? "LIBZ=\"\"\"".vms_info(64)->{def_zlib}."\"\"\"" : ();
1908                             }),
1909         ex_libs          => add(sub { return vms_info(64)->{zlib} || (); }),
1910         pointer_size     => sub { return vms_info(64)->{pointer_size} },
1911     },
1912     "vms-ia64" => {
1913         inherit_from     => [ "vms-generic" ],
1914         cflags           => add(sub { my @warnings =
1915                                           @{vms_info(0)->{disable_warns}};
1916                                       @warnings
1917                                           ? "/WARNINGS=DISABLE=(".join(",",@warnings).")" : (); }),
1918         defines          =>
1919                     add(sub {
1920                             return vms_info(0)->{def_zlib}
1921                                 ? "LIBZ=\"\"\"".vms_info(0)->{def_zlib}."\"\"\"" : ();
1922                             }),
1923         ex_libs          => add(sub { return vms_info(0)->{zlib} || (); }),
1924         pointer_size     => sub { return vms_info(0)->{pointer_size} },
1925         #as               => "I4S",
1926         #debug_aflags     => "/NOOPTIMIZE/DEBUG",
1927         #release_aflags   => "/OPTIMIZE/NODEBUG",
1928         bn_opts          => "SIXTY_FOUR_BIT RC4_INT",
1929     },
1930     "vms-ia64-p32" => {
1931         inherit_from     => [ "vms-generic" ],
1932         cflags           =>
1933             add("/POINTER_SIZE=32",
1934                 sub { my @warnings =
1935                           @{vms_info(32)->{disable_warns}};
1936                       @warnings
1937                           ? "/WARNINGS=DISABLE=(".join(",",@warnings).")" : ();
1938                 } ),
1939         defines          =>
1940                     add(sub {
1941                             return vms_info(32)->{def_zlib}
1942                                 ? "LIBZ=\"\"\"".vms_info(32)->{def_zlib}."\"\"\"" : ();
1943                             }),
1944         ex_libs          => add(sub { return vms_info(32)->{zlib} || (); }),
1945         pointer_size     => sub { return vms_info(32)->{pointer_size} },
1946     },
1947     "vms-ia64-p64" => {
1948         inherit_from     => [ "vms-generic" ],
1949         cflags           =>
1950             add("/POINTER_SIZE=64=ARGV",
1951                 sub { my @warnings =
1952                           @{vms_info(64)->{disable_warns}};
1953                       @warnings
1954                           ? "/WARNINGS=DISABLE=(".join(",",@warnings).")" : ();
1955                 } ),
1956         defines          =>
1957                     add(sub {
1958                             return vms_info(64)->{def_zlib}
1959                                 ? "LIBZ=\"\"\"".vms_info(64)->{def_zlib}."\"\"\"" : ();
1960                             }),
1961         ex_libs          => add(sub { return vms_info(64)->{zlib} || (); }),
1962         pointer_size     => sub { return vms_info(64)->{pointer_size} },
1963     },
1964
1965 );