7 use Debian::Debhelper::Dh_Lib;
10 # This variable can be used to turn off stripping (see Policy).
11 if (defined $ENV{DEB_BUILD_OPTIONS} && $ENV{DEB_BUILD_OPTIONS} =~ /nostrip/) {
15 # Check if a file is an elf binary, shared library, or static library,
16 # for use by File::Find. It'll fill the following 3 arrays with anything
18 my (@shared_libs, @executables, @static_libs);
20 return if -l $_ or -d $_; # Skip directories and symlinks always.
22 # See if we were asked to exclude this file.
23 # Note that we have to test on the full filename, including directory.
24 my $fn="$File::Find::dir/$_";
25 foreach my $f (@{$dh{EXCLUDE}}) {
26 return if ($fn=~m/\Q$f\E/);
29 # Does its filename look like a shared library?
31 # Ok, do the expensive test.
33 if ($type=~m/.*ELF.*shared.*/) {
34 push @shared_libs, $fn;
39 # Is it executable? -x isn't good enough, so we need to use stat.
40 my (undef,undef,$mode,undef)=stat(_);
44 if ($type=~m/.*ELF.*executable.*/) {
45 push @executables, $fn;
50 # Is it a static library, and not a debug library?
51 if (m/lib.*\.a/ && ! m/.*_g\.a/) {
52 push @static_libs, $fn;
57 foreach my $package (@{$dh{DOPACKAGES}}) {
58 my $tmp=tmpdir($package);
60 my (@shared_libs, @executables, @static_libs);
61 find(\&testfile,$tmp);
63 foreach (@shared_libs) {
64 # Note that all calls to strip on shared libs
65 # *must* inclde the --strip-unneeded.
66 doit("strip","--remove-section=.comment",
67 "--remove-section=.note","--strip-unneeded",$_);
70 foreach (@executables) {
71 doit("strip","--remove-section=.comment",
72 "--remove-section=.note",$_);
75 foreach (@static_libs) {
76 doit("strip","--strip-debug",$_);