6 BEGIN { push @INC, "debian", "/usr/lib/debhelper" }
10 # Check if a file is an elf binary, shared library, or static library,
11 # for use by File::Find. It'll fill the following 3 arrays with anything
13 my (@shared_libs, @executables, @static_libs);
15 return if -l $_ or -d $_; # Skip directories and symlinks always.
17 # See if we were asked to exclude this file.
18 # Note that we have to test on the full filename, including directory.
19 $fn="$File::Find::dir/$_";
20 foreach $f (@{$dh{EXCLUDE}}) {
21 return if ($fn=~m/\Q$f\E/);
24 # Does its filename look like a shared library?
26 # Ok, do the expensive test.
28 if ($type=~m/.*ELF.*shared.*/) {
29 push @shared_libs, $fn;
34 # Is it executable? -x isn't good enough, so we need to use stat.
35 (undef,undef,$mode,undef)=stat(_);
39 if ($type=~m/.*ELF.*executable.*/) {
40 push @executables, $fn;
45 # Is it a static library, and not a debug library?
46 if (m/lib.*\.a/ && ! m/.*_g\.a/) {
47 push @static_libs, $fn;
52 foreach $PACKAGE (@{$dh{DOPACKAGES}}) {
53 $TMP=tmpdir($PACKAGE);
55 @shared_libs=@executables=@static_libs=();
56 find(\&testfile,$TMP);
58 foreach (@shared_libs) {
59 # Note that all calls to strip on shared libs
60 # *must* inclde the --strip-unneeded.
61 doit("strip","--remove-section=.comment","--remove-section=.note","--strip-unneeded",$_);
64 foreach (@executables) {
65 doit("strip","--remove-section=.comment","--remove-section=.note",$_);
68 foreach (@static_libs) {
69 doit("strip","--strip-debug",$_);