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