aboutsummaryrefslogtreecommitdiff
path: root/devel/pecl-inotify/files/patch-config.m4
blob: 9054c2f26c1cf4dea07f555978b4863f736f65db (plain) (blame)
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
--- config.m4.orig	2016-01-30 12:34:05 UTC
+++ config.m4
@@ -1,22 +1,51 @@
 dnl $Id$
 dnl config.m4 for extension inotify
 
-PHP_ARG_ENABLE(inotify, whether to enable inotify support,
-[  --enable-inotify        Enable inotify support])
+PHP_ARG_WITH(inotify, whether to enable inotify support,
+[  --with-inotify        Enable inotify support])
 
 if test "$PHP_INOTIFY" != "no"; then
+  SEARCH_PATH="/usr /usr/local"
+  SEARCH_FOR="/sys/inotify.h"
 
-  AC_TRY_RUN([
-   #include <sys/inotify.h>
-   void testfunc(int (*passedfunc)()) {
-   }
-   int main() {
-    testfunc(inotify_init);
-    return 0;
-   }
-  ],[],[
-   AC_MSG_ERROR(Your system does not support inotify)
+  if test "$PHP_INOTIFY" = "yes"; then
+    AC_MSG_CHECKING([for libinotify headers in default path])
+    for i in $SEARCH_PATH ; do
+      if test -r $i/include/$SEARCH_FOR; then
+        LIBINOTIFY_DIR=$i
+        AC_MSG_RESULT(found in $i)
+      fi
+    done
+  else
+    AC_MSG_CHECKING([for libinotify headers in $PHP_INOTIFY])
+    if test -r $PHP_INOTIFY/$SEARCH_FOR; then
+      LIBINOTIFY_DIR=$PHP_INOTIFY
+      AC_MSG_RESULT([found])
+    fi
+  fi
+
+  if test -z "$LIBINOTIFY_DIR"; then
+    AC_MSG_RESULT([not found])
+    AC_MSG_ERROR([Cannot find libevent headers])
+  fi
+
+  LIBNAME=inotify
+  LIBSYMBOL=inotify_init
+
+  if test "x$PHP_LIBDIR" = "x"; then
+    PHP_LIBDIR=lib
+  fi
+
+  PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL,
+  [
+    PHP_ADD_INCLUDE($LIBINOTIFY_DIR/include)
+    PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $LIBINOTIFY_DIR/$PHP_LIBDIR, INOTIFY_SHARED_LIBADD)
+  ],[
+    AC_MSG_ERROR([Your system does not support inotify])
+  ],[
+    -L$LIBINOTIFY_DIR/$PHP_LIBDIR
   ])
 
+  PHP_SUBST(INOTIFY_SHARED_LIBADD)
   PHP_NEW_EXTENSION(inotify, inotify.c, $ext_shared)
 fi