blob: b8b99b8768454d7c994cfd7c3df7ed4ababfcca2 [file] [log] [blame]
Guido van Rossum00ff4331994-10-03 16:33:08 +00001# Write the actual Makefile.
2
3import os
Guido van Rossum00ff4331994-10-03 16:33:08 +00004
5def makemakefile(outfp, makevars, files, target):
Guido van Rossum541e7831998-03-05 05:22:36 +00006 outfp.write("# Makefile generated by freeze.py script\n\n")
Guido van Rossum00ff4331994-10-03 16:33:08 +00007
Guido van Rossum541e7831998-03-05 05:22:36 +00008 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 Rossum00ff4331994-10-03 16:33:08 +000013
Guido van Rossum541e7831998-03-05 05:22:36 +000014 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 Schemenauer89e90d62001-06-02 06:16:02 +000021 outfp.write("\t$(CC) $(CFLAGS) $(CPPFLAGS) -c %s\n" % file)
Guido van Rossum541e7831998-03-05 05:22:36 +000022 files[i] = dest
23 deps.append(dest)
Guido van Rossum00ff4331994-10-03 16:33:08 +000024
Walter Dörwaldaaab30e2002-09-11 20:36:02 +000025 outfp.write("\n%s: %s\n" % (target, ' '.join(deps)))
Marc-André Lemburg64b4f272002-04-04 16:15:41 +000026 outfp.write("\t$(LINKCC) $(LDFLAGS) $(LINKFORSHARED) %s -o %s $(LDLAST)\n" %
Walter Dörwaldaaab30e2002-09-11 20:36:02 +000027 (' '.join(files), target))
Guido van Rossum541e7831998-03-05 05:22:36 +000028
29 outfp.write("\nclean:\n\t-rm -f *.o %s\n" % target)