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