diff --git a/config/ext.json b/config/ext.json index 79d3831ec..7223055ec 100644 --- a/config/ext.json +++ b/config/ext.json @@ -210,7 +210,7 @@ "support": { "Windows": "wip", "BSD": "no", - "Linux": "no" + "Linux": "yes" }, "notes": true, "type": "external", diff --git a/config/lib.json b/config/lib.json index 58cbd4ba0..2acead37e 100644 --- a/config/lib.json +++ b/config/lib.json @@ -174,6 +174,12 @@ "OpenGL", "Cocoa", "IOKit" + ], + "static-libs-linux": [ + "libglfw3.a" + ], + "headers": [ + "GLFW" ] }, "gmp": { diff --git a/src/SPC/builder/extension/glfw.php b/src/SPC/builder/extension/glfw.php index 7cfdaaaf6..165d6ee51 100644 --- a/src/SPC/builder/extension/glfw.php +++ b/src/SPC/builder/extension/glfw.php @@ -23,6 +23,12 @@ public function patchBeforeBuildconf(): bool public function patchBeforeConfigure(): bool { FileSystem::replaceFileStr(SOURCE_PATH . '/php-src/configure', '-lglfw ', '-lglfw3 '); + + // ogt_vox_c_wrapper.cpp requires the C++ standard library + $cxxLib = PHP_OS_FAMILY === 'Darwin' ? '-lc++' : '-lstdc++'; + $extraLibs = trim($this->builder->getOption('extra-libs', '') . ' ' . $cxxLib); + $this->builder->setOption('extra-libs', $extraLibs); + return true; } diff --git a/src/SPC/builder/linux/library/glfw.php b/src/SPC/builder/linux/library/glfw.php new file mode 100644 index 000000000..8f2e06f8a --- /dev/null +++ b/src/SPC/builder/linux/library/glfw.php @@ -0,0 +1,27 @@ +setBuildDir("{$this->source_dir}/vendor/glfw") + ->setReset(false) + ->addConfigureArgs( + '-DGLFW_BUILD_EXAMPLES=OFF', + '-DGLFW_BUILD_TESTS=OFF', + '-DGLFW_BUILD_WAYLAND=OFF', + ) + ->build('.'); + // patch pkgconf + $this->patchPkgconfPrefix(['glfw3.pc']); + } +}