5
|
1 #!/bin/sh |
|
2 # |
|
3 # flibs -- try to get the Fortran compiler to tell us what libraries |
|
4 # it expects to link to, and echo the result to the standard output. |
|
5 # |
|
6 # John W. Eaton |
|
7 # jwe@che.utexas.edu |
|
8 # Department of Chemical Engineering |
|
9 # The University of Texas at Austin |
|
10 |
|
11 trap 'rm -f conftest* core; exit 1' 1 3 15 |
|
12 |
|
13 # Write a minimal program and compile it with -v. I don't know what |
|
14 # to do if your compiler doesn't have -v... |
|
15 |
|
16 echo " END" > conftest.f |
|
17 |
823
|
18 if test $# -eq 1 |
|
19 then |
|
20 foutput=`cat $1` |
|
21 else |
|
22 foutput=`${F77-f77} -v -o conftest conftest.f 2>&1` |
|
23 fi |
|
24 |
809
|
25 # The easiest thing to do for xlf output is to replace all the commas |
823
|
26 # with spaces. Try to only do that if the output is really from xlf, |
|
27 # since doing that causes problems on other systems. |
|
28 |
|
29 xlf_p=`echo $foutput | grep xlfentry` |
|
30 if test -n "$xlf_p" |
|
31 then |
|
32 foutput=`echo $foutput | sed 's/,/ /g'` |
|
33 fi |
5
|
34 |
823
|
35 ld_run_path=`echo $foutput | \ |
|
36 sed -n -e 's/.*\(LD_RUN_PATH *= *[^ ]*\).*/\1/p' | \ |
|
37 sed -e 's/LD_RUN_PATH *= *//'` |
|
38 |
832
|
39 # We are only supposed to find this on Solaris systems, and this |
|
40 # substitution is probably only going to work with gcc on those |
|
41 # systems... |
|
42 |
823
|
43 if test -n "$ld_run_path" |
|
44 then |
|
45 ld_run_path="-Xlinker -R -Xlinker $ld_run_path" |
|
46 fi |
5
|
47 |
|
48 flibs= |
|
49 lflags= |
809
|
50 |
1042
|
51 # If want_arg is set, we know we want the arg to be added to the list, |
809
|
52 # so we don't have to examine it. |
5
|
53 want_arg= |
|
54 |
|
55 for arg in $foutput |
|
56 do |
1176
|
57 old_want_arg=$want_arg |
|
58 want_arg= |
|
59 case "$old_want_arg" in |
|
60 '') |
|
61 case $arg in |
|
62 /*.a | /*values-X*.o) |
|
63 exists=false |
|
64 for f in $lflags |
|
65 do |
|
66 if test x$arg = x$f |
|
67 then |
|
68 exists=true |
|
69 fi |
|
70 done |
|
71 if $exists |
|
72 then |
|
73 arg= |
|
74 else |
|
75 lflags="$lflags $arg" |
|
76 fi |
|
77 ;; |
|
78 -lang*) |
|
79 arg= |
|
80 ;; |
|
81 -[lLR]) |
|
82 want_arg=$arg |
313
|
83 arg= |
1176
|
84 ;; |
|
85 -[lLR]*) |
|
86 exists=false |
|
87 for f in $lflags |
|
88 do |
|
89 if test x$arg = x$f |
|
90 then |
|
91 exists=true |
|
92 fi |
|
93 done |
|
94 if $exists || test x$arg = x-lm -o x$arg = x-lc |
|
95 then |
|
96 arg= |
|
97 else |
|
98 lflags="$lflags $arg" |
|
99 fi |
|
100 ;; |
|
101 -u) |
|
102 want_arg=$arg |
|
103 ;; |
|
104 -Y) |
|
105 want_arg=$arg |
5
|
106 arg= |
1176
|
107 ;; |
|
108 *) |
|
109 arg= |
|
110 ;; |
|
111 esac |
|
112 ;; |
|
113 -[lLR]) |
|
114 arg="$old_want_arg $arg" |
|
115 ;; |
|
116 -Y) |
832
|
117 |
|
118 # Should probably try to ensure unique directory options here too. |
|
119 # This probably only applies to Solaris systems, and then will only |
|
120 # work with gcc... |
|
121 |
|
122 arg=`echo $arg | sed -e 's%^P,%%'` |
|
123 SAVE_IFS=$IFS |
|
124 IFS=: |
|
125 list= |
|
126 for elt in $arg |
|
127 do |
1176
|
128 list="$list -L $elt" |
832
|
129 done |
|
130 IFS=$SAVE_IFS |
|
131 arg="$list" |
1176
|
132 ;; |
|
133 esac |
809
|
134 |
823
|
135 if test -n "$arg" |
5
|
136 then |
|
137 flibs="$flibs $arg" |
|
138 fi |
|
139 done |
|
140 |
823
|
141 echo "$ld_run_path $flibs" |
5
|
142 |
|
143 rm -f conftest* core |
|
144 |
|
145 # Bye-bye. |
|
146 |
|
147 exit 0 |