Merge "Add support for global LDFLAGS" into tizen
[platform/upstream/rpm.git] / autodeps / osf.req
1 #! /usr/bin/ksh
2
3 # Original Author: Tim Mooney <mooney@golem.phys.ndsu.NoDak.edu>
4 # $Id: osf.req,v 1.9 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 # On Digital/Tru64 Unix (OSF1), use `odump -Dl' to find the library
13 # dependencies for an executable.  `odump -D' does most of what we need,
14 # but it doesn't give us library version information, so you must use
15 # `odump -Dl'.  Note that Tru64 5.x and on have `ldd', but this works just
16 # as well, and works on older versions of the OS.
17 #
18 # Example `odump -Dl' output:
19 #
20 #$odump -Dl /usr/bin/X11/xterm
21
22 #
23 #
24 #
25 #                       ***LIBRARY LIST SECTION***
26 #       Name             Time-Stamp        CheckSum   Flags Version
27 #/usr/bin/X11/xterm:
28 #       libXaw.so    Dec  9 00:15:35 1997 0x285006d0     0 6.0
29 #       libXmu.so    Dec  9 00:13:36 1997 0x3bf3a33d     0 
30 #       libXt.so     Dec  9 00:12:18 1997 0x10dd9a17     0 
31 #       libSM.so     Dec  9 00:08:11 1997 0xb64c7082     0 
32 #       libICE.so    Dec  9 00:07:52 1997 0x1199be32     0 
33 #       libXext.so   Dec  9 00:08:51 1997 0xafcb84d5     0 
34 #       libX11.so    Dec  9 00:06:05 1997 0xaa1bf091     0 
35 #       libc.so      Dec  8 18:41:11 1997 0x5e955f9b     0 osf.1
36
37 PATH=/usr/bin:/usr/sbin:/sbin:/usr/ccs/bin
38 export PATH
39
40 #
41 # TVM: Marc Stephenson (marc@austin.ibm.com) points out we run things
42 # like `file', et. al. and expect the output to be what we see in the
43 # C/POSIX locale.  Make sure it is so.
44 #
45 LANG=C
46 export LANG
47
48 #
49 # TVM: switch to using `while read ...' instead of `for f in ...', because
50 # packages with a large number of files could be too big for one shell variable
51 # to hold.
52 #
53 IFS=""
54 while read f
55 do
56
57         #
58         # Uncomment the next line for addtional debugging:
59         # echo "read ->$f<-"
60
61         #
62         # Only run file once per file:
63         #
64         file_output=`file $f`
65
66         #
67         # handle shell scripts first
68         #
69         is_shell_script=`echo "$file_output" | grep 'shell script' | \
70                 cut -d: -f 2 | awk '{ print $1 }'`
71
72         #
73         # If it's a script...
74         #
75         if test X"$is_shell_script" != X ; then
76                 echo "$is_shell_script"
77                 #
78                 # use `continue' to skip back up to the top of the loop.
79                 # We have already done as much as we need to for this
80                 # file, and this saves me from having to have an else,
81                 # and another indent level... ;-)
82                 #
83                 continue
84         fi
85
86         #
87         # The `else' here is implied by the `continue' above...
88         #
89
90         #
91         # it might be a shared library.
92         #
93
94         maybe_shared_lib=`echo "$file_output" | grep 'executable'`
95         if test X"$maybe_shared_lib" != X ; then
96
97                 odump -Dl $f 2>/dev/null \
98                 | awk '
99
100                         #
101                         # Since this entire awk script is enclosed in single quotes,
102                         # you need to be careful to not use single quotes, even in awk
103                         # comments, if you modify this script.
104                         #
105
106                         BEGIN { 
107                                 found_program_name = 0;
108                                 FS = " ";
109                                 RS = "\n";
110                                 OFS="";
111                         }
112
113                         # uncomment the next line for debugging information
114                         #{ print "Saw input:", $0 }
115
116                         found_program_name == 1 && $0 !~ /^$/ {
117
118                                 # uncomment for debugging information
119                                 #print "found shared library: $0"
120
121                                 # get the library name (field 1) and the library version
122                                 # (field 8) if present.
123                                 numfields = split($0,fields)
124                                 if (numfields == 7) {
125                                         print fields[1]
126                                 } else if (numfields == 8) {
127                                         print fields[1], "(", fields[8], ")"
128                                 }
129                         }
130
131                         /^.*: *$/ {
132                                 found_program_name = 1
133                                 #
134                                 # uncomment the next line for debugging information
135                                 #print "found the program name: ", $1
136                         }
137
138                 ' # end of awk
139         fi
140 done | sort -u
141 # comment out the previous line and uncomment the next when debugging
142 # done