Skip to content

Commit fe5aaf9

Browse files
committed
Improve build-defs.h configuration
This adds a CMake-related template for generating the `main/build-defs.h` header. The ODBC build configuration is moved to its own config.h (or php_config.h) header.
1 parent f998516 commit fe5aaf9

File tree

4 files changed

+65
-25
lines changed

4 files changed

+65
-25
lines changed

cmake/ext/odbc/CMakeLists.txt

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -273,11 +273,6 @@ if(PHP_EXT_ODBC_VERSION AND NOT PHP_EXT_ODBC_VERSION MATCHES "^0x[0-9A-Fa-f]+$")
273273
)
274274
endif()
275275

276-
unset(PHP_ODBC_CFLAGS CACHE)
277-
unset(PHP_ODBC_LFLAGS CACHE)
278-
unset(PHP_ODBC_LIBS CACHE)
279-
unset(PHP_ODBC_TYPE CACHE)
280-
281276
if(NOT PHP_EXT_ODBC)
282277
return()
283278
endif()
@@ -332,7 +327,7 @@ if(PHP_EXT_ODBC_TYPE STREQUAL "ibm-db2" AND TARGET ODBC::ODBC)
332327
endif()
333328

334329
################################################################################
335-
# Set variables for main/build-defs.h and config.h file.
330+
# Configure config.h file.
336331
################################################################################
337332

338333
# Set PHP_ODBC_TYPE for configuration header value.
@@ -430,15 +425,14 @@ if(TARGET ODBC::ODBC)
430425
list(JOIN ldflags " " ldflags)
431426
list(JOIN libs " " libs)
432427

433-
set(PHP_ODBC_CFLAGS "${cflags}" CACHE INTERNAL "ODBC CFLAGS")
434-
set(PHP_ODBC_LFLAGS "${ldflags}" CACHE INTERNAL "ODBC linker flags")
435-
set(PHP_ODBC_LIBS "${libs}" CACHE INTERNAL "ODBC libraries")
436-
set(PHP_ODBC_TYPE "${PHP_ODBC_TYPE}" CACHE INTERNAL "ODBC type")
428+
set(PHP_ODBC_CFLAGS "${cflags}")
429+
set(PHP_ODBC_LFLAGS "${ldflags}")
430+
set(PHP_ODBC_LIBS "${libs}")
431+
set(PHP_ODBC_TYPE "${PHP_ODBC_TYPE}")
437432

438-
if(
439-
NOT ODBC_DRIVER STREQUAL "Windows"
440-
AND NOT EXISTS ${PHP_SOURCE_DIR}/main/build-defs.h.in
441-
)
433+
set(PHP_ODBC_BUILD_DEFINITIONS_CODE "")
434+
435+
if(NOT ODBC_DRIVER STREQUAL "Windows")
442436
set(
443437
PHP_ODBC_BUILD_DEFINITIONS_CODE
444438
[[

cmake/main/CMakeLists.txt

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -347,12 +347,8 @@ function(_php_main_create_files)
347347
set(PHP_CONFIG_H_WINDOWS 1)
348348
set(file config.w32.h)
349349
else()
350-
set(ODBC_CFLAGS "${PHP_ODBC_CFLAGS}")
351-
set(ODBC_LFLAGS "${PHP_ODBC_LFLAGS}")
352-
set(ODBC_LIBS "${PHP_ODBC_LIBS}")
353-
set(ODBC_TYPE "${PHP_ODBC_TYPE}")
354350
message(STATUS "Creating main/build-defs.h")
355-
file(READ main/build-defs.h.in content)
351+
file(READ main/cmake/build-defs.h.in content)
356352
string(CONFIGURE "${content}" content @ONLY)
357353

358354
# To be able to evaluate the generator expressions.
@@ -370,14 +366,10 @@ function(_php_main_create_files)
370366
phase. Needs to be adjusted further to rebuild PHP at such case.
371367
include(PHP/ConfigureFile)
372368
php_configure_file(
373-
INPUT ${PHP_SOURCE_DIR}/main/build-defs.h.in
369+
INPUT ${PHP_SOURCE_DIR}/main/cmake/build-defs.h.in
374370
OUTPUT ${PHP_BINARY_DIR}/main/build-defs.h
375371
VARIABLES
376372
CONFIGURE_COMMAND "cmake"
377-
ODBC_CFLAGS "${PHP_ODBC_CFLAGS}"
378-
ODBC_LFLAGS "${PHP_ODBC_LFLAGS}"
379-
ODBC_LIBS "${PHP_ODBC_LIBS}"
380-
ODBC_TYPE "${PHP_ODBC_TYPE}"
381373
PROG_SENDMAIL "${PROG_SENDMAIL}"
382374
EXPANDED_PEAR_INSTALLDIR "${EXPANDED_PEAR_INSTALLDIR}"
383375
INCLUDE_PATH "${INCLUDE_PATH}"

cmake/main/cmake/build-defs.h.in

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
/* This file contains PHP build definitions. */
2+
3+
/* Command used for configuring PHP at build phase. */
4+
#define CONFIGURE_COMMAND "@CONFIGURE_COMMAND@"
5+
6+
/* The path to the sendmail program. */
7+
#define PHP_PROG_SENDMAIL "@PROG_SENDMAIL@"
8+
9+
/* The path to the PEAR installation directory. */
10+
#define PEAR_INSTALLDIR "@EXPANDED_PEAR_INSTALLDIR@"
11+
12+
/* The default PHP include_path INI directive configuration. */
13+
#define PHP_INCLUDE_PATH "@INCLUDE_PATH@"
14+
15+
/* The path to the directory containing PHP extensions. */
16+
#define PHP_EXTENSION_DIR "@EXPANDED_EXTENSION_DIR@"
17+
18+
/* The installation prefix used when installing PHP. */
19+
#define PHP_PREFIX "@prefix@"
20+
21+
/* The path to the directory containing command-line executables (bin). */
22+
#define PHP_BINDIR "@EXPANDED_BINDIR@"
23+
24+
/* The path to the directory containing system admin executables (sbin). */
25+
#define PHP_SBINDIR "@EXPANDED_SBINDIR@"
26+
27+
/* The path to the directory containing man documentation. */
28+
#define PHP_MANDIR "@EXPANDED_MANDIR@"
29+
30+
/* The path to the directory containing system libraries. */
31+
#define PHP_LIBDIR "@EXPANDED_LIBDIR@"
32+
33+
/* The path to the directory containing architecture-independent data. */
34+
#define PHP_DATADIR "@EXPANDED_DATADIR@"
35+
36+
/* The path to the directory containing read-only single-machine data. */
37+
#define PHP_SYSCONFDIR "@EXPANDED_SYSCONFDIR@"
38+
39+
/* The path to the directory containing modifiable single-machine data. */
40+
#define PHP_LOCALSTATEDIR "@EXPANDED_LOCALSTATEDIR@"
41+
42+
/* The path to the directory in which PHP looks for php.ini configuration
43+
file. */
44+
#define PHP_CONFIG_FILE_PATH "@EXPANDED_PHP_CONFIG_FILE_PATH@"
45+
46+
/* The path to the directory where PHP scans for additional INI configuration
47+
files. */
48+
#define PHP_CONFIG_FILE_SCAN_DIR "@EXPANDED_PHP_CONFIG_FILE_SCAN_DIR@"
49+
50+
/* The file extension of the shared PHP extensions (.so, .dll, etc.). */
51+
#define PHP_SHLIB_SUFFIX "@SHLIB_DL_SUFFIX_NAME@"
52+
53+
/* The prefix for the shared library objects. */
54+
#define PHP_SHLIB_EXT_PREFIX ""

cmake/main/cmake/php_config.h.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -745,7 +745,7 @@
745745
/* The prefix for the shared library objects. */
746746
# define PHP_SHLIB_EXT_PREFIX "php_"
747747

748-
/* The shared library objects extension. */
748+
/* The file extension of the shared PHP extensions (.so, .dll, etc.). */
749749
# define PHP_SHLIB_SUFFIX "@SHLIB_DL_SUFFIX_NAME@"
750750

751751
/* The path to the etc directory. */

0 commit comments

Comments
 (0)