Now the make freeze is done when any of the *.py files in intern/python
[blender.git] / intern / python / freeze / makemakefile_ac.py
1 # Write the actual Makefile.
2 ##
3 ## Modified makemakefile for autotools Blender build
4 ##
5
6
7 import os
8 import string
9
10 def makemakefile(outfp, makevars, files, target):
11         outfp.write("# Makefile generated by freeze.py script\n\n")
12
13         target = "frozen"
14         libtarget = "lib" + target
15         targetlib = libtarget + ".a"
16         #targetlib = "libpyfrozen.a"
17
18         keys = makevars.keys()
19         keys.sort()
20         for key in keys:
21                 outfp.write("%s=%s\n" % (key, makevars[key]))
22
23 #        outfp.write("\n\ninclude nan_definitions.mk\n")
24         outfp.write("\nall: %s\n\n" % libtarget)
25
26         deps = []
27         for i in range(len(files)):
28                 file = files[i]
29                 if file[-2:] == '.c':
30                         base = os.path.basename(file)
31                         dest = base[:-2] + '.o'
32                 #       outfp.write("%s: %s\n" % (dest, file))
33                 #       outfp.write("\t$(CC) $(CFLAGS) -c %s\n" % file)
34                         files[i] = dest
35                         deps.append(dest)
36
37         mainfile = 'M___main__.o'
38         
39         try:
40                 deps.remove(mainfile)
41         except:
42                 pass
43         outfp.write("OBJS = %s\n" % string.join(deps))
44
45 #       libfiles.remove('M___main__.o') # don't link with __main__
46
47         outfp.write("\n%s: $(OBJS)\n" % (libtarget))
48 #       outfp.write("\t$(AR) ruv %s%s $(OBJS)\n" % 
49 #               ("$(OCGDIR)/blender/bpython/$(DEBUG_DIR)", targetlib))
50         outfp.write("\t$(AR) ruv %s $(OBJS)\n" % targetlib)
51
52         outfp.write("\n%s: %s $(OBJS)\n" % (target, mainfile))
53         outfp.write("\t$(CC) %s %s -o %s $(LDLAST)\n" % 
54                                 (mainfile, " ".join(deps), target))
55
56         outfp.write("\nclean:\n\t-rm -f *.o *.a %s\n" % target)