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