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