31f4ca1eccc68f903bb767c84c5ff47430a78c86
[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         src_list = open ('../frozen/src.list', 'w')
27         deps = []
28         for i in range(len(files)):
29                 file = files[i]
30                 if file[-2:] == '.c':
31                         base = os.path.basename(file)
32                         dest = base[:-2] + '.o'
33                         src_list.write("%s " % file)
34                 #       outfp.write("%s: %s\n" % (dest, file))
35                 #       outfp.write("\t$(CC) $(CFLAGS) -c %s\n" % file)
36                         files[i] = dest
37                         deps.append(dest)
38
39         src_list.close()
40         mainfile = 'M___main__.o'
41         
42         try:
43                 deps.remove(mainfile)
44         except:
45                 pass
46         outfp.write("OBJS = %s\n" % string.join(deps))
47
48 #       libfiles.remove('M___main__.o') # don't link with __main__
49
50         outfp.write("\n%s: $(OBJS)\n" % (libtarget))
51 #       outfp.write("\t$(AR) ruv %s%s $(OBJS)\n" % 
52 #               ("$(OCGDIR)/blender/bpython/$(DEBUG_DIR)", targetlib))
53         outfp.write("\t$(AR) ruv %s $(OBJS)\n" % targetlib)
54
55         outfp.write("\n%s: %s $(OBJS)\n" % (target, mainfile))
56         outfp.write("\t$(CC) %s %s -o %s $(LDLAST)\n" % 
57                                 (mainfile, " ".join(deps), target))
58
59         outfp.write("\nclean:\n\t-rm -f *.o *.a %s\n" % target)