6 use Debian::Debhelper::Dh_Lib;
9 # This variable can be used to turn off stripping (see Policy).
10 if (defined $ENV{DEB_BUILD_OPTIONS} && $ENV{DEB_BUILD_OPTIONS} =~ /nostrip/) {
14 # Check if a file is an elf binary, shared library, or static library,
15 # for use by File::Find. It'll fill the following 3 arrays with anything
17 my (@shared_libs, @executables, @static_libs);
19 return if -l $_ or -d $_; # Skip directories and symlinks always.
21 # See if we were asked to exclude this file.
22 # Note that we have to test on the full filename, including directory.
23 $fn="$File::Find::dir/$_";
24 foreach $f (@{$dh{EXCLUDE}}) {
25 return if ($fn=~m/\Q$f\E/);
28 # Does its filename look like a shared library?
30 # Ok, do the expensive test.
32 if ($type=~m/.*ELF.*shared.*/) {
33 push @shared_libs, $fn;
38 # Is it executable? -x isn't good enough, so we need to use stat.
39 (undef,undef,$mode,undef)=stat(_);
43 if ($type=~m/.*ELF.*executable.*/) {
44 push @executables, $fn;
49 # Is it a static library, and not a debug library?
50 if (m/lib.*\.a/ && ! m/.*_g\.a/) {
51 push @static_libs, $fn;
56 foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
57 $TMP=tmpdir($PACKAGE);
59 @shared_libs=@executables=@static_libs=();
60 find(\&testfile,$TMP);
62 foreach (@shared_libs) {
63 # Note that all calls to strip on shared libs
64 # *must* inclde the --strip-unneeded.
65 doit("strip","--remove-section=.comment","--remove-section=.note","--strip-unneeded",$_);
68 foreach (@executables) {
69 doit("strip","--remove-section=.comment","--remove-section=.note",$_);
72 foreach (@static_libs) {
73 doit("strip","--strip-debug",$_);