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