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 \
21 SOURCES_glwrap := source/glwrap.c \
22 source/glwrap_funcs.c \
24 SOURCES_gldump := source/gldump.c
25 SOURCES_gldbg := source/gldbg.cpp \
26 source/commandinterpreter.cpp \
30 source/texturestate.cpp \
31 source/bufferstate.cpp \
34 TEMPLATES := source/functions.enum.t \
35 source/gldecoder.funcs.t \
36 source/gldecoder.struct.t \
37 source/glprint.funcs.t \
38 source/glwrap.funcs.t \
41 rename = $(addprefix $(1)/,$(addsuffix $(2),$(basename $(notdir $(3)))))
42 objs = $(call rename,temp,.o,$(1))
43 deps = $(call rename,temp,.d,$(1))
44 gen = $(call rename,gensrc,,$(1))
46 GENSOURCES := $(call gen,$(TEMPLATES))
47 SOURCES_all := $(sort $(SOURCES_libgldbg) $(SOURCES_glwrap) $(SOURCES_gldump) $(SOURCES_gldbg))
49 OBJECTS_libgldbg := $(call objs,$(SOURCES_libgldbg))
50 OBJECTS_glwrap := $(call objs,$(SOURCES_glwrap))
51 OBJECTS_gldump := $(call objs,$(SOURCES_gldump))
52 OBJECTS_gldbg := $(call objs,$(SOURCES_gldbg))
54 OBJECTS_all := $(call objs,$(SOURCES_all))
55 DEPS_all := $(call deps,$(SOURCES_all) $(TEMPLATES))
58 all: glwrap.so gldump gldbg
60 include flavors/$(FLAVOR)/flavor.mk
62 $(OBJECTS_gldbg): CXXFLAGS += $(shell pkg-config --cflags $(PACKAGES_gldbg))
63 gldbg: LIBS += $(shell pkg-config --libs $(PACKAGES_gldbg)) -lreadline
64 gldump gldbg: LIBS += ./libgldbg.a
66 glwrap.so: $(OBJECTS_glwrap)
67 $(CC) -shared -o $@ $^ $(LIBS) $(LDFLAGS)
69 gldump: $(OBJECTS_gldump) libgldbg.a
70 $(CC) -o $@ $^ $(LIBS) $(LDFLAGS)
72 gldbg: $(OBJECTS_gldbg) libgldbg.a
73 $(CXX) -o $@ $^ $(LIBS) $(LDFLAGS)
75 libgldbg.a: $(OBJECTS_libgldbg)
78 temp/%.o: source/%.c temp/.created
79 $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
81 temp/%.o: source/%.cpp temp/.created
82 $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) -o $@ $<
88 gensrc/%: source/%.t gensrc/.created generate.py
89 python ./generate.py $< $(APIS) >$@
97 temp/%.d: source/%.c temp/.created
98 $(CC) $(CPPFLAGS) -MM -MF $@ -MT $(call rename,temp,.o,$<) -MG $<
100 temp/%.d: source/%.cpp temp/.created
101 $(CXX) $(CPPFLAGS) -MM -MF $@ -MT $(call rename,temp,.o,$<) -MG $<
103 temp/%.d: source/%.t temp/.created
104 python ./generate.py --depends=$(call rename,gensrc,,$<) $< $(APIS) >$@
110 $(RM) gensrc/enums.table $(GENSOURCES)
111 $(RM) glwrap.so libgldbg.a gldump gldbg