home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / MacHacksBug / Python 1.5.2c1 / Tools / freeze / makemakefile.py < prev    next >
Encoding:
Text File  |  2000-06-23  |  892 b   |  31 lines

  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\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 $(LDLAST)\n" % 
  28.                 (string.join(files), target))
  29.  
  30.     outfp.write("\nclean:\n\t-rm -f *.o %s\n" % target)
  31.