Guido van Rossum | 00ff433 | 1994-10-03 16:33:08 +0000 | [diff] [blame] | 1 | # Write the actual Makefile. |
| 2 | |
| 3 | import os |
| 4 | import string |
| 5 | |
| 6 | def makemakefile(outfp, makevars, files, target): |
| 7 | outfp.write("# Makefile generated by freeze.py script\n\n") |
| 8 | |
| 9 | keys = makevars.keys() |
| 10 | keys.sort() |
| 11 | for key in keys: |
| 12 | outfp.write("%s=%s\n" % (key, makevars[key])) |
| 13 | outfp.write("\nall: %s\n" % target) |
| 14 | |
| 15 | deps = [] |
| 16 | for i in range(len(files)): |
| 17 | file = files[i] |
| 18 | if file[-2:] == '.c': |
| 19 | base = os.path.basename(file) |
| 20 | dest = base[:-2] + '.o' |
| 21 | outfp.write("%s: %s\n" % (dest, file)) |
| 22 | outfp.write("\t$(CC) $(CFLAGS) -c %s\n" % file) |
| 23 | files[i] = dest |
| 24 | deps.append(dest) |
| 25 | |
| 26 | outfp.write("\n%s: %s\n" % (target, string.join(deps))) |
| 27 | outfp.write("\t$(CC) %s -o %s\n" % (string.join(files), target)) |