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