1+ dnl Licensed to the Apache Software Foundation (ASF) under one
2+ dnl or more contributor license agreements. See the NOTICE file
3+ dnl distributed with this work for additional information
4+ dnl regarding copyright ownership. The ASF licenses this file
5+ dnl to you under the Apache License, Version 2.0 (the
6+ dnl "License"); you may not use this file except in compliance
7+ dnl with the License. You may obtain a copy of the License at
8+ dnl
9+ dnl http://www.apache.org/licenses/LICENSE-2.0
10+ dnl
11+ dnl Unless required by applicable law or agreed to in writing,
12+ dnl software distributed under the License is distributed on an
13+ dnl "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+ dnl KIND, either express or implied. See the License for the
15+ dnl specific language governing permissions and limitations
16+ dnl under the License.
17+
18+ PHP_ARG_ENABLE([ fs_notify] ,
19+ [ whether to enable fs_notify support] ,
20+ [ AS_HELP_STRING ( [ --enable-fs-notify] ,
21+ [ Enable fs_notify support] ) ] ,
22+ [ no] )
23+
24+ PHP_ARG_ENABLE([ cargo_debug] , [ whether to enable cargo debug mode] ,
25+ [ --enable-cargo-debug Enable cargo debug] , no, no)
26+
27+ if test "$PHP_THREAD_SAFETY" == "yes"; then
28+ AC_MSG_ERROR ( [ fs_notify does not support ZTS] )
29+ fi
30+
31+ if test "$PHP_FS_NOTIFY" != "no"; then
32+ AC_PATH_PROG ( CARGO , cargo , no )
33+ if ! test -x "$CARGO"; then
34+ AC_MSG_ERROR ( [ cargo command missing, please reinstall the cargo distribution] )
35+ fi
36+
37+ AC_DEFINE ( HAVE_FS_NOTIFY , 1 , [ Have fs_notify support ] )
38+
39+ PHP_NEW_EXTENSION(fs_notify, [ ] , $ext_shared)
40+
41+ CARGO_MODE_FLAGS="--release"
42+ CARGO_MODE_DIR="release"
43+
44+ if test "$PHP_CARGO_DEBUG" != "no"; then
45+ CARGO_MODE_FLAGS=""
46+ CARGO_MODE_DIR="debug"
47+ fi
48+
49+ cat >>Makefile.objects<< EOF
50+ all: cargo_build
51+
52+ clean: cargo_clean
53+
54+ cargo_build:
55+ PHP_CONFIG=$PHP_PHP_CONFIG cargo build $CARGO_MODE_FLAGS
56+ if [ [ -f ./target/$CARGO_MODE_DIR/libphp_ext_fs_notify.dylib ] ] ; then \\
57+ cp ./target/$CARGO_MODE_DIR/libphp_ext_fs_notify.dylib ./modules/fs_notify.dylib ; fi
58+ if [ [ -f ./target/$CARGO_MODE_DIR/libphp_ext_fs_notify.so ] ] ; then \\
59+ cp ./target/$CARGO_MODE_DIR/libphp_ext_fs_notify.so ./modules/fs_notify.so ; fi
60+
61+ cargo_clean:
62+ cargo clean
63+
64+ .PHONY: cargo_build cargo_clean
65+ EOF
66+
67+ AC_CONFIG_LINKS ( [ \
68+ Cargo.lock:Cargo.lock \
69+ Cargo.toml:Cargo.toml \
70+ build.rs:build.rs \
71+ src:src \
72+ tests:tests \
73+ ] )
74+ fi
0 commit comments