forked from clearscene/pHash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
301 lines (237 loc) · 8.16 KB
/
configure.ac
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
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ(2.61)
AC_INIT([pHash],[0.9.4],[support@phash.org])
AM_INIT_AUTOMAKE($PACKAGE_NAME,$PACKAGE_VERSION)
AC_CONFIG_SRCDIR([src/pHash.cpp])
AC_CONFIG_HEADERS([config.h pHash-config.h])
# Checks for programs.
m4_include([m4/ax_pthread.m4])
AC_PROG_CXX
AC_PROG_CC
AM_PROG_GCJ
if test -z $DISTRO; then
AC_CHECK_FILE(/etc/gentoo-release, [DISTRO="gentoo"])
AC_CHECK_FILE(/etc/redhat-release, [DISTRO="redhat"])
AC_CHECK_FILE(/etc/slackware-version, [DISTRO="slackware"])
AC_CHECK_FILE(/etc/debian_version, [DISTRO="debian"])
AC_CHECK_FILE(/etc/SuSErelease, [DISTRO="suse"])
fi
# largefile support is needed for python bindings ( type off_t 64 bits)
AC_SYS_LARGEFILE
AC_ARG_ENABLE(pthread, [AS_HELP_STRING([--disable-pthread],
[pthread support @<:@default=no@:>@])],
[PTHREAD="$enableval"],
[PTHREAD="yes"])
if test "$PTHREAD" = "yes"; then
AX_PTHREAD([
LIBS="$PTHREAD_LIBS $LIBS"
CPPFLAGS="$CFLAGS $PTHREAD_CFLAGS"
CC="$PTHREAD_CC"
AC_DEFINE([HAVE_PTHREAD], [1], [configure with pthread support])
])
fi
AM_CONDITIONAL([HAVE_PTHREAD], [test "$PTHREAD" = "yes"])
AC_ARG_ENABLE(debug, [AS_HELP_STRING([--enable-debug],
[compile with debugging support @<:@default=no@:>@])],
debug=$enableval, debug=no)
AS_IF([test x"$debug" != x"no"],
[CXXFLAGS="`echo $CXXFLAGS' ' | sed 's/-O[0-9]//g'`"
CXXFLAGS="$CXXFLAGS -O0 -g"
LDFLAGS="$PTHREAD_LIBS $LIBS $CFLAGS $PTHREAD_CFLAGS"
LDFLAGS="`echo $LDFLAGS | sed 's/-g//g' | sed 's/-O[0-9]//g'`"],
[CXXFLAGS="`echo $CXXFLAGS' -ffast-math' | sed 's/-g//g' | sed 's/-O[0-9]//g'`"
CXXFLAGS="$CXXFLAGS -O3"
CPPFLAGS="`echo $CPPFLAGS | sed 's/-g//g' | sed 's/-O[0-9]//g'`"
LDFLAGS="$PTHREAD_LIBS $LIBS $CFLAGS $PTHREAD_CFLAGS"
LDFLAGS="`echo $LDFLAGS | sed 's/-g//g' | sed 's/-O[0-9]//g'`"])
AC_ARG_ENABLE(openmp, [AS_HELP_STRING([--enable-openmp],
[enable OpenMP support in pHash to use multiple cores/CPUs @<:@default=no@:>@])],
openmp=yes, openmp=no)
AS_IF([test "$openmp" = "yes"],
[
CPPFLAGS="$CPPFLAGS -Dcimg_use_openmp"
if test $GCC = "yes"; then
CXXFLAGS="$CXXFLAGS -fopenmp"
fi
])
AC_ARG_ENABLE(java, [AS_HELP_STRING([--enable-java],
[compile java (JNI) binding for pHash @<:@default=no@:>@])],
java=yes, java=no)
AS_IF([test "$java" = "yes"],
[
AC_CHECK_HEADER([jni.h], [found_jni="y"], [found_jni="n"])
if test x"$found_jni" = x"n"; then
AC_MSG_CHECKING([whether jni.h is in the current or src directory.])
if [test `ls . src | grep "jni.h"` >/dev/null 2>&1]; then
AC_MSG_RESULT([yes])
found_java="y"
else
AC_MSG_RESULT([no])
AC_MSG_CHECKING([if jni.h is in other system directories.])
jni_header=`locate jni.h|grep include/jni.h|head -n1`
if test x"$jni_header" != "x"; then
AC_MSG_RESULT([yes])
jni_header=`dirname $jni_header`
jni_md_header=$jni_header"/"`uname|tr '[A-Z]' '[a-z]'`
CPPFLAGS="$CPPFLAGS -I $jni_header -I $jni_md_header"
else
AC_MSG_RESULT([no])
fi
fi
fi
])
AM_CONDITIONAL([WITH_JAVA], test x$java != xno)
AC_PROG_INSTALL
AC_LANG([C++])
AC_PROG_LN_S
m4_defun([_LT_AC_LANG_F77_CONFIG], [:])
AC_PROG_LIBTOOL
AC_SUBST([LIBTOOLS_DEPS])
LDFLAGS="$LDFLAGS -L/usr/local/lib"
CPPFLAGS="$CPPFLAGS -I/usr/local/include"
AC_DEFUN([AC_CHECK_CIMG], [
AC_CHECK_HEADER([CImg.h], [found_cimg="y"], [found_cimg="n"])
if test x"$found_cimg" = x"n"; then
AC_MSG_CHECKING([whether CImg.h is in the current or src directory.])
if [test `ls . src | grep "CImg.h"` >/dev/null 2>&1]; then
AC_MSG_RESULT([yes])
found_cimg="y"
else
AC_MSG_RESULT([no])
fi
fi])
AC_DEFUN([AC_CHECK_FFTW3],
[
AC_MSG_CHECKING([whether FFTW3 is present])
AC_CHECK_LIB([fftw3], [fftw_plan_dft_r2c_1d], [], [AC_MSG_ERROR([
*** libfftw3 not found.
You need FFTW3. Get it at <http://fftw.org/>])])
found_fftw="y"])
AC_DEFUN([AC_CHECK_FFMPEG],
[
AC_MSG_CHECKING([whether FFmpeg is present])
AC_CHECK_LIB([avcodec], [avcodec_alloc_frame], [], [AC_MSG_ERROR([
*** libavcodec not found.
You need FFmpeg. Get it at <http://ffmpeg.org/>])])
AC_CHECK_LIB([avutil], [av_log_set_level], [], [AC_MSG_ERROR([
*** libavutil not found.
You need FFmpeg. Get it at <http://ffmpeg.org/>])])
AC_CHECK_LIB([avformat], [av_read_frame], [], [AC_MSG_ERROR([
*** libavformat not found.
You need FFmpeg. Get it at <http://ffmpeg.org/>])])
AC_CHECK_LIB([swscale], [sws_getContext], [], [AC_MSG_ERROR([
*** libswscale not found.
You need FFmpeg. Get it at <http://ffmpeg.org/>])])
found_ffmpeg="y"])
AC_DEFUN([AC_CHECK_SNDFILE],
[
AC_MSG_CHECKING([whether sndfile lib is present])
AC_CHECK_LIB([sndfile], [sf_readf_float], [], [AC_MSG_ERROR([
*** libsndfile not found.
You need sndfile. Get it at <http://www.mega-nerd.com/libsndfile/>])])
found_sndfile="y"])
AC_DEFUN([AC_CHECK_SAMPLERATE],
[
AC_MSG_CHECKING([whether samplerate lib is present])
AC_CHECK_LIB([samplerate],[src_process],[],[AC_MSG_ERROR([
*** libsamplerate not found.
You need samplerate. Get it at <http://www.mega-nerd.com/libsamplerate/>])])
found_samplerate="y"])
AC_DEFUN([AC_CHECK_MPG123],
[
AC_MSG_CHECKING([whether libmpg123 is present])
AC_CHECK_LIB([mpg123],[mpg123_init],[],[AC_MSG_ERROR([
*** libmpg123 not found.
You need libmpg123.
Get it at <http://www.mpg123.de/>])])
found_mpg123="y"])
AC_ARG_ENABLE([image-hash], [AS_HELP_STRING([--enable-image-hash],[include support for perceptual image hashes @<:@default=yes@:>@])],
[image_hash=$enableval], [image_hash=yes])
AS_IF([test x"$image_hash" != x"no"],
[
echo
echo "*** Configuring image hash ***"
echo
AC_CHECK_CIMG()
AC_DEFINE([HAVE_IMAGE_HASH], [1], [configure with image hash])
])
AM_CONDITIONAL(HAVE_IMAGE_HASH, test x$image_hash != xno)
AC_ARG_ENABLE([video-hash], [AS_HELP_STRING([--enable-video-hash],[include support for perceptual video hashes @<:@default=yes@:>@])],
[video_hash=$enableval], [video_hash=yes])
AS_IF([test x"$video_hash" != x"no"],
[
echo
echo "*** Configuring video Hash ***"
echo
if test "$found_ffmpeg" != "y"; then
AC_CHECK_FFMPEG()
fi
if test "$found_cimg" != "y"; then
AC_CHECK_CIMG()
fi
AC_DEFINE([HAVE_VIDEO_HASH],[1], [configure with video hash])
])
AM_CONDITIONAL(HAVE_VIDEO_HASH, test x$video_hash != xno)
AC_ARG_ENABLE([audio-hash], [AS_HELP_STRING([--enable-audio-hash],[include support for perceptual audio hashes @<:@default=yes@:>@])],
[audio_hash=$enableval], [audio_hash=yes])
AS_IF([test x"$audio_hash" != x"no"],
[
echo
echo "*** Configuring audio hash ***"
echo
if test "$found_sndfile" != "y"; then
AC_CHECK_SNDFILE()
fi
if test "$found_samplerate" != "y"; then
AC_CHECK_SAMPLERATE()
fi
if test "$found_mpg123" != "y"; then
AC_CHECK_MPG123()
fi
AC_DEFINE([HAVE_AUDIO_HASH],[1], [configure with audio hash])
])
AM_CONDITIONAL(HAVE_AUDIO_HASH, test x$audio_hash != xno)
if test "$video_hash" = "yes"; then
case "$DISTRO" in
debian)
CPPFLAGS="$CPPFLAGS -I/usr/include/ffmpeg"
;;
redhat)
CPPFLAGS="$CPPFLAGS -I/usr/include/libavcodec -I/usr/include/libavformat -I/usr/include/libswscale"
;;
esac
fi
# Checks for libraries.
AC_CHECK_LIB([jpeg], [jpeg_read_header], [use_jpeg="y"])
AC_CHECK_LIB([m], [sqrt])
AC_CHECK_LIB([png], [png_create_read_struct], [use_png="y"])
AS_IF([test "$found_fftw" = "y"],
[
CPPFLAGS="$CPPFLAGS -Dcimg_use_fftw3"])
AS_IF([test "$use_jpeg" = "y" -a \( "$image_hash" = "yes" -o "$video_hash" = "yes" \)],
[
CPPFLAGS="$CPPFLAGS -Dcimg_use_jpeg"
LDFLAGS="$LDFLAGS -ljpeg"])
AS_IF([test "$use_png" = "y" -a \( "$image_hash" = "yes" -o "$video_hash" = "yes" \)],
[
CPPFLAGS="$CPPFLAGS -Dcimg_use_png"
LDFLAGS="$LDFLAGS -lpng"])
CFLAGS="$CXXFLAGS"
# Checks for header files.
AC_CHECK_HEADERS([limits.h stdlib.h string.h sys/time.h unistd.h])
# Checks for typedefs, structures, and compiler characteristics.
AC_HEADER_STDBOOL
AC_C_INLINE
AC_TYPE_INT16_T
AC_TYPE_SIZE_T
AC_TYPE_UINT32_T
AC_TYPE_UINT8_T
AC_CHECK_TYPE([uint64_t],[],[AC_MSG_ERROR([
*** Required type uint64_t not found.
pHash requires 64-bit integers for video and image hashes.])])
# Checks for library functions.
AC_FUNC_ERROR_AT_LINE
AC_CHECK_FUNCS([mremap malloc realloc floor gettimeofday memmove memset pow sqrt strcasecmp strdup strncasecmp])
AC_CONFIG_FILES([Makefile src/Makefile examples/Makefile pHash.pc bindings/Makefile bindings/java/Makefile])
AC_OUTPUT