5 dh_makeshlibs - automatically create shlibs file
10 use Debian::Debhelper::Dh_Lib;
14 B<dh_makeshlibs> [S<I<debhelper options>>] [B<-m>I<major>] [B<-V>I<[dependancies]>] [B<-n>] [B<-X>I<item>]
18 dh_makeshlibs is a debhelper program that automatically scans for shared
19 libraries, and generates a shlibs file for the libraries it finds.
21 It also adds a call to ldconfig in the postinst and postrm scripts (in
22 V3 mode and above only) to any packages which it finds shared libraries in.
28 =item B<-m>I<major>, B<--major=>I<major>
30 Instead of trying to guess the major number of the library with objdump,
31 use the major number specified after the -m parameter. This is much less
32 useful than it used to be, back in the bad old days when this program
33 looked at library filenames rather than using objdump.
35 =item B<-V>, B<-V>I<dependancies>
37 =item B<--version-info>, B<--version-info=>I<dependancies>
39 By default, the shlibs file generated by this program does not make packages
40 depend on any particular version of the package containing the shared
41 library. It may be necessary for you to add some version dependancy
42 information to the shlibs file. If -V is specified with no dependancy
43 information, the current upstream version of the package is plugged into a
44 dependancy that looks like "packagename (>= packageversion)". Note that in
45 debhelper compatability levels before v4, the debian part of the package
46 version number is also included. If -V is specified with parameters, the
47 parameters can be used to specify the exact dependancy information needed
48 (be sure to include the package name).
50 Beware of using -V without any parameters; this is a conservative setting
51 that always ensures that other packages' shared library dependencies are at
52 least as tight as they need to be (unless your library is prone to changing
53 ABI without updating the upstream version number), so that if the
54 maintainer screws up then they won't break. The flip side is that packages
55 might end up with dependencies that are too tight and so find it harder to
58 =item B<-n>, B<--noscripts>
60 Do not modify postinst/postrm scripts.
62 =item B<-X>I<item>, B<--exclude=>I<item>
64 Exclude files that contain "item" anywhere in their filename or directory
65 from being treated as shared libraries.
75 Assuming this is a package named libfoobar1, generates a shlibs file that
77 libfoobar 1 libfoobar1
79 =item dh_makeshlibs -V
81 Assuming the current version of the package is 1.1-3, generates a shlibs
82 file that looks something like:
83 libfoobar 1 libfoobar1 (>= 1.1)
85 =item dh_makeshlibs -V 'libfoobar1 (>= 1.0)'
87 Generates a shlibs file that looks something like:
88 libfoobar 1 libfoobar1 (>= 1.0)
96 foreach my $package (@{$dh{DOPACKAGES}}) {
97 next if is_udeb($package);
99 my $tmp=tmpdir($package);
102 my $need_ldconfig = 0;
104 doit("rm", "-f", "$tmp/DEBIAN/shlibs");
106 # So, we look for files or links to existing files with names that
107 # match "*.so*". Matching *.so.* is not good enough because of
108 # broken crap like db3. And we only look at real files not
109 # symlinks, so we don't accidentually add shlibs data to -dev
110 # packages. This may have a few false positives, which is ok,
111 # because only if we can get a library name and a major number from
112 # objdump is anything actually added.
114 if (defined($dh{EXCLUDE_FIND}) && $dh{EXCLUDE_FIND} ne '') {
115 $exclude="! \\( $dh{EXCLUDE_FIND} \\) ";
117 open (FIND, "find $tmp -type f \\( -name '*.so' -or -name '*.so.*' \\) $exclude |");
119 my ($library, $major);
120 my $objdump=`objdump -p $_`;
121 if ($objdump=~m/\s+SONAME\s+(.+)\.so\.(.+)/) {
122 # proper soname format
126 elsif ($objdump=~m/\s+SONAME\s+(.+)-(.+)\.so/) {
127 # idiotic crap soname format
132 if (defined($dh{M_PARAMS}) && $dh{M_PARAMS} ne '') {
133 $major=$dh{M_PARAMS};
136 if (! -d "$tmp/DEBIAN") {
137 doit("install","-d","$tmp/DEBIAN");
140 if ($dh{V_FLAG_SET}) {
141 if ($dh{V_FLAG} ne '') {
145 # Call isnative becuase it sets $dh{VERSION}
148 my $version = $dh{VERSION};
149 # Old compatability levels include the
150 # debian revision, while new do not.
152 # Remove debian version, if any.
153 $version =~ s/-[^-]+$//;
155 $deps="$package (>= $version)";
158 if (defined($library) && defined($major) && defined($deps) &&
159 $library ne '' && $major ne '' && $deps ne '') {
161 # Prevent duplicate lines from entering the file.
162 my $line="$library $major $deps";
163 if (! $seen{$line}) {
165 complex_doit("echo '$line' >>$tmp/DEBIAN/shlibs");
172 if (! compat(2) && ! $dh{NOSCRIPTS} && $need_ldconfig) {
173 autoscript($package,"postinst","postinst-makeshlibs");
174 autoscript($package,"postrm","postrm-makeshlibs");
177 if (-e "$tmp/DEBIAN/shlibs") {
178 doit("chmod",644,"$tmp/DEBIAN/shlibs");
179 doit("chown","0:0","$tmp/DEBIAN/shlibs");
187 This program is a part of debhelper.
191 Joey Hess <joeyh@debian.org>