Add fabrication.
[build-benchmarks.git] / make.py
blob0486289f7976a4f7e9325815cc3db4b4916d7f0d
1 #!/usr/bin/python
3 import os
4 import cppcodebase
5 import random
8 def CreateLibMakefile(lib_number, classes):
9 os.chdir(cppcodebase.lib_name(lib_number))
10 handle = file("Makefile", "w");
11 handle.write ("""COMPILER = g++
12 INC = -I..
13 CCFLAGS = -g -Wall $(INC)
14 ARCHIVE = ar
15 DEPEND = makedepend
16 .SUFFIXES: .o .cpp
18 """)
19 handle.write ("lib = lib_" + str(lib_number) + ".a\n")
20 handle.write ("src = \\\n")
21 for i in xrange(classes):
22 handle.write('class_' + str(i) + '.cpp \\\n')
23 handle.write ("""
26 objects = $(patsubst %.cpp, %.o, $(src))
28 all: depend $(lib)
30 $(lib): $(objects)
31 $(ARCHIVE) cr $@ $^
32 touch $@
34 .cpp.o:
35 $(COMPILER) $(CCFLAGS) -c $<
37 clean:
38 @rm $(objects) $(lib) 2> /dev/null
40 depend:
41 @$(DEPEND) $(INC) $(src)
43 """)
44 os.chdir('..')
47 def CreateFullMakefile(libs):
48 handle = file("Makefile", "w")
50 handle.write('subdirs = \\\n')
51 for i in xrange(libs):
52 handle.write('lib_' + str(i) + '\\\n')
53 handle.write("""
55 all: $(subdirs)
56 @for i in $(subdirs); do \
57 $(MAKE) -C $$i all; done
59 clean:
60 @for i in $(subdirs); do \
61 (cd $$i; $(MAKE) clean); done
63 depend:
64 @for i in $(subdirs); do \
65 (cd $$i; $(MAKE) depend); done
66 """)
68 def CreateCodebase(libs, classes, internal_includes, external_includes):
69 cppcodebase.SetDir('make')
70 cppcodebase.CreateSetOfLibraries(libs, classes, internal_includes, external_includes, CreateLibMakefile)
71 CreateFullMakefile(libs)
72 os.chdir('..')