Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some major bugs are fixed on OSX. #10

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 29 additions & 9 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
# installed in the default directory, you can change that here.
#

PHP_CONFIG = php-config

PHP_CONFIG = php-config
UNAME := $(shell uname)

#
# Installation directory
Expand All @@ -30,7 +30,14 @@ PHP_CONFIG = php-config
# and /usr/local/lib. You can of course change it to whatever suits you best
#

INSTALL_PREFIX = /usr
# Since OSX 10.10 Yosemite, /usr/include gives problem
# So, let's switch to /usr/local as default instead.
ifeq ($(UNAME), Darwin)
INSTALL_PREFIX = /usr/local
else
INSTALL_PREFIX = /usr
endif

INSTALL_HEADERS = ${INSTALL_PREFIX}/include
INSTALL_LIB = ${INSTALL_PREFIX}/lib

Expand All @@ -45,6 +52,13 @@ INSTALL_LIB = ${INSTALL_PREFIX}/lib
SONAME = 1.5
VERSION = 1.5.7

# macOS is using install_name option instead of soname
ifeq ($(UNAME), Darwin)
SONAME_OPTION = install_name
else
SONAME_OPTION = soname
endif


#
# Name of the target library name and config-generator
Expand Down Expand Up @@ -94,7 +108,7 @@ endif
# you want to leave that flag out on production servers).
#

COMPILER_FLAGS = -Wall -c -std=c++11 -fvisibility=hidden -MD -DBUILDING_PHPCPP -Wno-write-strings
COMPILER_FLAGS = -Wall -c -std=c++11 -fvisibility=hidden -DBUILDING_PHPCPP -Wno-write-strings -MD
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SHARED_COMPILER_FLAGS = -fpic
STATIC_COMPILER_FLAGS =
PHP_COMPILER_FLAGS = ${COMPILER_FLAGS} `${PHP_CONFIG} --includes`
Expand All @@ -105,11 +119,12 @@ PHP_COMPILER_FLAGS = ${COMPILER_FLAGS} `${PHP_CONFIG} --includes`
# Just like the compiler, the linker can have flags too. The default flag
# is probably the only one you need.
#
# Are you compiling on OSX? You may have to append the option "-undefined dynamic_lookup"
# to the linker flags
#

LINKER_FLAGS = -shared
LINKER_FLAGS = -shared
ifeq ($(UNAME), Darwin)
LINKER_FLAGS += -undefined dynamic_lookup
endif

PHP_LINKER_FLAGS = ${LINKER_FLAGS} `${PHP_CONFIG} --ldflags`


Expand Down Expand Up @@ -176,7 +191,7 @@ phpcpp: ${PHP_SHARED_LIBRARY} ${PHP_STATIC_LIBRARY}
@echo "Build complete."

${PHP_SHARED_LIBRARY}: shared_directories ${COMMON_SHARED_OBJECTS} ${PHP_SHARED_OBJECTS}
${LINKER} ${PHP_LINKER_FLAGS} -Wl,-soname,libphpcpp.so.$(SONAME) -o $@ ${COMMON_SHARED_OBJECTS} ${PHP_SHARED_OBJECTS}
${LINKER} ${PHP_LINKER_FLAGS} -Wl,-$(SONAME_OPTION),libphpcpp.so.$(SONAME) -o $@ ${COMMON_SHARED_OBJECTS} ${PHP_SHARED_OBJECTS}

${PHP_STATIC_LIBRARY}: static_directories ${COMMON_STATIC_OBJECTS} ${PHP_STATIC_OBJECTS}
${ARCHIVER} $@ ${COMMON_STATIC_OBJECTS} ${PHP_STATIC_OBJECTS}
Expand Down Expand Up @@ -211,6 +226,7 @@ ${PHP_STATIC_OBJECTS}:

install:
${MKDIR} ${INSTALL_HEADERS}/phpcpp
${MKDIR} ${INSTALL_LIB}
${CP} phpcpp.h ${INSTALL_HEADERS}
${CP} include/*.h ${INSTALL_HEADERS}/phpcpp
if [ -e ${PHP_SHARED_LIBRARY} ]; then \
Expand All @@ -225,3 +241,7 @@ install:
sudo ldconfig; \
fi

uninstall:
${RM} ${INSTALL_HEADERS}/phpcpp*
${RM} ${INSTALL_LIB}/libphpcpp.*