Skip to content

Commit 1e16f52

Browse files
committed
Merge branch 'PHP-8.4'
2 parents 0619f19 + 8b3782c commit 1e16f52

File tree

3 files changed

+65
-31
lines changed

3 files changed

+65
-31
lines changed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ intricacies of how to build PHP with CMake.
1515

1616
```sh
1717
# Prerequisites for Debian-based distributions:
18-
sudo apt install cmake gcc g++ bison libsqlite3-dev
18+
sudo apt install cmake gcc g++ libsqlite3-dev
1919

2020
# Prerequisites for Fedora-based distributions:
21-
sudo dnf install cmake gcc gcc-c++ bison sqlite-devel
21+
sudo dnf install cmake gcc gcc-c++ sqlite-devel
2222
```
2323

2424
<details>
@@ -27,19 +27,19 @@ sudo dnf install cmake gcc gcc-c++ bison sqlite-devel
2727
```sh
2828
# Prerequisites for macOS:
2929
xcode-select --install # XCode command line tools
30-
brew install cmake bison # See https://brew.sh how to install Homebrew
30+
brew install cmake # See https://brew.sh how to install Homebrew
3131

3232
# Prerequisites for Alpine Linux:
33-
sudo apk add --no-cache cmake make gcc g++ musl-dev bison sqlite-dev
33+
sudo apk add --no-cache cmake make gcc g++ musl-dev sqlite-dev
3434

3535
# Prerequisites for BSD-based systems:
36-
sudo pkg install cmake bison sqlite3
36+
sudo pkg install cmake sqlite3
3737

3838
# Prerequisites for Haiku:
39-
pkgman install cmake bison sqlite_devel
39+
pkgman install cmake sqlite_devel
4040

4141
# Prerequisites for Solaris/illumos-based systems:
42-
sudo pkg install cmake bison sqlite-3
42+
sudo pkg install cmake sqlite-3
4343
```
4444
</details>
4545

cmake/cmake/modules/PHP/Bison.cmake

Lines changed: 55 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -645,16 +645,8 @@ function(_php_bison_download)
645645

646646
if(CMAKE_HOST_SYSTEM_NAME STREQUAL "Windows")
647647
_php_bison_download_windows()
648-
elseif(CMAKE_HOST_SYSTEM_NAME MATCHES "^(Haiku|Linux)$")
649-
_php_bison_download_gnu()
650648
else()
651-
# TODO: Add support for more platforms.
652-
message(
653-
WARNING
654-
"Bison couldn't be downloaded. The current platform ${CMAKE_SYSTEM_NAME} "
655-
"is not yet supported by PHP/Bison module. Please install Bison manually."
656-
)
657-
return()
649+
_php_bison_download_gnu()
658650
endif()
659651

660652
add_executable(Bison::Bison IMPORTED GLOBAL)
@@ -693,24 +685,30 @@ endfunction()
693685

694686
# Downloads GNU Bison.
695687
function(_php_bison_download_gnu)
696-
message(
697-
STATUS
698-
"Downloading GNU Bison ${BISON_VERSION} from https://ftp.gnu.org/gnu/bison"
699-
)
688+
set(url https://mirrors.dotsrc.org/gnu/bison/bison-${BISON_VERSION}.tar.gz)
689+
690+
message(STATUS "Downloading ${url}")
700691

701692
FetchContent_Declare(
702693
BISON
703-
URL https://ftp.gnu.org/gnu/bison/bison-${BISON_VERSION}.tar.gz
694+
URL ${url}
704695
SOURCE_SUBDIR non-existing
705696
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
706697
OVERRIDE_FIND_PACKAGE
707698
)
708699

709700
FetchContent_MakeAvailable(BISON)
710701

702+
# GNU Bison depends on m4 program.
703+
find_program(PHP_BISON_M4_EXECUTABLE m4)
704+
mark_as_advanced(PHP_BISON_M4_EXECUTABLE)
705+
if(NOT PHP_BISON_M4_EXECUTABLE)
706+
_php_bison_download_m4()
707+
endif()
708+
711709
ExternalProject_Add(
712710
BISON
713-
STEP_TARGETS build install
711+
STEP_TARGETS configure build install
714712
SOURCE_DIR ${bison_SOURCE_DIR}
715713
BINARY_DIR ${bison_BINARY_DIR}
716714
INSTALL_DIR ${FETCHCONTENT_BASE_DIR}/bison-install
@@ -720,26 +718,28 @@ function(_php_bison_download_gnu)
720718
--disable-yacc
721719
--enable-silent-rules
722720
--prefix=<INSTALL_DIR>
721+
M4=${PHP_BISON_M4_EXECUTABLE}
723722
LOG_INSTALL TRUE
724723
)
725724

726725
ExternalProject_Get_Property(BISON INSTALL_DIR)
727726

728727
set_property(CACHE BISON_EXECUTABLE PROPERTY VALUE ${INSTALL_DIR}/bin/bison)
728+
729+
if(TARGET M4-install)
730+
add_dependencies(BISON-configure M4-install)
731+
endif()
729732
endfunction()
730733

731734
# Downloads winflexbison.
732735
function(_php_bison_download_windows)
733-
message(
734-
STATUS
735-
"Downloading win_bison ${BISON_VERSION} from "
736-
"https://github.com/lexxmark/winflexbison "
737-
"(${PHP_BISON_WIN_VERSION_DOWNLOAD})"
738-
)
736+
set(url https://github.com/lexxmark/winflexbison/releases/download/v${PHP_BISON_WIN_VERSION_DOWNLOAD}/win_flex_bison-${PHP_BISON_WIN_VERSION_DOWNLOAD}.zip)
737+
738+
message(STATUS "Downloading ${url}")
739739

740740
FetchContent_Declare(
741741
BISON
742-
URL https://github.com/lexxmark/winflexbison/releases/download/v${PHP_BISON_WIN_VERSION_DOWNLOAD}/win_flex_bison-${PHP_BISON_WIN_VERSION_DOWNLOAD}.zip
742+
URL ${url}
743743
SOURCE_SUBDIR non-existing
744744
OVERRIDE_FIND_PACKAGE
745745
)
@@ -752,3 +752,36 @@ function(_php_bison_download_windows)
752752
PROPERTY VALUE "${bison_SOURCE_DIR}/win_bison.exe"
753753
)
754754
endfunction()
755+
756+
function(_php_bison_download_m4)
757+
set(url https://mirrors.dotsrc.org/gnu/m4/m4-1.4.20.tar.gz)
758+
759+
message(STATUS "Downloading ${url}")
760+
761+
FetchContent_Declare(
762+
M4
763+
URL ${url}
764+
SOURCE_SUBDIR non-existing
765+
DOWNLOAD_EXTRACT_TIMESTAMP TRUE
766+
)
767+
768+
FetchContent_MakeAvailable(M4)
769+
770+
ExternalProject_Add(
771+
M4
772+
STEP_TARGETS build install
773+
SOURCE_DIR ${m4_SOURCE_DIR}
774+
BINARY_DIR ${m4_BINARY_DIR}
775+
INSTALL_DIR ${FETCHCONTENT_BASE_DIR}/m4-install
776+
CONFIGURE_COMMAND
777+
<SOURCE_DIR>/configure
778+
--disable-dependency-tracking
779+
--enable-silent-rules
780+
--prefix=<INSTALL_DIR>
781+
LOG_INSTALL TRUE
782+
)
783+
784+
ExternalProject_Get_Property(M4 INSTALL_DIR)
785+
786+
set_property(CACHE PHP_BISON_M4_EXECUTABLE PROPERTY VALUE ${INSTALL_DIR}/bin/m4)
787+
endfunction()

docs/cmake/cmake.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,12 @@ Required:
111111
* g++
112112
* libsqlite3
113113

114-
Optional (if not found on the system, build system tries to download it):
114+
Optional (if not found on the system, build system tries to download them):
115115

116116
* libxml2
117117

118-
Optional when building from Git repository source code:
118+
Optional when building from Git repository source code (if not found on the
119+
system, build system tries to download them):
119120

120121
* Bison
121122
* re2c

0 commit comments

Comments
 (0)