GLAPI := $(TOP)/src/mapi/glapi
MAPI := $(TOP)/src/mapi/mapi
-# directory for generated sources/headers
-GEN := glapi
esapi_CPPFLAGS := \
-I$(TOP)/include \
esapi_LIB_DEPS := -L$(TOP)/$(LIB_DIR) -l$(GLAPI_LIB) $(esapi_LIB_DEPS)
.PHONY: default
-default: depend $(TOP)/$(LIB_DIR)/$(esapi_LIB_NAME)
+default: depend $(TOP)/$(LIB_DIR)/$(esapi_LIB_NAME) main/dispatch.h main/remap_helper.h
$(TOP)/$(LIB_DIR)/$(esapi_LIB_NAME): $(esapi_OBJECTS)
$(MKLIB) -o $(esapi_LIB) -linker '$(CC)' -ldflags '$(LDFLAGS)' \
$(esapi_OBJECTS): %.o: $(MAPI)/%.c
$(CC) -c $(esapi_CPPFLAGS) $(CFLAGS) $< -o $@
-$(esapi_SOURCES): | glapi-stamp
+$(esapi_SOURCES): glapi_mapi_tmp.h
-.PHONY: glapi-stamp
-glapi-stamp:
- @# generate sources/headers
- @$(MAKE) -C $(GLAPI)/gen-es $(ES)
- @touch $@
+include $(GLAPI)/gen/glapi_gen.mk
+glapi_mapi_tmp.h: $(GLAPI)/gen/gl_and_es_API.xml $(glapi_gen_mapi_deps)
+ $(call glapi_gen_mapi,$<,$(ESAPI))
+
+main/dispatch.h: $(GLAPI)/gen/gl_and_es_API.xml $(glapi_gen_dispatch_deps)
+ $(call glapi_gen_dispatch,$<,$(ES))
+
+main/remap_helper.h: $(GLAPI)/gen/gl_and_es_API.xml $(glapi_gen_remap_deps)
+ $(call glapi_gen_remap,$<,$(ES))
.PHONY: clean
clean:
-rm -f lib$(ESAPI).a
-rm -f $(esapi_OBJECTS)
-rm -f depend depend.bak
- -rm -f glapi-stamp
- @# clean generated sources/headers
- @$(MAKE) -C $(GLAPI)/gen-es clean-$(ES)
+ -rm -f glapi_mapi_tmp.h
+ -rm -rf main
pcedit = \
-e 's,@INSTALL_DIR@,$(INSTALL_DIR),' \
--- /dev/null
+# Helpers for glapi header generation
+
+ifndef TOP
+$(error TOP must be defined.)
+endif
+
+glapi_gen_common_deps := \
+ $(wildcard $(TOP)/src/mapi/glapi/gen/*.xml) \
+ $(wildcard $(TOP)/src/mapi/glapi/gen/*.py)
+
+glapi_gen_mapi_script := $(TOP)/src/mapi/mapi/mapi_abi.py
+glapi_gen_mapi_deps := \
+ $(glapi_gen_mapi_script) \
+ $(glapi_gen_common_deps)
+
+# $(1): path to an XML file
+# $(2): name of the printer
+define glapi_gen_mapi
+@mkdir -p $(dir $@)
+$(PYTHON2) $(PYTHON_FLAGS) $(glapi_gen_mapi_script) \
+ --mode lib --printer $(2) $(1) > $@
+endef
+
+glapi_gen_dispatch_script := $(TOP)/src/mapi/glapi/gen/gl_table.py
+glapi_gen_dispatch_deps := $(glapi_gen_common_deps)
+
+# $(1): path to an XML file
+# $(2): empty, es1, or es2 for entry point filtering
+define glapi_gen_dispatch
+@mkdir -p $(dir $@)
+$(PYTHON2) $(PYTHON_FLAGS) $(glapi_gen_dispatch_script) \
+ -f $(1) -m remap_table $(if $(2),-c $(2),) > $@
+endef
+
+glapi_gen_remap_script := $(TOP)/src/mapi/glapi/gen/remap_helper.py
+glapi_gen_remap_deps := $(glapi_gen_common_deps)
+
+# $(1): path to an XML file
+# $(2): empty, es1, or es2 for entry point filtering
+define glapi_gen_remap
+@mkdir -p $(dir $@)
+$(PYTHON2) $(PYTHON_FLAGS) $(glapi_gen_remap_script) \
+ -f $(1) $(if $(2),-c $(2),) > $@
+endef
$(glapi_SOURCES): glapi_mapi_tmp.h
-.PHONY: glapi_mapi_tmp.h
-glapi_mapi_tmp.h:
- @$(MAKE) -C $(GLAPI)/gen-es shared-glapi
+include $(GLAPI)/gen/glapi_gen.mk
+glapi_mapi_tmp.h: $(GLAPI)/gen/gl_and_es_API.xml $(glapi_gen_mapi_deps)
+ $(call glapi_gen_mapi,$<,shared-glapi)
.PHONY: clean
clean:
-rm -f $(TOP)/$(LIB_DIR)/$(GLAPI_LIB_NAME)
-rm -f $(glapi_OBJECTS)
-rm -f depend depend.bak
- @# clean generated sources/headers
- @$(MAKE) -C $(GLAPI)/gen-es clean-shared-glapi
+ -rm -f glapi_mapi_tmp.h
install:
$(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)