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 if (defined $dh{V_FLAG}) {
115 warning("You probably wanted to pass -V to dh_makeshlibs, it has no effect on dh_shlibdeps");
118 foreach my $package (@{$dh{DOPACKAGES}}) {
119 my $tmp=tmpdir($package);
120 my $ext=pkgext($package);
122 # dpkg-shlibdeps expects this directory to exist
123 if (! -d "$tmp/DEBIAN") {
124 doit("install","-o",0,"-g",0,"-d","$tmp/DEBIAN");
130 # Generate a list of ELF binaries in the package, ignoring any
131 # we were told to exclude.
133 if (defined($dh{EXCLUDE_FIND}) && $dh{EXCLUDE_FIND} ne '') {
134 $find_options="! \\( $dh{EXCLUDE_FIND} \\)";
136 foreach my $file (split(/\n/,`find $tmp -type f \\( -perm +111 -or -name "*.so*" -or -name "*.cmxs" \\) $find_options -print`)) {
137 # Prune directories that contain separated debug symbols.
138 next if $file=~m!^\Q$tmp\E/usr/lib/debug/(lib|lib64|usr|bin|sbin|opt|dev|emul)/!;
139 # TODO this is slow, optimize. Ie, file can run once on
142 if ($ff=~m/ELF/ && $ff!~/statically linked/) {
143 push @filelist,$file;
149 if (defined $dh{LIBPACKAGE} && length $dh{LIBPACKAGE}) {
150 @opts=("-S".tmpdir($dh{LIBPACKAGE}));
153 push @opts, "-tudeb" if is_udeb($package);
155 my $ld_library_path_orig=$ENV{LD_LIBRARY_PATH};
157 $ENV{LD_LIBRARY_PATH}=$dh{L_PARAMS};
158 verbose_print("LD_LIBRARY_PATH=$dh{L_PARAMS}");
161 doit("dpkg-shlibdeps","-Tdebian/${ext}substvars",
162 @opts,@{$dh{U_PARAMS}},@filelist);
165 if (defined $ld_library_path_orig) {
166 $ENV{LD_LIBRARY_PATH}=$ld_library_path_orig;
169 delete $ENV{LD_LIBRARY_PATH};
177 L<debhelper(7)>, L<dpkg-shlibdeps(1)>
179 This program is a part of debhelper.
183 Joey Hess <joeyh@debian.org>