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