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