Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 6d67b60

Browse files
committed
backup Makefile too
1 parent 9a707e8 commit 6d67b60

1 file changed

Lines changed: 13 additions & 1 deletion

File tree

Tools/freeze/freeze.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
-p prefix: This is the prefix used when you ran
2020
'Make inclinstall libainstall' in the Python build directory.
2121
(If you never ran this, freeze won't work.)
22-
The default is /usr/local.
22+
The default is /usr/local.
2323
2424
-e extension: A directory containing additional .o files that
2525
may be used to resolve modules. This directory
@@ -227,11 +227,23 @@ def main():
227227
addfiles + libs + \
228228
['$(MODLIBS)', '$(LIBS)', '$(SYSLIBS)']
229229

230+
backup = makefile + '~'
231+
try:
232+
os.rename(makefile, backup)
233+
except os.error:
234+
backup = None
230235
outfp = open(makefile, 'w')
231236
try:
232237
makemakefile.makemakefile(outfp, somevars, files, target)
233238
finally:
234239
outfp.close()
240+
if backup:
241+
if not cmp.cmp(backup, makefile):
242+
print 'previous Makefile saved as', backup
243+
else:
244+
sys.stderr.write('%s not changed, not written\n' %
245+
makefile)
246+
os.rename(backup, makefile)
235247

236248
# Done!
237249

0 commit comments

Comments
 (0)