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