-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.m4
68 lines (54 loc) · 2.02 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
dnl Copyright (c) 2022 PHPER Framework Team
dnl PHPER is licensed under Mulan PSL v2.
dnl You can use this software according to the terms and conditions of the Mulan
dnl PSL v2. You may obtain a copy of Mulan PSL v2 at:
dnl http://license.coscl.org.cn/MulanPSL2
dnl THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY
dnl KIND, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO
dnl NON-INFRINGEMENT, MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
dnl See the Mulan PSL v2 for more details.
PHP_ARG_ENABLE([crc64],
[whether to enable crc64 support],
[AS_HELP_STRING([--enable-crc64],
[Enable crc64 support])],
[no])
dnl If not enable, `cargo build` run with argument `--release`.
PHP_ARG_ENABLE([cargo_debug], [whether to enable cargo debug mode],
[ --enable-cargo-debug Enable cargo debug], no, no)
if test "$PHP_crc64" != "no"; then
dnl Check cargo command exists or not.
AC_PATH_PROG(CARGO, cargo, no)
if ! test -x "$CARGO"; then
AC_MSG_ERROR([cargo command missing, please reinstall the cargo distribution])
fi
AC_DEFINE(HAVE_crc64, 1, [ Have crc64 support ])
PHP_NEW_EXTENSION(crc64, [ ], $ext_shared)
CARGO_MODE_FLAGS="--release"
CARGO_MODE_DIR="release"
if test "$PHP_CARGO_DEBUG" != "no"; then
CARGO_MODE_FLAGS=""
CARGO_MODE_DIR="debug"
fi
cat >>Makefile.objects<< EOF
all: cargo_build
clean: cargo_clean
cargo_build:
# Build the extension file
PHP_CONFIG=$PHP_PHP_CONFIG cargo build $CARGO_MODE_FLAGS
# Copy the extension file from target dir to modules
if [[ -f ./target/$CARGO_MODE_DIR/libcrc64.dylib ]] ; then \\
cp ./target/$CARGO_MODE_DIR/libcrc64.dylib ./modules/crc64.so ; fi
if [[ -f ./target/$CARGO_MODE_DIR/libcrc64.so ]] ; then \\
cp ./target/$CARGO_MODE_DIR/libcrc64.so ./modules/crc64.so ; fi
cargo_clean:
cargo clean
.PHONY: cargo_build cargo_clean
EOF
dnl Symbolic link the files for `cargo build`
AC_CONFIG_LINKS([ \
Cargo.lock:Cargo.lock \
Cargo.toml:Cargo.toml \
build.rs:build.rs \
src:src \
])
fi