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