summaryrefslogtreecommitdiff
path: root/0001-Makefile-install-DESTDIR-and-more.patch
blob: a6cd7fe44172f01d4f06d1da2beb364eb720c70c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
From: Tzafrir Cohen <tzafrir@debian.org>
Date: Wed, 11 May 2016 14:25:02 +0300
Subject: Makefile: install: DESTDIR and more

Fix the install target of the Makefile:
* support DESTDIR
* create installed directories
* fix symlink targets
* less shell scripts: if Makefile if instead
---
 Makefile | 29 ++++++++++++++++-------------
 1 file changed, 16 insertions(+), 13 deletions(-)

diff --git a/Makefile b/Makefile
index d3d0596..b7a63e9 100644
--- a/Makefile
+++ b/Makefile
@@ -94,7 +94,7 @@ endif
 #   you want to leave that flag out on production servers).
 #
 
-COMPILER_FLAGS			=	-Wall -c -std=c++11 -fvisibility=hidden -DBUILDING_PHPCPP -Wno-write-strings
+COMPILER_FLAGS			=	-Wall -c -std=c++11 -fvisibility=hidden -DBUILDING_PHPCPP -Wno-write-strings $(CPPFLAGS) $(CXXFLAGS)
 SHARED_COMPILER_FLAGS	=	-fpic
 STATIC_COMPILER_FLAGS	=
 PHP_COMPILER_FLAGS		=	${COMPILER_FLAGS} `${PHP_CONFIG} --includes`
@@ -109,7 +109,7 @@ PHP_COMPILER_FLAGS		=	${COMPILER_FLAGS} `${PHP_CONFIG} --includes`
 #   to the linker flags
 #
 
-LINKER_FLAGS			=	-shared
+LINKER_FLAGS			=	-shared $(LDFLAGS)
 PHP_LINKER_FLAGS		=	${LINKER_FLAGS} `${PHP_CONFIG} --ldflags`
 
 
@@ -150,6 +150,7 @@ PHP_SHARED_OBJECTS		=	$(PHP_SOURCES:%.cpp=shared/%.o)
 COMMON_STATIC_OBJECTS	=	$(COMMON_SOURCES:%.cpp=static/%.o)
 PHP_STATIC_OBJECTS		=	$(PHP_SOURCES:%.cpp=static/%.o)
 
+DESTDIR			=
 
 #
 #   End of the variables section. Here starts the list of instructions and
@@ -203,17 +204,19 @@ ${PHP_STATIC_OBJECTS}:
 # 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}/; \
-		${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
+	${MKDIR} -p $(DESTDIR)${INSTALL_HEADERS}/phpcpp
+	${CP} phpcpp.h $(DESTDIR)${INSTALL_HEADERS}
+	${CP} include/*.h $(DESTDIR)${INSTALL_HEADERS}/phpcpp
+	${MKDIR} -p $(DESTDIR)${INSTALL_LIB}
+ifneq ($(wildcard ${PHP_SHARED_LIBRARY}),)
+	${CP} ${PHP_SHARED_LIBRARY} $(DESTDIR)${INSTALL_LIB}/
+	${LN} ${PHP_SHARED_LIBRARY} $(DESTDIR)${INSTALL_LIB}/libphpcpp.so.$(SONAME)
+	${LN} ${PHP_SHARED_LIBRARY} $(DESTDIR)${INSTALL_LIB}/libphpcpp.so
+endif
+ifneq ($(wildcard ${PHP_STATIC_LIBRARY}),)
+	${CP} ${PHP_STATIC_LIBRARY} $(DESTDIR)${INSTALL_LIB}/
+	${LN} ${PHP_STATIC_LIBRARY} $(DESTDIR)${INSTALL_LIB}/libphpcpp.a
+endif
 	if `which ldconfig`; then \
 		sudo ldconfig; \
 	fi