[4.0] Use strip (instead of eu-strip) to support --strip-debug of *.so at build time
[platform/upstream/rpm.git] / autodeps / hpux.prov
1 #! /usr/bin/ksh
2
3 # Original Author: Tim Mooney <mooney@golem.phys.ndsu.NoDak.edu>
4 # $Id: hpux.prov,v 1.8 2001/09/15 13:49:11 jbj 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 HP-UX, use `chatr' to find what libraries a package provides
14 #
15 # Example chatr output:
16 #
17 #$chatr /usr/lib/libc.sl
18 #
19 #/usr/lib/libc.sl: 
20 #         shared library 
21 #         shared library dynamic path search:
22 #             SHLIB_PATH     disabled  second 
23 #             embedded path  disabled  first  Not Defined
24 #         internal name:
25 #             libc.1
26 #         shared library list:
27 #             dynamic   /usr/lib/libdld.1
28 #         static branch prediction disabled
29 #         kernel assisted branch predictionenabled
30 #         lazy swap allocationdisabled
31 #         text segment lockingdisabled
32 #         data segment lockingdisabled
33 #         data page size: 4K
34 #         instruction page size: 4K
35 #
36
37 #
38 # Implementation notes: some of the system libraries are built without an
39 # `internal name' (HP-UX's equivalent to a SONAME), so I need to track what
40 # chatr outputs as its first line.  We'll use the basename of that line in
41 # the event of no internal name.
42 #
43
44 PATH=/usr/bin:/usr/sbin:/usr/ccs/bin
45 export PATH
46
47 #
48 # TVM: Marc Stephenson (marc@austin.ibm.com) points out we run things
49 # like `file', et. al. and expect the output to be what we see in the
50 # C/POSIX locale.  Make sure it is so.
51 #
52 LANG=C
53 export LANG
54
55 #
56 # TVM: use `while read ...' instead of `for f in ...', because there may
57 # be too many files to stuff into one shell variable.
58 #
59 IFS=""
60 while read f
61 do
62         # It's possible that I should be testing to make sure that the file
63         # we're trying isn't a symlink,  and skipping it if it is, because of
64         # the possible odd situation where we could have a link to a library
65         # with no internal name.  This would need more investigation, though.
66         chatr $f 2>/dev/null \
67         | awk '
68
69                 BEGIN { 
70                         FS = " ";
71                         RS = "\n";
72
73                         # This flag signfies that we have seen the internal name:
74                         # marker.  Once we see that, we set the flag to 1.  The next
75                         # line we read should contain the library internal name, the
76                         # SOM equivalent of an soname.  At that point we set the flag
77                         # found_internal_name to 1 and exit
78                         # the main body of the awk script, going through the END
79                         in_internal_name = 0;
80
81                         #
82                         # We have seen the internal name: section (yet)?
83                         #
84                         found_internal_name = 0;
85
86                         #
87                         # assume it is a shared library, until record 2 proves us wrong.
88                         #
89                         isa_shared_library = 1;
90                 }
91
92                 # Uncomment the next line for some debugging info.
93                 #{ print NR , ":", $0  }
94
95                 #
96                 # save the first line in case there is no internal name built
97                 # into this object.
98                 #
99                 NR == 1 {
100                         my_name = $0
101                         opened_something = 1;
102                 }
103
104                 #
105                 # Check the second line (record).  Clear the flag if it is not a
106                 # shared library.
107                 #
108                 NR == 2 && $0 !~ /^[    ]+shared library[       ]*$/ {
109                         # It is not a shared library.  Bow out early
110                         isa_shared_library = 0;
111                         exit
112                 }
113
114                 in_internal_name == 1 {
115                 
116                         # We found the library internal name.  If it does not contain
117                         # a path, print it.  At least a couple of the system libraries
118                         # have a full path as the internal name (this is probably a bug).
119
120                         if ( $0 ~ /\// ) {
121                                 numfields = split($0, internal_name, "/")
122                                 print internal_name[numfields]
123                         } else {
124                                 print $1
125                         }
126
127                         #
128                         # Set a flag for the EXIT section, to indicate that we found
129                         # an internal name
130                         #
131                         found_internal_name = 1;
132                         in_internal_name = 0
133                         exit
134                 }
135
136                 #
137                 # we have hit the internal name section.  Set the flag.  The next
138                 # line should be what we are looking for.
139                 #
140                 /^ +internal name: *$/ {
141                         in_internal_name = 1
142                 }
143
144                 END {
145                         # Uncomment the next line for debugging info
146                         #{ print "END: NR: ", NR }
147                         if ( (isa_shared_library == 0) || (NR < 2) ) {
148                                 # both of these indicate error conditions, for which we
149                                 # should not generate any output.
150                                 exit;
151                         } else {
152                                 if (found_internal_name == 1) {
153                                         exit;
154                                 } else {
155                                         #
156                                         # chop the : off the end of the line
157                                         #
158                                         colon = index(my_name, ":")
159                                         colon = colon - 1
160                                         temp = substr(my_name, 1, colon)
161                                         #
162                                         # get the basename
163                                         #
164                                         numfields = split(temp, basename, "/")
165                                         # Uncomment the next line for debugging info
166                                         #print "In END:",  numfields, ":", temp
167                                         print basename[numfields]
168                                         exit
169                                 }
170                         }
171                 }
172         ' # end of awk
173 done | sort -u
174 #comment out the previous line and uncomment the next line when debugging
175 #done