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