blob: 43cec946c23bc24803768682ba5369cc6480e585 (
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
|
#!/bin/sh
#
# usage: $1 is featurename, $2 verbose
# $3..$n librarynames like '-llibmysqlclient.*' or (optional) extra library paths like '-L/usr/local/lib'
# or filenames like "mysql.h" and (optional) extra include paths like '-I/usr/local/include'
# returns 0 on success
SUCCESS=
MODULE_NAME=$1
VERBOSE=$2
shift 2
LIBDIRS="/lib /usr/lib"
LIBNAMES=""
INCLUDEDIRS="/usr/include"
INCLUDES=""
PARAMS=$@
for PARAM in $PARAMS
do
PREFIX=`echo $PARAM | sed 's/^\(..\).*/\1/'`
case $PREFIX in
-L)
CLIBDIR=`echo $PARAM | sed -e 's/^-L//'`
LIBDIRS="$LIBDIRS $CLIBDIR"
;;
-l)
CLIBNAME=`echo $PARAM | sed -e 's/^-l//'`
LIBNAMES="$LIBNAMES lib${CLIBNAME}.*"
;;
-I)
CINCDIR=`echo $PARAM | sed -e 's/^-I//'`
INCLUDEDIRS="$INCLUDEDIRS $CINCDIR"
;;
*)
INCLUDES="$PARAM $INCLUDES"
;;
esac
done
# debuggery
if [ "$VERBOSE" = "yes" ]
then
echo "$MODULE_NAME auto-detection..."
# echo "searching for $LIBNAMES in $LIBDIRS"
# echo "and $INCLUDES in $INCLUDEDIRS"
fi
# check for lib
for LIBNAME in $LIBNAMES
do
SUCCESS=""
for LIBDIR in $LIBDIRS
do
FOUND_LIB=`ls $LIBDIR/$LIBNAME 2>/dev/null`
if [ ! -z "$FOUND_LIB" ]
then
SUCCESS=yes
if [ "$VERBOSE" = "yes" ]
then
echo " Found $LIBNAME in $LIBDIR"
fi
break
fi
done
if [ -z "$SUCCESS" ]
then
SUCCESS=no
if [ "$VERBOSE" = "yes" ]
then
echo " Could not find $LIBNAME anywhere in $LIBDIRS"
fi
break
fi
done
# check for includes
if [ "$SUCCESS" = "yes" ]
then
for INCLUDE in $INCLUDES
do
SUCCESS=""
for INCLUDEDIR in $INCLUDEDIRS
do
FOUND_INC=`ls $INCLUDEDIR/$INCLUDE 2>/dev/null`
if [ ! -z "$FOUND_INC" ]
then
SUCCESS=yes
if [ "$VERBOSE" = "yes" ]
then
echo " Found $INCLUDE in $INCLUDEDIR"
fi
break
fi
done
if [ -z "$SUCCESS" ]
then
SUCCESS=no
if [ "$VERBOSE" = "yes" ]
then
echo " Could not find $INCLUDE anywhere in $INCLUDEDIRS"
fi
break
fi
done
fi
if [ "$SUCCESS" != "yes" ]
then
if [ "$VERBOSE" = "yes" ]
then
echo "$MODULE_NAME disabled."
fi
exit 1
else
if [ "$VERBOSE" = "yes" ]
then
echo "$MODULE_NAME enabled."
fi
exit 0
fi
exit 1
|