Complain if there are missing symbols when creating a provider .so file
[openssl.git] / Configurations / shared-info.pl
1 #! /usr/bin/env perl
2 # -*- mode: perl; -*-
3 # Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved.
4 #
5 # Licensed under the Apache License 2.0 (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}$config{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}$config{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             dso_ldflags       => '-z defs',
36         };
37     },
38     'bsd-gcc-shared' => sub { return $shared_info{'linux-shared'}; },
39     'bsd-shared' => sub {
40         return $shared_info{'gnu-shared'} if detect_gnu_ld();
41         return {
42             shared_ldflag     => '-shared -nostdlib',
43         };
44     },
45     'darwin-shared' => {
46         module_ldflags        => '-bundle',
47         shared_ldflag         => '-dynamiclib -current_version $(SHLIB_VERSION_NUMBER) -compatibility_version $(SHLIB_VERSION_NUMBER)',
48         shared_sonameflag     => '-install_name $(INSTALLTOP)/$(LIBDIR)/',
49     },
50     'cygwin-shared' => {
51         shared_ldflag         => '-shared -Wl,--enable-auto-image-base',
52         shared_impflag        => '-Wl,--out-implib=',
53     },
54     'mingw-shared' => sub {
55         return {
56             %{$shared_info{'cygwin-shared'}},
57             # def_flag made to empty string so it still generates
58             # something
59             shared_defflag    => '',
60         };
61     },
62     'alpha-osf1-shared' => sub {
63         return $shared_info{'gnu-shared'} if detect_gnu_ld();
64         return {
65             module_ldflags    => '-shared -Wl,-Bsymbolic',
66             shared_ldflag     => '-shared -Wl,-Bsymbolic -set_version $(SHLIB_VERSION_NUMBER)',
67         };
68     },
69     'svr3-shared' => sub {
70         return $shared_info{'gnu-shared'} if detect_gnu_ld();
71         return {
72             shared_ldflag     => '-G',
73             shared_sonameflag => '-h ',
74         };
75     },
76     'svr5-shared' => sub {
77         return $shared_info{'gnu-shared'} if detect_gnu_ld();
78         return {
79             shared_ldflag     => detect_gnu_cc() ? '-shared' : '-G',
80             shared_sonameflag => '-h ',
81         };
82     },
83 );