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