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