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