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