Skip to content

Commit 9b9001f

Browse files
committed
Fix main/build-defs.h further
1 parent fe5aaf9 commit 9b9001f

File tree

4 files changed

+85
-118
lines changed

4 files changed

+85
-118
lines changed

cmake/ext/odbc/CMakeLists.txt

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ if(NOT PHP_EXT_ODBC_TYPE MATCHES "^(dbmaker|solid)$")
389389
set(HAVE_SQLDATASOURCES TRUE)
390390
endif()
391391

392-
if(TARGET ODBC::ODBC)
392+
if(TARGET ODBC::ODBC AND NOT ODBC_DRIVER STREQUAL "Windows")
393393
block(PROPAGATE PHP_ODBC_BUILD_DEFINITIONS_CODE)
394394
get_target_property(definitions ODBC::ODBC INTERFACE_COMPILE_DEFINITIONS)
395395
get_target_property(options ODBC::ODBC INTERFACE_COMPILE_OPTIONS)
@@ -425,36 +425,18 @@ if(TARGET ODBC::ODBC)
425425
list(JOIN ldflags " " ldflags)
426426
list(JOIN libs " " libs)
427427

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}")
432-
433-
set(PHP_ODBC_BUILD_DEFINITIONS_CODE "")
434-
435-
if(NOT ODBC_DRIVER STREQUAL "Windows")
436-
set(
437-
PHP_ODBC_BUILD_DEFINITIONS_CODE
438-
[[
428+
string(CONFIGURE [[
439429
/* The compile options that PHP odbc extension was built with. */
440-
#define PHP_ODBC_CFLAGS "@PHP_ODBC_CFLAGS@"
430+
#define PHP_ODBC_CFLAGS "@cflags@"
441431

442432
/* The linker flags that PHP odbc extension was built with. */
443-
#define PHP_ODBC_LFLAGS "@PHP_ODBC_LFLAGS@"
433+
#define PHP_ODBC_LFLAGS "@ldflags@"
444434

445435
/* The libraries linker flags that PHP odbc extension was built with. */
446-
#define PHP_ODBC_LIBS "@PHP_ODBC_LIBS@"
436+
#define PHP_ODBC_LIBS "@libs@"
447437

448438
/* The ODBC library used in the PHP odbc extension. */
449-
#define PHP_ODBC_TYPE "@PHP_ODBC_TYPE@"]]
450-
)
451-
452-
string(
453-
CONFIGURE
454-
"${PHP_ODBC_BUILD_DEFINITIONS_CODE}"
455-
PHP_ODBC_BUILD_DEFINITIONS_CODE
456-
)
457-
endif()
439+
#define PHP_ODBC_TYPE "@PHP_ODBC_TYPE@"]] PHP_ODBC_BUILD_DEFINITIONS_CODE)
458440
endblock()
459441
endif()
460442

cmake/main/CMakeLists.txt

Lines changed: 32 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -262,10 +262,14 @@ function(_php_main_create_files)
262262
)
263263

264264
# Set the directory where php.ini is looked for.
265-
set(
266-
EXPANDED_PHP_CONFIG_FILE_PATH
267-
"$<PATH:ABSOLUTE_PATH,NORMALIZE,${PHP_CONFIG_FILE_PATH},${CMAKE_INSTALL_PREFIX}>"
268-
)
265+
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
266+
set(EXPANDED_PHP_CONFIG_FILE_PATH "")
267+
else()
268+
set(
269+
EXPANDED_PHP_CONFIG_FILE_PATH
270+
"$<PATH:ABSOLUTE_PATH,NORMALIZE,${PHP_CONFIG_FILE_PATH},${CMAKE_INSTALL_PREFIX}>"
271+
)
272+
endif()
269273

270274
# Set the directory where additional ini files are searched for.
271275
set(
@@ -283,10 +287,14 @@ function(_php_main_create_files)
283287
"$<PATH:ABSOLUTE_PATH,NORMALIZE,${CMAKE_INSTALL_SBINDIR},${CMAKE_INSTALL_PREFIX}>"
284288
)
285289

286-
set(
287-
EXPANDED_MANDIR
288-
"$<PATH:ABSOLUTE_PATH,NORMALIZE,${CMAKE_INSTALL_MANDIR},${CMAKE_INSTALL_PREFIX}>"
289-
)
290+
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
291+
set(EXPANDED_MANDIR "")
292+
else()
293+
set(
294+
EXPANDED_MANDIR
295+
"$<PATH:ABSOLUTE_PATH,NORMALIZE,${CMAKE_INSTALL_MANDIR},${CMAKE_INSTALL_PREFIX}>"
296+
)
297+
endif()
290298

291299
set(
292300
EXPANDED_LIBDIR
@@ -303,7 +311,7 @@ function(_php_main_create_files)
303311
set(prefix "${CMAKE_INSTALL_PREFIX}")
304312

305313
# Set shared library object extension.
306-
string(REPLACE "." "" SHLIB_DL_SUFFIX_NAME ${CMAKE_SHARED_MODULE_SUFFIX})
314+
string(REPLACE "." "" SHLIB_DL_SUFFIX_NAME "${CMAKE_SHARED_MODULE_SUFFIX}")
307315

308316
if(PHP_DEFAULT_SHORT_OPEN_TAG)
309317
set(DEFAULT_SHORT_OPEN_TAG "1")
@@ -346,20 +354,32 @@ function(_php_main_create_files)
346354
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
347355
set(PHP_CONFIG_H_WINDOWS 1)
348356
set(file config.w32.h)
357+
set(PHP_SHLIB_EXT_PREFIX "php_")
349358
else()
359+
set(PHP_CONFIG_H_WINDOWS 0)
360+
set(file php_config.h)
361+
set(HAVE_BUILD_DEFS_H TRUE)
362+
set(PHP_SHLIB_EXT_PREFIX "")
363+
endif()
364+
365+
file(READ main/cmake/build-defs.h.in PHP_BUILD_DEFINITIONS_CODE)
366+
string(CONFIGURE "${PHP_BUILD_DEFINITIONS_CODE}" PHP_BUILD_DEFINITIONS_CODE @ONLY)
367+
368+
# Add build system configuration.
369+
if(NOT CMAKE_SYSTEM_NAME STREQUAL "Windows")
350370
message(STATUS "Creating main/build-defs.h")
351-
file(READ main/cmake/build-defs.h.in content)
352-
string(CONFIGURE "${content}" content @ONLY)
353371

354372
# To be able to evaluate the generator expressions.
355373
file(
356374
GENERATE
357375
# TODO: Multi-config generators need to write separate files.
358376
#OUTPUT $<CONFIG>/main/build-defs.h
359377
OUTPUT main/build-defs.h
360-
CONTENT "${content}"
378+
CONTENT "${PHP_BUILD_DEFINITIONS_CODE}"
361379
)
362380

381+
set(PHP_BUILD_DEFINITIONS_CODE "")
382+
363383
#[[
364384
TODO: This enables regenerating the build-defs.h file on the install step
365385
when using different install prefix at the 'cmake --install ... --prefix'
@@ -389,10 +409,6 @@ function(_php_main_create_files)
389409
add_custom_target(php_main_build_defs_h DEPENDS ${PHP_BINARY_DIR}/main/build-defs.h)
390410
add_dependencies(php_main php_main_build_defs_h)
391411
#]]
392-
393-
set(HAVE_BUILD_DEFS_H TRUE)
394-
set(PHP_CONFIG_H_WINDOWS 0)
395-
set(file php_config.h)
396412
endif()
397413

398414
message(STATUS "Creating main/${file}")

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

Lines changed: 46 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,68 @@
1-
/* This file contains PHP build definitions. */
1+
/* The following build system related configuration values are on *nix
2+
systems defined in the main/build-defs.h header and JScript Windows
3+
build system defines them in the configuration header file
4+
(main/config.w32.h). On *nix systems these are provided as a separate
5+
header file aiming to simplify the (re)building phase when multiple
6+
configurations are used. For example, using one installation prefix for
7+
the stage installation directory and the other for production. */
28

39
/* Command used for configuring PHP at build phase. */
410
#define CONFIGURE_COMMAND "@CONFIGURE_COMMAND@"
511

6-
/* The path to the sendmail program. */
7-
#define PHP_PROG_SENDMAIL "@PROG_SENDMAIL@"
8-
912
/* The path to the PEAR installation directory. */
1013
#define PEAR_INSTALLDIR "@EXPANDED_PEAR_INSTALLDIR@"
1114

12-
/* The default PHP include_path INI directive configuration. */
13-
#define PHP_INCLUDE_PATH "@INCLUDE_PATH@"
15+
/* The path to the directory containing command-line executables (bin). */
16+
#define PHP_BINDIR "@EXPANDED_BINDIR@"
1417

15-
/* The path to the directory containing PHP extensions. */
16-
#define PHP_EXTENSION_DIR "@EXPANDED_EXTENSION_DIR@"
18+
/* The path to the directory in which PHP looks for the php.ini
19+
configuration file. On Windows this macro isn't utilized in the C
20+
code. */
21+
#define PHP_CONFIG_FILE_PATH "@EXPANDED_PHP_CONFIG_FILE_PATH@"
1722

18-
/* The installation prefix used when installing PHP. */
19-
#define PHP_PREFIX "@prefix@"
23+
/* The path to the directory where PHP scans for additional INI
24+
configuration files. */
25+
#define PHP_CONFIG_FILE_SCAN_DIR "@EXPANDED_PHP_CONFIG_FILE_SCAN_DIR@"
2026

21-
/* The path to the directory containing command-line executables (bin). */
22-
#define PHP_BINDIR "@EXPANDED_BINDIR@"
27+
/* The path to the directory containing architecture-independent data
28+
(share). */
29+
#define PHP_DATADIR "@EXPANDED_DATADIR@"
2330

24-
/* The path to the directory containing system admin executables (sbin). */
25-
#define PHP_SBINDIR "@EXPANDED_SBINDIR@"
31+
/* The default path to the directory containing dynamically loadable PHP
32+
extensions. */
33+
#define PHP_EXTENSION_DIR "@EXPANDED_EXTENSION_DIR@"
2634

27-
/* The path to the directory containing man documentation. */
28-
#define PHP_MANDIR "@EXPANDED_MANDIR@"
35+
/* The default 'include_path' PHP INI directive. */
36+
#define PHP_INCLUDE_PATH "@INCLUDE_PATH@"
2937

30-
/* The path to the directory containing system libraries. */
38+
/* The path to the directory containing system libraries (lib, lib64,
39+
etc.). */
3140
#define PHP_LIBDIR "@EXPANDED_LIBDIR@"
3241

33-
/* The path to the directory containing architecture-independent data. */
34-
#define PHP_DATADIR "@EXPANDED_DATADIR@"
42+
/* The path to the directory containing modifiable single-machine data
43+
(var). */
44+
#define PHP_LOCALSTATEDIR "@EXPANDED_LOCALSTATEDIR@"
3545

36-
/* The path to the directory containing read-only single-machine data. */
37-
#define PHP_SYSCONFDIR "@EXPANDED_SYSCONFDIR@"
46+
/* The path to the directory containing man documentation. */
47+
#cmakedefine PHP_MANDIR "@EXPANDED_MANDIR@"
3848

39-
/* The path to the directory containing modifiable single-machine data. */
40-
#define PHP_LOCALSTATEDIR "@EXPANDED_LOCALSTATEDIR@"
49+
/* The PHP installation prefix. */
50+
#define PHP_PREFIX "@prefix@"
4151

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@"
52+
/* The path to the sendmail program. */
53+
#if !@PHP_CONFIG_H_WINDOWS@
54+
# define PHP_PROG_SENDMAIL "@PROG_SENDMAIL@"
55+
#endif
4556

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@"
57+
/* The path to the directory containing system admin executables (sbin). */
58+
#define PHP_SBINDIR "@EXPANDED_SBINDIR@"
59+
60+
/* The filename prefix for the shared PHP extensions. */
61+
#define PHP_SHLIB_EXT_PREFIX "@PHP_SHLIB_EXT_PREFIX@"
4962

50-
/* The file extension of the shared PHP extensions (.so, .dll, etc.). */
63+
/* The file extension of the shared PHP extensions ('so', 'dll'). */
5164
#define PHP_SHLIB_SUFFIX "@SHLIB_DL_SUFFIX_NAME@"
5265

53-
/* The prefix for the shared library objects. */
54-
#define PHP_SHLIB_EXT_PREFIX ""
66+
/* The path to the directory containing read-only single-machine data
67+
(etc). */
68+
#define PHP_SYSCONFDIR "@EXPANDED_SYSCONFDIR@"

cmake/main/cmake/php_config.h.in

Lines changed: 1 addition & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -704,52 +704,7 @@
704704
@ZEND_CONFIGURATION@
705705

706706
#if @PHP_CONFIG_H_WINDOWS@
707-
/* The following build system related configuration values are on *nix
708-
systems defined in the main/build-defs.h and JScript Windows build system
709-
defines them in the configuration header file. */
710-
711-
/* Configure line */
712-
# cmakedefine CONFIGURE_COMMAND "@CONFIGURE_COMMAND@"
713-
714-
/* The PEAR installation directory. */
715-
# define PEAR_INSTALLDIR "@EXPANDED_PEAR_INSTALLDIR@"
716-
717-
/* The path to the bin directory. */
718-
# define PHP_BINDIR "@EXPANDED_BINDIR@"
719-
720-
/* The path in which to look for php.ini. On Windows this macro isn't
721-
utilized in the C code. */
722-
# define PHP_CONFIG_FILE_PATH ""
723-
724-
/* The path where to scan for additional INI configuration files. */
725-
# define PHP_CONFIG_FILE_SCAN_DIR "@EXPANDED_PHP_CONFIG_FILE_SCAN_DIR@"
726-
727-
/* The path to the share directory. */
728-
# define PHP_DATADIR "@EXPANDED_DATADIR@"
729-
730-
/* Default directory for dynamically loadable PHP extensions. */
731-
# define PHP_EXTENSION_DIR "@EXPANDED_EXTENSION_DIR@"
732-
733-
/* The 'include_path' PHP INI directive. */
734-
# define PHP_INCLUDE_PATH "@INCLUDE_PATH@"
735-
736-
/* The path containing system libraries (lib or lib64). */
737-
# define PHP_LIBDIR "@EXPANDED_LIBDIR@"
738-
739-
/* The path to the var directory. */
740-
# define PHP_LOCALSTATEDIR "@EXPANDED_LOCALSTATEDIR@"
741-
742-
/* The installation prefix. */
743-
# define PHP_PREFIX "@prefix@"
744-
745-
/* The prefix for the shared library objects. */
746-
# define PHP_SHLIB_EXT_PREFIX "php_"
747-
748-
/* The file extension of the shared PHP extensions (.so, .dll, etc.). */
749-
# define PHP_SHLIB_SUFFIX "@SHLIB_DL_SUFFIX_NAME@"
750-
751-
/* The path to the etc directory. */
752-
# define PHP_SYSCONFDIR "@EXPANDED_SYSCONFDIR@"
707+
@PHP_BUILD_DEFINITIONS_CODE@
753708

754709
# if __has_include("main/config.pickle.h")
755710
# include "main/config.pickle.h"

0 commit comments

Comments
 (0)