Skip to content

Commit

Permalink
Add soname and release build traget, default make target is debug
Browse files Browse the repository at this point in the history
  • Loading branch information
RafalGoslawski committed May 19, 2015
1 parent b7729b9 commit 4b32f9f
Showing 1 changed file with 46 additions and 13 deletions.
59 changes: 46 additions & 13 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ INSTALL_HEADERS = ${INSTALL_PREFIX}/include
INSTALL_LIB = ${INSTALL_PREFIX}/lib


#
# SONAME and version
#
# When ABI changes, soname and minor version of the library should be raised.
# Otherwise only release verions changes. (version is MAJOR.MINOR.RELEASE)
#

SONAME = 1.4
VERSION = 1.4.0


#
# Name of the target library name and config-generator
#
Expand All @@ -55,10 +66,10 @@ INSTALL_LIB = ${INSTALL_PREFIX}/lib
# you can change that here.
#

PHP_SHARED_LIBRARY = libphpcpp.so
PHP_STATIC_LIBRARY = libphpcpp.a
HHVM_SHARED_LIBRARY = libhhvmcpp.so
HHVM_STATIC_LIBRARY = libhhvmcpp.a
PHP_SHARED_LIBRARY = libphpcpp.so.$(VERSION)
PHP_STATIC_LIBRARY = libphpcpp.a.$(VERSION)
HHVM_SHARED_LIBRARY = libhhvmcpp.so.$(VERSION)
HHVM_STATIC_LIBRARY = libhhvmcpp.a.$(VERSION)


#
Expand Down Expand Up @@ -97,7 +108,7 @@ endif
# you want to leave that flag out on production servers).
#

COMPILER_FLAGS = -Wall -c -g -std=c++11 -fvisibility=hidden -DBUILDING_PHPCPP
COMPILER_FLAGS = -Wall -c -std=c++11 -fvisibility=hidden -DBUILDING_PHPCPP
SHARED_COMPILER_FLAGS = -fpic
STATIC_COMPILER_FLAGS =
PHP_COMPILER_FLAGS = ${COMPILER_FLAGS} `${PHP_CONFIG} --includes`
Expand All @@ -119,14 +130,15 @@ HHVM_LINKER_FLAGS = ${LINKER_FLAGS}


#
# Command to remove files, copy files and create directories.
# Command to remove files, copy files, link files and create directories.
#
# I've never encountered a *nix environment in which these commands do not work.
# So you can probably leave this as it is
#

RM = rm -fr
CP = cp -f
LN = ln -f -s
MKDIR = mkdir -p


Expand Down Expand Up @@ -164,8 +176,14 @@ HHVM_STATIC_OBJECTS = $(HHVM_SOURCES:%.cpp=static/%.o)
# dependencies that are used by the compiler.
#

all: COMPILER_FLAGS += -g
all: LINKER_FLAGS += -g
all: phpcpp

release: COMPILER_FLAGS += -O2
release: LINKER_FLAGS += -O2
release: phpcpp

phpcpp: ${PHP_SHARED_LIBRARY} ${PHP_STATIC_LIBRARY}
@echo
@echo "Build complete."
Expand All @@ -175,13 +193,13 @@ hhvmcpp: ${HHVM_SHARED_LIBRARY} ${PHP_STATIC_LIBRARY}
@echo "Build complete."

${PHP_SHARED_LIBRARY}: shared_directories ${COMMON_SHARED_OBJECTS} ${PHP_SHARED_OBJECTS}
${LINKER} ${PHP_LINKER_FLAGS} -o $@ ${COMMON_SHARED_OBJECTS} ${PHP_SHARED_OBJECTS}
${LINKER} ${PHP_LINKER_FLAGS} -Wl,-soname,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}

${HHVM_SHARED_LIBRARY}: shared_directories ${COMMON_SHARED_OBJECTS} ${HHVM_SHARED_OBJECTS}
${LINKER} ${HHVM_LINKER_FLAGS} -o $@ ${COMMON_SHARED_OBJECTS} ${HHVM_SHARED_OBJECTS}
${LINKER} ${HHVM_LINKER_FLAGS} -Wl,-soname,libhhvmcpp.so.$(SONAME) -o $@ ${COMMON_SHARED_OBJECTS} ${HHVM_SHARED_OBJECTS}

${HHVM_STATIC_LIBRARY}: static_directories ${COMMON_STATIC_OBJECTS} ${HHVM_STATIC_OBJECTS}
${ARCHIVER} $@ ${COMMON_STATIC_OBJECTS} ${HHVM_STATIC_OBJECTS}
Expand Down Expand Up @@ -219,16 +237,31 @@ ${HHVM_SHARED_OBJECTS}:
${HHVM_STATIC_OBJECTS}:
${COMPILER} ${HHVM_COMPILER_FLAGS} ${STATIC_COMPILER_FLAGS} -o $@ ${@:static/%.o=%.cpp}

# The if statements below must be seen as single line by make

install:
${MKDIR} ${INSTALL_HEADERS}/phpcpp
${CP} phpcpp.h ${INSTALL_HEADERS}
${CP} include/*.h ${INSTALL_HEADERS}/phpcpp
if [ -e ${PHP_SHARED_LIBRARY} ]; then ${CP} ${PHP_SHARED_LIBRARY} ${INSTALL_LIB}; fi
if [ -e ${PHP_STATIC_LIBRARY} ]; then ${CP} ${PHP_STATIC_LIBRARY} ${INSTALL_LIB}; fi
if [ -e ${HHVM_SHARED_LIBRARY} ]; then ${CP} ${HHVM_SHARED_LIBRARY} ${INSTALL_LIB}; fi
if [ -e ${HHVM_STATIC_LIBRARY} ]; then ${CP} ${HHVM_STATIC_LIBRARY} ${INSTALL_LIB}; fi
if [ -e ${PHP_SHARED_LIBRARY} ]; then \
${CP} ${PHP_SHARED_LIBRARY} ${INSTALL_LIB}/; \
${LN} ${INSTALL_LIB}/${PHP_SHARED_LIBRARY} ${INSTALL_LIB}/libphpcpp.so.$(SONAME); \
${LN} ${INSTALL_LIB}/${PHP_SHARED_LIBRARY} ${INSTALL_LIB}/libphpcpp.so; \
fi
if [ -e ${PHP_STATIC_LIBRARY} ]; then ${CP} ${PHP_STATIC_LIBRARY} ${INSTALL_LIB}/; \
${LN} ${INSTALL_LIB}/${PHP_STATIC_LIBRARY} ${INSTALL_LIB}/libphpcpp.a; \
fi
if [ -e ${HHVM_SHARED_LIBRARY} ]; then \
${CP} ${HHVM_SHARED_LIBRARY} ${INSTALL_LIB}/; \
${LN} ${INSTALL_LIB}/${HHVM_SHARED_LIBRARY} ${INSTALL_LIB}/libhhvmcpp.so.$(SONAME);\
${LN} ${INSTALL_LIB}/${HHVM_SHARED_LIBRARY} ${INSTALL_LIB}/libhhvmcpp.so; \
fi
if [ -e ${HHVM_STATIC_LIBRARY} ]; then \
${CP} ${HHVM_STATIC_LIBRARY} ${INSTALL_LIB}/; \
${LN} ${INSTALL_LIB}/${HHVM_STATIC_LIBRARY} ${INSTALL_LIB}/libhhvmcpp.a; \
fi

test:
mkdir -p ./tests/include/zts/phpcpp
mkdir -p tests/include/zts/phpcpp
cd tests && ./test.sh -p "${PHP_BIN}"

0 comments on commit 4b32f9f

Please sign in to comment.