-
Notifications
You must be signed in to change notification settings - Fork 6
/
configure
executable file
·244 lines (208 loc) · 6.06 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
#!/bin/sh
#----------------------------------------------------------------------------
# configure script for VapourSynth-Bilateral
#----------------------------------------------------------------------------
## This script was modified based on d2vsource/configure.
# -- help -------------------------------------------------------------------
if test x"$1" = x"-h" -o x"$1" = x"--help" ; then
cat << EOF
Usage: [PKG_CONFIG_PATH=/foo/bar/lib/pkgconfig] ./configure [options]
options:
-h, --help print help (this)
--install=PATH set dir for install library
[/usr/local/lib/vapoursynth]
--cxx=CXX use a defined compiler for compilation and linking
[g++]
--target-os=OS build programs to run on OS [auto]
--cross-prefix=PREFIX use PREFIX for compilation tools
--sysroot=SYSROOT root of cross-build tree
--enable-debug compile with debug symbols and never strip
--extra-cxxflags=XCXXFLAGS add XCXXFLAGS to CXXFLAGS
--extra-ldflags=XLDFLAGS add XLDFLAGS to LDFLAGS
--extra-libs=XLIBS add XLIBS to LIBS
--target=TARGET set target instruction set [sse2]
EOF
exit 1
fi
#-- func --------------------------------------------------------------------
error_exit()
{
echo error: $1
exit 1
}
log_echo()
{
echo $1
echo >> config.log
echo --------------------------------- >> config.log
echo $1 >> config.log
}
cc_check()
{
rm -f conftest.c
if [ -n "$3" ]; then
echo "#include <$3>" >> config.log
echo 'extern "C" {' > conftest.cpp
echo "#include <$3>" >> conftest.cpp
echo } >> conftest.cpp
fi
echo "int main(void){$4 return 0;}" >> config.log
echo "int main(void){$4 return 0;}" >> conftest.cpp
echo $CXX conftest.cpp -o conftest $1 $2 >> config.log
$CXX conftest.cpp -o conftest $1 $2 2>> config.log
ret=$?
echo $ret >> config.log
rm -f conftest*
return $ret
}
#----------------------------------------------------------------------------
rm -f config.* .depend
SRCDIR="$(cd $(dirname $0); pwd)"
test "$SRCDIR" = "$(pwd)" && SRCDIR=.
test -n "$(echo $SRCDIR | grep ' ')" && \
error_exit "out-of-tree builds are impossible with whitespace in source path"
# -- init -------------------------------------------------------------------
libdir="/usr/local/lib/vapoursynth"
TARGET_OS=""
CROSS=""
SYSROOT=""
CXX="g++"
LD="g++"
STRIP="strip"
DEBUG=""
LIBNAME=""
CXXFLAGS="-std=c++11 -Wall -I. -I$SRCDIR/include"
LDFLAGS=""
SOFLAGS="-shared"
TARGET="-msse2"
# -- options ----------------------------------------------------------------
echo all command lines: > config.log
echo "$*" >> config.log
for opt; do
optarg="${opt#*=}"
case "$opt" in
--install=*)
libdir="$optarg"
;;
--enable-debug)
DEBUG="enabled"
CXXFLAGS="$CXXFLAGS -g"
;;
--cxx=*)
CXX="$optarg"
LD="$optarg"
;;
--extra-cxxflags=*)
XCXXFLAGS="$optarg"
;;
--extra-ldflags=*)
XLDFLAGS="$optarg"
;;
--extra-libs=*)
XLIBS="$optarg"
;;
--target-os=*)
TARGET_OS="$optarg"
;;
--cross-prefix=*)
CROSS="$optarg"
;;
--sysroot=*)
CXXFLAGS="$CXXFLAGS --sysroot=$optarg"
LDFLAGS="$LDFLAGS --sysroot=$optarg"
;;
--target=*)
TARGET="-m$optarg"
;;
*)
error_exit "unknown option $opt"
;;
esac
done
CXXFLAGS="$CXXFLAGS $XCXXFLAGS $TARGET"
LDFLAGS="$LDFLAGS $XLDFLAGS"
CXX="${CROSS}${CXX}"
LD="${CROSS}${LD}"
STRIP="${CROSS}${STRIP}"
for f in "$CXX" "$LD" "$STRIP"; do
test -n "$(which $f 2> /dev/null)" || error_exit "$f is not executable"
done
if test -n "$TARGET_OS"; then
TARGET_OS=$(echo $TARGET_OS | tr '[A-Z]' '[a-z]')
else
TARGET_OS=$($CXX -dumpmachine | tr '[A-Z]' '[a-z]')
fi
case "$TARGET_OS" in
*mingw*)
LIBNAME="Bilateral.dll"
SOFLAGS="$SOFLAGS -Wl,--dll,--add-stdcall-alias"
;;
*darwin*)
LIBNAME="libbilateral.dylib"
SOFLAGS="$SOFLAGS -dynamiclib -Wl,-undefined,suppress -Wl,-read_only_relocs,suppress -Wl,-flat_namespace"
;;
*linux*)
LIBNAME="libbilateral.so"
CXXFLAGS="$CXXFLAGS -fPIC"
SOFLAGS="$SOFLAGS -fPIC"
;;
*)
error_exit "target is unsupported system"
esac
log_echo "CXXFLAGS/LDFLAGS checking..."
if ! cc_check "$CXXFLAGS" "$LDFLAGS"; then
error_exit "invalid CXXFLAGS/LDFLAGS"
fi
if cc_check "-O2 -ffast-math $CXXFLAGS" "$LDFLAGS"; then
CXXFLAGS="-O2 -ffast-math $CXXFLAGS"
fi
if cc_check "$CXXFLAGS" "$LDFLAGS"; then
CXXFLAGS="$CXXFLAGS"
fi
PKGCONFIGBIN="pkg-config"
test -n "$(which ${CROSS}${PKGCONFIGBIN} 2> /dev/null)" && \
PKGCONFIGBIN=${CROSS}${PKGCONFIGBIN}
log_echo "checking for vapoursynth headers..."
if $PKGCONFIGBIN --exists vapoursynth 2> /dev/null; then
VSCFLAGS="$($PKGCONFIGBIN --cflags vapoursynth)"
else
log_echo "warning: pkg-config or pc files not found, header detection may be inaccurate."
fi
if ! cc_check "$CXXFLAGS $VSCFLAGS" "$LDFLAGS $LIBS $XLIBS" "VapourSynth.h" "getVapourSynthAPI;" ; then
log_echo "error: vapoursynth checking failed."
error_exit "VapourSynth.h might not be installed."
fi
LDFLAGS="$SOFLAGS $LDFLAGS"
LIBS="$LIBS $XLIBS"
CXXFLAGS="$CXXFLAGS $VSCFLAGS"
cat >> config.mak << EOF
CXX = $CXX
LD = $LD
STRIP = $STRIP
CXXFLAGS = $CXXFLAGS
LDFLAGS = $LDFLAGS
LIBS = $LIBS
SRCDIR = $SRCDIR
LIBNAME = $LIBNAME
libdir = $libdir
EOF
cat >> config.log << EOF
---------------------------------
setting
---------------------------------
EOF
cat config.mak >> config.log
cat << EOF
settings...
CXX = $CXX
LD = $LD
STRIP = $STRIP
CXXFLAGS = $CXXFLAGS
LDFLAGS = $LDFLAGS
LIBS = $LIBS
LIBNAME = $LIBNAME
install path = $libdir
EOF
test "$SRCDIR" = "." || ln -sf $SRCDIR/GNUmakefile .
echo configure finished.
exit 0