1
0
Fork 0
mirror of https://we.phorge.it/source/arcanist.git synced 2024-11-22 14:52:40 +01:00
phorge-arcanist/support/xhpast/Makefile
epriestley 763ac445dc Revert xhpast changes that impacted builds under Bison 2.3
Summary:
Fixes T9753. Changes some time ago (in D13970 + D13974) improved XHPAST build compile-time warning behavior under Bison 3.

However, macOS still ships with Bison 2.3 and these changes prevent XHPAST from building with Bison 2.3. The changes didn't introduce version detection, so Bison 2.3 builds fail somewhat mysteriously without obvious next steps.

It's relatively easy to install Bison 3 on macOS via Homebrew, but the Bison 3 changes aren't terribly substantive and XHPAST doesn't actually depend on any Bison 3 features, so just return to Bison 2.3 for now.

It would be reasonable to undo this again and retarget Bison 3 in the future, but ideally we should wait until macOS ships with Bison 3 or we have a specific reason to bump the minimum required version to 3. If/when we do, we should version-detect Bison and raise a clear error message.

Test Plan: Built xhpast under Bison 2.3 on a default macOS install using "make cleanall && make install".

Maniphest Tasks: T9753

Differential Revision: https://secure.phabricator.com/D21063
2020-04-07 14:29:19 -07:00

77 lines
1.6 KiB
Makefile

BISONFLAGS = --verbose --name-prefix xhpast
CPPFLAGS = -fPIC -Wall
FLEXFLAGS = -CFr
ifdef DEBUG
BISONFLAGS += --debug
CPPFLAGS += -ggdb -DDEBUG
FLEXFLAGS += --debug
else
CPPFLAGS += -O3 -minline-all-stringops
endif
ifdef PROFILE
CPPFLAGS += -pg
endif
ifdef STATIC
CPPFLAGS += -static
endif
ifdef MSYSTEM
CPPFLAGS += -static-libgcc -static-libstdc++
endif
ROOT = ../../src/parser/xhpast
.PHONY: all
all: xhpast
clean:
rm -f xhpast parser.yacc.output libxhpast.a *.o
cleanall: clean
rm -f scanner.lex.hpp scanner.lex.cpp parser.yacc.hpp parser.yacc.cpp
rm -f node_names.hpp parser_nodes.php
.PHONY: install
install: xhpast
cp xhpast $(ROOT)/bin/xhpast
.PHONY: parser scanner
parser: parser.yacc.hpp parser.yacc.cpp
scanner: scanner.lex.hpp scanner.lex.cpp
%.lex.hpp %.lex.cpp: %.l
ifndef SKIP_SCANNER
flex $(FLEXFLAGS) --header-file=$*.lex.hpp --outfile=$*.lex.cpp $<
@echo '/* @gen''er''ated */' >> $*.lex.hpp
@echo '/* @gen''er''ated */' >> $*.lex.cpp
else
touch $*.lex.hpp $*.lex.cpp
endif
%.yacc.hpp %.yacc.cpp: %.y
ifndef SKIP_PARSER
bison $(BISONFLAGS) --defines=$*.yacc.hpp --output=$*.yacc.cpp $<
@echo '/* @gen''er''ated */' >> $*.yacc.hpp
@echo '/* @gen''er''ated */' >> $*.yacc.cpp
else
touch $*.yacc.hpp $*.yacc.cpp
endif
%.o: %.cpp
$(CXX) -c $(CPPFLAGS) -o $@ $<
node_names.hpp parser_nodes.php: generate_nodes.php
php -f $<
parser.yacc.o: scanner.lex.hpp
scanner.lex.o: parser.yacc.hpp node_names.hpp scanner.lex.hpp
libxhpast.a: scanner.lex.o parser.yacc.o
$(AR) -crs $@ $^
xhpast: xhpast.cpp libxhpast.a
$(CXX) $(CPPFLAGS) -o $@ $^