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