source/gldecoder.funcs.t \
source/gldecoder.struct.t \
source/glprint.funcs.t \
- source/glwrap.funcs.t
+ source/glwrap.funcs.t \
+ source/enums.table.t
-objs = $(patsubst source/%.cpp,temp/%.o,$(patsubst source/%.c,temp/%.o,$(1)))
-deps = $(patsubst source/%.cpp,temp/%.d,$(patsubst source/%.c,temp/%.d,$(1)))
-gen = $(patsubst source/%.t,gensrc/%,$(1))
+rename = $(addprefix $(1)/,$(addsuffix $(2),$(basename $(notdir $(3)))))
+objs = $(call rename,temp,.o,$(1))
+deps = $(call rename,temp,.d,$(1))
+gen = $(call rename,gensrc,,$(1))
GENSOURCES := $(call gen,$(TEMPLATES))
SOURCES_all := $(sort $(SOURCES_libgldbg) $(SOURCES_glwrap) $(SOURCES_gldump) $(SOURCES_gldbg))
OBJECTS_gldbg := $(call objs,$(SOURCES_gldbg))
OBJECTS_all := $(call objs,$(SOURCES_all))
-DEPS_all := $(call deps,$(SOURCES_all))
+DEPS_all := $(call deps,$(SOURCES_all) $(TEMPLATES))
+
+.PHONY: all
+all: glwrap.so gldump gldbg
$(OBJECTS_gldbg): CXXFLAGS += $(shell pkg-config --cflags $(PACKAGES_gldbg))
gldbg: LIBS += $(shell pkg-config --libs $(PACKAGES_gldbg)) -lreadline
gldump gldbg: LIBS += ./libgldbg.a
-all: glwrap.so gldump gldbg
-
glwrap.so: $(OBJECTS_glwrap)
$(CC) -shared -o $@ $^ $(LIBS) $(LDFLAGS)
mkdir -p temp
touch $@
-gensrc/%: source/%.t gensrc/.created generate.py gl.api gl.tm gl.io gl.spec glx.api glx.tm glx.io glx.spec glxext.spec
+gensrc/%: source/%.t gensrc/.created generate.py
python ./generate.py $< gl.api glx.api >$@
gensrc/.created:
-include $(DEPS_all)
temp/%.d: source/%.c temp/.created
- $(CC) $(CPPFLAGS) -MM -MF $@ -MT $(patsubst source/%.c,temp/%.o,$<) -MG $<
+ $(CC) $(CPPFLAGS) -MM -MF $@ -MT $(call rename,temp,.o,$<) -MG $<
temp/%.d: source/%.cpp temp/.created
- $(CXX) $(CPPFLAGS) -MM -MF $@ -MT $(patsubst source/%.cpp,temp/%.o,$<) -MG $<
+ $(CXX) $(CPPFLAGS) -MM -MF $@ -MT $(call rename,temp,.o,$<) -MG $<
+
+temp/%.d: source/%.t temp/.created
+ python ./generate.py --depends=$(call rename,gensrc,,$<) $< gl.api glx.api >$@
.PHONY: clean
clean:
import sys
import os
+import optparse
class InputFile:
def __init__(self, fn):
return enums
-template = Template(sys.argv[1])
+parser = optparse.OptionParser()
+parser.add_option("--depends", dest="depends", default=False)
+(options, args) = parser.parse_args()
+
+template = Template(args[0])
apis = []
-for i in sys.argv[2:]:
+for i in args[1:]:
apis.append(Api(i))
-template.process(apis)
+if options.depends:
+ deps = args[:]
+ if template.mode=="functions":
+ for api in apis:
+ deps += api.specs
+ deps.append(api.typemap)
+ deps.append(api.iomap)
+ elif template.mode=="enums":
+ for api in apis:
+ deps += api.enumspecs
+ sys.stdout.write("%s: %s\n"%(options.depends, " ".join(deps)))
+else:
+ template.process(apis)