Skip to content

Commit 69d571f

Browse files
committed
Improvements to makefile
Summary: Various improvements to the XHPAST `Makefile`. Test Plan: ``` > make -C support/xhpast cleanall parser scanner xhpast make: Entering directory '/home/joshua/workspace/github.com/phacility/libphutil/support/xhpast' rm --force xhpast parser.yacc.output libxhpast.a *.o rm --force scanner.lex.hpp scanner.lex.cpp parser.yacc.hpp parser.yacc.cpp rm --force node_names.hpp parser_nodes.php bison --verbose -Wall --defines=parser.yacc.hpp --output=parser.yacc.cpp parser.y flex -CFr --header-file=scanner.lex.hpp --outfile=scanner.lex.cpp scanner.l php -f generate_nodes.php Wrote C++ definition. Wrote PHP definition. g++ -c -fPIC -Wall -O3 -minline-all-stringops -o scanner.lex.o scanner.lex.cpp g++ -c -fPIC -Wall -O3 -minline-all-stringops -o parser.yacc.o parser.yacc.cpp ar -crs libxhpast.a scanner.lex.o parser.yacc.o g++ -fPIC -Wall -O3 -minline-all-stringops -o xhpast xhpast.cpp libxhpast.a make: Leaving directory '/home/joshua/workspace/github.com/phacility/libphutil/support/xhpast' ``` Reviewers: epriestley, #blessed_reviewers Reviewed By: epriestley, #blessed_reviewers Subscribers: Korvin, epriestley Differential Revision: https://secure.phabricator.com/D13978
1 parent a00d404 commit 69d571f

File tree

2 files changed

+22
-26
lines changed

2 files changed

+22
-26
lines changed

.gitignore

+1-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
/support/xhpast/parser.yacc.output
1212
/support/xhpast/node_names.hpp
1313
/support/xhpast/xhpast
14+
/support/xhpast/xhpast.exe
1415
/src/parser/xhpast/bin/xhpast
1516

1617
## NOTE: Don't .gitignore these files! Even though they're build artifacts, we
@@ -23,9 +24,6 @@
2324
# This is an OS X build artifact.
2425
/support/xhpast/xhpast.dSYM
2526

26-
# This is a Windows build artifact.
27-
/support/xhpast/xhpast.exe
28-
2927
# libphutil
3028
/src/.phutil_module_cache
3129
/support/phutiltestlib/.phutil_module_cache

support/xhpast/Makefile

+21-23
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
BISONFLAGS = --verbose -d -Wall
1+
BISONFLAGS = --verbose -Wall
22
CPPFLAGS = -fPIC -Wall
33
FLEXFLAGS = -CFr
44

@@ -24,47 +24,45 @@ endif
2424

2525
ROOT = ../../src/parser/xhpast
2626

27+
.PHONY: all
2728
all: xhpast
2829

2930
clean:
30-
-rm xhpast parser.yacc.output libxhpast.a *.o 2>/dev/null
31+
rm --force xhpast parser.yacc.output libxhpast.a *.o
3132

3233
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
3436

37+
.PHONY: install
3538
install: xhpast
3639
cp xhpast $(ROOT)/bin/xhpast
3740

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
4244

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
4749

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
5154

5255
%.o: %.cpp
5356
$(CXX) -c $(CPPFLAGS) -o $@ $<
5457

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 $<
5960

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
6363

6464
libxhpast.a: scanner.lex.o parser.yacc.o
6565
$(AR) -crs $@ $^
6666

6767
xhpast: xhpast.cpp libxhpast.a
6868
$(CXX) $(CPPFLAGS) -o $@ $^
69-
70-
.PHONY: all clean

0 commit comments

Comments
 (0)