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