Guido van Rossum | 00ff433 | 1994-10-03 16:33:08 +0000 | [diff] [blame] | 1 | # Write the actual Makefile. |
| 2 | |
| 3 | import os |
Guido van Rossum | 00ff433 | 1994-10-03 16:33:08 +0000 | [diff] [blame] | 4 | |
| 5 | def makemakefile(outfp, makevars, files, target): |
Guido van Rossum | 541e783 | 1998-03-05 05:22:36 +0000 | [diff] [blame] | 6 | outfp.write("# Makefile generated by freeze.py script\n\n") |
Guido van Rossum | 00ff433 | 1994-10-03 16:33:08 +0000 | [diff] [blame] | 7 | |
Guido van Rossum | 541e783 | 1998-03-05 05:22:36 +0000 | [diff] [blame] | 8 | keys = makevars.keys() |
| 9 | keys.sort() |
| 10 | for key in keys: |
| 11 | outfp.write("%s=%s\n" % (key, makevars[key])) |
| 12 | outfp.write("\nall: %s\n\n" % target) |
Guido van Rossum | 00ff433 | 1994-10-03 16:33:08 +0000 | [diff] [blame] | 13 | |
Guido van Rossum | 541e783 | 1998-03-05 05:22:36 +0000 | [diff] [blame] | 14 | deps = [] |
| 15 | for i in range(len(files)): |
| 16 | file = files[i] |
| 17 | if file[-2:] == '.c': |
| 18 | base = os.path.basename(file) |
| 19 | dest = base[:-2] + '.o' |
| 20 | outfp.write("%s: %s\n" % (dest, file)) |
Neil Schemenauer | 89e90d6 | 2001-06-02 06:16:02 +0000 | [diff] [blame] | 21 | outfp.write("\t$(CC) $(CFLAGS) $(CPPFLAGS) -c %s\n" % file) |
Guido van Rossum | 541e783 | 1998-03-05 05:22:36 +0000 | [diff] [blame] | 22 | files[i] = dest |
| 23 | deps.append(dest) |
Guido van Rossum | 00ff433 | 1994-10-03 16:33:08 +0000 | [diff] [blame] | 24 | |
Walter Dörwald | aaab30e | 2002-09-11 20:36:02 +0000 | [diff] [blame] | 25 | outfp.write("\n%s: %s\n" % (target, ' '.join(deps))) |
Marc-André Lemburg | 64b4f27 | 2002-04-04 16:15:41 +0000 | [diff] [blame] | 26 | outfp.write("\t$(LINKCC) $(LDFLAGS) $(LINKFORSHARED) %s -o %s $(LDLAST)\n" % |
Walter Dörwald | aaab30e | 2002-09-11 20:36:02 +0000 | [diff] [blame] | 27 | (' '.join(files), target)) |
Guido van Rossum | 541e783 | 1998-03-05 05:22:36 +0000 | [diff] [blame] | 28 | |
| 29 | outfp.write("\nclean:\n\t-rm -f *.o %s\n" % target) |