Skip to content

Commit b714227

Browse files
committed
Move SAPIs configuration to separate config.h files
This simplifies understanding where something gets defined and also enables SAPIs not present in the sapi directory.
1 parent 31a0ae5 commit b714227

File tree

10 files changed

+134
-123
lines changed

10 files changed

+134
-123
lines changed

cmake/main/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,20 @@ function(_php_main_create_files)
360360
file(READ ${CMAKE_CURRENT_BINARY_DIR}/Zend/CMakeFiles/zend_config.h config)
361361
string(STRIP "${config}" ZEND_CONFIGURATION)
362362

363+
# Add sapis configuration.
364+
set(config "")
365+
get_cmake_property(sapis PHP_SAPIS)
366+
list(SORT sapis COMPARE NATURAL)
367+
foreach(sapi IN LISTS sapis)
368+
if(EXISTS ${CMAKE_CURRENT_BINARY_DIR}/sapi/${sapi}/config.h)
369+
file(READ ${CMAKE_CURRENT_BINARY_DIR}/sapi/${sapi}/config.h content)
370+
if(content)
371+
string(APPEND config "\n${content}")
372+
endif()
373+
endif()
374+
endforeach()
375+
string(STRIP "${config}" PHP_SAPIS_CONFIGURATION)
376+
363377
# Add extensions configuration.
364378
set(config "")
365379
get_cmake_property(extensions PHP_EXTENSIONS)

cmake/main/php_config.cmake.h.in

Lines changed: 6 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,6 @@
5858
and to string "0" if they are not. */
5959
#define DEFAULT_SHORT_OPEN_TAG "@DEFAULT_SHORT_OPEN_TAG@"
6060

61-
/* Define to 1 if 'TIOCGWINSZ' requires <sys/ioctl.h>. */
62-
#cmakedefine GWINSZ_IN_SYS_IOCTL 1
63-
6461
/* Define to 1 when aarch64 CRC32 API is available. */
6562
#cmakedefine HAVE_AARCH64_CRC32 1
6663

@@ -76,9 +73,6 @@
7673
/* Define to 1 if you have the 'alphasort' function. */
7774
#cmakedefine HAVE_ALPHASORT 1
7875

79-
/* Define to 1 if AppArmor confinement is available for PHP-FPM. */
80-
#cmakedefine HAVE_APPARMOR 1
81-
8276
/* Define to 1 if you have the <arpa/inet.h> header file. */
8377
#cmakedefine HAVE_ARPA_INET_H 1
8478

@@ -103,30 +97,15 @@
10397
/* Define to 1 if PHP has the <main/build-defs.h> header file. */
10498
#cmakedefine HAVE_BUILD_DEFS_H 1
10599

106-
/* Define to 1 if compiler supports __sync_bool_compare_and_swap() a.o. */
107-
#cmakedefine HAVE_BUILTIN_ATOMIC 1
108-
109100
/* Define to 1 if you have the 'chroot' function. */
110101
#cmakedefine HAVE_CHROOT 1
111102

112-
/* Define to 1 if you have the 'clearenv' function. */
113-
#cmakedefine HAVE_CLEARENV 1
114-
115-
/* Define to 1 if you have the 'clock_gettime' function. */
116-
#cmakedefine HAVE_CLOCK_GETTIME 1
117-
118-
/* Define to 1 if you have the 'clock_get_time' function. */
119-
#cmakedefine HAVE_CLOCK_GET_TIME 1
120-
121103
/* Define to 1 if you have the 'copy_file_range' function. */
122104
#cmakedefine HAVE_COPY_FILE_RANGE 1
123105

124106
/* Define to 1 if you have the 'ctime_r' function. */
125107
#cmakedefine HAVE_CTIME_R 1
126108

127-
/* Define to 1 if system has a working '/dev/poll'. */
128-
#cmakedefine HAVE_DEVPOLL 1
129-
130109
/* Define to 1 if you have the <dirent.h> header file. */
131110
#cmakedefine HAVE_DIRENT_H 1
132111

@@ -142,9 +121,6 @@
142121
/* Define to 1 if DTrace support is enabled. */
143122
#cmakedefine HAVE_DTRACE 1
144123

145-
/* Define to 1 if system has a working epoll. */
146-
#cmakedefine HAVE_EPOLL 1
147-
148124
/* Define to 1 if you have the 'explicit_bzero' function. */
149125
#cmakedefine HAVE_EXPLICIT_BZERO 1
150126

@@ -163,9 +139,6 @@
163139
/* Define to 1 if you have the 'fopencookie' function. */
164140
#cmakedefine HAVE_FOPENCOOKIE 1
165141

166-
/* Define to 1 if PHP-FPM has ACL support. */
167-
#cmakedefine HAVE_FPM_ACL 1
168-
169142
/* Define to 1 if you have the 'ftok' function. */
170143
#cmakedefine HAVE_FTOK 1
171144

@@ -277,9 +250,6 @@
277250
/* Define to 1 if IPv6 is enabled and supported. */
278251
#cmakedefine HAVE_IPV6 1
279252

280-
/* Define to 1 if system has a working 'kqueue' function. */
281-
#cmakedefine HAVE_KQUEUE 1
282-
283253
/* Define to 1 if you have the <langinfo.h> header file. */
284254
#cmakedefine HAVE_LANGINFO_H 1
285255

@@ -301,18 +271,6 @@
301271
/* Define to 1 if you have the 'localtime_r' function. */
302272
#cmakedefine HAVE_LOCALTIME_R 1
303273

304-
/* Define to 1 if you have 'SO_LISTENQ*'. */
305-
#cmakedefine HAVE_LQ_SO_LISTENQ 1
306-
307-
/* Define to 1 if you have 'TCP_CONNECTION_INFO'. */
308-
#cmakedefine HAVE_LQ_TCP_CONNECTION_INFO 1
309-
310-
/* Define to 1 if you have 'TCP_INFO'. */
311-
#cmakedefine HAVE_LQ_TCP_INFO 1
312-
313-
/* Define to 1 if you have the 'mach_vm_read' function. */
314-
#cmakedefine HAVE_MACH_VM_READ 1
315-
316274
/* Define to 1 if you have the 'memcntl' function. */
317275
#cmakedefine HAVE_MEMCNTL 1
318276

@@ -355,33 +313,21 @@
355313
/* Define to 1 if you have the <os/signpost.h> header file. */
356314
#cmakedefine HAVE_OS_SIGNPOST_H 1
357315

358-
/* Define to 1 if the phpdbg SAPI has libedit/readline integration. */
359-
#cmakedefine HAVE_PHPDBG_READLINE 1
360-
361316
/* Define to 1 if you have the 'poll' function. */
362317
#cmakedefine HAVE_POLL 1
363318

364319
/* Define to 1 if you have the <poll.h> header file. */
365320
#cmakedefine HAVE_POLL_H 1
366321

367-
/* Define to 1 if you have the 'port_create' function. */
368-
#cmakedefine HAVE_PORT 1
369-
370322
/* Define to 1 if you have the 'prctl' function. */
371323
#cmakedefine HAVE_PRCTL 1
372324

373325
/* Define to 1 if you have the 'procctl' function. */
374326
#cmakedefine HAVE_PROCCTL 1
375327

376-
/* Define if the PS_STRINGS exists. */
377-
#cmakedefine HAVE_PS_STRINGS
378-
379328
/* Define to 1 if you have the 'pthread_jit_write_protect_np' function. */
380329
#cmakedefine HAVE_PTHREAD_JIT_WRITE_PROTECT_NP 1
381330

382-
/* Define to 1 if you have the 'ptrace' function. */
383-
#cmakedefine HAVE_PTRACE 1
384-
385331
/* Define to 1 if the system has the type 'ptrdiff_t'. */
386332
#cmakedefine HAVE_PTRDIFF_T 1
387333

@@ -400,27 +346,12 @@
400346
/* Define to 1 if you have the 'scandir' function. */
401347
#cmakedefine HAVE_SCANDIR 1
402348

403-
/* Define to 1 if system has a working 'select' function. */
404-
#cmakedefine HAVE_SELECT 1
405-
406-
/* Define to 1 if SELinux is available in PHP-FPM. */
407-
#cmakedefine HAVE_SELINUX 1
408-
409349
/* Define to 1 if you have the 'setenv' function. */
410350
#cmakedefine HAVE_SETENV 1
411351

412352
/* Define to 1 if you have the 'setitimer' function. */
413353
#cmakedefine HAVE_SETITIMER 1
414354

415-
/* Define to 1 if you have the 'setpflags' function. */
416-
#cmakedefine HAVE_SETPFLAGS 1
417-
418-
/* Define to 1 if you have the 'setproctitle' function. */
419-
#cmakedefine HAVE_SETPROCTITLE 1
420-
421-
/* Define to 1 if you have the 'setproctitle_fast' function. */
422-
#cmakedefine HAVE_SETPROCTITLE_FAST 1
423-
424355
/* Define to 1 if you have the 'shutdown' function. */
425356
#cmakedefine HAVE_SHUTDOWN 1
426357

@@ -433,9 +364,6 @@
433364
/* Define to 1 if the system has the type 'struct sockaddr_storage'. */
434365
#cmakedefine HAVE_SOCKADDR_STORAGE 1
435366

436-
/* Define to 1 if 'sun_len' is a member of 'struct sockaddr_un'. */
437-
#cmakedefine HAVE_SOCKADDR_UN_SUN_LEN 1
438-
439367
/* Define to 1 if you have the 'socketpair' function. */
440368
#cmakedefine HAVE_SOCKETPAIR 1
441369

@@ -499,21 +427,12 @@
499427
/* Define to 1 if you have the 'symlink' function. */
500428
#cmakedefine HAVE_SYMLINK 1
501429

502-
/* Define to 1 if you have the 'sysconf' function. */
503-
#cmakedefine HAVE_SYSCONF 1
504-
505430
/* Define to 1 if you have the <sysexits.h> header file. */
506431
#cmakedefine HAVE_SYSEXITS_H 1
507432

508433
/* Define to 1 if you have the <syslog.h> header file. */
509434
#cmakedefine HAVE_SYSLOG_H 1
510435

511-
/* Define to 1 if FPM has systemd integration. */
512-
#cmakedefine HAVE_SYSTEMD 1
513-
514-
/* Define to 1 if you have the <sys/acl.h> header file. */
515-
#cmakedefine HAVE_SYS_ACL_H 1
516-
517436
/* Define to 1 if you have the <sys/file.h> header file. */
518437
#cmakedefine HAVE_SYS_FILE_H 1
519438

@@ -541,9 +460,6 @@
541460
/* Define to 1 if you have the <sys/procctl.h> header file. */
542461
#cmakedefine HAVE_SYS_PROCCTL_H 1
543462

544-
/* Define to 1 if you have the <sys/pstat.h> header file. */
545-
#cmakedefine HAVE_SYS_PSTAT_H 1
546-
547463
/* Define to 1 if you have the <sys/resource.h> header file. */
548464
#cmakedefine HAVE_SYS_RESOURCE_H 1
549465

@@ -583,9 +499,6 @@
583499
/* Define to 1 if you have the <sys/wait.h> header file. */
584500
#cmakedefine HAVE_SYS_WAIT_H 1
585501

586-
/* Define to 1 if you have the 'times' function. */
587-
#cmakedefine HAVE_TIMES 1
588-
589502
/* Define to 1 if you have the <tmmintrin.h> header file. */
590503
#cmakedefine HAVE_TMMINTRIN_H 1
591504

@@ -601,10 +514,6 @@
601514
/* Define to 1 if you have the 'unsetenv' function. */
602515
#cmakedefine HAVE_UNSETENV 1
603516

604-
/* Define to 1 if faulting on write-protected memory support can be compiled
605-
for userfaultfd. */
606-
#cmakedefine HAVE_USERFAULTFD_WRITEFAULT 1
607-
608517
/* Define to 1 if you have the 'usleep' function. */
609518
#cmakedefine HAVE_USLEEP 1
610519

@@ -753,9 +662,6 @@
753662
/* Define to 1 if 'write(2)' works. */
754663
#cmakedefine PHP_WRITE_STDOUT 1
755664

756-
/* Define to the /proc/pid/mem interface filename value. */
757-
#cmakedefine PROC_MEM_FILE "@PROC_MEM_FILE@"
758-
759665
/* The size of 'int', as computed by sizeof. */
760666
@SIZEOF_INT_CODE@
761667

@@ -783,9 +689,6 @@
783689
/* Define to 1 if strerror_r returns char *. */
784690
#cmakedefine STRERROR_R_CHAR_P 1
785691

786-
/* Define to 1 if cross-process locking is required by 'accept()'. */
787-
#cmakedefine USE_LOCKING 1
788-
789692
@PHP_SYSTEM_EXTENSIONS@
790693

791694
/* Define if processor uses big-endian word. */
@@ -810,6 +713,12 @@
810713

811714
@ZEND_CONFIGURATION@
812715

716+
/*****************************************************************************
717+
PHP SAPIs configuration
718+
****************************************************************************/
719+
720+
@PHP_SAPIS_CONFIGURATION@
721+
813722
/*****************************************************************************
814723
PHP extensions configuration
815724
****************************************************************************/

cmake/sapi/cgi/CMakeLists.txt

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,10 @@ check_struct_has_member("struct sockaddr_un" sun_len sys/un.h HAVE_SOCKADDR_UN_S
5555

5656
message(CHECK_START "Checking whether accept() requires cross-process locking")
5757
if(CMAKE_SYSTEM_NAME STREQUAL "SunOS")
58-
set(USE_LOCKING 1 CACHE INTERNAL "Whether accept() requires cross-process locking")
59-
endif()
60-
if(USE_LOCKING)
58+
set(USE_LOCKING 1)
6159
message(CHECK_PASS "yes")
6260
else()
61+
set(USE_LOCKING 0)
6362
message(CHECK_FAIL "no")
6463
endif()
6564

@@ -77,3 +76,5 @@ install(
7776
RENAME ${PHP_PROGRAM_PREFIX}php-cgi${PHP_PROGRAM_SUFFIX}.1
7877
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
7978
)
79+
80+
configure_file(config.cmake.h.in config.h)

cmake/sapi/cgi/config.cmake.h.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/* Define to 1 if 'sun_len' is a member of 'struct sockaddr_un'. */
2+
#cmakedefine HAVE_SOCKADDR_UN_SUN_LEN 1
3+
4+
/* Define to 1 if cross-process locking is required by 'accept()'. */
5+
#cmakedefine USE_LOCKING 1

cmake/sapi/cli/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -168,3 +168,5 @@ install(
168168
RENAME ${PHP_PROGRAM_PREFIX}php${PHP_PROGRAM_SUFFIX}.1
169169
DESTINATION ${CMAKE_INSTALL_MANDIR}/man1
170170
)
171+
172+
configure_file(config.cmake.h.in config.h)

cmake/sapi/cli/config.cmake.h.in

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/* Define if the PS_STRINGS exists. */
2+
#cmakedefine HAVE_PS_STRINGS
3+
4+
/* Define to 1 if you have the 'setproctitle' function. */
5+
#cmakedefine HAVE_SETPROCTITLE 1
6+
7+
/* Define to 1 if you have the <sys/pstat.h> header file. */
8+
#cmakedefine HAVE_SYS_PSTAT_H 1

cmake/sapi/fpm/CMakeLists.txt

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,6 @@ php_set(
3030
VALUE "nobody"
3131
DOC "Set the user for running PHP FPM (default: nobody)"
3232
)
33-
unset(PHP_FPM_USER CACHE)
34-
if(SAPI_FPM_USER)
35-
set(PHP_FPM_USER "${SAPI_FPM_USER}" CACHE INTERNAL "FPM user")
36-
endif()
3733

3834
php_set(
3935
SAPI_FPM_GROUP
@@ -44,10 +40,6 @@ php_set(
4440
"Set the group for running PHP FPM. For a system user, this should usually "
4541
"be set to match the FPM username (default: nobody)"
4642
)
47-
unset(PHP_FPM_GROUP CACHE)
48-
if(SAPI_FPM_GROUP)
49-
set(PHP_FPM_GROUP "${SAPI_FPM_GROUP}" CACHE INTERNAL "FPM group")
50-
endif()
5143

5244
php_set(
5345
SAPI_FPM_SYSTEMD
@@ -360,14 +352,14 @@ if(SAPI_FPM_SYSTEMD)
360352
target_link_libraries(php_fpm PRIVATE Systemd::Systemd)
361353

362354
if(TARGET Systemd::Systemd)
363-
set(HAVE_SYSTEMD 1 CACHE INTERNAL "Whether FPM is using systemd integration")
355+
set(HAVE_SYSTEMD 1)
364356

365357
target_sources(php_fpm PRIVATE fpm/fpm_systemd.c)
366358
endif()
367359

368-
set(PHP_FPM_SYSTEMD "notify" CACHE INTERNAL "FPM systemd service type")
360+
set(PHP_FPM_SYSTEMD "notify")
369361
else()
370-
set(PHP_FPM_SYSTEMD "simple" CACHE INTERNAL "FPM systemd service type")
362+
set(PHP_FPM_SYSTEMD "simple")
371363
endif()
372364

373365
if(SAPI_FPM_ACL)
@@ -388,7 +380,7 @@ if(SAPI_FPM_ACL)
388380
check_include_file(sys/acl.h HAVE_SYS_ACL_H)
389381
cmake_pop_check_state()
390382

391-
set(HAVE_FPM_ACL 1 CACHE INTERNAL "Whether FPM has ACL support")
383+
set(HAVE_FPM_ACL 1)
392384
endif()
393385
endif()
394386

@@ -404,7 +396,7 @@ if(SAPI_FPM_APPARMOR)
404396
target_link_libraries(php_fpm PRIVATE AppArmor::AppArmor)
405397

406398
if(TARGET AppArmor::AppArmor)
407-
set(HAVE_APPARMOR 1 CACHE INTERNAL "Whether AppArmor is present")
399+
set(HAVE_APPARMOR 1)
408400
endif()
409401
endif()
410402

@@ -420,7 +412,7 @@ if(SAPI_FPM_SELINUX)
420412
target_link_libraries(php_fpm PRIVATE SELinux::SELinux)
421413

422414
if(TARGET SELinux::SELinux)
423-
set(HAVE_SELINUX 1 CACHE INTERNAL "Whether SELinux is present")
415+
set(HAVE_SELINUX 1)
424416
endif()
425417
endif()
426418

@@ -567,3 +559,5 @@ install(
567559
${CMAKE_CURRENT_BINARY_DIR}/status.html
568560
DESTINATION ${CMAKE_INSTALL_DATADIR}/fpm
569561
)
562+
563+
configure_file(config.cmake.h.in config.h)

0 commit comments

Comments
 (0)