@@ -230,6 +230,7 @@ PYTHON= python$(EXE)
230230BUILDPYTHON= python$(BUILDEXE)
231231
232232PYTHON_FOR_REGEN=@PYTHON_FOR_REGEN@
233+ UPDATE_FILE=@PYTHON_FOR_REGEN@ $(srcdir)/Tools/scripts/update_file.py
233234PYTHON_FOR_BUILD=@PYTHON_FOR_BUILD@
234235_PYTHON_HOST_PLATFORM=@_PYTHON_HOST_PLATFORM@
235236BUILD_GNU_TYPE= @build@
@@ -691,12 +692,14 @@ regen-importlib: Programs/_freeze_importlib
691692 # from Lib/importlib/_bootstrap_external.py using _freeze_importlib
692693 ./Programs/_freeze_importlib \
693694 $(srcdir)/Lib/importlib/_bootstrap_external.py \
694- $(srcdir)/Python/importlib_external.h
695+ $(srcdir)/Python/importlib_external.h.new
696+ $(UPDATE_FILE) $(srcdir)/Python/importlib_external.h $(srcdir)/Python/importlib_external.h.new
695697 # Regenerate Python/importlib.h from Lib/importlib/_bootstrap.py
696698 # using _freeze_importlib
697699 ./Programs/_freeze_importlib \
698700 $(srcdir)/Lib/importlib/_bootstrap.py \
699- $(srcdir)/Python/importlib.h
701+ $(srcdir)/Python/importlib.h.new
702+ $(UPDATE_FILE) $(srcdir)/Python/importlib.h $(srcdir)/Python/importlib.h.new
700703
701704
702705############################################################################
@@ -770,8 +773,10 @@ regen-grammar: $(PGEN)
770773 # from Grammar/Grammar using pgen
771774 @$(MKDIR_P) Include
772775 $(PGEN) $(srcdir)/Grammar/Grammar \
773- $(srcdir)/Include/graminit.h \
774- $(srcdir)/Python/graminit.c
776+ $(srcdir)/Include/graminit.h.new \
777+ $(srcdir)/Python/graminit.c.new
778+ $(UPDATE_FILE) $(srcdir)/Include/graminit.h $(srcdir)/Include/graminit.h.new
779+ $(UPDATE_FILE) $(srcdir)/Python/graminit.c $(srcdir)/Python/graminit.c.new
775780
776781Parser/grammar.o: $(srcdir)/Parser/grammar.c \
777782 $(srcdir)/Include/token.h \
@@ -789,21 +794,24 @@ regen-ast:
789794 # Regenerate Include/Python-ast.h using Parser/asdl_c.py -h
790795 $(MKDIR_P) $(srcdir)/Include
791796 $(PYTHON_FOR_REGEN) $(srcdir)/Parser/asdl_c.py \
792- -h $(srcdir)/Include \
797+ -h $(srcdir)/Include/Python-ast.h.new \
793798 $(srcdir)/Parser/Python.asdl
799+ $(UPDATE_FILE) $(srcdir)/Include/Python-ast.h $(srcdir)/Include/Python-ast.h.new
794800 # Regenerate Python/Python-ast.c using Parser/asdl_c.py -c
795801 $(MKDIR_P) $(srcdir)/Python
796802 $(PYTHON_FOR_REGEN) $(srcdir)/Parser/asdl_c.py \
797- -c $(srcdir)/Python \
803+ -c $(srcdir)/Python/Python-ast.c.new \
798804 $(srcdir)/Parser/Python.asdl
805+ $(UPDATE_FILE) $(srcdir)/Python/Python-ast.c $(srcdir)/Python/Python-ast.c.new
799806
800807.PHONY: regen-opcode
801808regen-opcode:
802809 # Regenerate Include/opcode.h from Lib/opcode.py
803810 # using Tools/scripts/generate_opcode_h.py
804811 $(PYTHON_FOR_REGEN) $(srcdir)/Tools/scripts/generate_opcode_h.py \
805812 $(srcdir)/Lib/opcode.py \
806- $(srcdir)/Include/opcode.h
813+ $(srcdir)/Include/opcode.h.new
814+ $(UPDATE_FILE) $(srcdir)/Include/opcode.h $(srcdir)/Include/opcode.h.new
807815
808816Python/compile.o Python/symtable.o Python/ast.o: $(srcdir)/Include/graminit.h $(srcdir)/Include/Python-ast.h
809817
@@ -860,7 +868,8 @@ regen-opcode-targets:
860868 # Regenerate Python/opcode_targets.h from Lib/opcode.py
861869 # using Python/makeopcodetargets.py
862870 $(PYTHON_FOR_REGEN) $(srcdir)/Python/makeopcodetargets.py \
863- $(srcdir)/Python/opcode_targets.h
871+ $(srcdir)/Python/opcode_targets.h.new
872+ $(UPDATE_FILE) $(srcdir)/Python/opcode_targets.h $(srcdir)/Python/opcode_targets.h.new
864873
865874Python/ceval.o: $(srcdir)/Python/opcode_targets.h $(srcdir)/Python/ceval_gil.h
866875
@@ -887,7 +896,8 @@ regen-typeslots:
887896 # using Objects/typeslots.py
888897 $(PYTHON_FOR_REGEN) $(srcdir)/Objects/typeslots.py \
889898 < $(srcdir)/Include/typeslots.h \
890- $(srcdir)/Objects/typeslots.inc
899+ $(srcdir)/Objects/typeslots.inc.new
900+ $(UPDATE_FILE) $(srcdir)/Objects/typeslots.inc $(srcdir)/Objects/typeslots.inc.new
891901
892902############################################################################
893903# Header files
0 commit comments