[4.0] Use strip (instead of eu-strip) to support --strip-debug of *.so at build time
[platform/upstream/rpm.git] / autodeps / aix4.prov
1 #! /usr/bin/ksh
2
3 # Current Maintainer: Tim Mooney <mooney@golem.phys.ndsu.NoDak.edu>
4 #
5 # Original Author: Ralph Goers(rgoer@Candle.Com)
6 # Borrowed heavily from H10 version created by Tim Mooney.
7 # This file is distributed under the terms of the GNU Public License
8 #
9 # find-provides is part of RPM, the RedHat Package Manager.  find-provides
10 # reads a list of full pathnames (in a package) on stdin, and outputs all
11 # shared libraries provided by (contained in) the package.
12 #
13 # On AIX, use `dump -o' to find what the library provides, if anything.
14 #
15 #
16 # Ralph's comments:
17 #
18 # Executables are skipped because, by convention, shared libraries
19 # which are not dynamically loaded are packaged as archives. Also,
20 # it is impossible to tell the difference between an executable
21 # program and a dynamically loaded shared library.
22 #
23 # Because archives can contain any number of things, including
24 # apparently, multiple shared libraries, dependencies in archives
25 # will be specified as file[member]. Any member in an archive which
26 # has a loader section will be listed as provided.
27 #
28 # Tim's (subsequent) comments:
29 #
30 # Based on discussions on the rpm-list in mid-March of 2000, I've modified
31 # the copy of find-provides that Ralph provided me to use `dump -o' instead
32 # of `dump -H', and I've followed Brandon S. Allbery's suggestions and modified
33 # the awk script to look for a modtype of `RE', which is what constitutes a
34 # shared member of a library.  Just like everything else on AIX, libraries are
35 # weird.  :-|
36 #
37 # I've followed Ralph's convention of generating provides in the form of
38 # `filebasename(member-object)' *if* there is a member object, or just
39 # `filebasename' if there isn't (such as in the case of certain perl modules,
40 # locally built shared libraries, etc.).
41 #
42 # Example dump output:
43 #
44 #$dump -o /usr/lpp/X11/lib/R6/libX11.a
45 #
46 #/usr/lpp/X11/lib/R6/libX11.a[shr4.o]:
47 #
48 #                       ***Object Module Header***
49 ## Sections     Symbol Ptr      # Symbols       Opt Hdr Len     Flags
50 #         4     0x00126c28          14557                72     0x3002
51 #Timestamp = 920377624
52 #Magic = 0x1df  
53 #
54 #                       ***Optional Header***
55 #Tsize       Dsize       Bsize       Tstart      Dstart
56 #0x000bcc20  0x00024bd4  0x00000e0c  0x00000000  0x00000000
57 #
58 #SNloader     SNentry     SNtext             SNtoc       SNdata
59 #0x0004      0x0000      0x0001      0x0002      0x0002    
60 #
61 #TXTalign     DATAalign   TOC         vstamp      entry
62 #0x0005      0x0003      0x00023d74  0x0001      0xffffffff
63 #
64 #maxSTACK     maxDATA     SNbss       magic       modtype
65 #0x00000000  0x00000000  0x0003      0x010b        RE
66 #
67 #/usr/lpp/X11/lib/R6/libX11.a[shr4net.o]:
68 #
69 #                       ***Object Module Header***
70 ## Sections     Symbol Ptr      # Symbols       Opt Hdr Len     Flags
71 #         7     0x000006fb             22                72     0x3002
72 #Timestamp = 774732998
73 #Magic = 0x1df  
74 #
75 #                       ***Optional Header***
76 #Tsize       Dsize       Bsize       Tstart      Dstart
77 #0x00000084  0x00000088  0x00000000  0x00000200  0x00000000
78 #
79 #SNloader     SNentry     SNtext             SNtoc       SNdata
80 #0x0007      0x0000      0x0002      0x0004      0x0004    
81 #
82 #TXTalign     DATAalign   TOC         vstamp      entry
83 #0x0002      0x0003      0x00000080  0x0001      0xffffffff
84 #
85 #maxSTACK     maxDATA     SNbss       magic       modtype
86 #0x00000000  0x00000000  0x0005      0x010b        RE
87
88 PATH=/usr/bin:/usr/ccs/bin
89 export PATH
90
91 #
92 # TVM: Marc Stephenson (marc@austin.ibm.com) points out we run things
93 # like `file', et. al. and expect the output to be what we see in the
94 # C/POSIX locale.  Make sure it is so.
95 #
96 LANG=C
97 export LANG
98
99 #
100 # TVM: Because AIX libraries don't have the equivalent of a SONAME, if you do
101 #
102 # ln -s /usr/lib/libc.a /tmp/libmy_libc_link.a
103 #
104 # and then link your program with `-L/tmp -lmy_libc_link', that's the name
105 # that will be recorded as the BASE in the Import File Strings area.
106 # This means we need to include "symbolic link" in the list of files to check
107 # out.
108 #
109 filelist=`sed "s/['\"]/\\\&/g" | xargs file \
110         | grep -E 'archive|executable|symbolic link' | cut -d: -f1`
111
112 for f in $filelist
113 do
114    #
115    # Uncomment the next line for some additional debugging info:
116    #echo "Checking $f"
117    dump -o $f 2>/dev/null | awk '
118
119         # TVM: be careful to not use any single quotes, even in comments,
120         # since this entire awk script is enclosed in single quotes.
121
122         BEGIN {
123                 FS = " ";
124                 RS = "\n";
125                 # our flag to indicate we found a filename[membername] or
126                 # filename.
127                 found_file_or_member = 0
128                 # our flag to indicate we found the modtype tag.  If so,
129                 # we want to look for RE on the next line.
130                 found_modtype = 0
131                                 #
132                                 # number of times gsub substituted, used twice below
133                                 nsub = 0
134         }
135
136         # Uncomment the next line for some debugging info.
137         # { print NR , ":", $0 }
138
139         found_modtype == 1 && found_file_or_member == 1 {
140
141           if ( $0 ~ / RE/ ) {
142             # we have seen a filename, we have seen a modtype line, and now
143             # we know that the modtype is RE.  Print out the member name.
144                         #
145                         # Note that member names generally look like foo[bar.o], and
146                         # since the RPM standard has become to use parens, we will
147                         # translate the [ and ] into ( and ) in the output stream.
148                         # awk on AIX 4 has sub() and gsub(), so we can use them to do
149                         # it.  If this script is adapted for use on some other platform
150                         # make sure that awk on that platform has sub/gsub.  If not,
151                         # you will need to postprocess the output stream (probably before
152                         # the sort -u) with tr or sed.
153                         nsub = gsub(/\[/, "(", member)
154                         if ( nsub > 1 ) {
155                                 print "substituted too many times for [:", member | "cat 1>&2"
156                         }
157                         nsub = gsub(/\]/, ")", member)
158                         if ( nsub > 1 ) {
159                                 print "substituted too many times for ]:", member | "cat 1>&2"
160                         }
161             print member
162           }
163           # In any case, reset our flags to zero, to indicate we are done
164           # with this member, so we are ready to handle additional members
165           # if needed.
166           found_file_or_member = 0
167           found_modtype = 0
168         }
169
170         found_file_or_member == 1 && /magic *modtype/ {
171           # we have seen a filename, and now we have seen the modtype
172           # line.  Set the found_modtype flag.  The next line of input
173           # will be caught by the rule above, and we will print out
174           # the member if the modtype is RE.
175           found_modtype = 1
176         }
177
178         /:$/ {
179           numfields = split($0,fields, "/")
180           # chop off the trailing colon
181           fieldlen = length(fields[numfields])-1
182           member= substr(fields[numfields], 1, fieldlen)
183           # Set the flat to indicate we found a file or a file(member).
184           found_file_or_member = 1
185         }
186    ' # end of awk
187 done | sort -u
188 #comment out the previous line and uncomment the next line when debugging
189 #done