aboutsummaryrefslogtreecommitdiff
blob: 1ecf8f353414a7f390277936e42df1bc9164b134 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
--- ./net/xrootd/src/xrootd/configure.classic.orig	2008-06-25 07:24:15.000000000 +0100
+++ ./net/xrootd/src/xrootd/configure.classic	2008-07-04 20:06:20.537658375 +0100
@@ -342,7 +342,8 @@
 
     # Assert that we got enough arguments
     if test $# -ne 3 ; then
-	echo "check_symbol: Not 3 arguments"
+	echo "check_symbol: not 3 arguments"
+        found_symbol=0
 	return 1
     fi
 
@@ -351,34 +352,105 @@
     symbollib=$1  ; shift
     symboldir=$1
 
+    if test "x$symbollib" = "x" ; then
+        found_symbol=0
+        return 1
+    fi
+
+    symbollib=`echo $symbollib | sed -e 's/^-l/lib/'`
+
+    if test ! "x$symboldir" = "x" ; then
+        symboldir=`echo $symboldir | sed -e 's/^-L//'`
+    fi
+
     # Check if we got a specific argument as to where the library
     # is to be found
     symbolfile=$symbollib
-    if test ! "x$symboldir" = "x" ; then
-        symbolfile=$symboldir/$symbollib
-        if test ! -r $symbolfile ; then
-            for i in .a .so .lib ; do
-                if test -r $symbolfile$i ; then
-                    symbolfile=$symbolfile$i
-                    break
+    exts=".so .lib"
+    if test ! "x$shared" = "xno" ; then
+	exts="$exts .a"
+    else
+	exts=".a $exts"
+    fi
+
+    usrlib="/usr/lib"
+    # look first in the lib32 directories
+    if test "x$checklib32" = "xyes" ; then
+        usrlib="/usr/lib32 $usrlib"
+    fi
+    # look first in the lib64 directories
+    if test "x$checklib64" = "xyes" ; then
+        usrlib="/usr/lib64 $usrlib"
+    fi
+    # look only in the lib64 directories
+    if test "x$checkonlylib64" = "xyes" ; then
+        usrlib="/usr/lib64"
+    fi
+    # look only in the hpux64 directories
+    if test "x$checkhpux64" = "xyes" ; then
+        usrlib="/usr/lib/hpux64"
+    fi
+
+    for d in "$symboldir" $usrlib ; do
+	echo " Checking in $d"
+	if test ! -r $d/$symbollib ; then
+	    echo "  $d/$symbollib not readable"
+	    for i in $exts ; do
+		echo "   Checking extension $i with $d/$symbollib"
+		if test -r $d/$symbollib$i ; then
+		    echo "   $d/$symbollib$i readable"
+		    symbolfile=$d/$symbollib$i
+		    break 2
                 fi
              done
+        else
+            echo "$d/$symbollib readable"
+            symbolfile=$d/$symbollib
+            break
         fi
-    fi
+    done
 
     if test "x$symbolfile" = "x" || test ! -r $symbolfile ; then
        found_symbol=0
+       echo " Symbol not found"
        return 1
     fi
 
-    symbol_in_lib=`nm $symbolfile | grep $symbol > /dev/null 2>&1`
+    checking_msg "$symbol in $symbolfile"
+    nm $symbolfile 2>&1 | grep $symbol > /dev/null 2>&1
     if test $? -eq 0 ; then
         found_symbol=1
+        echo " Symbol found"
     else
-        found_symbol=0
+	nm $symbolfile 2>&1 | grep "no symbols" > /dev/null 2>&1
+	if test $? -eq 0 ; then
+	    echo " $symbolfile is stripped, trying a link"
+	    # stripped library - only safe test is to link against the
+	    # library!  However, we do not know what compiler to use
+	    # so we can not do the test.  Assume the symbol is in
+	    cat <<EOF > conftest.mk
+conftest:conftest.c $symbolfile
+	\$(CC) \$(CFLAGS) \$(LDFLAGS) $symbolfile \$< -o \$@
+
+conftest.c:
+	echo "extern int $symbol (); " > \$@
+	echo "int main() { $symbol (); return 0; }" >> \$@
+EOF
+	    make -f conftest.mk >> config.log 2>&1
+	    if test $? -eq 0 ; then
+		found_symbol=1
+		echo " Link OK"
+	    else
+		found_symbol=0
+		echo " Failed code was"
+		cat conftest.mk >> config.log
+	    fi
+	    rm -rf conftest.c conftest.mk conftest
+	else
+	    found_symbol=0
+	fi
     fi
 }
-
 #_____________________________________________________________________
 guess_architecture () {
     # Try to guess the architecture of the host system