5 dh_shlibdeps - calculate shared library dependencies
11 use Debian::Debhelper::Dh_Lib;
15 B<dh_shlibdeps> [S<I<debhelper options>>] [B<-L>I<package>] [B<-l>I<directory>] [B<-X>I<item>] [S<B<--> I<params>>]
19 B<dh_shlibdeps> is a debhelper program that is responsible for calculating
20 shared library dependencies for packages.
22 This program is merely a wrapper around L<dpkg-shlibdeps(1)> that calls it
23 once for each package listed in the F<control> file, passing it
24 a list of ELF executables and shared libraries it has found.
30 =item B<-X>I<item>, B<--exclude=>I<item>
32 Exclude files that contain F<item> anywhere in their filename from being
33 passed to B<dpkg-shlibdeps>. This will make their dependencies be ignored.
34 This may be useful in some situations, but use it with caution. This option
35 may be used more than once to exclude more than one thing.
39 Pass I<params> to L<dpkg-shlibdeps(1)>.
41 =item B<-u>I<params>, B<--dpkg-shlibdeps-params=>I<params>
43 This is another way to pass I<params> to L<dpkg-shlibdeps(1)>.
44 It is deprecated; use B<--> instead.
46 =item B<-l>I<directory>[B<:>I<directory> ...]
48 With recent versions of B<dpkg-shlibdeps>, this option is generally not
51 Before B<dpkg-shlibdeps> is run, B<LD_LIBRARY_PATH> will have added to it the
52 specified directory (or directories -- separate with colons). With recent
53 versions of B<dpkg-shlibdeps>, this is mostly only useful for packages that
54 build multiple flavors of the same library, or other situations where
55 the library is installed into a directory not on the regular library search
58 =item B<-L>I<package>, B<--libpackage=>I<package>
60 With recent versions of B<dpkg-shlibdeps>, this option is generally not
61 needed, unless your package builds multiple flavors of the same library.
63 It tells B<dpkg-shlibdeps> (via its B<-S> parameter) to look first in the package
64 build directory for the specified package, when searching for libraries,
65 symbol files, and shlibs files.
71 Suppose that your source package produces libfoo1, libfoo-dev, and
72 libfoo-bin binary packages. libfoo-bin links against libfoo1, and should
73 depend on it. In your rules file, first run B<dh_makeshlibs>, then B<dh_shlibdeps>:
78 This will have the effect of generating automatically a shlibs file for
79 libfoo1, and using that file and the libfoo1 library in the
80 F<debian/libfoo1/usr/lib> directory to calculate shared library dependency
83 If a libbar1 package is also produced, that is an alternate build of
84 libfoo, and is installed into F</usr/lib/bar/>, you can make libfoo-bin depend
85 on libbar1 as follows:
87 dh_shlibdeps -Llibbar1 -l/usr/lib/bar
92 "L|libpackage=s" => \$dh{LIBPACKAGE},
93 "dpkg-shlibdeps-params=s", => \$dh{U_PARAMS},
94 "l=s", => \$dh{L_PARAMS},
99 # Add to existing paths, if set.
100 push @paths, $ENV{'LD_LIBRARY_PATH'}
101 if exists $ENV{'LD_LIBRARY_PATH'};
102 foreach (split(/:/, $dh{L_PARAMS})) {
103 # Force the path absolute.
111 $dh{L_PARAMS}=join(':', @paths);
114 foreach my $package (@{$dh{DOPACKAGES}}) {
115 my $tmp=tmpdir($package);
116 my $ext=pkgext($package);
118 # dpkg-shlibdeps expects this directory to exist
119 if (! -d "$tmp/DEBIAN") {
120 doit("install","-o",0,"-g",0,"-d","$tmp/DEBIAN");
126 # Generate a list of ELF binaries in the package, ignoring any
127 # we were told to exclude.
129 if (defined($dh{EXCLUDE_FIND}) && $dh{EXCLUDE_FIND} ne '') {
130 $find_options="! \\( $dh{EXCLUDE_FIND} \\)";
132 foreach my $file (split(/\n/,`find $tmp -type f \\( -perm +111 -or -name "*.so*" -or -name "*.cmxs" \\) $find_options -print`)) {
133 # Prune directories that contain separated debug symbols.
134 next if $file=~m!^\Q$tmp\E/usr/lib/debug/(lib|lib64|usr|bin|sbin|opt|dev|emul)/!;
135 # TODO this is slow, optimize. Ie, file can run once on
138 if ($ff=~m/ELF/ && $ff!~/statically linked/) {
139 push @filelist,$file;
145 if (defined $dh{LIBPACKAGE} && length $dh{LIBPACKAGE}) {
146 @opts=("-S".tmpdir($dh{LIBPACKAGE}));
149 push @opts, "-tudeb" if is_udeb($package);
151 my $ld_library_path_orig=$ENV{LD_LIBRARY_PATH};
153 $ENV{LD_LIBRARY_PATH}=$dh{L_PARAMS};
154 verbose_print("LD_LIBRARY_PATH=$dh{L_PARAMS}");
157 doit("dpkg-shlibdeps","-Tdebian/${ext}substvars",
158 @opts,@{$dh{U_PARAMS}},@filelist);
161 if (defined $ld_library_path_orig) {
162 $ENV{LD_LIBRARY_PATH}=$ld_library_path_orig;
165 delete $ENV{LD_LIBRARY_PATH};
173 L<debhelper(7)>, L<dpkg-shlibdeps(1)>
175 This program is a part of debhelper.
179 Joey Hess <joeyh@debian.org>