diff --git a/configure.ac b/configure.ac index 2bd6ae26ce625..6caf24b8f0ee4 100644 --- a/configure.ac +++ b/configure.ac @@ -1437,6 +1437,11 @@ AS_VAR_IF([PHP_BUILD_ARCH],,, [AC_DEFINE_UNQUOTED([PHP_BUILD_ARCH], ["$PHP_BUILD_ARCH"], [The build architecture.])]) +AC_ARG_VAR([PHP_BUILD_OS], [The build OS]) +AS_VAR_IF([PHP_BUILD_OS],,, + [AC_DEFINE_UNQUOTED([PHP_BUILD_OS], ["$PHP_BUILD_OS"], + [The build OS.])]) + PHP_SUBST([PHP_FASTCGI_OBJS]) PHP_SUBST([PHP_SAPI_OBJS]) PHP_SUBST([PHP_BINARY_OBJS]) diff --git a/main/main.c b/main/main.c index e2973f17c248c..fde678b1a25b8 100644 --- a/main/main.c +++ b/main/main.c @@ -130,17 +130,20 @@ PHPAPI char *php_get_version(sapi_module_struct *sapi_module) #else "NTS" #endif -#ifdef PHP_BUILD_COMPILER - " " PHP_BUILD_COMPILER -#endif -#ifdef PHP_BUILD_ARCH - " " PHP_BUILD_ARCH -#endif #if ZEND_DEBUG " DEBUG" #endif #ifdef HAVE_GCOV " GCOV" +#endif +#ifdef PHP_BUILD_ARCH + " " PHP_BUILD_ARCH +#endif +#ifdef PHP_BUILD_OS + " " PHP_BUILD_OS +#endif +#ifdef PHP_BUILD_COMPILER + " " PHP_BUILD_COMPILER #endif ); smart_string_appends(&version_info, "Copyright (c) The PHP Group\n"); diff --git a/main/php_main.h b/main/php_main.h index bd28a0dee1d7f..8d5748c2c521f 100644 --- a/main/php_main.h +++ b/main/php_main.h @@ -89,6 +89,45 @@ PHPAPI bool php_tsrm_startup(void); #define PHP_OS_STR PHP_OS #endif +#define _PHP_STRINGIFY(s) #s +#define PHP_STRINGIFY(s) _PHP_STRINGIFY(s) + +#ifndef PHP_BUILD_COMPILER +# if defined(__clang__) +# define PHP_BUILD_COMPILER "Clang " PHP_STRINGIFY(__clang_major__) +# elif defined(__GNUC__) +# define PHP_BUILD_COMPILER "GCC " PHP_STRINGIFY(__GNUC__) +# endif +#endif + +#ifndef PHP_BUILD_ARCH +# if defined(__x86_64__) +# define PHP_BUILD_ARCH "x64" +# elif defined(__i386__) +# define PHP_BUILD_ARCH "x86" +# elif defined(__aarch64__) +# define PHP_BUILD_ARCH "aarch64" +# endif +#endif + +#ifndef PHP_BUILD_OS +# if defined(PHP_WIN32) +# define PHP_BUILD_OS "WINNT" +# elif defined(__APPLE__) +# define PHP_BUILD_OS "Darwin" +# elif defined(__linux__) +# define PHP_BUILD_OS "Linux" +# elif defined(__FreeBSD__) +# define PHP_BUILD_OS "FreeBSD" +# elif defined(__NetBSD__) +# define PHP_BUILD_OS "NetBSD" +# elif defined(__OpenBSD__) +# define PHP_BUILD_OS "OpenBSD" +#elif defined(__sun__) +# define PHP_BUILD_OS "Solaris" +# endif +#endif + END_EXTERN_C() #endif