53ba0409db1fc2c9fce7416760a84e2b08aa274c
[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   => "elf",
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       => "/Zl /Zi /Fdlib",
1242         dso_cflags       => "/Zi",
1243         bin_cflags       => "/Zi /Fdapp",
1244         lflags           => add("/debug"),
1245         shared_cflag     => "-D_WINDLL",
1246         shared_ldflag    => "/dll",
1247         shared_target    => "win-shared", # meaningless except it gives Configure a hint
1248         thread_scheme    => "winthreads",
1249         dso_scheme       => "win32",
1250     },
1251     "VC-noCE-common" => {
1252         inherit_from     => [ "VC-common", "uplink_common" ],
1253         cflags           => add(picker(default => "-DUNICODE -D_UNICODE",
1254                                        debug   =>
1255                                        sub {
1256                                            ($disabled{shared} ? "/MT" : "/MD")
1257                                                ."d /Od -DDEBUG -D_DEBUG";
1258                                        },
1259                                        release =>
1260                                        sub {
1261                                            ($disabled{shared} ? "/MT" : "/MD")
1262                                                ." /Ox /O2 /Ob2";
1263                                        })),
1264         bin_lflags       => add("/subsystem:console /opt:ref"),
1265         ex_libs          => sub {
1266             my @ex_libs = ();
1267             push @ex_libs, 'ws2_32.lib' unless $disabled{sock};
1268             push @ex_libs, 'gdi32.lib advapi32.lib crypt32.lib user32.lib';
1269             return join(" ", @ex_libs);
1270         },
1271     },
1272     "VC-WIN64-common" => {
1273         inherit_from     => [ "VC-noCE-common" ],
1274         ex_libs          => sub {
1275             my @ex_libs = ();
1276             push @ex_libs, 'bufferoverflowu.lib' if (`cl 2>&1` =~ /14\.00\.4[0-9]{4}\./);
1277             return join(" ", @_, @ex_libs);
1278         },
1279         bn_ops           => "SIXTY_FOUR_BIT EXPORT_VAR_AS_FN",
1280         build_scheme     => add("VC-W64", { separator => undef }),
1281     },
1282     "VC-WIN64I" => {
1283         inherit_from     => [ "VC-WIN64-common", asm("ia64_asm") ],
1284         as               => "ias",
1285         asflags          => "-d debug",
1286         asoutflag        => "-o",
1287         sys_id           => "WIN64I",
1288         rc4_asm_src      => "",
1289         perlasm_scheme   => "ias",
1290     },
1291     "VC-WIN64A" => {
1292         inherit_from     => [ "VC-WIN64-common", asm("x86_64_asm") ],
1293         as               => sub { vc_win64a_info()->{as} },
1294         asflags          => sub { vc_win64a_info()->{asflags} },
1295         asoutflag        => sub { vc_win64a_info()->{asoutflag} },
1296         sys_id           => "WIN64A",
1297         bn_asm_src       => sub { return undef unless @_;
1298                                   my $r=join(" ",@_); $r=~s|asm/x86_64-gcc|bn_asm|; $r; },
1299         perlasm_scheme   => "auto",
1300     },
1301     "VC-WIN32" => {
1302         # x86 Win32 target defaults to ANSI API, if you want UNICODE,
1303         # configure with 'perl Configure VC-WIN32 -DUNICODE -D_UNICODE'
1304         inherit_from     => [ "VC-noCE-common", asm("x86_asm") ],
1305         as               => sub { my $ver=`nasm -v 2>NUL`;
1306                                   my $vew=`nasmw -v 2>NUL`;
1307                                   return $ver ge $vew ? "nasm" : "nasmw" },
1308         asflags          => "-f win32",
1309         asoutflag        => "-o",
1310         ex_libs          => sub {
1311             my @ex_libs = ();
1312             # WIN32 UNICODE build gets linked with unicows.lib for
1313             # backward compatibility with Win9x.
1314             push @ex_libs, 'unicows.lib'
1315                 if (grep { $_ eq "UNICODE" } @user_defines);
1316             return join(" ", @ex_libs, @_);
1317         },
1318         sys_id           => "WIN32",
1319         bn_ops           => "BN_LLONG EXPORT_VAR_AS_FN",
1320         perlasm_scheme   => "win32n",
1321         build_scheme     => add("VC-W32", { separator => undef }),
1322     },
1323     "VC-CE" => {
1324         inherit_from     => [ "VC-common" ],
1325         as               => "ml",
1326         asflags          => "/nologo /Cp /coff /c /Cx /Zi",
1327         asoutflag        => "/Fo",
1328         cc               => "cl",
1329         cflags           =>
1330             picker(default =>
1331                    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',
1332                            sub { vc_wince_info()->{cflags}; },
1333                            sub { defined($ENV{'WCECOMPAT'})
1334                                      ? '-I$(WCECOMPAT)/include' : (); },
1335                            sub { defined($ENV{'PORTSDK_LIBPATH'})
1336                                      ? '-I$(PORTSDK_LIBPATH)/../../include' : (); },
1337                            sub { `cl 2>&1` =~ /Version ([0-9]+)\./ && $1>=14
1338                                      ? ($disabled{shared} ? " /MT" : " /MD")
1339                                      : " /MC"; }),
1340                    debug   => "/Od -DDEBUG -D_DEBUG",
1341                    release => "/O1i"),
1342         lflags           => combine("/nologo /opt:ref",
1343                                     sub { vc_wince_info()->{lflags}; },
1344                                     sub { defined($ENV{PORTSDK_LIBPATH})
1345                                               ? "/entry:mainCRTstartup" : (); }),
1346         sys_id           => "WINCE",
1347         bn_ops           => "BN_LLONG EXPORT_VAR_AS_FN",
1348         ex_libs          => sub {
1349             my @ex_libs = ();
1350             push @ex_libs, 'ws2.lib' unless $disabled{sock};
1351             push @ex_libs, 'crypt32.lib';
1352             if (defined($ENV{WCECOMPAT})) {
1353                 my $x = '$(WCECOMPAT)/lib';
1354                 if (-f "$x/$ENV{TARGETCPU}/wcecompatex.lib") {
1355                     $x .= '/$(TARGETCPU)/wcecompatex.lib';
1356                 } else {
1357                     $x .= '/wcecompatex.lib';
1358                 }
1359                 push @ex_libs, $x;
1360             }
1361             push @ex_libs, '$(PORTSDK_LIBPATH)/portlib.lib'
1362                 if (defined($ENV{'PORTSDK_LIBPATH'}));
1363             push @ex_libs, ' /nodefaultlib coredll.lib corelibc.lib'
1364                 if ($ENV{'TARGETCPU'} eq "X86");
1365             return @ex_libs;
1366         },
1367         build_scheme     => add("VC-WCE", { separator => undef }),
1368     },
1369
1370 ###### Borland C++ 4.5
1371 ##    "BC-32" => {
1372 ##        inherit_from     => [ "BASE_Windows" ],
1373 ##        cc               => "bcc32",
1374 ##        sys_id           => "WIN32",
1375 ##        bn_ops           => "BN_LLONG EXPORT_VAR_AS_FN",
1376 ##        dso_scheme       => "win32",
1377 ##        build_scheme     => add("BC", { separator => undef }),
1378 ##    },
1379
1380 #### MinGW
1381     "mingw" => {
1382         inherit_from     => [ "BASE_unix", asm("x86_asm"),
1383                               sub { $disabled{shared} ? () : "x86_uplink" } ],
1384         cc               => "gcc",
1385         cflags           => combine(picker(default => "-DL_ENDIAN -DWIN32_LEAN_AND_MEAN -DUNICODE -D_UNICODE -m32 -Wall",
1386                                            debug   => "-g -O0",
1387                                            release => "-O3 -fomit-frame-pointer"),
1388                                     threads("-D_MT")),
1389         sys_id           => "MINGW32",
1390         ex_libs          => add("-lws2_32 -lgdi32 -lcrypt32"),
1391         bn_ops           => "BN_LLONG EXPORT_VAR_AS_FN",
1392         thread_scheme    => "winthreads",
1393         perlasm_scheme   => "coff",
1394         dso_scheme       => "win32",
1395         shared_target    => "mingw-shared",
1396         shared_cflag     => add("-D_WINDLL"),
1397         shared_ldflag    => "-static-libgcc",
1398         shared_rcflag    => "--target=pe-i386",
1399         shared_extension => ".dll",
1400         multilib         => "",
1401     },
1402     "mingw64" => {
1403         # As for OPENSSL_USE_APPLINK. Applink makes it possible to use
1404         # .dll compiled with one compiler with application compiled with
1405         # another compiler. It's possible to engage Applink support in
1406         # mingw64 build, but it's not done, because till mingw64
1407         # supports structured exception handling, one can't seriously
1408         # consider its binaries for using with non-mingw64 run-time
1409         # environment. And as mingw64 is always consistent with itself,
1410         # Applink is never engaged and can as well be omitted.
1411         inherit_from     => [ "BASE_unix", asm("x86_64_asm") ],
1412         cc               => "gcc",
1413         cflags           => combine(picker(default => "-DL_ENDIAN -DWIN32_LEAN_AND_MEAN -DUNICODE -D_UNICODE -m64 -Wall",
1414                                            debug   => "-g -O0",
1415                                            release => "-O3"),
1416                                     threads("-D_MT")),
1417         sys_id           => "MINGW64",
1418         ex_libs          => add("-lws2_32 -lgdi32 -lcrypt32"),
1419         bn_ops           => "SIXTY_FOUR_BIT EXPORT_VAR_AS_FN",
1420         thread_scheme    => "winthreads",
1421         perlasm_scheme   => "mingw64",
1422         dso_scheme       => "win32",
1423         shared_target    => "mingw-shared",
1424         shared_cflag     => add("-D_WINDLL"),
1425         shared_ldflag    => "-static-libgcc",
1426         shared_rcflag    => "--target=pe-x86-64",
1427         shared_extension => ".dll",
1428         multilib         => "64",
1429     },
1430
1431 #### UEFI
1432     "UEFI" => {
1433         inherit_from     => [ "BASE_unix" ],
1434         cc               => "cc",
1435         cflags           => "-DL_ENDIAN -O",
1436         sys_id           => "UEFI",
1437     },
1438
1439 #### UWIN
1440     "UWIN" => {
1441         inherit_from     => [ "BASE_unix" ],
1442         cc               => "cc",
1443         cflags           => "-DTERMIOS -DL_ENDIAN -O -Wall",
1444         sys_id           => "UWIN",
1445         bn_ops           => "BN_LLONG",
1446         dso_scheme       => "win32",
1447     },
1448
1449 #### Cygwin
1450     "Cygwin-x86" => {
1451         inherit_from     => [ "BASE_unix", asm("x86_asm") ],
1452         cc               => "gcc",
1453         cflags           => picker(default => "-DTERMIOS -DL_ENDIAN -Wall",
1454                                    debug   => "-g -O0",
1455                                    release => "-O3 -fomit-frame-pointer"),
1456         sys_id           => "CYGWIN",
1457         bn_ops           => "BN_LLONG",
1458         thread_scheme    => "pthread",
1459         perlasm_scheme   => "coff",
1460         dso_scheme       => "dlfcn",
1461         shared_target    => "cygwin-shared",
1462         shared_cflag     => "-D_WINDLL",
1463         shared_ldflag    => "-shared",
1464         shared_extension => ".dll",
1465     },
1466     "Cygwin-x86_64" => {
1467         inherit_from     => [ "BASE_unix", asm("x86_64_asm") ],
1468         cc               => "gcc",
1469         cflags           => picker(default => "-DTERMIOS -DL_ENDIAN -Wall",
1470                                    debug   => "-g -O0",
1471                                    release => "-O3"),
1472         sys_id           => "CYGWIN",
1473         bn_ops           => "SIXTY_FOUR_BIT_LONG",
1474         thread_scheme    => "pthread",
1475         perlasm_scheme   => "mingw64",
1476         dso_scheme       => "dlfcn",
1477         shared_target    => "cygwin-shared",
1478         shared_cflag     => "-D_WINDLL",
1479         shared_ldflag    => "-shared",
1480         shared_extension => ".dll",
1481     },
1482     # Backward compatibility for those using this target
1483     "Cygwin" => {
1484         inherit_from     => [ "Cygwin-x86" ]
1485     },
1486     # In case someone constructs the Cygwin target name themself
1487     "Cygwin-i386" => {
1488         inherit_from     => [ "Cygwin-x86" ]
1489     },
1490     "Cygwin-i486" => {
1491         inherit_from     => [ "Cygwin-x86" ]
1492     },
1493     "Cygwin-i586" => {
1494         inherit_from     => [ "Cygwin-x86" ]
1495     },
1496     "Cygwin-i686" => {
1497         inherit_from     => [ "Cygwin-x86" ]
1498     },
1499
1500 #### NetWare from David Ward (dsward@novell.com)
1501 # requires either MetroWerks NLM development tools, or gcc / nlmconv
1502 # NetWare defaults socket bio to WinSock sockets. However,
1503 # the builds can be configured to use BSD sockets instead.
1504 # netware-clib => legacy CLib c-runtime support
1505     "netware-clib" => {
1506         inherit_from     => [ "BASE_Windows" ],
1507         cc               => "mwccnlm",
1508         build_scheme     => add("netware", { separator => undef }),
1509     },
1510     "netware-clib-bsdsock" => {
1511         inherit_from     => [ "BASE_Windows" ],
1512         cc               => "mwccnlm",
1513         build_scheme     => add("netware", { separator => undef }),
1514     },
1515     "netware-clib-gcc" => {
1516         inherit_from     => [ "BASE_unix" ],
1517         cc               => "i586-netware-gcc",
1518         cflags           => "-nostdinc -I/ndk/nwsdk/include/nlm -I/ndk/ws295sdk/include -DL_ENDIAN -DNETWARE_CLIB -DOPENSSL_SYS_NETWARE -O2 -Wall",
1519     },
1520     "netware-clib-bsdsock-gcc" => {
1521         inherit_from     => [ "BASE_unix" ],
1522         cc               => "i586-netware-gcc",
1523         cflags           => "-nostdinc -I/ndk/nwsdk/include/nlm -DNETWARE_BSDSOCK -DNETDB_USE_INTERNET -DL_ENDIAN -DNETWARE_CLIB -DOPENSSL_SYS_NETWARE -O2 -Wall",
1524     },
1525     # netware-libc => LibC/NKS support
1526     "netware-libc" => {
1527         inherit_from     => [ "BASE_Windows" ],
1528         cc               => "mwccnlm",
1529         bn_ops           => "BN_LLONG",
1530         build_scheme     => add("netware", { separator => undef }),
1531     },
1532     "netware-libc-bsdsock" => {
1533         inherit_from     => [ "BASE_Windows" ],
1534         cc               => "mwccnlm",
1535         bn_ops           => "BN_LLONG",
1536         build_scheme     => add("netware", { separator => undef }),
1537     },
1538     "netware-libc-gcc" => {
1539         inherit_from     => [ "BASE_unix" ],
1540         cc               => "i586-netware-gcc",
1541         cflags           => "-nostdinc -I/ndk/libc/include -I/ndk/libc/include/winsock -DL_ENDIAN -DNETWARE_LIBC -DOPENSSL_SYS_NETWARE -DTERMIO -O2 -Wall",
1542         bn_ops           => "BN_LLONG",
1543     },
1544     "netware-libc-bsdsock-gcc" => {
1545         inherit_from     => [ "BASE_unix" ],
1546         cc               => "i586-netware-gcc",
1547         cflags           => "-nostdinc -I/ndk/libc/include -DNETWARE_BSDSOCK -DL_ENDIAN -DNETWARE_LIBC -DOPENSSL_SYS_NETWARE -DTERMIO -O2 -Wall",
1548         bn_ops           => "BN_LLONG",
1549     },
1550
1551 #### DJGPP
1552     "DJGPP" => {
1553         inherit_from     => [ asm("x86_asm") ],
1554         cc               => "gcc",
1555         cflags           => "-I/dev/env/WATT_ROOT/inc -DTERMIO -DL_ENDIAN -fomit-frame-pointer -O2 -Wall",
1556         sys_id           => "MSDOS",
1557         ex_libs          => add("-L/dev/env/WATT_ROOT/lib -lwatt"),
1558         bn_ops           => "BN_LLONG",
1559         perlasm_scheme   => "a.out",
1560     },
1561
1562 #### Ultrix from Bernhard Simon <simon@zid.tuwien.ac.at>
1563     "ultrix-cc" => {
1564         inherit_from     => [ "BASE_unix" ],
1565         cc               => "cc",
1566         cflags           => "-std1 -O -Olimit 2500 -DL_ENDIAN",
1567         thread_scheme    => "(unknown)",
1568     },
1569     "ultrix-gcc" => {
1570         inherit_from     => [ "BASE_unix" ],
1571         cc               => "gcc",
1572         cflags           => "-O3 -DL_ENDIAN",
1573         bn_ops           => "BN_LLONG",
1574         thread_scheme    => "(unknown)",
1575     },
1576 # K&R C is no longer supported; you need gcc on old Ultrix installations
1577 ##"ultrix","cc:-O2 -DNOPROTO -DNOCONST -DL_ENDIAN::(unknown):::::::",
1578
1579 ##### MacOS X (a.k.a. Darwin) setup
1580     "darwin-common" => {
1581         inherit_from     => [ "BASE_unix" ],
1582         template         => 1,
1583         cc               => "cc",
1584         cflags           => combine(picker(default => "",
1585                                            debug   => "-g -O0",
1586                                            release => "-O3"),
1587                                    threads("-D_REENTRANT")),
1588         sys_id           => "MACOSX",
1589         plib_lflags      => "-Wl,-search_paths_first",
1590         bn_ops           => "BN_LLONG RC4_CHAR",
1591         thread_scheme    => "pthreads",
1592         perlasm_scheme   => "osx32",
1593         dso_scheme       => "dlfcn",
1594         ranlib           => "ranlib -c",
1595         shared_target    => "darwin-shared",
1596         shared_cflag     => "-fPIC",
1597         shared_ldflag    => "-dynamiclib",
1598         shared_extension => ".\$(SHLIB_MAJOR).\$(SHLIB_MINOR).dylib",
1599     },
1600     "darwin-ppc-cc" => {
1601         inherit_from     => [ "darwin-common", asm("ppc32_asm") ],
1602         cflags           => add("-arch ppc -DB_ENDIAN -Wa,-force_cpusubtype_ALL"),
1603         perlasm_scheme   => "osx32",
1604         shared_ldflag    => "-arch ppc -dynamiclib",
1605     },
1606     "darwin64-ppc-cc" => {
1607         inherit_from     => [ "darwin-common", asm("ppc64_asm") ],
1608         cflags           => add("-arch ppc64 -DB_ENDIAN"),
1609         bn_ops           => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
1610         perlasm_scheme   => "osx64",
1611         shared_ldflag    => "-arch ppc64 -dynamiclib",
1612     },
1613     "darwin-i386-cc" => {
1614         inherit_from     => [ "darwin-common", asm("x86_asm") ],
1615         cflags           => add(picker(default => "-arch i386 -DL_ENDIAN",
1616                                        release => "-fomit-frame-pointer")),
1617         bn_ops           => "BN_LLONG RC4_INT",
1618         perlasm_scheme   => "macosx",
1619         shared_ldflag    => "-arch i386 -dynamiclib",
1620     },
1621     "darwin64-x86_64-cc" => {
1622         inherit_from     => [ "darwin-common", asm("x86_64_asm") ],
1623         cflags           => add("-arch x86_64 -DL_ENDIAN -Wall"),
1624         bn_ops           => "SIXTY_FOUR_BIT_LONG",
1625         perlasm_scheme   => "macosx",
1626         shared_ldflag    => "-arch x86_64 -dynamiclib",
1627     },
1628
1629 #### iPhoneOS/iOS
1630 #
1631 # It takes three prior-set environment variables to make it work:
1632 #
1633 # CROSS_COMPILE=/where/toolchain/is/usr/bin/ [note ending slash]
1634 # CROSS_TOP=/where/SDKs/are
1635 # CROSS_SDK=iPhoneOSx.y.sdk
1636 #
1637 # Exact paths vary with Xcode releases, but for couple of last ones
1638 # they would look like this:
1639 #
1640 # CROSS_COMPILE=`xcode-select --print-path`/Toolchains/XcodeDefault.xctoolchain/usr/bin/
1641 # CROSS_TOP=`xcode-select --print-path`/Platforms/iPhoneOS.platform/Developer
1642 # CROSS_SDK=iPhoneOS.sdk
1643 #
1644     "iphoneos-cross" => {
1645         inherit_from     => [ "darwin-common" ],
1646         cflags           => add("-isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK) -fno-common"),
1647         sys_id           => "iOS",
1648     },
1649     "ios-cross" => {
1650         inherit_from     => [ "darwin-common", asm("armv4_asm") ],
1651         # It should be possible to go below iOS 6 and even add -arch armv6,
1652         # thus targeting iPhone pre-3GS, but it's assumed to be irrelevant
1653         # at this point.
1654         cflags           => add("-arch armv7 -mios-version-min=6.0.0 -isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK) -fno-common"),
1655         sys_id           => "iOS",
1656         perlasm_scheme   => "ios32",
1657     },
1658     "ios64-cross" => {
1659         inherit_from     => [ "darwin-common", asm("aarch64_asm") ],
1660         cflags           => add("-arch arm64 -mios-version-min=7.0.0 -isysroot \$(CROSS_TOP)/SDKs/\$(CROSS_SDK) -fno-common"),
1661         sys_id           => "iOS",
1662         bn_ops           => "SIXTY_FOUR_BIT_LONG RC4_CHAR",
1663         perlasm_scheme   => "ios64",
1664     },
1665
1666 ##### GNU Hurd
1667     "hurd-x86" => {
1668         inherit_from     => [ "BASE_unix" ],
1669         inherit_from     => [ asm("x86_elf_asm") ],
1670         cc               => "gcc",
1671         cflags           => combine("-DL_ENDIAN -O3 -fomit-frame-pointer -Wall",
1672                                     threads("-pthread")),
1673         ex_libs          => add("-ldl"),
1674         bn_ops           => "BN_LLONG",
1675         thread_scheme    => "pthreads",
1676         dso_scheme       => "dlfcn",
1677         shared_target    => "linux-shared",
1678         shared_cflag     => "-fPIC",
1679     },
1680
1681 ##### OS/2 EMX
1682     "OS2-EMX" => {
1683         inherit_from     => [ "BASE_unix" ],
1684         cc               => "gcc",
1685     },
1686
1687 ##### VxWorks for various targets
1688     "vxworks-ppc60x" => {
1689         inherit_from     => [ "BASE_unix" ],
1690         cc               => "ccppc",
1691         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",
1692         sys_id           => "VXWORKS",
1693         ex_libs          => add("-Wl,--defsym,__wrs_rtp_base=0xe0000000 -L \$(WIND_BASE)/target/usr/lib/ppc/PPC32/common"),
1694     },
1695     "vxworks-ppcgen" => {
1696         inherit_from     => [ "BASE_unix" ],
1697         cc               => "ccppc",
1698         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",
1699         sys_id           => "VXWORKS",
1700         ex_libs          => add("-Wl,--defsym,__wrs_rtp_base=0xe0000000 -L \$(WIND_BASE)/target/usr/lib/ppc/PPC32/sfcommon"),
1701     },
1702     "vxworks-ppc405" => {
1703         inherit_from     => [ "BASE_unix" ],
1704         cc               => "ccppc",
1705         cflags           => "-g -msoft-float -mlongcall -DCPU=PPC405 -I\$(WIND_BASE)/target/h",
1706         sys_id           => "VXWORKS",
1707         lflags           => "-r",
1708     },
1709     "vxworks-ppc750" => {
1710         inherit_from     => [ "BASE_unix" ],
1711         cc               => "ccppc",
1712         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)",
1713         sys_id           => "VXWORKS",
1714         lflags           => "-r",
1715     },
1716     "vxworks-ppc750-debug" => {
1717         inherit_from     => [ "BASE_unix" ],
1718         cc               => "ccppc",
1719         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",
1720         sys_id           => "VXWORKS",
1721         lflags           => "-r",
1722     },
1723     "vxworks-ppc860" => {
1724         inherit_from     => [ "BASE_unix" ],
1725         cc               => "ccppc",
1726         cflags           => "-nostdinc -msoft-float -DCPU=PPC860 -DNO_STRINGS_H -I\$(WIND_BASE)/target/h",
1727         sys_id           => "VXWORKS",
1728         lflags           => "-r",
1729     },
1730     "vxworks-simlinux" => {
1731         inherit_from     => [ "BASE_unix" ],
1732         cc               => "ccpentium",
1733         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",
1734         sys_id           => "VXWORKS",
1735         lflags           => "-r",
1736         ranlib           => "ranlibpentium",
1737     },
1738     "vxworks-mips" => {
1739         inherit_from     => [ "BASE_unix", asm("mips32_asm") ],
1740         cc               => "ccmips",
1741         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",
1742                                     threads("-D_REENTRANT")),
1743         sys_id           => "VXWORKS",
1744         ex_libs          => add("-Wl,--defsym,__wrs_rtp_base=0xe0000000 -L \$(WIND_BASE)/target/usr/lib/mips/MIPSI32/sfcommon"),
1745         thread_scheme    => "pthreads",
1746         perlasm_scheme   => "o32",
1747         ranlib           => "ranlibmips",
1748     },
1749
1750 #### uClinux
1751     "uClinux-dist" => {
1752         inherit_from     => [ "BASE_unix" ],
1753         cc               => "$ENV{'CC'}",
1754         cflags           => combine("\$(CFLAGS)",
1755                                     threads("-D_REENTRANT")),
1756         plib_lflags      => "\$(LDFLAGS)",
1757         ex_libs          => add("\$(LDLIBS)"),
1758         bn_ops           => "BN_LLONG",
1759         thread_scheme    => "pthreads",
1760         dso_scheme       => "$ENV{'LIBSSL_dlfcn'}",
1761         shared_target    => "linux-shared",
1762         shared_cflag     => "-fPIC",
1763         shared_ldflag    => "-shared",
1764         shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
1765         ranlib           => "$ENV{'RANLIB'}",
1766     },
1767     "uClinux-dist64" => {
1768         inherit_from     => [ "BASE_unix" ],
1769         cc               => "$ENV{'CC'}",
1770         cflags           => combine("\$(CFLAGS)",
1771                                     threads("-D_REENTRANT")),
1772         plib_lflags      => "\$(LDFLAGS)",
1773         ex_libs          => add("\$(LDLIBS)"),
1774         bn_ops           => "SIXTY_FOUR_BIT_LONG",
1775         thread_scheme    => "pthreads",
1776         dso_scheme       => "$ENV{'LIBSSL_dlfcn'}",
1777         shared_target    => "linux-shared",
1778         shared_cflag     => "-fPIC",
1779         shared_ldflag    => "-shared",
1780         shared_extension => ".so.\$(SHLIB_MAJOR).\$(SHLIB_MINOR)",
1781         ranlib           => "$ENV{'RANLIB'}",
1782     },
1783
1784     ##### VMS
1785     "vms-generic" => {
1786         inherit_from     => [ "BASE_VMS" ],
1787         template         => 1,
1788         cc               => "CC/DECC",
1789         cflags           => picker(default => "/STANDARD=RELAXED/NOLIST/PREFIX=ALL/NAMES=(AS_IS,SHORTENED)",
1790                                    debug   => "/NOOPTIMIZE/DEBUG",
1791                                    release => "/OPTIMIZE/NODEBUG"),
1792         lflags           => picker(default => "/MAP",
1793                                    debug   => "/DEBUG/TRACEBACK",
1794                                    release => "/NODEBUG/NOTRACEBACK"),
1795         shared_target    => "vms-shared",
1796         thread_scheme    => "pthreads",
1797
1798         apps_aux_src     => "vms_decc_init.c",
1799     },
1800
1801     # VMS on VAX is *unsupported*
1802     #"vms-asm" => {
1803     #   template          => 1,
1804     #   bn_obj            => "[.asm]vms.obj vms-helper.obj"
1805     #},
1806     #"vms-vax" => {
1807     #   inherit_from      => [ "vms-generic", asm("vms-asm") ],
1808     #   as                => "MACRO",
1809     #   debug_aflags      => "/NOOPTIMIZE/DEBUG",
1810     #   release_aflags    => "/OPTIMIZE/NODEBUG",
1811     #   bn_opts           => "THIRTY_TWO_BIT RC4_CHAR RC4_CHUNK DES_PTR BF_PTR",
1812     #},
1813     "vms-alpha" => {
1814         inherit_from     => [ "vms-generic" ],
1815         #as               => "???",
1816         #debug_aflags     => "/NOOPTIMIZE/DEBUG",
1817         #release_aflags   => "/OPTIMIZE/NODEBUG",
1818         bn_opts          => "SIXTY_FOUR_BIT RC4_INT RC4_CHUNK_LL DES_PTR BF_PTR",
1819     },
1820     "vms-alpha-P32" => {
1821         inherit_from     => [ "vms-alpha" ],
1822         cflags           => add("/POINTER_SIZE=32"),
1823         ex_libs          => sub { join(",", map { s|SHR([\./])|SHR32$1|g; $_ } @_) },
1824     },
1825     "vms-alpha-P64" => {
1826         inherit_from     => [ "vms-alpha" ],
1827         cflags           => add("/POINTER_SIZE=64"),
1828         ex_libs          => sub { join(",", map { s|SHR([\./])|SHR64$1|g; $_ } @_) },
1829     },
1830     "vms-ia64" => {
1831         inherit_from     => [ "vms-generic" ],
1832         #as               => "I4S",
1833         #debug_aflags     => "/NOOPTIMIZE/DEBUG",
1834         #release_aflags   => "/OPTIMIZE/NODEBUG",
1835         bn_opts          => "SIXTY_FOUR_BIT RC4_INT RC4_CHUNK_LL DES_PTR BF_PTR",
1836     },
1837     "vms-ia64-P32" => {
1838         inherit_from     => [ "vms-ia64" ],
1839         cflags           => add("/POINTER_SIZE=32"),
1840         ex_libs          => sub { join(",", map { s|SHR([\./])|SHR32$1|g; $_ } @_) },
1841     },
1842     "vms-ia64-P64" => {
1843         inherit_from     => [ "vms-ia64" ],
1844         cflags           => add("/POINTER_SIZE=64"),
1845         ex_libs          => sub { join(",", map { s|SHR([\./])|SHR64$1|g; $_ } @_) },
1846     },
1847
1848 );