From afa88f6b5e6b7a8e9d5df0973034dd107ccb9aa4 Mon Sep 17 00:00:00 2001 From: Shawn Webb Date: Sat, 17 Oct 2020 09:08:58 -0400 Subject: [PATCH 1/9] Blackhawk: Install into /usr/local Third-party applications on FreeBSD/HardenedBSD install into /usr/local. Signed-off-by: Shawn Webb Sponsored-by: BlackhawkNest, Inc --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index 6ecab3fd..3426f46e 100644 --- a/Makefile +++ b/Makefile @@ -34,9 +34,13 @@ UNAME := $(shell uname) # So, let's switch to /usr/local as default instead. ifeq ($(UNAME), Darwin) INSTALL_PREFIX = /usr/local +else +ifeq ($(UNAME), FreeBSD) + INSTALL_PREFIX = /usr/local else INSTALL_PREFIX = /usr endif +endif INSTALL_HEADERS = ${INSTALL_PREFIX}/include INSTALL_LIB = ${INSTALL_PREFIX}/lib From 6214d518047ff55450caa098825e6663a4daa149 Mon Sep 17 00:00:00 2001 From: Shawn Webb Date: Sat, 17 Oct 2020 09:13:59 -0400 Subject: [PATCH 2/9] Blackhawk: Allow ${PREFIX} override for FreeBSD Signed-off-by: Shawn Webb Sponsored-by: BlackhawkNest, Inc --- Makefile | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Makefile b/Makefile index 3426f46e..aed96ecf 100644 --- a/Makefile +++ b/Makefile @@ -36,7 +36,11 @@ ifeq ($(UNAME), Darwin) INSTALL_PREFIX = /usr/local else ifeq ($(UNAME), FreeBSD) +ifdef PREFIX + INSTALL_PREFIX = $(PREFIX) +else INSTALL_PREFIX = /usr/local +endif else INSTALL_PREFIX = /usr endif From f7c98eb24fdd138212be13aa9c2eacde186c3095 Mon Sep 17 00:00:00 2001 From: Shawn Webb Date: Sat, 17 Oct 2020 10:07:26 -0400 Subject: [PATCH 3/9] Blackhawk: Add obj directory Signed-off-by: Shawn Webb Sponsored-by: BlackhawkNest, Inc --- obj/.gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 obj/.gitignore diff --git a/obj/.gitignore b/obj/.gitignore new file mode 100644 index 00000000..d6b7ef32 --- /dev/null +++ b/obj/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore From 6ad4dff76a56a6be9ad6feed6fcc0b4534769e25 Mon Sep 17 00:00:00 2001 From: Shawn Webb Date: Sat, 17 Oct 2020 10:07:53 -0400 Subject: [PATCH 4/9] Blackhawk: Add FreeBSD-specific Makefile Signed-off-by: Shawn Webb Sponsored-by: BlackhawkNest, Inc --- Makefile.FreeBSD | 63 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 Makefile.FreeBSD diff --git a/Makefile.FreeBSD b/Makefile.FreeBSD new file mode 100644 index 00000000..158efbef --- /dev/null +++ b/Makefile.FreeBSD @@ -0,0 +1,63 @@ +.PATH: ${.CURDIR}/common +.PATH: ${.CURDIR}/zend + +SHLIB= phpcpp +SHLIB_MAJOR= 2.2.1 +MAN= + +# common +SRCS= modifiers.cpp + +# zend +SRCS+= base.cpp +SRCS+= callable.cpp +SRCS+= classbase.cpp +SRCS+= classimpl.cpp +SRCS+= constant.cpp +SRCS+= constantfuncs.cpp +SRCS+= error.cpp +SRCS+= eval.cpp +SRCS+= exception.cpp +SRCS+= exception_handler.cpp +SRCS+= exists.cpp +SRCS+= extension.cpp +SRCS+= extensionimpl.cpp +SRCS+= file.cpp +SRCS+= function.cpp +SRCS+= functor.cpp +SRCS+= global.cpp +SRCS+= globals.cpp +SRCS+= hashmember.cpp +SRCS+= ini.cpp +SRCS+= inivalue.cpp +SRCS+= iteratorimpl.cpp +SRCS+= members.cpp +SRCS+= module.cpp +SRCS+= namespace.cpp +SRCS+= object.cpp +SRCS+= sapi.cpp +SRCS+= script.cpp +SRCS+= stream.cpp +SRCS+= streambuf.cpp +SRCS+= streams.cpp +SRCS+= super.cpp +SRCS+= throwable.cpp +SRCS+= value.cpp +SRCS+= valueiterator.cpp +SRCS+= zendcallable.cpp +SRCS+= zval.cpp + +CFLAGS+= -std=c++11 -DBUILDING_PHPCPP -MD -Wno-write-strings -fvisibility=hidden + +PHP_CONFIG= php-config +PHP_CFLAGS!= ${PHP_CONFIG} --includes +PHP_LDFLAGS!= ${PHP_CONFIG} --ldflags +CFLAGS+= ${PHP_CFLAGS} +LDFLAGS+= ${PHP_LDFLAGS} + +.if defined(PREFIX) +LIBDIR= ${PREFIX}/lib +INCLUDEDIR= ${PREFIX}/include +.endif + +.include From 71745d1ab99941eec4b54a2bcd773f2dc78118ad Mon Sep 17 00:00:00 2001 From: Shawn Webb Date: Sat, 17 Oct 2020 10:52:45 -0400 Subject: [PATCH 5/9] Blackhawk: Undo changes to Makefile Since I created a FreeBSD-specific Makefile, there's no need to modify the primary Makefile. Signed-off-by: Shawn Webb Sponsored-by: BlackhawkNest, Inc --- Makefile | 8 -------- 1 file changed, 8 deletions(-) diff --git a/Makefile b/Makefile index aed96ecf..6ecab3fd 100644 --- a/Makefile +++ b/Makefile @@ -34,17 +34,9 @@ UNAME := $(shell uname) # So, let's switch to /usr/local as default instead. ifeq ($(UNAME), Darwin) INSTALL_PREFIX = /usr/local -else -ifeq ($(UNAME), FreeBSD) -ifdef PREFIX - INSTALL_PREFIX = $(PREFIX) -else - INSTALL_PREFIX = /usr/local -endif else INSTALL_PREFIX = /usr endif -endif INSTALL_HEADERS = ${INSTALL_PREFIX}/include INSTALL_LIB = ${INSTALL_PREFIX}/lib From 21f04a5007d649abd7151e137a5ad69eed326da7 Mon Sep 17 00:00:00 2001 From: Shawn Webb Date: Mon, 19 Oct 2020 17:36:31 -0400 Subject: [PATCH 6/9] Blackhawk: Install include files Also, default to /usr/local if PREFIX is undefined. Signed-off-by: Shawn Webb --- Makefile.FreeBSD | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/Makefile.FreeBSD b/Makefile.FreeBSD index 158efbef..c46de11e 100644 --- a/Makefile.FreeBSD +++ b/Makefile.FreeBSD @@ -5,6 +5,56 @@ SHLIB= phpcpp SHLIB_MAJOR= 2.2.1 MAN= +INCS= phpcpp.h +INCS+= include/argument.h +INCS+= include/array.h +INCS+= include/arrayaccess.h +INCS+= include/base.h +INCS+= include/byref.h +INCS+= include/byval.h +INCS+= include/call.h +INCS+= include/class.h +INCS+= include/classbase.h +INCS+= include/classtype.h +INCS+= include/constant.h +INCS+= include/countable.h +INCS+= include/deprecated.h +INCS+= include/error.h +INCS+= include/exception.h +INCS+= include/extension.h +INCS+= include/file.h +INCS+= include/function.h +INCS+= include/global.h +INCS+= include/globals.h +INCS+= include/hashmember.h +INCS+= include/hashparent.h +INCS+= include/ini.h +INCS+= include/inivalue.h +INCS+= include/interface.h +INCS+= include/iterator.h +INCS+= include/message.h +INCS+= include/modifiers.h +INCS+= include/namespace.h +INCS+= include/noexcept.h +INCS+= include/object.h +INCS+= include/parameters.h +INCS+= include/platform.h +INCS+= include/script.h +INCS+= include/serializable.h +INCS+= include/stream.h +INCS+= include/streams.h +INCS+= include/super.h +INCS+= include/thread_local.h +INCS+= include/throwable.h +INCS+= include/traversable.h +INCS+= include/type.h +INCS+= include/value.h +INCS+= include/valueiterator.h +INCS+= include/version.h +INCS+= include/visibility.h +INCS+= include/zendcallable.h +INCS+= include/zval.h + # common SRCS= modifiers.cpp @@ -58,6 +108,9 @@ LDFLAGS+= ${PHP_LDFLAGS} .if defined(PREFIX) LIBDIR= ${PREFIX}/lib INCLUDEDIR= ${PREFIX}/include +.else +LIBDIR= /usr/local/lib +INCLUDEDIR= /usr/local/include/phpcpp .endif .include From 62648e5db29542b49e96868eb4ef724e8949dd06 Mon Sep 17 00:00:00 2001 From: Shawn Webb Date: Tue, 20 Oct 2020 12:14:08 -0400 Subject: [PATCH 7/9] Blackhawk: Use the right version number Signed-off-by: Shawn Webb --- Makefile.FreeBSD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.FreeBSD b/Makefile.FreeBSD index c46de11e..b833272c 100644 --- a/Makefile.FreeBSD +++ b/Makefile.FreeBSD @@ -2,7 +2,7 @@ .PATH: ${.CURDIR}/zend SHLIB= phpcpp -SHLIB_MAJOR= 2.2.1 +SHLIB_MAJOR= 2.2.0 MAN= INCS= phpcpp.h From b8293b09752ba00560a8217d0e4a61c5d81a89a6 Mon Sep 17 00:00:00 2001 From: Shawn Webb Date: Fri, 23 Oct 2020 13:32:07 -0400 Subject: [PATCH 8/9] Blackhawk: Prioritize the zend subdirectory When telling the BSD build infrastructure where to find source code files, the order matters. In this repo, there are some source code files with the same file name that live in /common and /zend. For example, /common/streambuf.cpp and /zend/streambuf.cpp. It seams that the former is scaffolding while the latter is the complete implementation. With this fix, PHP is able to load a custom extension that builds on top of PHP-CPP. PHP Warning: PHP Startup: Unable to load dynamic library '/usr/home/shawn/projects/php-lib[sanitized]/obj/libphp-lib[sanitized].so' (tried: /usr /home/shawn/projects/php-lib[sanitized]/obj/libphp-lib[sanitized].so (/usr/local/lib/libphpcpp.so.2.2.0: Undefined symbol "_ZN3Php9StreamBuf4sync Ev"), /usr/local/lib/php/20190902//usr/home/shawn/projects/php-lib[sanitized]/obj/libphp-lib[sanitized].so.so (Cannot open "/usr/local/lib/php/20 190902//usr/home/shawn/projects/php-lib[sanitized]/obj/libphp-lib[sanitized].so.so")) in Unknown on line 0 Signed-off-by: Shawn Webb --- Makefile.FreeBSD | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.FreeBSD b/Makefile.FreeBSD index b833272c..d03cf2c3 100644 --- a/Makefile.FreeBSD +++ b/Makefile.FreeBSD @@ -1,5 +1,5 @@ -.PATH: ${.CURDIR}/common .PATH: ${.CURDIR}/zend +.PATH: ${.CURDIR}/common SHLIB= phpcpp SHLIB_MAJOR= 2.2.0 From d201dc522557e65f27d56ea3393b6d290df8a078 Mon Sep 17 00:00:00 2001 From: Shawn Webb Date: Fri, 23 Oct 2020 14:17:09 -0400 Subject: [PATCH 9/9] Blackhawk: Rename a file Rename /common/streambuf.cpp to /common/common_streambuf.cpp to address file name conflict with /zend/streambuf.cpp. Signed-off-by: Shawn Webb --- Makefile.FreeBSD | 1 + common/{streambuf.cpp => common_streambuf.cpp} | 0 2 files changed, 1 insertion(+) rename common/{streambuf.cpp => common_streambuf.cpp} (100%) diff --git a/Makefile.FreeBSD b/Makefile.FreeBSD index d03cf2c3..6ec4b945 100644 --- a/Makefile.FreeBSD +++ b/Makefile.FreeBSD @@ -63,6 +63,7 @@ SRCS+= base.cpp SRCS+= callable.cpp SRCS+= classbase.cpp SRCS+= classimpl.cpp +SRCS+= common_streambuf.cpp SRCS+= constant.cpp SRCS+= constantfuncs.cpp SRCS+= error.cpp diff --git a/common/streambuf.cpp b/common/common_streambuf.cpp similarity index 100% rename from common/streambuf.cpp rename to common/common_streambuf.cpp