1174
|
1 #!/bin/sh |
|
2 # |
|
3 # cxxlibs -- try to get the C++ 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 "int main (void) { return 0; }" > conftest.c |
|
17 |
|
18 # I don't think that stripping commas out of this will ever hurt. |
|
19 |
|
20 coutput=`${CXX-c++} -v -o conftest conftest.c 2>&1 | sed 's/,/ /g'` |
|
21 |
|
22 clibs= |
|
23 lflags= |
|
24 want_arg= |
|
25 |
|
26 for arg in $coutput |
|
27 do |
|
28 if test x$want_arg = x |
|
29 then |
|
30 want_arg= |
|
31 case $arg in |
|
32 /*.a) |
|
33 exists=false |
|
34 for f in $lflags |
|
35 do |
|
36 if test x$arg = x$f |
|
37 then |
|
38 exists=true |
|
39 fi |
|
40 done |
|
41 if $exists |
|
42 then |
|
43 arg= |
|
44 else |
|
45 lflags="$lflags $arg" |
|
46 fi |
|
47 ;; |
|
48 -[LR]*) |
|
49 exists=false |
|
50 for f in $lflags |
|
51 do |
|
52 if test x$arg = x$f |
|
53 then |
|
54 exists=true |
|
55 fi |
|
56 done |
|
57 ;; |
|
58 -l*) |
|
59 if test x$arg = x-lang-c++ |
|
60 then |
|
61 arg= |
|
62 else |
|
63 lflags="$lflags $arg" |
|
64 fi |
|
65 ;; |
|
66 -u) |
|
67 want_arg=$arg |
|
68 ;; |
|
69 *) |
|
70 arg= |
|
71 ;; |
|
72 esac |
|
73 else |
|
74 want_arg= |
|
75 fi |
|
76 if test x$arg != x |
|
77 then |
|
78 clibs="$clibs $arg" |
|
79 fi |
|
80 done |
|
81 |
|
82 echo "$clibs" |
|
83 |
|
84 rm -f conftest* core |
|
85 |
|
86 # Bye-bye. |
|
87 |
|
88 exit 0 |