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