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 |
|
39 if test -n "$ld_run_path" |
|
40 then |
|
41 ld_run_path="-Xlinker -R -Xlinker $ld_run_path" |
|
42 fi |
5
|
43 |
|
44 flibs= |
|
45 lflags= |
809
|
46 |
|
47 # If want arg is set, we know we want the arg to be added to the list, |
|
48 # so we don't have to examine it. |
5
|
49 want_arg= |
|
50 |
|
51 for arg in $foutput |
|
52 do |
823
|
53 if test -z "$want_arg" |
5
|
54 then |
|
55 case $arg in |
313
|
56 /*.a) |
|
57 exists=false |
|
58 for f in $lflags |
|
59 do |
|
60 if test x$arg = x$f |
|
61 then |
|
62 exists=true |
|
63 fi |
|
64 done |
|
65 if $exists |
|
66 then |
|
67 arg= |
|
68 else |
|
69 lflags="$lflags $arg" |
|
70 fi |
|
71 ;; |
5
|
72 -[lL]*) |
|
73 exists=false |
|
74 for f in $lflags |
|
75 do |
|
76 if test x$arg = x$f |
|
77 then |
|
78 exists=true |
|
79 fi |
|
80 done |
|
81 if $exists || test x$arg = x-lm -o x$arg = x-lc |
|
82 then |
|
83 arg= |
|
84 else |
|
85 lflags="$lflags $arg" |
|
86 fi |
|
87 ;; |
|
88 -u) |
|
89 want_arg=$arg |
|
90 ;; |
809
|
91 -Y) |
|
92 want_arg=$arg |
|
93 arg= |
|
94 ;; |
5
|
95 *) |
|
96 arg= |
|
97 ;; |
|
98 esac |
|
99 else |
809
|
100 if test x$want_arg = x-Y |
|
101 then |
823
|
102 arg="-Xlinker -Y -Xlinker $arg" |
809
|
103 fi |
823
|
104 want_arg= |
5
|
105 fi |
809
|
106 |
823
|
107 if test -n "$arg" |
5
|
108 then |
|
109 flibs="$flibs $arg" |
|
110 fi |
|
111 done |
|
112 |
823
|
113 echo "$ld_run_path $flibs" |
5
|
114 |
|
115 rm -f conftest* core |
|
116 |
|
117 # Bye-bye. |
|
118 |
|
119 exit 0 |