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