forked from OpenVVC/OpenVVC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·247 lines (200 loc) · 5.86 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
245
246
247
#!/bin/sh
config="$@"
prefix_default="/usr/local"
cc_default="gcc"
builddir_default="$(pwd)/build"
srcdir_default="$(pwd)/"
teststreams_dir_default="$(pwd)/CI/test_bitstreams/all_intra/"
teststreams_url_default="http://openvvc.insa-rennes.fr/bitstreams/JVET_CTC/all_intra/"
debug_cflags="-O0 -g -Wall --pedantic"
release_cflags="-O3 -Wall"
cflags_olevel="-O3"
cflags_warnings="-Wall"
cflags_error=
cflags_default="${cflags_warnings} ${cflags_olevel}"
sse_enabled="1"
neon_enabled="1"
posix_memalign="0"
aligned_malloc="0"
log_enabled="1"
is_win32="0"
slhdr_enabled="0"
show_help() {
cat <<EOF
Usage: configure [options]
Options: [defaults in brackets after descriptions]
Options:
--prefix=PREFIX install in PREFIX [$prefix_default]
--libdir=LIBDIR install library in LIBDIR [PREFIX/lib]
--includedir=DIR install includes in DIR [PREFIX/include]
--pkgconfigdir=DIR install pkg-config files in DIR [LIBDIR/pkgconfig]
--build-dir=DIR build objects in DIR [$builddir_default]
--src-dir=DIR build objects in DIR [$srcdir_default]
--help print this message
--disable-log disable log reportings [no]
--disable-sse disable sse optimizations [no]
--disable-neon disable neon optimizations [no]
--disable-static do not build static libraries [no]
--enable-shared build shared libraries [no]
--enable-slhdr build slhdr feature [no]
--cc=CC select compiler [$cc_default]
--arch=ARCH select architecture [$arch]
--target-os=OS compiler targets OS [$target_os]
--cross-prefix=PREFIX use PREFIX for compilation tools [$cross_prefix]
--enable-cross-compile assume a cross-compiler is used
--cflags=CFLAGS use CFLAGS as compiler flags [$cflags_default]
--release use specific release compiler flags [CFLAGS ${release_cflags}]
--debug use specific debug compiler cflags [CFLAGS ${debug_cflags}]
--teststreams-dir=DIR read test bitstreams from DIR[$teststreams_dir_default]
--teststreams-url=URL download test bitstreams and md5sum from URL[$teststreams_url_default]
EOF
exit 0
}
# Set default values
prefix=$prefix_default
libdir='${prefix}/lib'
includedir='${prefix}/include'
pkgconfigdir='${libdir}/pkgconfig'
build_dir=$builddir_default
src_dir=$srcdir_default
teststreams_dir=$teststreams_dir_default
teststreams_url=$teststreams_url_default
cc=$cc_default
arch="$(uname -m)"
target_os="$(uname -s)"
# Override values set by user
for opt do
optval="${opt#*=}"
case "$opt" in
--help|-h) show_help
;;
--release)
cflags="${cflags} ${release_cflags}"
;;
--debug)
cflags="${cflags} ${debug_cflags}"
;;
--disable-sse)
sse_enabled="0"
;;
--disable-neon)
neon_enabled="0"
;;
--disable-log)
log_enabled="0"
;;
--enable-slhdr)
slhdr_enabled="1"
;;
*)
optname="${opt%%=*}"
optname="${optname#--}"
optname=$(echo "$optname" | sed 's/-/_/g')
eval $optname='$optval'
;;
esac
done
# Create build directory if it doesn't exist
[ -d $build_dir ] || mkdir -p $build_dir
# cat >> Makefile <<EOF
# cd $build_dir
# EOF
# Force path to absolute
build_dir=$( cd $build_dir; pwd )
# Copy Makefile to build directory
cp Makefile.in $build_dir/Makefile
if [ -z "$cflags" ] ; then
cflags="$cflags_default"
fi
# Select arch var according to common arch names
is_arm="0"
is_x86="0"
case "$arch" in
arm*|aarch*)
arch="arm"
is_arm="1"
;;
i[3-6]86*|x86_64|x86_32|amd64)
arch="x86"
is_x86="1"
;;
*)
echo "Unsupported archictecture $arch"
exit 1.
;;
esac
case $target_os in
*win32|*win64)
shlib_suffix=".dll"
stlib_suffix=".lib"
aligned_malloc="1"
is_win32="1"
;;
*)
shlib_suffix=".so"
stlib_suffix=".a"
# Append PIC flag for shared lib
cflags="${cflags} -fPIC"
posix_memalign="1"
;;
esac
cc="${cross_prefix}${cc}"
ar="${cross_prefix}ar"
ranlib="${cross_prefix}ranlib"
cat > ${build_dir}/config.mak <<EOF
OVVC_CONFIG="${config}"
CC=${cc}
AR=${ar}
RANLIB=${ranlib}
ARCH=${arch}
CFLAGS=${cflags}
LD_FLAGS=-lpthread
SSE_CFLAGS= -mssse3 -msse4.1
SHARED_LIBSUFF:=${shlib_suffix}
STATIC_LIBSUFF:=${stlib_suffix}
SRC_PATH=${src_dir}
BUILDDIR=${build_dir}
TESTSTREAMSDIR=$teststreams_dir_default
STREAMURL=$teststreams_url
INSTALL_PREFIX=${prefix}
INSTALL_LIB=\$(INSTALL_PREFIX)/lib/libopenvvc
INSTALL_INCLUDE=\$(INSTALL_PREFIX)/include/libopenvvc
INSTALL_PKGCONFIG=\$(INSTALL_PREFIX)/lib/pkgconfig
INSTALL_BIN=\$(INSTALL_PREFIX)/bin
EOF
test_slhdr() {
pkg-config --exists slhdr_cwrap && return 0 || slhdr_enabled="0" && return 1
}
set_slhdr() {
EXTRA_LD_FLAGS=$(pkg-config --libs slhdr_cwrap)
EXTRA_CFLAGS=$(pkg-config --cflags slhdr_cwrap)
cat >> ${build_dir}/config.mak <<EOF
EXTRA_CFLAGS=${EXTRA_CFLAGS}
EXTRA_LD_FLAGS=${EXTRA_LD_FLAGS}
EOF
}
if [ ${slhdr_enabled} = "1" ] ; then
test_slhdr && set_slhdr || { echo "SL-HDR C wrapper not found" && exit 1 ; }
fi
cat > ${build_dir}/config.sh <<EOF
INSTALL_PREFIX=${prefix}
INSTALL_LIB=\${INSTALL_PREFIX}/lib/libopenvvc
INSTALL_INCLUDE=\${INSTALL_PREFIX}/include/libopenvvc
INSTALL_PKGCONFIG=\${INSTALL_PREFIX}/lib/pkgconfig
INSTALL_BIN=\${INSTALL_PREFIX}/bin
EXTRA_CFLAGS="${EXTRA_CFLAGS}"
EXTRA_LD_FLAGS="${EXTRA_LD_FLAGS}"
EOF
cat > ${build_dir}/ovconfig.h <<EOF
#define _WIN32 $is_win32
#define ARCH_X86 $is_x86
#define SSE_ENABLED $sse_enabled
#define AVX_ENABLED 0
#define ARCH_AARCH64 $is_arm
#define NEON_ENABLED $neon_enabled
#define HAVE_POSIX_MEMALIGN $posix_memalign
#define HAVE_ALIGNED_MALLOC $aligned_malloc
#define ENABLE_LOG $log_enabled
#define ENABLE_SLHDR $slhdr_enabled
EOF
exit 0