]>
Commit | Line | Data |
---|---|---|
793077d0 RL |
1 | #! /usr/bin/env perl |
2 | # -*- mode: perl; -*- | |
6738bf14 | 3 | # Copyright 2016-2018 The OpenSSL Project Authors. All Rights Reserved. |
793077d0 | 4 | # |
402dd558 | 5 | # Licensed under the Apache License 2.0 (the "License"). You may not use |
793077d0 RL |
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 = | |
abe256e7 | 16 | `$config{CROSS_COMPILE}$config{CC} -Wl,-V /dev/null 2>&1`; |
793077d0 RL |
17 | return grep /^GNU ld/, @lines; |
18 | } | |
19 | sub detect_gnu_cc { | |
20 | my @lines = | |
abe256e7 | 21 | `$config{CROSS_COMPILE}$config{CC} -v 2>&1`; |
793077d0 RL |
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=', | |
72eb100f | 35 | dso_ldflags => |
54af7f55 RL |
36 | (grep /(?:^|\s)-fsanitize/, |
37 | @{$config{CFLAGS}}, @{$config{cflags}}) | |
ad37edce RL |
38 | ? '' |
39 | : '-z defs', | |
793077d0 RL |
40 | }; |
41 | }, | |
42 | 'bsd-gcc-shared' => sub { return $shared_info{'linux-shared'}; }, | |
43 | 'bsd-shared' => sub { | |
44 | return $shared_info{'gnu-shared'} if detect_gnu_ld(); | |
45 | return { | |
46 | shared_ldflag => '-shared -nostdlib', | |
47 | }; | |
48 | }, | |
49 | 'darwin-shared' => { | |
48dcca26 | 50 | module_ldflags => '-bundle', |
793077d0 RL |
51 | shared_ldflag => '-dynamiclib -current_version $(SHLIB_VERSION_NUMBER) -compatibility_version $(SHLIB_VERSION_NUMBER)', |
52 | shared_sonameflag => '-install_name $(INSTALLTOP)/$(LIBDIR)/', | |
53 | }, | |
54 | 'cygwin-shared' => { | |
55 | shared_ldflag => '-shared -Wl,--enable-auto-image-base', | |
56 | shared_impflag => '-Wl,--out-implib=', | |
57 | }, | |
58 | 'mingw-shared' => sub { | |
59 | return { | |
60 | %{$shared_info{'cygwin-shared'}}, | |
ef2dfc99 | 61 | # def_flag made to empty string so it still generates |
793077d0 RL |
62 | # something |
63 | shared_defflag => '', | |
64 | }; | |
65 | }, | |
66 | 'alpha-osf1-shared' => sub { | |
67 | return $shared_info{'gnu-shared'} if detect_gnu_ld(); | |
68 | return { | |
48dcca26 | 69 | module_ldflags => '-shared -Wl,-Bsymbolic', |
793077d0 RL |
70 | shared_ldflag => '-shared -Wl,-Bsymbolic -set_version $(SHLIB_VERSION_NUMBER)', |
71 | }; | |
72 | }, | |
793077d0 RL |
73 | 'svr3-shared' => sub { |
74 | return $shared_info{'gnu-shared'} if detect_gnu_ld(); | |
75 | return { | |
76 | shared_ldflag => '-G', | |
77 | shared_sonameflag => '-h ', | |
78 | }; | |
79 | }, | |
80 | 'svr5-shared' => sub { | |
81 | return $shared_info{'gnu-shared'} if detect_gnu_ld(); | |
82 | return { | |
83 | shared_ldflag => detect_gnu_cc() ? '-shared' : '-G', | |
84 | shared_sonameflag => '-h ', | |
85 | }; | |
86 | }, | |
793077d0 | 87 | ); |