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