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