Staging
v0.8.1
Revision 72927d0d1787809b4b25e5086c5a9167bdb807bb authored by Miss Islington (bot) on 12 October 2018, 07:19:20 UTC, committed by GitHub on 12 October 2018, 07:19:20 UTC
(cherry picked from commit 53ebf4b0709f431b7262aa5daccef7eafde7383e)

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
1 parent 1c2cb51
Raw File
makemakefile.py
# Write the actual Makefile.

import os

def makemakefile(outfp, makevars, files, target):
    outfp.write("# Makefile generated by freeze.py script\n\n")

    keys = sorted(makevars.keys())
    for key in keys:
        outfp.write("%s=%s\n" % (key, makevars[key]))
    outfp.write("\nall: %s\n\n" % target)

    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))
            outfp.write("\t$(CC) $(PY_CFLAGS) $(PY_CPPFLAGS) -c %s\n" % file)
            files[i] = dest
            deps.append(dest)

    outfp.write("\n%s: %s\n" % (target, ' '.join(deps)))
    outfp.write("\t$(LINKCC) $(PY_LDFLAGS) $(LINKFORSHARED) %s -o %s $(LDLAST)\n" %
                (' '.join(files), target))

    outfp.write("\nclean:\n\t-rm -f *.o %s\n" % target)
back to top