[4.0] Use strip (instead of eu-strip) to support --strip-debug of *.so at build time
[platform/upstream/rpm.git] / autodeps / osf.prov
1 #! /usr/bin/ksh
2
3 # Original Author: Tim Mooney <mooney@golem.phys.ndsu.NoDak.edu>
4 # $Id: osf.prov,v 1.7 2000/10/31 20:47:23 mooney Exp $
5 #
6 # This file is distributed under the terms of the GNU Public License
7 #
8 # find-provides is part of RPM, the Red Hat Package Manager.  find-provides
9 # reads a list of full pathnames (in a package) on stdin, and outputs all
10 # shared libraries provided by (contained in) the package.
11 #
12 #
13 # On Digital/Tru64 Unix (OSF1), use `odump -D' to find what libraries a
14 # package provides.  Note that Tru64 Unix 5.x and later come with `ldd',
15 # but sticking with `odump' works with versions of the OS back to at least
16 # 3.x, so it's the preferred method.
17 #
18 # Example `odump -D' output:
19 #
20 #$odump -D /usr/shlib/libc.so
21 #
22 #
23 #
24 #
25 #                       ***DYNAMIC SECTION***
26 #                Tag            Value
27 #
28 #/usr/shlib/libc.so:
29 #                 UNREFEXTNO: 14.
30 #                LOCAL_GOTNO: 521.
31 #                     GOTSYM: 2205.
32 #                LOCAL_GOTNO: 1606.
33 #                     GOTSYM: 3289.
34 #                     SONAME: libc.so
35 #                 TIME_STAMP: (0x34a82daa) Mon Dec 29 17:09:30 1997
36 #
37 #                  ICHECKSUM: 0x5e955f9b
38 #                   IVERSION: osf.1
39 #                 CONFLICTNO: 0.
40 #                RLD_VERSION: 2.
41 #                       HASH: 0x000003ff800a82e0
42 #                     STRTAB: 0x000003ff8008aad0
43 #                     SYMTAB: 0x000003ff80094ab0
44 #                       MSYM: 0x000003ff800842c0
45 #                      STRSZ: 40922.
46 #                     SYMENT: 24.
47 #                     PLTGOT: 0x000003ffc008f240
48 #                   SYMTABNO: 3330.
49 #               BASE_ADDRESS: 0x000003ff80080000
50 #                   HIPAGENO: 0.
51 #                      RELSZ: 15296.
52 #                     RELENT: 16.
53 #                        REL: 0x000003ff80080700
54 #                  LIBLISTNO: 0.
55 #                       INIT: 0x000003ff8019c520
56 #                       FINI: 0x000003ff8019c570
57 #                      FLAGS: 0x00000001
58 #
59
60 PATH=/usr/bin:/usr/sbin:/sbin:/usr/ccs/bin
61 export PATH
62
63 #
64 # TVM: Marc Stephenson (marc@austin.ibm.com) points out we run things
65 # like `file', et. al. and expect the output to be what we see in the
66 # C/POSIX locale.  Make sure it is so.
67 #
68 LANG=C
69 export LANG
70
71 #
72 # Use `while read ...' instead of a `for f in ...', because there may
73 # be too many files to stuff into one shell variable.
74 #
75 IFS=""
76 while read f
77 do
78
79         #
80         # if it's a shared library, run odump on it.
81         #
82         maybe_shared_lib=`file $f | grep -E 'COFF.*shared library'`
83         if test X"$maybe_shared_lib" != X ; then
84                 odump -D $f 2>/dev/null | awk '
85
86                         BEGIN { 
87                                 FS = " ";
88                                 RS = "\n";
89                                 OFS = "";
90
91                                 found_soname = 0;
92                                 found_iversion = 0;
93
94                         }
95
96                         # Uncomment the next line for some debugging info.
97                         #{ print NR , ":", $0  }
98
99                         /^[      ]+SONAME: .*[  ]*$/ {
100                                 found_soname = 1;
101                                 numfields = split($0, internal_name)
102                                 if (numfields == 2) {
103                                         soname = $2
104                                         #
105                                         # we should probably check to see if the soname ends with
106                                         # a number (indicating that it contains versioning info,
107                                         # possibly in addition to the versioning info in the
108                                         # versions field) and generate a warning here.  Shared
109                                         # libraries should not be built with version info in
110                                         # the soname on Digital/Tru64 Unix.
111                                         #
112                                 } else {
113                                         #
114                                         # Should never be here.
115                                         #
116                                         print "Really odd looking soname:", $0 | "cat 1>&2"
117                                         exit
118                                 }
119                         }
120
121                         /^[     ]+IVERSION: .*[         ]*$/ {
122                                 if (found_soname == 1) {
123                                         numfields = split($0, iversion)
124                                         if (numfields == 2) {
125                                                 version = $2
126                                                 #
127                                                 # handle libraries with multiple versions, like
128                                                 # 1.1:1.2.  Since they really provide both versions,
129                                                 # we need to generate output for each version.
130                                                 #
131                                                 numfields = split(version, versions, ":")
132                                                 if (numfields > 1) {
133                                                         for (i = 1; i < numfields; i++) {
134                                                                 print soname, "(", versions[i], ")"
135                                                         }
136                                                         #
137                                                         # let our END routine print out the *last* version
138                                                         # provided
139                                                         #
140                                                         version = versions[numfields]
141                                                 }
142                                                 #
143                                                 # stick a fork in us.
144                                                 #
145                                                 found_iversion = 1;
146                                                 exit
147                                         } else {
148                                                 #
149                                                 # Should never be here.
150                                                 #
151                                                 print "Odd looking library version:", $0 | "cat 1>&2"
152                                                 exit
153                                         }
154                                 } else {
155                                         #
156                                         # found an iversion without an soname.  Is that possible?
157                                         #
158                                         print "Found version but no soname:", $0 | "cat 1>&2"
159                                         exit
160                                 }
161                         }
162
163                         #
164                         # we could probably watch for some other token (like RLD_VERSION)
165                         # that *generally* occurs later in the input than the stuff we watch
166                         # for, and exit if we see it, but it is just as easy to read all
167                         # the output, even after we have seen what we are looking for.
168                         #
169
170                         END {
171                                 # Uncomment the next line for debugging info
172                                 #{ print "END: NR: ", NR }
173                                 if ( (found_soname == 1) && (found_iversion == 1) ) {
174                                         print soname, "(", version, ")"
175                                         exit
176                                 } else if (found_soname == 1) {
177                                         #
178                                         # no library version information
179                                         #
180                                         print soname
181                                 }
182                                 # else do nothing
183                         }
184                 ' # end of awk
185         fi
186 done | sort -u
187 #comment out the previous line and uncomment the next line when debugging
188 #done