-
Notifications
You must be signed in to change notification settings - Fork 93
/
Copy pathconfig.m4
86 lines (73 loc) · 2.46 KB
/
config.m4
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
dnl
dnl $ Id: opencv 1.0.1$
dnl
PHP_ARG_WITH(opencv, for OpenCV support,
[ --with-opencv Enable OpenCV support], yes)
if test "$PHP_OPENCV" != "no"; then
export OLD_CPPFLAGS="$CPPFLAGS"
export CPPFLAGS="$CPPFLAGS $INCLUDES -DHAVE_OPENCV"
AC_MSG_CHECKING(PHP version)
AC_TRY_COMPILE([#include <php_version.h>], [
#if PHP_VERSION_ID < 50200
#error this extension requires at least PHP version 5.2.0
#endif
],
[AC_MSG_RESULT(ok)],
[AC_MSG_ERROR([need at least PHP 5.2.0])])
export CPPFLAGS="$OLD_CPPFLAGS"
PHP_REQUIRE_CXX()
PHP_SUBST(OPENCV_SHARED_LIBADD)
PHP_ADD_LIBRARY(stdc++, 1, OPENCV_SHARED_LIBADD)
AC_DEFINE(HAVE_OPENCV, 1, [ ])
PHP_NEW_EXTENSION(
opencv,
opencv.cpp opencv_error.cpp opencv_mat.cpp opencv_image.cpp opencv_histogram.cpp opencv_capture.cpp,
$ext_shared,
,
,
"yes")
EXT_OPENCV_HEADERS="php_opencv_api.h"
ifdef([PHP_INSTALL_HEADERS], [
PHP_INSTALL_HEADERS(ext/opencv, $EXT_OPENCV_HEADERS)
])
if test "$PHP_OPENCV" != "no"; then
OPENCV_CHECK_DIR=$PHP_OPENCV
OPENCV_TEST_FILE=opencv/include/cv.h
OPENCV_LIBNAME=opencv
fi
condition="$OPENCV_CHECK_DIR$OPENCV_TEST_FILE"
if test -r $condition; then
OPENCV_DIR=$OPENCV_CHECK_DIR
CFLAGS="$CFLAGS -I$OPENCV_DIR/include"
LDFLAGS=`$OPENCV_DIR/bin/opencv-config --libs`
else
AC_MSG_CHECKING(for pkg-config)
if test ! -f "$PKG_CONFIG"; then
PKG_CONFIG=`which pkg-config`
fi
if test -f "$PKG_CONFIG"; then
AC_MSG_RESULT(found)
AC_MSG_CHECKING(for opencv)
if $PKG_CONFIG --exists opencv; then
if $PKG_CONFIG --atleast-version=2.1.0 opencv; then
opencv_version_full=`$PKG_CONFIG --modversion opencv`
AC_MSG_RESULT([found $opencv_version_full])
OPENCV_LIBS="$LDFLAGS `$PKG_CONFIG --libs opencv`"
OPENCV_INCS="$CFLAGS `$PKG_CONFIG --cflags-only-I opencv`"
PHP_EVAL_INCLINE($OPENCV_INCS)
PHP_EVAL_LIBLINE($OPENCV_LIBS, OPENCV_SHARED_LIBADD)
AC_DEFINE(HAVE_OPENCV, 1, [whether opencv exists in the system])
else
AC_MSG_RESULT(too old)
AC_MSG_ERROR(Ooops ! You need at least opencv 2.1.0)
fi
else
AC_MSG_RESULT(not found)
AC_MSG_ERROR(Ooops ! no opencv detected in the system)
fi
else
AC_MSG_RESULT(not found)
AC_MSG_ERROR(Ooops ! no pkg-config found .... )
fi
fi
fi