1994-10-03 13:33:08 -03:00
|
|
|
# Write the actual Makefile.
|
|
|
|
|
|
|
|
import os
|
|
|
|
|
|
|
|
def makemakefile(outfp, makevars, files, target):
|
1998-03-05 01:22:36 -04:00
|
|
|
outfp.write("# Makefile generated by freeze.py script\n\n")
|
1994-10-03 13:33:08 -03:00
|
|
|
|
2007-06-11 21:28:30 -03:00
|
|
|
keys = sorted(makevars.keys())
|
1998-03-05 01:22:36 -04:00
|
|
|
for key in keys:
|
|
|
|
outfp.write("%s=%s\n" % (key, makevars[key]))
|
|
|
|
outfp.write("\nall: %s\n\n" % target)
|
1994-10-03 13:33:08 -03:00
|
|
|
|
1998-03-05 01:22:36 -04:00
|
|
|
deps = []
|
|
|
|
for i in range(len(files)):
|
|
|
|
file = files[i]
|
|
|
|
if file[-2:] == '.c':
|
|
|
|
base = os.path.basename(file)
|
|
|
|
dest = base[:-2] + '.o'
|
|
|
|
outfp.write("%s: %s\n" % (dest, file))
|
2016-03-18 14:29:43 -03:00
|
|
|
outfp.write("\t$(CC) $(PY_CFLAGS) $(PY_CPPFLAGS) -c %s\n" % file)
|
1998-03-05 01:22:36 -04:00
|
|
|
files[i] = dest
|
|
|
|
deps.append(dest)
|
1994-10-03 13:33:08 -03:00
|
|
|
|
2002-09-11 17:36:02 -03:00
|
|
|
outfp.write("\n%s: %s\n" % (target, ' '.join(deps)))
|
2016-03-18 14:29:43 -03:00
|
|
|
outfp.write("\t$(LINKCC) $(PY_LDFLAGS) $(LINKFORSHARED) %s -o %s $(LDLAST)\n" %
|
2002-09-11 17:36:02 -03:00
|
|
|
(' '.join(files), target))
|
1998-03-05 01:22:36 -04:00
|
|
|
|
|
|
|
outfp.write("\nclean:\n\t-rm -f *.o %s\n" % target)
|