Restore makedepend capabilities for Windows and VMS
[openssl.git] / Configurations / shared-info.pl
1 #! /usr/bin/env perl
2 # -*- mode: perl; -*-
3 # Copyright 2016-2017 The OpenSSL Project Authors. All Rights Reserved.
4 #
5 # Licensed under the OpenSSL license (the "License").  You may not use
6 # this file except in compliance with the License.  You can obtain a copy
7 # in the file LICENSE in the source distribution or at
8 # https://www.openssl.org/source/license.html
9
10 # This is a collection of extra attributes to be used as input for creating
11 # shared libraries, currently on any Unix variant, including Unix like
12 # environments on Windows.
13
14 sub detect_gnu_ld {
15     my @lines =
16         `$config{cross_compile_prefix}$target{cc} -Wl,-V /dev/null 2>&1`;
17     return grep /^GNU ld/, @lines;
18 }
19 sub detect_gnu_cc {
20     my @lines =
21         `$config{cross_compile_prefix}$target{cc} -v 2>&1`;
22     return grep /gcc/, @lines;
23 }
24
25 my %shared_info;
26 %shared_info = (
27     'gnu-shared' => {
28         shared_ldflag         => '-shared -Wl,-Bsymbolic',
29         shared_sonameflag     => '-Wl,-soname=',
30     },
31     'linux-shared' => sub {
32         return {
33             %{$shared_info{'gnu-shared'}},
34             shared_defflag    => '-Wl,--version-script=',
35         };
36     },
37     'bsd-gcc-shared' => sub { return $shared_info{'linux-shared'}; },
38     'bsd-shared' => sub {
39         return $shared_info{'gnu-shared'} if detect_gnu_ld();
40         return {
41             shared_ldflag     => '-shared -nostdlib',
42         };
43     },
44     'darwin-shared' => {
45         dso_lflags            => '-bundle',
46         shared_ldflag         => '-dynamiclib -current_version $(SHLIB_VERSION_NUMBER) -compatibility_version $(SHLIB_VERSION_NUMBER)',
47         shared_sonameflag     => '-install_name $(INSTALLTOP)/$(LIBDIR)/',
48     },
49     'cygwin-shared' => {
50         shared_ldflag         => '-shared -Wl,--enable-auto-image-base',
51         shared_impflag        => '-Wl,--out-implib=',
52     },
53     'mingw-shared' => sub {
54         return {
55             %{$shared_info{'cygwin-shared'}},
56             # def_flag made to empty string so  it still generates
57             # something
58             shared_defflag    => '',
59         };
60     },
61     'alpha-osf1-shared' => sub {
62         return $shared_info{'gnu-shared'} if detect_gnu_ld();
63         return {
64             dso_lflags        => '-shared -Wl,-Bsymbolic',
65             shared_ldflag     => '-shared -Wl,-Bsymbolic -set_version $(SHLIB_VERSION_NUMBER)',
66         };
67     },
68     'solaris-shared' => {
69         shared_ldflag     => '-Wl,-Bsymbolic',
70         shared_defflag    => '-Wl,-M,',
71     },
72     'svr3-shared' => sub {
73         return $shared_info{'gnu-shared'} if detect_gnu_ld();
74         return {
75             shared_ldflag     => '-G',
76             shared_sonameflag => '-h ',
77         };
78     },
79     'svr5-shared' => sub {
80         return $shared_info{'gnu-shared'} if detect_gnu_ld();
81         return {
82             shared_ldflag     => detect_gnu_cc() ? '-shared' : '-G',
83             shared_sonameflag => '-h ',
84         };
85     },
86     'irix-shared' => sub {
87         return $shared_info{'gnu-shared'} if detect_gnu_ld();
88         return {
89             shared_ldflag     => '-shared -Wl,-Bsymbolic',
90             shared_sonameflag => '-Wl,-soname=',
91         };
92     },
93     'hpux-shared' => {
94         bin_lflags        => '-Wl,+s,+cdp,../:,+cdp,./:',
95         shared_ldflag     => '-Wl,-B,symbolic,+vnocompatwarnings,-z,+s,+cdp,../:,+cdp,./:',
96         shared_sonameflag => '-Wl,+h,',
97     },
98     'aix-shared' => {
99         bin_lflags            => '-Wl,-bsvr4',
100         shared_ldflag         => '-Wl,-bexpall,-bnolibpath,-bM:SRE',
101     },
102 );