[4.0] Use strip (instead of eu-strip) to support --strip-debug of *.so at build time
[platform/upstream/rpm.git] / autodeps / irix6.req
1 #! /usr/bin/ksh
2
3 # Original Author: Tim Mooney <mooney@golem.phys.ndsu.NoDak.edu>
4 # $Id: irix6.req,v 1.7 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-requires is part of RPM, the Red Hat Package Manager.  find-requires
9 # reads a list of full pathnames (in a package) on stdin, and outputs all
10 # shared libraries the package requires to execute.
11 #
12 # NOTE: IRIX libraries (even system libraries) have "version information"
13 # in both the soname and the internal version field, so it's important to
14 # be able to separate the soname and internal version fields.  As has
15 # become the case on other platforms, the soname/iversion delimiters have
16 # become the `(' and `)' characters.
17 #
18 # On IRIX, use `elfdump -Dl' to find what libraries are required by
19 # an executable.  `elfdump -L' does what we need too, but it gives us more
20 # than we really need.
21 #
22 # Example `elfdump -Dl' output:
23 #
24 #$elfdump -Dl /usr/bin/X11/xterm
25 #
26 #
27 #
28 #/usr/bin/X11/xterm:
29 #
30 #                  **** MIPS LIBLIST INFORMATION ****
31 #.liblist :
32 #[INDEX]        Timestamp               Checksum        Flags   Name            Version
33 #[1]    Nov 23 15:39:02 1997    0x4da65893      -----   libXaw.so.2     sgi2.0
34 #[2]    Nov 23 15:39:02 1997    0x414eece6      -----   libXmu.so       sgi1.0
35 #[3]    Nov 23 15:39:02 1997    0x6f314e69      -----   libXt.so        sgi1.0
36 #[4]    Nov 23 15:39:02 1997    0xcbe81fff      -----   libXext.so      sgi1.0
37 #[5]    Nov 23 15:39:02 1997    0x89ae8e98      -----   libX11.so.1     sgi1.0
38 #[6]    Oct 27 01:00:29 1997    0x99b27890      -----   libcurses.so    sgi1.0
39 #[7]    Jun 16 18:23:15 1997    0x92321a0c      -----   libc.so.1       sgi1.0
40 #
41  
42 #
43 # TVM: it might be better to re-write this so that `file' isn't used, since
44 # it can all be done with `elfdump',  but this works.
45 #
46
47 PATH=/usr/bin:/usr/sbin
48 export PATH
49
50 #
51 # TVM: Marc Stephenson (marc@austin.ibm.com) points out we run things
52 # like `file', et. al. and expect the output to be what we see in the
53 # C/POSIX locale.  Make sure it is so.
54 #
55 LANG=C
56 export LANG
57
58 #
59 # TVM: switch to using `while read ...' instead of `for f in ...', because
60 # packages with a large number of files could be too big for one shell
61 # variable to hold.
62 #
63 IFS=""
64 while read f
65 do
66
67         #
68         # Uncomment the next line for additional debugging:
69         #echo "read ->$f<-"
70         
71         #
72         # Only run file once per file:
73         #
74         file_output=`file $f`
75
76         #
77         # Handle scripts first
78         #
79         is_shell_script=`echo "$file_output" | grep 'script text' | \
80                 cut -d: -f 2 | awk '{ print $1 }'`
81         
82         #
83         # If it's a script...
84         #
85         if test X"$is_shell_script" != X ; then
86                 echo "$is_shell_script"
87                 #
88                 # use `continue' to skip back up to the top of the loop.  We've
89                 # already done as much as we need to, and this saves me from having
90                 # to have an else, and another indent level... ;-)
91                 #
92                 continue
93         fi
94
95         #
96         # the `else' is implied here, since we used `continue' in the test above
97         #
98
99         #
100         # It might be a shared library.
101         #
102         maybe_shared_lib=`echo "$file_output" | grep -E 'executable|lib'`
103         if test X"$maybe_shared_lib" != X ; then
104
105                 elfdump -Dl $f 2>/dev/null \
106                 | awk '
107
108                 #
109                 # Since this entire awk script is enclosed in single quotes,
110                 # you need to be careful to not use single quotes, even in awk
111                 # comments, if you modify this script.
112                 #
113
114                 BEGIN { 
115                         found_column_headers = 0;
116                         FS = " ";
117                         RS = "\n";
118                         OFS="";
119                 }
120
121                 # uncomment the next line for debugging information
122                 #{ print "Saw input:", $0 }
123
124                 found_column_headers == 1 && $0 !~ /^$/ {
125
126                         # get the library name (field 15) and the library version (field 16)
127                         # if present.
128                         numfields = split($0,fields)
129                         if (numfields == 8) {
130                                 print fields[8]
131                         } else if (numfields == 9) {
132                                 #
133                                 print fields[8], "(", fields[9], ")"
134                         } else if (numfields > 9) {
135                                 #
136                                 # SGI has this annoying habit of putting comments, complete
137                                 # with whitespace, in their library IVERSION field.  Yuck.
138                                 #
139                                 # Handle libraries like this gracefully.
140                                 #
141                                 verfields = split(fields[NF], junk, "#")
142                                 if (verfields == 2) {
143                                         print fields[8], "(", junk[2], ")"
144                                 } else if (verfields > 2) {
145                                         print fields[8], "(", junk[verfields], ")"
146                                 } else {
147                                         print "Cannot find version:", fields[numfields] | "cat 2>&1"
148                                 }
149                         }
150                 }
151
152                 /^\[INDEX\].Timestamp.*Checksum.*Flags.*Name.*Version$/ {
153                         # we better start paying attention now.
154                         found_column_headers = 1
155                         #
156                         # uncomment the next line for debugging information
157                         #print "found the column headers: ", $0
158                 }
159
160         ' # end of awk
161         fi
162 done | sort -u
163 # comment out the previous line and uncomment the next when debugging
164 #done