6 use Debian::Debhelper::Dh_Lib;
9 # Check if a file is an elf binary, shared library, or static library,
10 # for use by File::Find. It'll fill the following 3 arrays with anything
12 my (@shared_libs, @executables, @static_libs);
14 return if -l $_ or -d $_; # Skip directories and symlinks always.
16 # See if we were asked to exclude this file.
17 # Note that we have to test on the full filename, including directory.
18 $fn="$File::Find::dir/$_";
19 foreach $f (@{$dh{EXCLUDE}}) {
20 return if ($fn=~m/\Q$f\E/);
23 # Does its filename look like a shared library?
25 # Ok, do the expensive test.
27 if ($type=~m/.*ELF.*shared.*/) {
28 push @shared_libs, $fn;
33 # Is it executable? -x isn't good enough, so we need to use stat.
34 (undef,undef,$mode,undef)=stat(_);
38 if ($type=~m/.*ELF.*executable.*/) {
39 push @executables, $fn;
44 # Is it a static library, and not a debug library?
45 if (m/lib.*\.a/ && ! m/.*_g\.a/) {
46 push @static_libs, $fn;
51 foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
52 $TMP=tmpdir($PACKAGE);
54 @shared_libs=@executables=@static_libs=();
55 find(\&testfile,$TMP);
57 foreach (@shared_libs) {
58 # Note that all calls to strip on shared libs
59 # *must* inclde the --strip-unneeded.
60 doit("strip","--remove-section=.comment","--remove-section=.note","--strip-unneeded",$_);
63 foreach (@executables) {
64 doit("strip","--remove-section=.comment","--remove-section=.note",$_);
67 foreach (@static_libs) {
68 doit("strip","--strip-debug",$_);