7 CPPFLAGS := -I. -Isource -Iflavors/$(FLAVOR)/source
8 CFLAGS := -ggdb -Wall -Wextra
11 PACKAGES_gldbg := mspcore mspstrings mspio mspfs
13 FLAVOR_ROOT := flavors/$(FLAVOR)
14 VPATH := $(FLAVOR_ROOT)
16 SOURCES_libgldbg := source/gldecoder.c \
23 SOURCES_glwrap := source/glwrap.c \
24 source/glwrap_funcs.c \
28 SOURCES_gldump := source/gldump.c
29 SOURCES_gldbg := source/gldbg.cpp \
30 source/commandinterpreter.cpp \
33 SOURCES_tracer := source/tracer.cpp
34 SOURCES_profiler := source/profiler.cpp
35 SOURCES_inspector := source/inspector.cpp \
37 source/arraystate.cpp \
38 source/texturestate.cpp \
39 source/bufferstate.cpp
40 TEMPLATES := source/functions.enum.t \
41 source/functions.table.t \
42 source/gldecoder.funcs.t \
43 source/gldecoder.struct.t \
44 source/glprint.funcs.t \
45 source/glwrap.funcs.t \
48 rename = $(addprefix $(1)/,$(addsuffix $(2),$(basename $(notdir $(3)))))
49 objs = $(call rename,temp,.o,$(1))
50 deps = $(call rename,temp,.d,$(1))
51 gen = $(call rename,gensrc,,$(1))
54 all: glwrap.so gldump gldbg
56 include flavors/$(FLAVOR)/flavor.mk
58 SOURCES_gldbg += $(foreach tool,$(TOOLS),$(SOURCES_$(tool)))
59 GENSOURCES := $(call gen,$(TEMPLATES))
60 SOURCES_all := $(sort $(SOURCES_libgldbg) $(SOURCES_glwrap) $(SOURCES_gldump) $(SOURCES_gldbg))
62 OBJECTS_libgldbg := $(call objs,$(SOURCES_libgldbg))
63 OBJECTS_glwrap := $(call objs,$(SOURCES_glwrap))
64 OBJECTS_gldump := $(call objs,$(SOURCES_gldump))
65 OBJECTS_gldbg := $(call objs,$(SOURCES_gldbg))
67 OBJECTS_all := $(call objs,$(SOURCES_all))
68 DEPS_all := $(call deps,$(SOURCES_all) $(TEMPLATES))
70 $(OBJECTS_gldbg): CXXFLAGS += $(shell pkg-config --cflags $(PACKAGES_gldbg))
71 gldbg: LIBS += $(shell pkg-config --libs $(PACKAGES_gldbg)) -lreadline
72 gldump gldbg: LIBS += ./libgldbg.a
73 glwrap.so: LDFLAGS += -s
75 glwrap.so: $(OBJECTS_glwrap) glwrap.ld
76 $(CC) -shared -o $@ $^ $(LIBS) $(LDFLAGS)
78 gldump: $(OBJECTS_gldump) libgldbg.a
79 $(CC) -o $@ $^ $(LIBS) $(LDFLAGS)
81 gldbg: $(OBJECTS_gldbg) libgldbg.a
82 $(CXX) -o $@ $^ $(LIBS) $(LDFLAGS)
84 libgldbg.a: $(OBJECTS_libgldbg)
87 temp/%.o: source/%.c temp/.created
88 $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
90 temp/%.o: source/%.cpp temp/.created
91 $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) -o $@ $<
97 gensrc/%: source/%.t gensrc/.created generate.py
98 python ./generate.py $< $(APIS) >$@
106 temp/%.d: source/%.c temp/.created
107 $(CC) $(CPPFLAGS) -MM -MF $@ -MT $(call rename,temp,.o,$<) -MG $<
109 temp/%.d: source/%.cpp temp/.created
110 $(CXX) $(CPPFLAGS) -MM -MF $@ -MT $(call rename,temp,.o,$<) -MG $<
112 temp/%.d: source/%.t temp/.created
113 python ./generate.py --depends=$(call rename,gensrc,,$<) $< $(APIS) >$@
119 $(RM) gensrc/enums.table $(GENSOURCES)
120 $(RM) glwrap.so libgldbg.a gldump gldbg