3775e64657d75c827a6dc01d19cd89a158f74e2b
[blender.git] / intern / python / freeze / makemakefile.py
1 # Write the actual Makefile.
2 ##
3 ##
4 ## Customized makemakefile for NaN
5 ##
6 ##
7 ## 1.11.2001, strubi@blender.nl
8 ##
9 ##
10
11
12 import os
13 import string
14
15 def makemakefile(outfp, makevars, files, target):
16         outfp.write("# Makefile generated by freeze.py script\n\n")
17
18         target = "frozen"
19         libtarget = "lib" + target
20         targetlib = libtarget + ".a"
21         #targetlib = "libpyfrozen.a"
22
23         keys = makevars.keys()
24         keys.sort()
25         for key in keys:
26                 outfp.write("%s=%s\n" % (key, makevars[key]))
27
28         outfp.write("\n\ninclude nan_definitions.mk\n")
29         outfp.write("ifeq ($(OS),windows)\n")
30         outfp.write("  CC=$(NANBLENDERHOME)/source/tools/cygwin/cl_wrapper.pl\n")
31         outfp.write("  CFLAGS=-I../../../../lib/windows/python/include/python2.2/ $(OPT)\n")
32         outfp.write("endif\n")
33
34         outfp.write("\nall: %s\n\n" % libtarget)
35
36         deps = []
37         for i in range(len(files)):
38                 file = files[i]
39                 if file[-2:] == '.c':
40                         base = os.path.basename(file)
41                         dest = base[:-2] + '.o'
42                 #       outfp.write("%s: %s\n" % (dest, file))
43                 #       outfp.write("\t$(CC) $(CFLAGS) -c %s\n" % file)
44                         files[i] = dest
45                         deps.append(dest)
46
47         mainfile = 'M___main__.o'
48         
49         try:
50                 deps.remove(mainfile)
51         except:
52                 pass
53         outfp.write("OBJS = %s\n" % string.join(deps))
54
55 #       libfiles.remove('M___main__.o') # don't link with __main__
56
57         outfp.write("\n%s: $(OBJS)\n" % (libtarget))
58         outfp.write("\t$(AR) ruv %s%s $(OBJS)\n" % 
59                 ("$(OCGDIR)/blender/bpython/$(DEBUG_DIR)", targetlib))
60
61         outfp.write("\n%s: %s $(OBJS)\n" % (target, mainfile))
62         outfp.write("\t$(CC) %s %s -o %s $(LDLAST)\n" % 
63                                 (mainfile, " ".join(deps), target))
64
65         outfp.write("\nclean:\n\t-rm -f *.o *.a %s\n" % target)