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