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