]> git.tdb.fi Git - gldbg.git/blob - Makefile
Track owners of breakpoints
[gldbg.git] / Makefile
1 # $Id$
2
3 ifeq ($(FLAVOR),)
4 FLAVOR := gl
5 endif
6
7 CPPFLAGS := -I. -Isource -Iflavors/$(FLAVOR)/source
8 CFLAGS := -ggdb -Wall -Wextra
9 CXXFLAGS := $(CFLAGS)
10
11 PACKAGES_gldbg := mspcore mspstrings mspio mspfs
12
13 FLAVOR_ROOT := flavors/$(FLAVOR)
14 VPATH := $(FLAVOR_ROOT)
15
16 SOURCES_libgldbg := source/gldecoder.c \
17         source/glprint.c \
18         source/enums.c \
19         source/arraysize.c \
20         source/tmpalloc.c \
21         source/packet.c \
22         source/functions.c
23 SOURCES_glwrap := source/glwrap.c \
24         source/glwrap_funcs.c \
25         source/arraysize.c \
26         source/packet.c \
27         source/tmpalloc.c
28 SOURCES_gldump := source/gldump.c
29 SOURCES_gldbg := source/gldbg.cpp \
30         source/commandinterpreter.cpp \
31         source/process.cpp \
32         source/tool.cpp
33 SOURCES_tracer := source/tracer.cpp
34 SOURCES_profiler := source/profiler.cpp
35 SOURCES_inspector := source/inspector.cpp \
36         source/glstate.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 \
46         source/enums.table.t
47
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))
52
53 .PHONY: all
54 all: glwrap.so gldump gldbg
55
56 include flavors/$(FLAVOR)/flavor.mk
57
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))
61
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))
66
67 OBJECTS_all := $(call objs,$(SOURCES_all))
68 DEPS_all := $(call deps,$(SOURCES_all) $(TEMPLATES))
69
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
75
76 glwrap.so: $(OBJECTS_glwrap) glwrap.ld
77         $(CC) -shared -o $@ $^ $(LIBS) $(LDFLAGS)
78
79 gldump: $(OBJECTS_gldump) libgldbg.a
80         $(CC) -o $@ $^ $(LIBS) $(LDFLAGS)
81
82 gldbg: $(OBJECTS_gldbg) libgldbg.a
83         $(CXX) -o $@ $^ $(LIBS) $(LDFLAGS)
84
85 libgldbg.a: $(OBJECTS_libgldbg)
86         $(AR) rc $@ $^
87
88 temp/%.o: source/%.c temp/.created
89         $(CC) -c $(CPPFLAGS) $(CFLAGS) -o $@ $<
90
91 temp/%.o: source/%.cpp temp/.created
92         $(CXX) -c $(CPPFLAGS) $(CXXFLAGS) -o $@ $<
93
94 temp/.created:
95         mkdir -p temp
96         touch $@
97
98 gensrc/%: source/%.t gensrc/.created generate.py
99         python ./generate.py $< $(APIS) >$@
100
101 gensrc/.created:
102         mkdir -p gensrc
103         touch $@
104
105 -include $(DEPS_all)
106
107 temp/%.d: source/%.c temp/.created
108         $(CC) $(CPPFLAGS) -MM -MF $@ -MT $(call rename,temp,.o,$<) -MG $<
109
110 temp/%.d: source/%.cpp temp/.created
111         $(CXX) $(CPPFLAGS) -MM -MF $@ -MT $(call rename,temp,.o,$<) -MG $<
112
113 temp/%.d: source/%.t temp/.created
114         python ./generate.py --depends=$(call rename,gensrc,,$<) $< $(APIS) >$@
115
116 .PHONY: clean
117 clean:
118         $(RM) $(DEPS_all)
119         $(RM) $(OBJECTS_all)
120         $(RM) gensrc/enums.table $(GENSOURCES)
121         $(RM) glwrap.so libgldbg.a gldump gldbg