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