diff options
author | Joey Hess <joey@kitenet.net> | 2011-02-08 15:32:22 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2011-02-08 15:32:22 -0400 |
commit | c51b87a19648c4527a0c6612dd8f1bfbceda812d (patch) | |
tree | 463998575cc40f3a57c172e9b3edca431a1bc443 | |
parent | 7bc99d44cfc0275e1b44b390bed1362c457da9ab (diff) |
refactor cross command generation
-rw-r--r-- | Debian/Debhelper/Dh_Lib.pm | 15 | ||||
-rwxr-xr-x | dh_makeshlibs | 13 | ||||
-rwxr-xr-x | dh_strip | 10 |
3 files changed, 20 insertions, 18 deletions
diff --git a/Debian/Debhelper/Dh_Lib.pm b/Debian/Debhelper/Dh_Lib.pm index fb83480b..9b6118e9 100644 --- a/Debian/Debhelper/Dh_Lib.pm +++ b/Debian/Debhelper/Dh_Lib.pm @@ -17,7 +17,8 @@ use vars qw(@ISA @EXPORT %dh); &is_udeb &udeb_filename &debhelper_script_subst &escape_shell &inhibit_log &load_log &write_log &dpkg_architecture_value &sourcepackage - &is_make_jobserver_unavailable &clean_jobserver_makeflags); + &is_make_jobserver_unavailable &clean_jobserver_makeflags + &cross_command); my $max_compat=8; @@ -858,4 +859,16 @@ sub clean_jobserver_makeflags { } } +# If cross-compiling, returns appropriate cross version of command. +sub cross_command { + my $command=shift; + if (dpkg_architecture_value("DEB_BUILD_GNU_TYPE") + ne dpkg_architecture_value("DEB_HOST_GNU_TYPE")) { + return dpkg_architecture_value("DEB_HOST_GNU_TYPE")."-$command"; + } + else { + return $command; + } +} + 1 diff --git a/dh_makeshlibs b/dh_makeshlibs index 29d3f4d3..b6779f90 100755 --- a/dh_makeshlibs +++ b/dh_makeshlibs @@ -121,12 +121,7 @@ init(options => { "add-udeb=s" => \$dh{SHLIBS_UDEB}, }); -my $od = "objdump"; -# cross-compiling? -if (dpkg_architecture_value("DEB_BUILD_GNU_TYPE") - ne dpkg_architecture_value("DEB_HOST_GNU_TYPE")) { - $od=dpkg_architecture_value("DEB_HOST_GNU_TYPE") . "-objdump"; -} +my $objdump=cross_command("objdump"); foreach my $package (@{$dh{DOPACKAGES}}) { next if is_udeb($package); @@ -153,13 +148,13 @@ foreach my $package (@{$dh{DOPACKAGES}}) { while (<FIND>) { my ($library, $major); push @lib_files, $_; - my $objdump=`$od -p $_`; - if ($objdump=~m/\s+SONAME\s+(.+)\.so\.(.+)/) { + my $ret=`$objdump -p $_`; + if ($ret=~m/\s+SONAME\s+(.+)\.so\.(.+)/) { # proper soname format $library=$1; $major=$2; } - elsif ($objdump=~m/\s+SONAME\s+(.+)-(.+)\.so/) { + elsif ($ret=~m/\s+SONAME\s+(.+)-(.+)\.so/) { # idiotic crap soname format $library=$1; $major=$2; @@ -86,14 +86,8 @@ if (defined $ENV{DEB_BUILD_OPTIONS} && $ENV{DEB_BUILD_OPTIONS} =~ /nostrip/) { exit; } -my $objcopy = "objcopy"; -my $strip = "strip"; -# cross-compiling? -if (dpkg_architecture_value("DEB_BUILD_GNU_TYPE") - ne dpkg_architecture_value("DEB_HOST_GNU_TYPE")) { - $objcopy=dpkg_architecture_value("DEB_HOST_GNU_TYPE") . "-objcopy"; - $strip=dpkg_architecture_value("DEB_HOST_GNU_TYPE") . "-strip"; -} +my $objcopy = cross_command("objcopy"); +my $strip = cross_command("strip"); # I could just use `file $_[0]`, but this is safer sub get_file_type { |