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 |
|
51 # If want arg is set, we know we want the arg to be added to the list, |
|
52 # so we don't have to examine it. |
5
|
53 want_arg= |
|
54 |
|
55 for arg in $foutput |
|
56 do |
823
|
57 if test -z "$want_arg" |
5
|
58 then |
|
59 case $arg in |
313
|
60 /*.a) |
|
61 exists=false |
|
62 for f in $lflags |
|
63 do |
|
64 if test x$arg = x$f |
|
65 then |
|
66 exists=true |
|
67 fi |
|
68 done |
|
69 if $exists |
|
70 then |
|
71 arg= |
|
72 else |
|
73 lflags="$lflags $arg" |
|
74 fi |
|
75 ;; |
5
|
76 -[lL]*) |
|
77 exists=false |
|
78 for f in $lflags |
|
79 do |
|
80 if test x$arg = x$f |
|
81 then |
|
82 exists=true |
|
83 fi |
|
84 done |
|
85 if $exists || test x$arg = x-lm -o x$arg = x-lc |
|
86 then |
|
87 arg= |
|
88 else |
|
89 lflags="$lflags $arg" |
|
90 fi |
|
91 ;; |
|
92 -u) |
|
93 want_arg=$arg |
|
94 ;; |
809
|
95 -Y) |
|
96 want_arg=$arg |
|
97 arg= |
|
98 ;; |
5
|
99 *) |
|
100 arg= |
|
101 ;; |
|
102 esac |
|
103 else |
809
|
104 if test x$want_arg = x-Y |
|
105 then |
832
|
106 |
|
107 # Should probably try to ensure unique directory options here too. |
|
108 # This probably only applies to Solaris systems, and then will only |
|
109 # work with gcc... |
|
110 |
|
111 arg=`echo $arg | sed -e 's%^P,%%'` |
|
112 SAVE_IFS=$IFS |
|
113 IFS=: |
|
114 list= |
|
115 for elt in $arg |
|
116 do |
|
117 list="$list -L $elt" |
|
118 done |
|
119 IFS=$SAVE_IFS |
|
120 arg="$list" |
809
|
121 fi |
823
|
122 want_arg= |
5
|
123 fi |
809
|
124 |
823
|
125 if test -n "$arg" |
5
|
126 then |
|
127 flibs="$flibs $arg" |
|
128 fi |
|
129 done |
|
130 |
823
|
131 echo "$ld_run_path $flibs" |
5
|
132 |
|
133 rm -f conftest* core |
|
134 |
|
135 # Bye-bye. |
|
136 |
|
137 exit 0 |