Adapt build script for changes to argument interpretation in fabricate's Builder...
[build-benchmarks.git] / make_nonrecursive.py
blobb8aa50ea8f78946cc8b373244948aef2c17ec827
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.module", "w");
11 handle.write('module := %s\n' % (cppcodebase.lib_name(lib_number),))
12 handle.write ("lib := $(module)/lib_" + str(lib_number) + ".a\n")
13 handle.write ("src := \\\n")
14 for i in xrange(classes):
15 handle.write(' $(module)/class_' + str(i) + '.cpp \\\n')
16 handle.write ("""
19 SRC += $(src)
21 obj := $(patsubst %.cpp,%.o,$(src))
22 dep := $(patsubst %.cpp,%.d,$(src))
24 include $(dep)
26 OBJ += $(obj)
27 LIBS += $(lib)
29 all: $(lib)
31 $(lib): $(obj)
32 $(ARCHIVE) cr $@ $^
33 touch $@
35 $(obj): INC := -I. -I$(module)
36 $(dep): INC := -I. -I$(module)
38 """)
39 os.chdir('..')
42 def CreateFullMakefile(libs):
43 handle = file("Makefile", "w")
45 handle.write('subdirs = \\\n')
46 for i in xrange(libs):
47 handle.write(' lib_' + str(i) + '\\\n')
48 handle.write("""
50 COMPILER = g++
51 CCFLAGS = -g -Wall $(INC)
52 ARCHIVE = ar
53 DEPEND = makedepend
54 .SUFFIXES: .o .cpp
56 all:
58 SRC :=
59 OBJ :=
60 LIBS :=
62 include $(patsubst %,%/Makefile.module,$(subdirs))
64 clean:
65 @rm -f $(OBJ) $(LIBS)
67 %.d: %.cpp
68 $(COMPILER) -MM -MG -MT "$*.o $*.d" -MF $@ $(INC) $<
70 %.o: %.cpp
71 $(COMPILER) $(CCFLAGS) $(OUTPUT_OPTION) -c $<
73 """)
75 def CreateCodebase(libs, classes, internal_includes, external_includes):
76 cppcodebase.SetDir('make_nonrecursive')
77 cppcodebase.CreateSetOfLibraries(libs, classes, internal_includes, external_includes, CreateLibMakefile)
78 CreateFullMakefile(libs)
79 os.chdir('..')