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