1
- BISONFLAGS = --verbose -d - Wall
1
+ BISONFLAGS = --verbose -Wall
2
2
CPPFLAGS = -fPIC -Wall
3
3
FLEXFLAGS = -CFr
4
4
@@ -24,47 +24,45 @@ endif
24
24
25
25
ROOT = ../../src/parser/xhpast
26
26
27
+ .PHONY : all
27
28
all : xhpast
28
29
29
30
clean :
30
- - rm xhpast parser.yacc.output libxhpast.a * .o 2> /dev/null
31
+ rm --force xhpast parser.yacc.output libxhpast.a * .o
31
32
32
33
cleanall : clean
33
- -rm scanner.lex.cpp scanner.lex.hpp parser.yacc.cpp parser.yacc.hpp
34
+ rm --force scanner.lex.hpp scanner.lex.cpp parser.yacc.hpp parser.yacc.cpp
35
+ rm --force node_names.hpp parser_nodes.php
34
36
37
+ .PHONY : install
35
38
install : xhpast
36
39
cp xhpast $(ROOT ) /bin/xhpast
37
40
38
- scanner : scanner.l
39
- flex $(FLEXFLAGS ) --header-file=scanner.lex.hpp --outfile=scanner.lex.cpp $<
40
- echo ' /* @gen' ' er' ' ated */' >> scanner.lex.cpp
41
- echo ' /* @gen' ' er' ' ated */' >> scanner.lex.hpp
41
+ .PHONY : parser scanner
42
+ parser : parser.yacc.hpp parser.yacc.cpp
43
+ scanner : scanner.lex.hpp scanner.lex.cpp
42
44
43
- parser : parser.y
44
- bison $(BISONFLAGS ) --output=parser.yacc .cpp $<
45
- echo ' /* @gen' ' er' ' ated */' >> parser.yacc.cpp
46
- echo ' /* @gen' ' er' ' ated */' >> parser.yacc.hpp
45
+ % .lex.hpp % .lex.cpp : % .l
46
+ flex $(FLEXFLAGS ) --header-file= $* .lex.hpp --outfile= $* .lex .cpp $<
47
+ @ echo ' /* @gen' ' er' ' ated */' >> $* .lex.hpp
48
+ @ echo ' /* @gen' ' er' ' ated */' >> $* .lex.cpp
47
49
48
- node_names.hpp : generate_nodes.php
49
- php -f generate_nodes.php
50
- cp parser_nodes.php $(ROOT ) /
50
+ % .yacc.hpp % .yacc.cpp : % .y
51
+ bison $(BISONFLAGS ) --defines=$* .yacc.hpp --output=$* .yacc.cpp $<
52
+ @echo ' /* @gen' ' er' ' ated */' >> $* .yacc.hpp
53
+ @echo ' /* @gen' ' er' ' ated */' >> $* .yacc.cpp
51
54
52
55
% .o : % .cpp
53
56
$(CXX ) -c $(CPPFLAGS ) -o $@ $<
54
57
55
- needparserscanner :
56
- @ ([ -e parser.yacc.hpp ] && [ -e parser.yacc.cpp ] && \
57
- [ -e scanner.lex.hpp ] && [ -e scanner.lex.cpp ]) \
58
- || (echo " Run 'make parser scanner' first.'" && exit 1)
58
+ node_names.hpp parser_nodes.php : generate_nodes.php
59
+ php -f $<
59
60
60
- parser.yacc.o : needparserscanner scanner.lex.hpp
61
-
62
- scanner.lex.o : needparserscanner parser.yacc.hpp node_names.hpp scanner.lex.hpp
61
+ parser.yacc.o : scanner.lex.hpp
62
+ scanner.lex.o : parser.yacc.hpp node_names.hpp scanner.lex.hpp
63
63
64
64
libxhpast.a : scanner.lex.o parser.yacc.o
65
65
$(AR ) -crs $@ $^
66
66
67
67
xhpast : xhpast.cpp libxhpast.a
68
68
$(CXX ) $(CPPFLAGS ) -o $@ $^
69
-
70
- .PHONY : all clean
0 commit comments