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