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