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