-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
89 lines (59 loc) · 1.56 KB
/
Makefile
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
NAME = berry-spi
#
# INI directories
#
PHP_MAJOR_VERSION := $(shell php -v | grep -i 'PHP [57]' | sed s/'PHP '//g | cut -c1-1)
PHP_SUB_VERSION := $(shell php -v | grep -i 'PHP [57]' | cut -c1-8 | sed s/'PHP '//g | cut -c1-3)
ifeq (${PHP_MAJOR_VERSION}, 7)
INI_DIR := /etc/php/${PHP_SUB_VERSION}/mods-available/
else
INI_DIR := /etc/php5/mods-available/
endif
#
# The extension dirs
#
EXTENSION_DIR = $(shell php-config --extension-dir)
#
# The include dirs
#
INCLUDE_DIR = $(shell php-config --include-dir)
#
# The name of the extension and the name of the .ini file
#
EXTENSION = ${NAME}.so
INI = ${NAME}.ini
#
# Compiler
#
COMPILER = g++
LINKER = g++
#
# Compiler and linker flags
#
COMPILER_FLAGS = -Wall -I${INCLUDE_DIR} -I${INCLUDE_DIR}/main -I${INCLUDE_DIR}/Zend -I${INCLUDE_DIR}/TSRM -c -O2 -std=c++11 -fpic -o
LINKER_FLAGS = -shared
LINKER_DEPENDENCIES = -lpigpio -lphpcpp
#
# Command to remove files, copy files and create directories.
#
RM = rm -f
CP = cp -f
MKDIR = mkdir -p
#
# All source files are simply all *.cpp files found in the current directory
#
SOURCES = $(wildcard src/*.cpp)
OBJECTS = $(SOURCES:%.cpp=%.o)
#
# From here the build instructions start
#
all: ${OBJECTS} ${EXTENSION}
${EXTENSION}: ${OBJECTS}
${LINKER} ${LINKER_FLAGS} -o $@ ${OBJECTS} ${LINKER_DEPENDENCIES}
${OBJECTS}:
${COMPILER} ${COMPILER_FLAGS} $@ ${@:%.o=%.cpp}
install:
${CP} ${EXTENSION} ${EXTENSION_DIR}
${CP} ${INI} ${INI_DIR}
clean:
${RM} ${EXTENSION} ${OBJECTS}