1 | n/a | # Write the actual Makefile. |
---|
2 | n/a | |
---|
3 | n/a | import os |
---|
4 | n/a | |
---|
5 | n/a | def makemakefile(outfp, makevars, files, target): |
---|
6 | n/a | outfp.write("# Makefile generated by freeze.py script\n\n") |
---|
7 | n/a | |
---|
8 | n/a | keys = sorted(makevars.keys()) |
---|
9 | n/a | for key in keys: |
---|
10 | n/a | outfp.write("%s=%s\n" % (key, makevars[key])) |
---|
11 | n/a | outfp.write("\nall: %s\n\n" % target) |
---|
12 | n/a | |
---|
13 | n/a | deps = [] |
---|
14 | n/a | for i in range(len(files)): |
---|
15 | n/a | file = files[i] |
---|
16 | n/a | if file[-2:] == '.c': |
---|
17 | n/a | base = os.path.basename(file) |
---|
18 | n/a | dest = base[:-2] + '.o' |
---|
19 | n/a | outfp.write("%s: %s\n" % (dest, file)) |
---|
20 | n/a | outfp.write("\t$(CC) $(PY_CFLAGS) $(PY_CPPFLAGS) -c %s\n" % file) |
---|
21 | n/a | files[i] = dest |
---|
22 | n/a | deps.append(dest) |
---|
23 | n/a | |
---|
24 | n/a | outfp.write("\n%s: %s\n" % (target, ' '.join(deps))) |
---|
25 | n/a | outfp.write("\t$(LINKCC) $(PY_LDFLAGS) $(LINKFORSHARED) %s -o %s $(LDLAST)\n" % |
---|
26 | n/a | (' '.join(files), target)) |
---|
27 | n/a | |
---|
28 | n/a | outfp.write("\nclean:\n\t-rm -f *.o %s\n" % target) |
---|