-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathconfig.m4
More file actions
46 lines (39 loc) · 1.74 KB
/
Copy pathconfig.m4
File metadata and controls
46 lines (39 loc) · 1.74 KB
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
dnl config.m4 for extension ext_math
PHP_ARG_ENABLE(ext_math, whether to enable ext_math support,
[ --enable-ext-math Enable native pocketmine\math extension])
if test "$PHP_EXT_MATH" != "no"; then
PHP_REQUIRE_CXX()
dnl Detect C++23 support (-std=c++23, fallback -std=c++2b for older toolchains)
AC_LANG_PUSH([C++])
EXT_MATH_SAVED_CXXFLAGS="$CXXFLAGS"
EXT_MATH_STD_FLAG=""
for ext_math_flag in "-std=c++23" "-std=c++2b"; do
if test -z "$EXT_MATH_STD_FLAG"; then
CXXFLAGS="$EXT_MATH_SAVED_CXXFLAGS $ext_math_flag"
AC_MSG_CHECKING([whether $CXX supports $ext_math_flag])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
#if __cplusplus < 202100L
#error "compiler does not target C++23"
#endif
]], [[]])], [
AC_MSG_RESULT([yes])
EXT_MATH_STD_FLAG="$ext_math_flag"
], [
AC_MSG_RESULT([no])
])
fi
done
CXXFLAGS="$EXT_MATH_SAVED_CXXFLAGS"
AC_LANG_POP([C++])
if test -z "$EXT_MATH_STD_FLAG"; then
AC_MSG_ERROR([ext_math requires a C++23-capable compiler (GCC 13+ or Clang 17+)])
fi
dnl the 6th parameter here is required for C++ shared extensions
PHP_NEW_EXTENSION(ext_math, ext_math.cpp src/PhpAxis.cpp src/PhpFacing.cpp src/PhpMath.cpp src/PhpVector2.cpp src/PhpVector3.cpp src/PhpVectorMath.cpp src/PhpRayTraceResult.cpp src/PhpAxisAlignedBB.cpp src/PhpMatrix.cpp src/PhpVoxelRayTrace.cpp, $ext_shared,, -DZEND_ENABLE_STATIC_TSRMLS_CACHE=1 -fno-strict-aliasing, yes)
PHP_SUBST(EXT_MATH_SHARED_LIBADD)
dnl .cpp sources are compiled with $(CXX) $(CXXFLAGS) $(EXTRA_CXXFLAGS) in Makefile.global
EXTRA_CXXFLAGS="$EXT_MATH_STD_FLAG"
PHP_SUBST(EXTRA_CXXFLAGS)
PHP_ADD_BUILD_DIR($ext_builddir/src, 1)
PHP_ADD_INCLUDE($ext_builddir)
fi