@@ -224,7 +224,7 @@ LIBOBJS= @LIBOBJS@
224224PYTHON= python$(EXE)
225225BUILDPYTHON= python$(BUILDEXE)
226226
227- PYTHON_FOR_GEN=@PYTHON_FOR_GEN @
227+ PYTHON_FOR_REGEN=@PYTHON_FOR_REGEN @
228228PYTHON_FOR_BUILD=@PYTHON_FOR_BUILD@
229229_PYTHON_HOST_PLATFORM=@_PYTHON_HOST_PLATFORM@
230230BUILD_GNU_TYPE= @build@
@@ -271,11 +271,6 @@ IO_OBJS= \
271271 Modules/_io/stringio.o
272272
273273##########################################################################
274- # Grammar
275- GRAMMAR_H= Include/graminit.h
276- GRAMMAR_C= Python/graminit.c
277- GRAMMAR_INPUT= $(srcdir)/Grammar/Grammar
278-
279274
280275LIBFFI_INCLUDEDIR= @LIBFFI_INCLUDEDIR@
281276
@@ -337,38 +332,9 @@ PARSER_HEADERS= \
337332PGENSRCS= $(PSRCS) $(PGSRCS)
338333PGENOBJS= $(POBJS) $(PGOBJS)
339334
340- ##########################################################################
341- # opcode.h generation
342- OPCODE_H_DIR= $(srcdir)/Include
343- OPCODE_H_SCRIPT= $(srcdir)/Tools/scripts/generate_opcode_h.py
344- OPCODE_H= $(OPCODE_H_DIR)/opcode.h
345- OPCODE_H_GEN= $(PYTHON_FOR_GEN) $(OPCODE_H_SCRIPT) $(srcdir)/Lib/opcode.py $(OPCODE_H)
346- #
347- ##########################################################################
348- # AST
349- AST_H_DIR= Include
350- AST_H= $(AST_H_DIR)/Python-ast.h
351- AST_C_DIR= Python
352- AST_C= $(AST_C_DIR)/Python-ast.c
353- AST_ASDL= $(srcdir)/Parser/Python.asdl
354-
355- ASDLGEN_FILES= $(srcdir)/Parser/asdl.py $(srcdir)/Parser/asdl_c.py
356- # Note that a build now requires Python to exist before the build starts.
357- # Use "hg touch" to fix up screwed up file mtimes in a checkout.
358- ASDLGEN= $(PYTHON_FOR_GEN) $(srcdir)/Parser/asdl_c.py
359-
360335##########################################################################
361336# Python
362337
363- OPCODETARGETS_H= \
364- Python/opcode_targets.h
365-
366- OPCODETARGETGEN= \
367- $(srcdir)/Python/makeopcodetargets.py
368-
369- OPCODETARGETGEN_FILES= \
370- $(OPCODETARGETGEN) $(srcdir)/Lib/opcode.py
371-
372338PYTHON_OBJS= \
373339 Python/_warnings.o \
374340 Python/Python-ast.o \
@@ -551,7 +517,8 @@ coverage-lcov:
551517 @echo "lcov report at $(COVERAGE_REPORT)/index.html"
552518 @echo
553519
554- coverage-report:
520+ # Force regeneration of parser and importlib
521+ coverage-report: regen-grammar regen-importlib
555522 : # force rebuilding of parser and importlib
556523 @touch $(GRAMMAR_INPUT)
557524 @touch $(srcdir)/Lib/importlib/_bootstrap.py
@@ -721,14 +688,24 @@ Programs/_freeze_importlib.o: Programs/_freeze_importlib.c Makefile
721688Programs/_freeze_importlib: Programs/_freeze_importlib.o $(LIBRARY_OBJS_OMIT_FROZEN)
722689 $(LINKCC) $(PY_LDFLAGS) -o $@ Programs/_freeze_importlib.o $(LIBRARY_OBJS_OMIT_FROZEN) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)
723690
724- Python/importlib_external.h: @GENERATED_COMMENT@ $(srcdir)/Lib/importlib/_bootstrap_external.py Programs/_freeze_importlib
691+ .PHONY: regen-importlib
692+ regen-importlib: Programs/_freeze_importlib
693+ # Regenerate Python/importlib_external.h
694+ # from Lib/importlib/_bootstrap_external.py using _freeze_importlib
725695 ./Programs/_freeze_importlib \
726- $(srcdir)/Lib/importlib/_bootstrap_external.py Python/importlib_external.h
727-
728- Python/importlib.h: @GENERATED_COMMENT@ $(srcdir)/Lib/importlib/_bootstrap.py Programs/_freeze_importlib
696+ $(srcdir)/Lib/importlib/_bootstrap_external.py \
697+ $(srcdir)/Python/importlib_external.h
698+ # Regenerate Python/importlib.h from Lib/importlib/_bootstrap.py
699+ # using _freeze_importlib
729700 ./Programs/_freeze_importlib \
730- $(srcdir)/Lib/importlib/_bootstrap.py Python/importlib.h
701+ $(srcdir)/Lib/importlib/_bootstrap.py \
702+ $(srcdir)/Python/importlib.h
703+
704+
705+ ############################################################################
706+ # Regenerate all generated files
731707
708+ regen-all: regen-opcode regen-opcode-targets regen-typeslots regen-grammar regen-ast regen-importlib
732709
733710############################################################################
734711# Special rules for object files
@@ -787,15 +764,18 @@ Python/sysmodule.o: $(srcdir)/Python/sysmodule.c Makefile
787764
788765$(IO_OBJS): $(IO_H)
789766
790- $(GRAMMAR_H): @GENERATED_COMMENT@ $(GRAMMAR_INPUT) $(PGEN)
791- @$(MKDIR_P) Include
792- $(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
793- $(GRAMMAR_C): @GENERATED_COMMENT@ $(GRAMMAR_H)
794- touch $(GRAMMAR_C)
795-
796767$(PGEN): $(PGENOBJS)
797768 $(CC) $(OPT) $(PY_LDFLAGS) $(PGENOBJS) $(LIBS) -o $(PGEN)
798769
770+ .PHONY: regen-grammar
771+ regen-grammar: $(PGEN)
772+ # Regenerate Include/graminit.h and Python/graminit.c
773+ # from Grammar/Grammar using pgen
774+ @$(MKDIR_P) Include
775+ $(PGEN) $(srcdir)/Grammar/Grammar \
776+ $(srcdir)/Include/graminit.h \
777+ $(srcdir)/Python/graminit.c
778+
799779Parser/grammar.o: $(srcdir)/Parser/grammar.c \
800780 $(srcdir)/Include/token.h \
801781 $(srcdir)/Include/grammar.h
@@ -807,18 +787,28 @@ Parser/printgrammar.o: $(srcdir)/Parser/printgrammar.c
807787
808788Parser/pgenmain.o: $(srcdir)/Include/parsetok.h
809789
810- $(AST_H): $(AST_ASDL) $(ASDLGEN_FILES)
811- $(MKDIR_P) $(AST_H_DIR)
812- $(ASDLGEN) -h $(AST_H_DIR) $(AST_ASDL)
813-
814- $(AST_C): $(AST_H) $(AST_ASDL) $(ASDLGEN_FILES)
815- $(MKDIR_P) $(AST_C_DIR)
816- $(ASDLGEN) -c $(AST_C_DIR) $(AST_ASDL)
817-
818- $(OPCODE_H): $(srcdir)/Lib/opcode.py $(OPCODE_H_SCRIPT)
819- $(OPCODE_H_GEN)
820-
821- Python/compile.o Python/symtable.o Python/ast.o: $(GRAMMAR_H) $(AST_H)
790+ .PHONY=regen-ast
791+ regen-ast:
792+ # Regenerate Include/Python-ast.h using Parser/asdl_c.py -h
793+ $(MKDIR_P) $(srcdir)/Include
794+ $(PYTHON_FOR_REGEN) $(srcdir)/Parser/asdl_c.py \
795+ -h $(srcdir)/Include \
796+ $(srcdir)/Parser/Python.asdl
797+ # Regenerate Python/Python-ast.c using Parser/asdl_c.py -c
798+ $(MKDIR_P) $(srcdir)/Python
799+ $(PYTHON_FOR_REGEN) $(srcdir)/Parser/asdl_c.py \
800+ -c $(srcdir)/Python \
801+ $(srcdir)/Parser/Python.asdl
802+
803+ .PHONY: regen-opcode
804+ regen-opcode:
805+ # Regenerate Include/opcode.h from Lib/opcode.py
806+ # using Tools/scripts/generate_opcode_h.py
807+ $(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_opcode_h.py \
808+ $(srcdir)/Lib/opcode.py \
809+ $(srcdir)/Include/opcode.h
810+
811+ Python/compile.o Python/symtable.o Python/ast.o: $(srcdir)/Include/graminit.h $(srcdir)/Include/Python-ast.h
822812
823813Python/getplatform.o: $(srcdir)/Python/getplatform.c
824814 $(CC) -c $(PY_CORE_CFLAGS) -DPLATFORM='"$(MACHDEP)"' -o $@ $(srcdir)/Python/getplatform.c
@@ -867,16 +857,26 @@ Objects/unicodeobject.o: $(srcdir)/Objects/unicodeobject.c $(UNICODE_DEPS)
867857Objects/dictobject.o: $(srcdir)/Objects/stringlib/eq.h
868858Objects/setobject.o: $(srcdir)/Objects/stringlib/eq.h
869859
870- $(OPCODETARGETS_H): $(OPCODETARGETGEN_FILES)
871- $(PYTHON_FOR_GEN) $(OPCODETARGETGEN) $(OPCODETARGETS_H)
860+ .PHONY: regen-opcode-targets
861+ regen-opcode-targets:
862+ # Regenerate Python/opcode_targets.h from Lib/opcode.py
863+ # using Python/makeopcodetargets.py
864+ $(PYTHON_FOR_REGEN) $(srcdir)/Python/makeopcodetargets.py \
865+ $(srcdir)/Python/opcode_targets.h
872866
873- Python/ceval.o: $(OPCODETARGETS_H) $(srcdir)/Python/ceval_gil.h
867+ Python/ceval.o: $(srcdir)/Python/opcode_targets.h $(srcdir)/Python/ceval_gil.h
874868
875- Python/frozen.o: Python/importlib.h Python/importlib_external.h
869+ Python/frozen.o: $(srcdir)/ Python/importlib.h $(srcdir)/ Python/importlib_external.h
876870
877871Objects/typeobject.o: Objects/typeslots.inc
878- Objects/typeslots.inc: $(srcdir)/Include/typeslots.h $(srcdir)/Objects/typeslots.py
879- $(PYTHON_FOR_GEN) $(srcdir)/Objects/typeslots.py < $(srcdir)/Include/typeslots.h Objects/typeslots.inc
872+
873+ .PHONY: regen-typeslots
874+ regen-typeslots:
875+ # Regenerate Objects/typeslots.inc from Include/typeslotsh
876+ # using Objects/typeslots.py
877+ $(PYTHON_FOR_REGEN) $(srcdir)/Objects/typeslots.py \
878+ < $(srcdir)/Include/typeslots.h \
879+ $(srcdir)/Objects/typeslots.inc
880880
881881############################################################################
882882# Header files
@@ -929,7 +929,7 @@ PYTHON_HEADERS= \
929929 $(srcdir)/Include/node.h \
930930 $(srcdir)/Include/object.h \
931931 $(srcdir)/Include/objimpl.h \
932- $(OPCODE_H) \
932+ $(srcdir)/Include/opcode.h \
933933 $(srcdir)/Include/osdefs.h \
934934 $(srcdir)/Include/patchlevel.h \
935935 $(srcdir)/Include/pgen.h \
@@ -970,7 +970,7 @@ PYTHON_HEADERS= \
970970 $(srcdir)/Include/weakrefobject.h \
971971 pyconfig.h \
972972 $(PARSER_HEADERS) \
973- $(AST_H)
973+ $(srcdir)/Include/Python-ast.h
974974
975975$(LIBRARY_OBJS) $(MODOBJS) Programs/python.o: $(PYTHON_HEADERS)
976976
@@ -1551,9 +1551,12 @@ recheck:
15511551 $(SHELL) config.status --recheck
15521552 $(SHELL) config.status
15531553
1554- # Rebuild the configure script from configure.ac; also rebuild pyconfig.h.in
1554+ # Regenerate configure and pyconfig.h.in
1555+ .PHONY: autoconf
15551556autoconf:
1557+ # Regenerate the configure script from configure.ac using autoconf
15561558 (cd $(srcdir); autoconf -Wall)
1559+ # Regenerate pyconfig.h.in from configure.ac using autoheader
15571560 (cd $(srcdir); autoheader -Wall)
15581561
15591562# Create a tags file for vi
@@ -1570,14 +1573,6 @@ TAGS::
15701573 etags Include/*.h; \
15711574 for i in $(SRCDIRS); do etags -a $$i/*.[ch]; done
15721575
1573- # This fixes up the mtimes of checked-in generated files, assuming that they
1574- # only *appear* to be outdated because of checkout order.
1575- # This is run while preparing a source release tarball, and can be run manually
1576- # to avoid bootstrap issues.
1577- touch:
1578- cd $(srcdir); \
1579- hg --config extensions.touch=Tools/hg/hgtouch.py touch -v
1580-
15811576# Sanitation targets -- clean leaves libraries, executables and tags
15821577# files, which clobber removes as well
15831578pycremoval:
@@ -1695,7 +1690,7 @@ Python/thread.o: @THREADHEADERS@
16951690.PHONY: maninstall libinstall inclinstall libainstall sharedinstall
16961691.PHONY: frameworkinstall frameworkinstallframework frameworkinstallstructure
16971692.PHONY: frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools
1698- .PHONY: frameworkaltinstallunixtools recheck autoconf clean clobber distclean
1693+ .PHONY: frameworkaltinstallunixtools recheck clean clobber distclean
16991694.PHONY: smelly funny patchcheck touch altmaninstall commoninstall
17001695.PHONY: gdbhooks
17011696
0 commit comments