-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
69 lines (54 loc) · 2.23 KB
/
Makefile
File metadata and controls
69 lines (54 loc) · 2.23 KB
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
# Name of the PHP extension
NAME = graphql-parser
# Location of your PHP installations configured con.d directory
INI_DIR = /usr/local/etc/php/7.1/conf.d
# Location of your PHP installations configured extension directory
EXTENSION_DIR = $(shell php-config --extension-dir)
EXTENSION = ${NAME}.so
INI = ${NAME}.ini
COMPILER = g++
LINKER = g++
# Compiler flag -O2 enables code optimization. For debugging remove and add -g
COMPILER_FLAGS = -Wall -c -O2 -std=c++11 -fpic -o
LINKER_FLAGS = -shared -undefined dynamic_lookup
# If your extension depends on other libraries, you should update this with a list
# of all flags that should be passed to the linker.
LINKER_DEPENDENCIES = -lphpcpp -lgraphqlparser
#
# All source files are simply all *.cpp files found in the current directory
#
# A builtin Makefile macro is used to scan the current directory and find
# all source files. The object files are all compiled versions of the source
# file, with the .cpp extension being replaced by .o.
#
SOURCES = $(wildcard src/*.cpp)
OBJECTS = $(SOURCES:%.cpp=%.o)
AST = ast/ast.ast
AST_SOURCE = https://raw.githubusercontent.com/graphql/libgraphqlparser/master/ast/ast.ast
AST_CPP_AST = generated/ast.cpp
AST_CPP_AST_INC = generated/ast.php.inc
AST_CPP_AST_TO_PHP_VISITOR = generated/ASTToPHPVisitor.cpp
AST_PHP_AST_STUBS = $(wildcard generated/php_ast_stubs/*.php)
# Generated is a sub dir of all the code generated from the ast.ast required to build the PHP extension.
.PHONY: generated
all: generated ${EXTENSION}
${EXTENSION}: ${OBJECTS}
${LINKER} ${LINKER_FLAGS} -o $@ ${OBJECTS} ${LINKER_DEPENDENCIES}
${OBJECTS}:
${COMPILER} ${COMPILER_FLAGS} $@ ${@:%.o=%.cpp}
generated:
if [ ! -f ${AST} ]; then wget -O ${AST} ${AST_SOURCE}; fi
if [ ! -f generated/ast.cpp ]; then \
python ast/ast.py cpp_ast ${AST} > ${AST_CPP_AST}; \
python ast/ast.py cpp_ast_inc ${AST} > ${AST_CPP_AST_INC}; \
python ast/ast.py cpp_ast_to_php_visitor ${AST} > ${AST_CPP_AST_TO_PHP_VISITOR}; \
python ast/ast.py php_ast_stubs ${AST}; \
fi;
clean-ast:
rm -f ${AST}
install:
cp -f ${EXTENSION} ${EXTENSION_DIR}
cp -f ${INI} ${INI_DIR}
clean:
rm -f ${EXTENSION} ${OBJECTS}
rm -f ${AST_CPP_AST} ${AST_CPP_AST_INC} ${AST_PHP_AST_STUBS}