2
0

shared-info.pl 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #! /usr/bin/env perl
  2. # -*- mode: perl; -*-
  3. # Copyright 2016-2018 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. # This is a collection of extra attributes to be used as input for creating
  10. # shared libraries, currently on any Unix variant, including Unix like
  11. # environments on Windows.
  12. sub detect_gnu_ld {
  13. my @lines =
  14. `$config{CROSS_COMPILE}$config{CC} -Wl,-V /dev/null 2>&1`;
  15. return grep /^GNU ld/, @lines;
  16. }
  17. sub detect_gnu_cc {
  18. my @lines =
  19. `$config{CROSS_COMPILE}$config{CC} -v 2>&1`;
  20. return grep /gcc/, @lines;
  21. }
  22. my %shared_info;
  23. %shared_info = (
  24. 'gnu-shared' => {
  25. shared_ldflag => '-shared -Wl,-Bsymbolic',
  26. shared_sonameflag => '-Wl,-soname=',
  27. },
  28. 'linux-shared' => sub {
  29. return {
  30. %{$shared_info{'gnu-shared'}},
  31. shared_defflag => '-Wl,--version-script=',
  32. };
  33. },
  34. 'bsd-gcc-shared' => sub { return $shared_info{'linux-shared'}; },
  35. 'bsd-shared' => sub {
  36. return $shared_info{'gnu-shared'} if detect_gnu_ld();
  37. return {
  38. shared_ldflag => '-shared -nostdlib',
  39. };
  40. },
  41. 'darwin-shared' => {
  42. module_ldflags => '-bundle',
  43. shared_ldflag => '-dynamiclib -current_version $(SHLIB_VERSION_NUMBER) -compatibility_version $(SHLIB_VERSION_NUMBER)',
  44. shared_sonameflag => '-install_name $(INSTALLTOP)/$(LIBDIR)/',
  45. },
  46. 'cygwin-shared' => {
  47. shared_ldflag => '-shared -Wl,--enable-auto-image-base',
  48. shared_impflag => '-Wl,--out-implib=',
  49. },
  50. 'mingw-shared' => sub {
  51. return {
  52. %{$shared_info{'cygwin-shared'}},
  53. # def_flag made to empty string so it still generates
  54. # something
  55. shared_defflag => '',
  56. };
  57. },
  58. 'alpha-osf1-shared' => sub {
  59. return $shared_info{'gnu-shared'} if detect_gnu_ld();
  60. return {
  61. module_ldflags => '-shared -Wl,-Bsymbolic',
  62. shared_ldflag => '-shared -Wl,-Bsymbolic -set_version $(SHLIB_VERSION_NUMBER)',
  63. };
  64. },
  65. 'svr3-shared' => sub {
  66. return $shared_info{'gnu-shared'} if detect_gnu_ld();
  67. return {
  68. shared_ldflag => '-G',
  69. shared_sonameflag => '-h ',
  70. };
  71. },
  72. 'svr5-shared' => sub {
  73. return $shared_info{'gnu-shared'} if detect_gnu_ld();
  74. return {
  75. shared_ldflag => detect_gnu_cc() ? '-shared' : '-G',
  76. shared_sonameflag => '-h ',
  77. };
  78. },
  79. );