[Mesa-dev] [PATCH 4/6] glapi: add glapi_gen.mk to help header generation
Chia-I Wu
olvaffe at gmail.com
Thu Aug 11 02:45:24 PDT 2011
From: Chia-I Wu <olv at lunarg.com>
glapi_gen.mk is supposed to be included by glapi users to simplify
header generation. This commit also makes es1api, es2api, and
shared-glapi use it.
---
src/mapi/es1api/Makefile | 25 +++++++++++----------
src/mapi/glapi/gen/glapi_gen.mk | 44 +++++++++++++++++++++++++++++++++++++++
src/mapi/shared-glapi/Makefile | 9 +++----
3 files changed, 61 insertions(+), 17 deletions(-)
create mode 100644 src/mapi/glapi/gen/glapi_gen.mk
diff --git a/src/mapi/es1api/Makefile b/src/mapi/es1api/Makefile
index aef6948..df2a681 100644
--- a/src/mapi/es1api/Makefile
+++ b/src/mapi/es1api/Makefile
@@ -34,8 +34,6 @@ ESAPI = $(ES)api
GLAPI := $(TOP)/src/mapi/glapi
MAPI := $(TOP)/src/mapi/mapi
-# directory for generated sources/headers
-GEN := glapi
esapi_CPPFLAGS := \
-I$(TOP)/include \
@@ -50,7 +48,7 @@ esapi_CPPFLAGS += -DMAPI_MODE_BRIDGE
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)' \
@@ -68,13 +66,17 @@ lib$(ESAPI).a: $(esapi_OBJECTS)
$(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_mapi_deps)
+ $(call glapi_mapi_gen,$<,$(ESAPI))
+
+main/dispatch.h: $(GLAPI)/gen/gl_and_es_API.xml $(glapi_dispatch_deps)
+ $(call glapi_dispatch_gen,$<,$(ES))
+
+main/remap_helper.h: $(GLAPI)/gen/gl_and_es_API.xml $(glapi_remap_helper_deps)
+ $(call glapi_remap_helper_gen,$<,$(ES))
.PHONY: clean
clean:
@@ -83,9 +85,8 @@ 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, at INSTALL_DIR@,$(INSTALL_DIR),' \
diff --git a/src/mapi/glapi/gen/glapi_gen.mk b/src/mapi/glapi/gen/glapi_gen.mk
new file mode 100644
index 0000000..7def303
--- /dev/null
+++ b/src/mapi/glapi/gen/glapi_gen.mk
@@ -0,0 +1,44 @@
+# Helpers for glapi header generation
+
+ifndef TOP
+$(error TOP must be defined.)
+endif
+
+glapi_common_deps := \
+ $(wildcard $(TOP)/src/mapi/glapi/gen/*.xml) \
+ $(wildcard $(TOP)/src/mapi/glapi/gen/*.py)
+
+glapi_mapi_script := $(TOP)/src/mapi/mapi/mapi_abi.py
+glapi_mapi_deps := \
+ $(glapi_mapi_script) \
+ $(glapi_common_deps)
+
+# $(1): path to an XML file
+# $(2): name of the printer
+define glapi_mapi_gen
+ at mkdir -p $(dir $@)
+$(PYTHON2) $(PYTHON_FLAGS) $(glapi_mapi_script) \
+ --mode lib --printer $(2) $(1) > $@
+endef
+
+glapi_dispatch_script := $(TOP)/src/mapi/glapi/gen/gl_table.py
+glapi_dispatch_deps := $(glapi_common_deps)
+
+# $(1): path to an XML file
+# $(2): empty, es1, or es2 for entry point filtering
+define glapi_dispatch_gen
+ at mkdir -p $(dir $@)
+$(PYTHON2) $(PYTHON_FLAGS) $(glapi_dispatch_script) \
+ -f $(1) -m remap_table $(if $(2),-c $(2),) > $@
+endef
+
+glapi_remap_helper_script := $(TOP)/src/mapi/glapi/gen/remap_helper.py
+glapi_remap_helper_deps := $(glapi_common_deps)
+
+# $(1): path to an XML file
+# $(2): empty, es1, or es2 for entry point filtering
+define glapi_remap_helper_gen
+ at mkdir -p $(dir $@)
+$(PYTHON2) $(PYTHON_FLAGS) $(glapi_remap_helper_script) \
+ -f $(1) $(if $(2),-c $(2),) > $@
+endef
diff --git a/src/mapi/shared-glapi/Makefile b/src/mapi/shared-glapi/Makefile
index c928f82..3f3f1ef 100644
--- a/src/mapi/shared-glapi/Makefile
+++ b/src/mapi/shared-glapi/Makefile
@@ -34,17 +34,16 @@ $(glapi_OBJECTS): %.o: $(MAPI)/%.c
$(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_mapi_deps)
+ $(call glapi_mapi_gen,$<,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)
--
1.7.5.4
More information about the mesa-dev
mailing list