Files
mongo-php-driver/scripts/autotools/CheckCompiler.m4
Jeremy Mikola 21d46fe06a PHPC-2382: Allow static builds with php-src (#1555)
* PHPC-2382: Allow static builds with php-src

Prefer PHP_VERSION_ID for static builds, and fall back to invoking php-config otherwise.

mongocrypt.h previously used a path relative to the PHPC project root, which is not compatible with static builds. The current path is relative to src/, which is explicitly defined as an include path in config.m4.

* Preserve CPPFLAGS before modification by PlatformFlags.m4

PlatformFlags.m4 modifies CPPFLAGS in order to make checks in subsequent M4 scripts consistent with PHP_MONGODB_BUNDLED_CFLAGS. Restoring its original value after executing all M4 scripts will avoid unintended side effects on a static PHP build.

* Remove obsolete STD_CFLAGS assignments

STD_CFLAGS was never appended to PHP_MONGODB_BUNDLED_CFLAGS after these M4 scripts were run, so it's safe to assume they had no effect and can be removed entirely.

For CheckCompiler.m4, bumping the GCC requirement to 4.6 (still quite old) will ensure compatibility for libmongoc's BEGIN_IGNORE_DEPRECATIONS macro.

* Prefix names of internal CFLAGS vars in config.m4

* Remove obsolete comment in config.m4

This comment should have been removed in d8d30e5a88

* Include CPPFLAGS in build config output

Co-authored-by: Andreas Braun <git@alcaeus.org>
2024-05-22 09:46:25 -04:00

61 lines
1.7 KiB
Plaintext

# If CFLAGS and CXXFLAGS are unset, default to empty.
# This is to tell automake not to include '-g' if C{XX,}FLAGS is not set.
# For more info - http://www.gnu.org/software/automake/manual/autoconf.html#C_002b_002b-Compiler
if test -z "$CXXFLAGS"; then
CXXFLAGS=""
fi
if test -z "$CFLAGS"; then
CFLAGS=""
fi
AC_PROG_CC
AC_PROG_CXX
dnl AC_PROG_CC_C99 is previously called in config.m4, but AC_PROG_CC resets CC
dnl so call it once more to ensure C99 remains enabled
m4_version_prereq([2.70],,[AC_PROG_CC_C99])
# Check that an appropriate C compiler is available.
# Note: BEGIN_IGNORE_DEPRECATIONS macro requires GCC 4.6+.
c_compiler="unknown"
AC_LANG_PUSH([C])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
#if !(defined(__GNUC__) && !defined(__clang__) && !defined(__INTEL_COMPILER))
#error Not a supported GCC compiler
#endif
#if defined(__GNUC__)
#define GCC_VERSION (__GNUC__ * 10000 \
+ __GNUC_MINOR__ * 100 \
+ __GNUC_PATCHLEVEL__)
#if GCC_VERSION < 40600
#error Not a supported GCC compiler
#endif
#endif
])], [c_compiler="gcc"], [])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
#if defined(__clang__)
#define CLANG_VERSION (__clang_major__ * 10000 \
+ __clang_minor__ * 100 \
+ __clang_patchlevel__)
#if CLANG_VERSION < 30300
#error Not a supported Clang compiler
#endif
#endif
])], [c_compiler="clang"], [])
AC_COMPILE_IFELSE([AC_LANG_PROGRAM([
#if !(defined(__SUNPRO_C))
#error Not a supported Sun compiler
#endif
])], [c_compiler="sun"], [])
AC_LANG_POP([C])
if test "$c_compiler" = "unknown"; then
AC_MSG_ERROR([Compiler GCC >= 4.6 or Clang >= 3.3 is required for C compilation])
fi
AC_C_CONST
AC_C_INLINE
AC_C_TYPEOF