-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·149 lines (136 loc) · 3.55 KB
/
configure
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
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
#!/bin/bash
prefix=/usr/local
libpath=""
cc="$CC"
if [[ -z "$cc" ]] ; then
cc=gcc
fi
no_c=""
python_install_option=""
python="python"
no_python=""
targets=""
for opt in "$@" ; do
case $opt in
--lib-path=*)
libpath=$(echo "$opt" | sed -n 's/--lib-path=\(.*\)/\1/p')
;;
--prefix=*)
prefix=`echo "$opt" | sed -n 's/--prefix=\(.*\)/\1/p'`
;;
--package-prefix=*)
packageprefix=`echo "$opt" | sed -n 's/--package-prefix=\(.*\)/\1/p'`
;;
--home)
prefix="$HOME"
LDFLAGS="-L$HOME/lib -Wl,-rpath,$HOME/lib"
python_install_option="--user"
;;
--c-compiler=*)
cc=`echo "$opt" | sed -n 's/--c-compiler=\(.*\)/\1/p'`
;;
--python=*)
python=`echo "$opt" | sed -n 's/--python=\(.*\)/\1/p'`
;;
--without-c)
no_c="true"
;;
--without-python)
no_python="true"
;;
--help)
echo ""
echo "Valid options are:"
echo "--lib-path=dir Install libraries to 'dir'."
echo "--prefix=dir Install program to prefix 'dir'."
echo "--package-prefix=dest Pretend to install to the prefix,"
echo " but copy files to 'dest/prefix' on make install."
echo "--home Install bencode libraries to $HOME directory."
echo "--c-compiler=exe Use given C compiler."
echo "--python=exe Use given Python interpreter for installation."
echo "--without-c Don't install C library."
echo "--without-python Don't install Python library."
exit
;;
*)
echo "Unknown configure option: $opt"
exit 1
esac
done
if [[ -n $no_python ]] ; then
python="/bin/false"
fi
"$python" --version >/dev/null 2>/dev/null
if [[ $? = 0 ]] ; then
targets="python $targets"
else
if [[ -z $no_python ]] ; then
echo "Python interpreter not found: $python"
exit 1
fi
python=""
fi
if [[ -z "$libpath" ]] ; then
if [[ -d "$prefix/lib64" ]] ; then
libpath="$prefix/lib64"
else
libpath="$prefix/lib"
fi
fi
if [[ ! -z "$packageprefix" ]] ; then
prefix="$packageprefix/$prefix"
libpath="$packageprefix/$libpath"
fi
if [[ -n $no_c ]] ; then
cc="/bin/false"
fi
"$cc" --version >/dev/null 2>/dev/null
if [[ $? = 0 ]] ; then
targets="c $targets"
else
if [[ -z $no_c ]] ; then
echo "C compiler not found: $cc"
exit 1
fi
cc=""
fi
# Linux shared library config
SHAREDLIBRARYFLAGS="-fPIC -shared"
SHAREDFLAG="-shared"
LIBNAME="libbencodetools.so"
SHAREDNAMEFLAG="-Wl,-soname,$LIBNAME"
if test "x$(uname)" = "xDarwin" ; then
# Mac OS X shared library config
SHAREDLIBRARYFLAGS="-dynamic -bundle -undefined suppress -force_flat_namespace"
SHAREDFLAG="-dynamiclib"
LIBNAME="libbencodetools.dylib"
SHAREDNAMEFLAG="-install_name \$(PREFIX)/lib/$LIBNAME"
fi
compile_targets=""
install_targets=""
for target in $targets ; do
compile_targets="$compile_targets compile-$target"
install_targets="$install_targets install-$target"
done
sed -e "s|{PREFIX}|$prefix|g" \
-e "s|{CC}|$cc|g" \
-e "s|{LIBPATH}|$libpath|g" \
-e "s|{CFLAGS}|$CFLAGS|g" \
-e "s|{LDFLAGS}|$LDFLAGS|g" \
-e "s|{SHAREDLIBRARYFLAGS}|$SHAREDLIBRARYFLAGS|g" \
-e "s|{SHAREDFLAG}|$SHAREDFLAG|g" \
-e "s|{SHAREDNAMEFLAG}|$SHAREDNAMEFLAG|g" \
-e "s|{LIBNAME}|$LIBNAME|g" \
-e "s|{PYTHON}|$python|g" \
-e "s|{PYTHON_INSTALL_OPTION}|$python_install_option|g" \
-e "s|{COMPILE_TARGETS}|$compile_targets|g" \
-e "s|{INSTALL_TARGETS}|$install_targets|g" \
< Makefile.in > Makefile
echo
echo "Install prefix: $prefix"
echo "Library path: $libpath"
echo "Compiler: $cc"
echo "Python: $python"
echo "Targets: $targets"
echo
echo "Configure successful"