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