@@ -229,7 +229,7 @@ LIBOBJS= @LIBOBJS@
229229PYTHON= python$(EXE)
230230BUILDPYTHON= python$(BUILDEXE)
231231
232- PYTHON_FOR_GEN=@PYTHON_FOR_GEN @
232+ PYTHON_FOR_REGEN=@PYTHON_FOR_REGEN @
233233PYTHON_FOR_BUILD=@PYTHON_FOR_BUILD@
234234_PYTHON_HOST_PLATFORM=@_PYTHON_HOST_PLATFORM@
235235BUILD_GNU_TYPE= @build@
@@ -273,11 +273,6 @@ IO_OBJS= \
273273 Modules/_io/stringio.o
274274
275275##########################################################################
276- # Grammar
277- GRAMMAR_H= Include/graminit.h
278- GRAMMAR_C= Python/graminit.c
279- GRAMMAR_INPUT= $(srcdir)/Grammar/Grammar
280-
281276
282277LIBFFI_INCLUDEDIR= @LIBFFI_INCLUDEDIR@
283278
@@ -316,38 +311,9 @@ PARSER_HEADERS= \
316311
317312PGENOBJS= $(POBJS) $(PGOBJS)
318313
319- ##########################################################################
320- # opcode.h generation
321- OPCODE_H_DIR= $(srcdir)/Include
322- OPCODE_H_SCRIPT= $(srcdir)/Tools/scripts/generate_opcode_h.py
323- OPCODE_H= $(OPCODE_H_DIR)/opcode.h
324- OPCODE_H_GEN= $(PYTHON_FOR_GEN) $(OPCODE_H_SCRIPT) $(srcdir)/Lib/opcode.py $(OPCODE_H)
325-
326- ##########################################################################
327- # AST
328- AST_H_DIR= Include
329- AST_H= $(AST_H_DIR)/Python-ast.h
330- AST_C_DIR= Python
331- AST_C= $(AST_C_DIR)/Python-ast.c
332- AST_ASDL= $(srcdir)/Parser/Python.asdl
333-
334- ASDLGEN_FILES= $(srcdir)/Parser/asdl.py $(srcdir)/Parser/asdl_c.py
335- # Note that a build now requires Python to exist before the build starts.
336- # Use "hg touch" to fix up screwed up file mtimes in a checkout.
337- ASDLGEN= $(PYTHON_FOR_GEN) $(srcdir)/Parser/asdl_c.py
338-
339314##########################################################################
340315# Python
341316
342- OPCODETARGETS_H= \
343- Python/opcode_targets.h
344-
345- OPCODETARGETGEN= \
346- $(srcdir)/Python/makeopcodetargets.py
347-
348- OPCODETARGETGEN_FILES= \
349- $(OPCODETARGETGEN) $(srcdir)/Lib/opcode.py
350-
351317PYTHON_OBJS= \
352318 Python/_warnings.o \
353319 Python/Python-ast.o \
@@ -547,7 +513,8 @@ coverage-lcov:
547513 @echo "lcov report at $(COVERAGE_REPORT)/index.html"
548514 @echo
549515
550- coverage-report:
516+ # Force regeneration of parser and importlib
517+ coverage-report: regen-grammar regen-importlib
551518 : # force rebuilding of parser and importlib
552519 @touch $(GRAMMAR_INPUT)
553520 @touch $(srcdir)/Lib/importlib/_bootstrap.py
@@ -723,14 +690,24 @@ Programs/_freeze_importlib.o: Programs/_freeze_importlib.c Makefile
723690Programs/_freeze_importlib: Programs/_freeze_importlib.o $(LIBRARY_OBJS_OMIT_FROZEN)
724691 $(LINKCC) $(PY_LDFLAGS) -o $@ Programs/_freeze_importlib.o $(LIBRARY_OBJS_OMIT_FROZEN) $(LIBS) $(MODLIBS) $(SYSLIBS) $(LDLAST)
725692
726- Python/importlib_external.h: @GENERATED_COMMENT@ $(srcdir)/Lib/importlib/_bootstrap_external.py Programs/_freeze_importlib Python/marshal.c
693+ .PHONY: regen-importlib
694+ regen-importlib: Programs/_freeze_importlib
695+ # Regenerate Python/importlib_external.h
696+ # from Lib/importlib/_bootstrap_external.py using _freeze_importlib
727697 ./Programs/_freeze_importlib \
728- $(srcdir)/Lib/importlib/_bootstrap_external.py Python/importlib_external.h
729-
730- Python/importlib.h: @GENERATED_COMMENT@ $(srcdir)/Lib/importlib/_bootstrap.py Programs/_freeze_importlib Python/marshal.c
698+ $(srcdir)/Lib/importlib/_bootstrap_external.py \
699+ $(srcdir)/Python/importlib_external.h
700+ # Regenerate Python/importlib.h from Lib/importlib/_bootstrap.py
701+ # using _freeze_importlib
731702 ./Programs/_freeze_importlib \
732- $(srcdir)/Lib/importlib/_bootstrap.py Python/importlib.h
703+ $(srcdir)/Lib/importlib/_bootstrap.py \
704+ $(srcdir)/Python/importlib.h
705+
706+
707+ ############################################################################
708+ # Regenerate all generated files
733709
710+ regen-all: regen-opcode regen-opcode-targets regen-typeslots regen-grammar regen-ast regen-importlib
734711
735712############################################################################
736713# Special rules for object files
@@ -789,15 +766,18 @@ Python/sysmodule.o: $(srcdir)/Python/sysmodule.c Makefile
789766
790767$(IO_OBJS): $(IO_H)
791768
792- $(GRAMMAR_H): @GENERATED_COMMENT@ $(GRAMMAR_INPUT) $(PGEN)
793- @$(MKDIR_P) Include
794- $(PGEN) $(GRAMMAR_INPUT) $(GRAMMAR_H) $(GRAMMAR_C)
795- $(GRAMMAR_C): @GENERATED_COMMENT@ $(GRAMMAR_H)
796- touch $(GRAMMAR_C)
797-
798769$(PGEN): $(PGENOBJS)
799770 $(CC) $(OPT) $(PY_LDFLAGS) $(PGENOBJS) $(LIBS) -o $(PGEN)
800771
772+ .PHONY: regen-grammar
773+ regen-grammar: $(PGEN)
774+ # Regenerate Include/graminit.h and Python/graminit.c
775+ # from Grammar/Grammar using pgen
776+ @$(MKDIR_P) Include
777+ $(PGEN) $(srcdir)/Grammar/Grammar \
778+ $(srcdir)/Include/graminit.h \
779+ $(srcdir)/Python/graminit.c
780+
801781Parser/grammar.o: $(srcdir)/Parser/grammar.c \
802782 $(srcdir)/Include/token.h \
803783 $(srcdir)/Include/grammar.h
@@ -809,18 +789,28 @@ Parser/printgrammar.o: $(srcdir)/Parser/printgrammar.c
809789
810790Parser/pgenmain.o: $(srcdir)/Include/parsetok.h
811791
812- $(AST_H): $(AST_ASDL) $(ASDLGEN_FILES)
813- $(MKDIR_P) $(AST_H_DIR)
814- $(ASDLGEN) -h $(AST_H_DIR) $(AST_ASDL)
815-
816- $(AST_C): $(AST_H) $(AST_ASDL) $(ASDLGEN_FILES)
817- $(MKDIR_P) $(AST_C_DIR)
818- $(ASDLGEN) -c $(AST_C_DIR) $(AST_ASDL)
819-
820- $(OPCODE_H): $(srcdir)/Lib/opcode.py $(OPCODE_H_SCRIPT)
821- $(OPCODE_H_GEN)
822-
823- Python/compile.o Python/symtable.o Python/ast.o: $(GRAMMAR_H) $(AST_H)
792+ .PHONY=regen-ast
793+ regen-ast:
794+ # Regenerate Include/Python-ast.h using Parser/asdl_c.py -h
795+ $(MKDIR_P) $(srcdir)/Include
796+ $(PYTHON_FOR_REGEN) $(srcdir)/Parser/asdl_c.py \
797+ -h $(srcdir)/Include \
798+ $(srcdir)/Parser/Python.asdl
799+ # Regenerate Python/Python-ast.c using Parser/asdl_c.py -c
800+ $(MKDIR_P) $(srcdir)/Python
801+ $(PYTHON_FOR_REGEN) $(srcdir)/Parser/asdl_c.py \
802+ -c $(srcdir)/Python \
803+ $(srcdir)/Parser/Python.asdl
804+
805+ .PHONY: regen-opcode
806+ regen-opcode:
807+ # Regenerate Include/opcode.h from Lib/opcode.py
808+ # using Tools/scripts/generate_opcode_h.py
809+ $(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_opcode_h.py \
810+ $(srcdir)/Lib/opcode.py \
811+ $(srcdir)/Include/opcode.h
812+
813+ Python/compile.o Python/symtable.o Python/ast.o: $(srcdir)/Include/graminit.h $(srcdir)/Include/Python-ast.h
824814
825815Python/getplatform.o: $(srcdir)/Python/getplatform.c
826816 $(CC) -c $(PY_CORE_CFLAGS) -DPLATFORM='"$(MACHDEP)"' -o $@ $(srcdir)/Python/getplatform.c
@@ -870,12 +860,16 @@ Objects/odictobject.o: $(srcdir)/Objects/dict-common.h
870860Objects/dictobject.o: $(srcdir)/Objects/stringlib/eq.h $(srcdir)/Objects/dict-common.h
871861Objects/setobject.o: $(srcdir)/Objects/stringlib/eq.h
872862
873- $(OPCODETARGETS_H): $(OPCODETARGETGEN_FILES)
874- $(PYTHON_FOR_GEN) $(OPCODETARGETGEN) $(OPCODETARGETS_H)
863+ .PHONY: regen-opcode-targets
864+ regen-opcode-targets:
865+ # Regenerate Python/opcode_targets.h from Lib/opcode.py
866+ # using Python/makeopcodetargets.py
867+ $(PYTHON_FOR_REGEN) $(srcdir)/Python/makeopcodetargets.py \
868+ $(srcdir)/Python/opcode_targets.h
875869
876- Python/ceval.o: $(OPCODETARGETS_H) $(srcdir)/Python/ceval_gil.h
870+ Python/ceval.o: $(srcdir)/Python/opcode_targets.h $(srcdir)/Python/ceval_gil.h
877871
878- Python/frozen.o: Python/importlib.h Python/importlib_external.h
872+ Python/frozen.o: $(srcdir)/ Python/importlib.h $(srcdir)/ Python/importlib_external.h
879873
880874# Generate DTrace probe macros, then rename them (PYTHON_ -> PyDTrace_) to
881875# follow our naming conventions. dtrace(1) uses the output filename to generate
@@ -890,8 +884,14 @@ Python/pydtrace.o: $(srcdir)/Include/pydtrace.d $(DTRACE_DEPS)
890884 $(DTRACE) $(DFLAGS) -o $@ -G -s $< $(DTRACE_DEPS)
891885
892886Objects/typeobject.o: Objects/typeslots.inc
893- Objects/typeslots.inc: $(srcdir)/Include/typeslots.h $(srcdir)/Objects/typeslots.py
894- $(PYTHON_FOR_GEN) $(srcdir)/Objects/typeslots.py < $(srcdir)/Include/typeslots.h Objects/typeslots.inc
887+
888+ .PHONY: regen-typeslots
889+ regen-typeslots:
890+ # Regenerate Objects/typeslots.inc from Include/typeslotsh
891+ # using Objects/typeslots.py
892+ $(PYTHON_FOR_REGEN) $(srcdir)/Objects/typeslots.py \
893+ < $(srcdir)/Include/typeslots.h \
894+ $(srcdir)/Objects/typeslots.inc
895895
896896############################################################################
897897# Header files
@@ -944,7 +944,7 @@ PYTHON_HEADERS= \
944944 $(srcdir)/Include/node.h \
945945 $(srcdir)/Include/object.h \
946946 $(srcdir)/Include/objimpl.h \
947- $(OPCODE_H) \
947+ $(srcdir)/Include/opcode.h \
948948 $(srcdir)/Include/osdefs.h \
949949 $(srcdir)/Include/osmodule.h \
950950 $(srcdir)/Include/patchlevel.h \
@@ -987,7 +987,7 @@ PYTHON_HEADERS= \
987987 $(srcdir)/Include/weakrefobject.h \
988988 pyconfig.h \
989989 $(PARSER_HEADERS) \
990- $(AST_H) \
990+ $(srcdir)/Include/Python-ast.h \
991991 $(DTRACE_HEADERS)
992992
993993$(LIBRARY_OBJS) $(MODOBJS) Programs/python.o: $(PYTHON_HEADERS)
@@ -1554,9 +1554,12 @@ recheck:
15541554 $(SHELL) config.status --recheck
15551555 $(SHELL) config.status
15561556
1557- # Rebuild the configure script from configure.ac; also rebuild pyconfig.h.in
1557+ # Regenerate configure and pyconfig.h.in
1558+ .PHONY: autoconf
15581559autoconf:
1560+ # Regenerate the configure script from configure.ac using autoconf
15591561 (cd $(srcdir); autoconf -Wall)
1562+ # Regenerate pyconfig.h.in from configure.ac using autoheader
15601563 (cd $(srcdir); autoheader -Wall)
15611564
15621565# Create a tags file for vi
@@ -1573,14 +1576,6 @@ TAGS::
15731576 etags Include/*.h; \
15741577 for i in $(SRCDIRS); do etags -a $$i/*.[ch]; done
15751578
1576- # This fixes up the mtimes of checked-in generated files, assuming that they
1577- # only *appear* to be outdated because of checkout order.
1578- # This is run while preparing a source release tarball, and can be run manually
1579- # to avoid bootstrap issues.
1580- touch:
1581- cd $(srcdir); \
1582- hg --config extensions.touch=Tools/hg/hgtouch.py touch -v
1583-
15841579# Sanitation targets -- clean leaves libraries, executables and tags
15851580# files, which clobber removes as well
15861581pycremoval:
@@ -1698,7 +1693,7 @@ Python/thread.o: @THREADHEADERS@
16981693.PHONY: maninstall libinstall inclinstall libainstall sharedinstall
16991694.PHONY: frameworkinstall frameworkinstallframework frameworkinstallstructure
17001695.PHONY: frameworkinstallmaclib frameworkinstallapps frameworkinstallunixtools
1701- .PHONY: frameworkaltinstallunixtools recheck autoconf clean clobber distclean
1696+ .PHONY: frameworkaltinstallunixtools recheck clean clobber distclean
17021697.PHONY: smelly funny patchcheck touch altmaninstall commoninstall
17031698.PHONY: gdbhooks
17041699
0 commit comments