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