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