Skip to content

Commit cfc3460

Browse files
we now use the same objects for the shared and static object files (because they both need the -fpic flag anyway) (resolves CopernicaMarketingSoftware#378)
1 parent d778788 commit cfc3460

File tree

2 files changed

+18
-34
lines changed

2 files changed

+18
-34
lines changed

.gitignore

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,5 @@
44
*.txt
55
*.a.*
66
*.so.*
7-
shared/
8-
static/
7+
build/
98
.vscode/

Makefile

+17-32
Original file line numberDiff line numberDiff line change
@@ -101,10 +101,7 @@ endif
101101
# you want to leave that flag out on production servers).
102102
#
103103

104-
COMPILER_FLAGS = -Wall -c -std=c++11 -fvisibility=hidden -DBUILDING_PHPCPP -Wno-write-strings -MD
105-
SHARED_COMPILER_FLAGS = -fpic
106-
STATIC_COMPILER_FLAGS =
107-
PHP_COMPILER_FLAGS = ${COMPILER_FLAGS} `${PHP_CONFIG} --includes`
104+
COMPILER_FLAGS = -Wall -c -std=c++11 -fvisibility=hidden -DBUILDING_PHPCPP -Wno-write-strings -MD -fpic `${PHP_CONFIG} --includes`
108105

109106
#
110107
# Linker flags
@@ -160,16 +157,14 @@ PHP_SOURCES = $(wildcard zend/*.cpp)
160157
# library. We also use a Makefile function here that takes all source files.
161158
#
162159

163-
COMMON_SHARED_OBJECTS = $(COMMON_SOURCES:%.cpp=shared/%.o)
164-
PHP_SHARED_OBJECTS = $(PHP_SOURCES:%.cpp=shared/%.o)
165-
COMMON_STATIC_OBJECTS = $(COMMON_SOURCES:%.cpp=static/%.o)
166-
PHP_STATIC_OBJECTS = $(PHP_SOURCES:%.cpp=static/%.o)
160+
COMMON_OBJECTS = $(COMMON_SOURCES:%.cpp=build/%.o)
161+
PHP_OBJECTS = $(PHP_SOURCES:%.cpp=build/%.o)
167162

168163
#
169164
# Dependencies
170165
#
171166

172-
DEPENDENCIES = $(wildcard shared/common/*.d) $(wildcard shared/zend/*.d) $(wildcard static/common/*.d) $(wildcard static/zend/*.d)
167+
DEPENDENCIES = $(wildcard build/common/*.d) $(wildcard build/zend/*.d)
173168

174169
#
175170
# End of the variables section. Here starts the list of instructions and
@@ -190,36 +185,26 @@ phpcpp: ${PHP_SHARED_LIBRARY} ${PHP_STATIC_LIBRARY}
190185
@echo
191186
@echo "Build complete."
192187

193-
${PHP_SHARED_LIBRARY}: shared_directories ${COMMON_SHARED_OBJECTS} ${PHP_SHARED_OBJECTS}
194-
${LINKER} ${PHP_LINKER_FLAGS} -Wl,${LINKER_SONAME_OPTION},libphpcpp.so.$(SONAME) -o $@ ${COMMON_SHARED_OBJECTS} ${PHP_SHARED_OBJECTS}
188+
${PHP_SHARED_LIBRARY}: build_directories ${COMMON_OBJECTS} ${PHP_OBJECTS}
189+
${LINKER} ${PHP_LINKER_FLAGS} -Wl,${LINKER_SONAME_OPTION},libphpcpp.so.$(SONAME) -o $@ ${COMMON_OBJECTS} ${PHP_OBJECTS}
195190

196-
${PHP_STATIC_LIBRARY}: static_directories ${COMMON_STATIC_OBJECTS} ${PHP_STATIC_OBJECTS}
197-
${ARCHIVER} $@ ${COMMON_STATIC_OBJECTS} ${PHP_STATIC_OBJECTS}
191+
${PHP_STATIC_LIBRARY}: build_directories ${COMMON_OBJECTS} ${PHP_OBJECTS}
192+
${ARCHIVER} $@ ${COMMON_OBJECTS} ${PHP_OBJECTS}
198193

199-
shared_directories:
200-
${MKDIR} shared/common
201-
${MKDIR} shared/zend
202-
203-
static_directories:
204-
${MKDIR} static/common
205-
${MKDIR} static/zend
194+
build_directories:
195+
${MKDIR} build/common
196+
${MKDIR} build/zend
206197

207198
clean:
208-
${RM} shared ${PHP_SHARED_LIBRARY}
209-
${RM} static ${PHP_STATIC_LIBRARY}
199+
${RM} build ${PHP_SHARED_LIBRARY} ${PHP_STATIC_LIBRARY}
210200
find -name *.o | xargs ${RM}
201+
find -name *.d | xargs ${RM}
211202

212-
${COMMON_SHARED_OBJECTS}:
213-
${COMPILER} ${PHP_COMPILER_FLAGS} ${SHARED_COMPILER_FLAGS} -o $@ ${@:shared/%.o=%.cpp}
214-
215-
${COMMON_STATIC_OBJECTS}:
216-
${COMPILER} ${PHP_COMPILER_FLAGS} ${STATIC_COMPILER_FLAGS} -o $@ ${@:static/%.o=%.cpp}
217-
218-
${PHP_SHARED_OBJECTS}:
219-
${COMPILER} ${PHP_COMPILER_FLAGS} ${SHARED_COMPILER_FLAGS} -o $@ ${@:shared/%.o=%.cpp}
203+
${COMMON_OBJECTS}:
204+
${COMPILER} ${COMPILER_FLAGS} -o $@ ${@:build/%.o=%.cpp}
220205

221-
${PHP_STATIC_OBJECTS}:
222-
${COMPILER} ${PHP_COMPILER_FLAGS} ${STATIC_COMPILER_FLAGS} -o $@ ${@:static/%.o=%.cpp}
206+
${PHP_OBJECTS}:
207+
${COMPILER} ${COMPILER_FLAGS} -o $@ ${@:build/%.o=%.cpp}
223208

224209

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

0 commit comments

Comments
 (0)