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