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