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
74 glwrap.so: LIBS += -ldl
76 glwrap.so: $(OBJECTS_glwrap) glwrap.ld
77 $(CC) -shared -o $@ $^ $(LIBS) $(LDFLAGS)
79 gldump: $(OBJECTS_gldump) libgldbg.a
80 $(CC) -o $@ $^ $(LIBS) $(LDFLAGS)
82 gldbg: $(OBJECTS_gldbg) libgldbg.a
83 $(CXX) -o $@ $^ $(LIBS) $(LDFLAGS)
85 libgldbg.a: $(OBJECTS_libgldbg)
88 temp/%.o: source/%.c temp/.created
89 $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
91 temp/%.o: source/%.cpp temp/.created
92 $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) -o $@ $<
98 gensrc/%: source/%.t gensrc/.created generate.py
99 python ./generate.py $< $(APIS) >$@
107 temp/%.d: source/%.c temp/.created
108 $(CC) $(CPPFLAGS) -MM -MF $@ -MT $(call rename,temp,.o,$<) -MG $<
110 temp/%.d: source/%.cpp temp/.created
111 $(CXX) $(CPPFLAGS) -MM -MF $@ -MT $(call rename,temp,.o,$<) -MG $<
113 temp/%.d: source/%.t temp/.created
114 python ./generate.py --depends=$(call rename,gensrc,,$<) $< $(APIS) >$@
120 $(RM) gensrc/enums.table $(GENSOURCES)
121 $(RM) glwrap.so libgldbg.a gldump gldbg