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