@@ -199,6 +199,7 @@ UNICODE_OBJS= @UNICODE_OBJS@
199199PYTHON= python$(EXE)
200200BUILDPYTHON= python$(BUILDEXE)
201201
202+ PYTHON_FOR_REGEN=@PYTHON_FOR_REGEN@
202203PYTHON_FOR_BUILD=@PYTHON_FOR_BUILD@
203204_PYTHON_HOST_PLATFORM=@_PYTHON_HOST_PLATFORM@
204205HOST_GNU_TYPE= @host@
@@ -233,11 +234,6 @@ SIGNAL_OBJS= @SIGNAL_OBJS@
233234
234235
235236##########################################################################
236- # Grammar
237- GRAMMAR_H= Include/graminit.h
238- GRAMMAR_C= Python/graminit.c
239- GRAMMAR_INPUT= $(srcdir)/Grammar/Grammar
240-
241237
242238LIBFFI_INCLUDEDIR= @LIBFFI_INCLUDEDIR@
243239
@@ -297,29 +293,6 @@ PGENSRCS= $(PSRCS) $(PGSRCS)
297293PGENOBJS= $(POBJS) $(PGOBJS)
298294
299295##########################################################################
300- # AST
301- AST_H_DIR= Include
302- AST_H= $(AST_H_DIR)/Python-ast.h
303- AST_C_DIR= Python
304- AST_C= $(AST_C_DIR)/Python-ast.c
305- AST_ASDL= $(srcdir)/Parser/Python.asdl
306-
307- ASDLGEN_FILES= $(srcdir)/Parser/asdl.py $(srcdir)/Parser/asdl_c.py
308- # XXX Note that a build now requires Python exist before the build starts
309- ASDLGEN= $(srcdir)/Parser/asdl_c.py
310-
311- ##########################################################################
312- # Python
313-
314- OPCODETARGETS_H= \
315- $(srcdir)/Python/opcode_targets.h
316-
317- OPCODETARGETGEN= \
318- $(srcdir)/Python/makeopcodetargets.py
319-
320- OPCODETARGETGEN_FILES= \
321- $(OPCODETARGETGEN) $(srcdir)/Lib/opcode.py
322-
323296PYTHON_OBJS= \
324297 Python/_warnings.o \
325298 Python/Python-ast.o \
@@ -493,9 +466,8 @@ coverage-lcov:
493466 @echo "lcov report at $(COVERAGE_REPORT)/index.html"
494467 @echo
495468
496- coverage-report:
497- : # force rebuilding of parser
498- @touch $(GRAMMAR_INPUT)
469+ # Force regeneration of parser
470+ coverage-report: regen-grammar
499471 : # build with coverage info
500472 $(MAKE) coverage
501473 : # run tests, ignore failures
@@ -644,6 +616,12 @@ Modules/Setup: $(srcdir)/Modules/Setup.dist
644616 echo "-----------------------------------------------"; \
645617 fi
646618
619+
620+ ############################################################################
621+ # Regenerate all generated files
622+
623+ regen-all: regen-opcode-targets regen-grammar regen-ast
624+
647625############################################################################
648626# Special rules for object files
649627
@@ -677,15 +655,18 @@ Modules/grpmodule.o: $(srcdir)/Modules/grpmodule.c $(srcdir)/Modules/posixmodule
677655
678656Modules/pwdmodule.o: $(srcdir)/Modules/pwdmodule.c $(srcdir)/Modules/posixmodule.h
679657
680- $(GRAMMAR_H): @GENERATED_COMMENT@ $(GRAMMAR_INPUT) $(PGEN)
681- @$(MKDIR_P) Include
682- $(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
683- $(GRAMMAR_C): @GENERATED_COMMENT@ $(GRAMMAR_H)
684- touch $(GRAMMAR_C)
685-
686658$(PGEN): $(PGENOBJS)
687659 $(CC) $(OPT) $(LDFLAGS) $(PGENOBJS) $(LIBS) -o $(PGEN)
688660
661+ .PHONY: regen-grammar
662+ regen-grammar: $(PGEN)
663+ # Regenerate Include/graminit.h and Python/graminit.c
664+ # from Grammar/Grammar using pgen
665+ @$(MKDIR_P) Include
666+ $(PGEN) $(srcdir)/Grammar/Grammar \
667+ $(srcdir)/Include/graminit.h \
668+ $(srcdir)/Python/graminit.c
669+
689670Parser/grammar.o: $(srcdir)/Parser/grammar.c \
690671 $(srcdir)/Include/token.h \
691672 $(srcdir)/Include/grammar.h
@@ -695,15 +676,20 @@ Parser/tokenizer_pgen.o: $(srcdir)/Parser/tokenizer.c
695676
696677Parser/pgenmain.o: $(srcdir)/Include/parsetok.h
697678
698- $(AST_H): $(AST_ASDL) $(ASDLGEN_FILES)
699- $(MKDIR_P) $(AST_H_DIR)
700- $(ASDLGEN) -h $(AST_H_DIR) $(AST_ASDL)
701-
702- $(AST_C): $(AST_ASDL) $(ASDLGEN_FILES)
703- $(MKDIR_P) $(AST_C_DIR)
704- $(ASDLGEN) -c $(AST_C_DIR) $(AST_ASDL)
705-
706- Python/compile.o Python/symtable.o Python/ast.o: $(GRAMMAR_H) $(AST_H)
679+ .PHONY=regen-ast
680+ regen-ast:
681+ # Regenerate Include/Python-ast.h using Parser/asdl_c.py -h
682+ $(MKDIR_P) $(srcdir)/Include
683+ $(PYTHON_FOR_REGEN) $(srcdir)/Parser/asdl_c.py \
684+ -h $(srcdir)/Include \
685+ $(srcdir)/Parser/Python.asdl
686+ # Regenerate Python/Python-ast.c using Parser/asdl_c.py -c
687+ $(MKDIR_P) $(srcdir)/Python
688+ $(PYTHON_FOR_REGEN) $(srcdir)/Parser/asdl_c.py \
689+ -c $(srcdir)/Python \
690+ $(srcdir)/Parser/Python.asdl
691+
692+ Python/compile.o Python/symtable.o Python/ast.o: $(srcdir)/Include/graminit.h $(srcdir)/Include/Python-ast.h
707693
708694Python/getplatform.o: $(srcdir)/Python/getplatform.c
709695 $(CC) -c $(PY_CFLAGS) -DPLATFORM='"$(MACHDEP)"' -o $@ $(srcdir)/Python/getplatform.c
@@ -738,10 +724,14 @@ Objects/bytearrayobject.o: $(srcdir)/Objects/bytearrayobject.c \
738724Objects/stringobject.o: $(srcdir)/Objects/stringobject.c \
739725 $(STRINGLIB_HEADERS)
740726
741- $(OPCODETARGETS_H): $(OPCODETARGETGEN_FILES)
742- $(OPCODETARGETGEN) $(OPCODETARGETS_H)
727+ .PHONY: regen-opcode-targets
728+ regen-opcode-targets:
729+ # Regenerate Python/opcode_targets.h from Lib/opcode.py
730+ # using Python/makeopcodetargets.py
731+ $(PYTHON_FOR_REGEN) $(srcdir)/Python/makeopcodetargets.py \
732+ $(srcdir)/Python/opcode_targets.h
743733
744- Python/ceval.o: $(OPCODETARGETS_H)
734+ Python/ceval.o: $(srcdir)/Python/opcode_targets.h
745735
746736Python/formatter_unicode.o: $(srcdir)/Python/formatter_unicode.c \
747737 $(STRINGLIB_HEADERS)
@@ -836,7 +826,7 @@ PYTHON_HEADERS= \
836826 Include/weakrefobject.h \
837827 pyconfig.h \
838828 $(PARSER_HEADERS) \
839- $(AST_H)
829+ $(srcdir)/Include/Python-ast.h
840830
841831$(LIBRARY_OBJS) $(MODOBJS) Modules/python.o: $(PYTHON_HEADERS)
842832
@@ -1356,9 +1346,12 @@ recheck:
13561346 $(SHELL) config.status --recheck
13571347 $(SHELL) config.status
13581348
1359- # Rebuild the configure script from configure.ac; also rebuild pyconfig.h.in
1349+ # Regenerate configure and pyconfig.h.in
1350+ .PHONY: autoconf
13601351autoconf:
1352+ # Regenerate the configure script from configure.ac using autoconf
13611353 (cd $(srcdir); autoconf)
1354+ # Regenerate pyconfig.h.in from configure.ac using autoheader
13621355 (cd $(srcdir); autoheader)
13631356
13641357# Create a tags file for vi
@@ -1375,11 +1368,6 @@ TAGS::
13751368 etags Include/*.h; \
13761369 for i in $(SRCDIRS); do etags -a $$i/*.[ch]; done
13771370
1378- # Touch generated files
1379- touch:
1380- cd $(srcdir); \
1381- touch Include/Python-ast.h Python/Python-ast.c
1382-
13831371# Sanitation targets -- clean leaves libraries, executables and tags
13841372# files, which clobber removes as well
13851373pycremoval:
@@ -1476,8 +1464,8 @@ Python/thread.o: @THREADHEADERS@
14761464.PHONY: maninstall libinstall inclinstall libainstall sharedinstall
14771465.PHONY: frameworkinstall frameworkinstallframework frameworkinstallstructure
14781466.PHONY: frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools
1479- .PHONY: frameworkaltinstallunixtools recheck autoconf clean clobber distclean
1480- .PHONY: smelly funny patchcheck touch altmaninstall commoninstall
1467+ .PHONY: frameworkaltinstallunixtools recheck clean clobber distclean
1468+ .PHONY: smelly funny patchcheck altmaninstall commoninstall
14811469.PHONY: gdbhooks
14821470
14831471# IF YOU PUT ANYTHING HERE IT WILL GO AWAY
0 commit comments