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