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