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