2
0

Unix.pm 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  1. package platform::Unix;
  2. use strict;
  3. use warnings;
  4. use Carp;
  5. use vars qw(@ISA);
  6. require platform::BASE;
  7. @ISA = qw(platform::BASE);
  8. # Assume someone set @INC right before loading this module
  9. use configdata;
  10. sub binext { $target{exe_extension} || '' }
  11. sub dsoext { $target{dso_extension} || platform->shlibextsimple()
  12. || '.so' }
  13. # Because these are also used in scripts and not just Makefile, we must
  14. # convert $(SHLIB_VERSION_NUMBER) to the actual number.
  15. sub shlibext { (my $x = $target{shared_extension}
  16. || '.so.$(SHLIB_VERSION_NUMBER)')
  17. =~ s|\.\$\(SHLIB_VERSION_NUMBER\)
  18. |.$config{shlib_version}|x;
  19. $x; }
  20. sub libext { $target{lib_extension} || '.a' }
  21. sub defext { $target{def_extension} || '.ld' }
  22. sub objext { $target{obj_extension} || '.o' }
  23. sub depext { $target{obj_extension} || '.d' }
  24. # Other extra that aren't defined in platform::BASE
  25. sub shlibextsimple { (my $x = $target{shared_extension} || '.so')
  26. =~ s|\.\$\(SHLIB_VERSION_NUMBER\)||;
  27. $x; }
  28. sub shlibvariant { $target{shlib_variant} || "" }
  29. sub makedepcmd { $disabled{makedepend} ? undef : $config{makedepcmd} }
  30. # No conversion of assembler extension on Unix
  31. sub asm {
  32. return $_[1];
  33. }
  34. # At some point, we might decide that static libraries are called something
  35. # other than the default...
  36. sub staticname {
  37. # Non-installed libraries are *always* static, and their names remain
  38. # the same, except for the mandatory extension
  39. my $in_libname = platform::BASE->staticname($_[1]);
  40. return $in_libname
  41. if $unified_info{attributes}->{libraries}->{$_[1]}->{noinst};
  42. # We currently return the same name anyway... but we might choose to
  43. # append '_static' or '_a' some time in the future.
  44. return platform::BASE->staticname($_[1]);
  45. }
  46. sub sharedname {
  47. return platform::BASE::__concat(platform::BASE->sharedname($_[1]),
  48. ($_[0]->shlibvariant() // ''));
  49. }
  50. sub sharedname_simple {
  51. return platform::BASE::__isshared($_[1]) ? $_[1] : undef;
  52. }
  53. sub sharedlib_simple {
  54. # This function returns the simplified shared library name (no version
  55. # or variant in the shared library file name) if the simple variants of
  56. # the base name or the suffix differ from the full variants of the same.
  57. # Note: if $_[1] isn't a shared library name, then $_[0]->sharedname()
  58. # and $_[0]->sharedname_simple() will return undef. This needs being
  59. # accounted for.
  60. my $name = $_[0]->sharedname($_[1]);
  61. my $simplename = $_[0]->sharedname_simple($_[1]);
  62. my $ext = $_[0]->shlibext();
  63. # Allow override of the extension passed in as parameter
  64. my $simpleext = $_[2];
  65. $simpleext = $_[0]->shlibextsimple() unless defined $simpleext;
  66. return undef unless defined $simplename && defined $name;
  67. return undef if ($name eq $simplename && $ext eq $simpleext);
  68. return platform::BASE::__concat($simplename, $simpleext);
  69. }
  70. sub sharedlib_import {
  71. return undef;
  72. }
  73. 1;