Home | History | Annotate | Download | only in mesa
      1 # Mesa 3-D graphics library
      2 #
      3 # Copyright (C) 2010-2011 Chia-I Wu <olvaffe (a] gmail.com>
      4 # Copyright (C) 2010-2011 LunarG Inc.
      5 #
      6 # Permission is hereby granted, free of charge, to any person obtaining a
      7 # copy of this software and associated documentation files (the "Software"),
      8 # to deal in the Software without restriction, including without limitation
      9 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
     10 # and/or sell copies of the Software, and to permit persons to whom the
     11 # Software is furnished to do so, subject to the following conditions:
     12 #
     13 # The above copyright notice and this permission notice shall be included
     14 # in all copies or substantial portions of the Software.
     15 #
     16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
     17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
     18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
     19 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
     20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
     21 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
     22 # DEALINGS IN THE SOFTWARE.
     23 
     24 # included by core mesa Android.mk for source generation
     25 
     26 ifeq ($(LOCAL_MODULE_CLASS),)
     27 LOCAL_MODULE_CLASS := STATIC_LIBRARIES
     28 endif
     29 
     30 intermediates := $(call local-intermediates-dir)
     31 
     32 # This is the list of auto-generated files: sources and headers
     33 sources := \
     34 	main/enums.c \
     35 	main/api_exec_es1.c \
     36 	main/api_exec_es1_dispatch.h \
     37 	main/api_exec_es1_remap_helper.h \
     38 	program/program_parse.tab.c \
     39 	program/lex.yy.c \
     40 	main/dispatch.h \
     41 	main/remap_helper.h
     42 
     43 LOCAL_SRC_FILES := $(filter-out $(sources), $(LOCAL_SRC_FILES))
     44 
     45 LOCAL_C_INCLUDES += $(intermediates)/main
     46 
     47 ifeq ($(strip $(MESA_ENABLE_ASM)),true)
     48 ifeq ($(TARGET_ARCH),x86)
     49 sources += x86/matypes.h
     50 LOCAL_C_INCLUDES += $(intermediates)/x86
     51 endif
     52 endif
     53 
     54 sources += main/git_sha1.h
     55 
     56 sources := $(addprefix $(intermediates)/, $(sources))
     57 
     58 LOCAL_GENERATED_SOURCES += $(sources)
     59 
     60 glapi := $(MESA_TOP)/src/mapi/glapi/gen
     61 
     62 es_src_deps := \
     63 	$(LOCAL_PATH)/main/APIspec.xml \
     64 	$(LOCAL_PATH)/main/es_generator.py \
     65 	$(LOCAL_PATH)/main/APIspecutil.py \
     66 	$(LOCAL_PATH)/main/APIspec.py
     67 
     68 es_hdr_deps := \
     69 	$(wildcard $(glapi)/*.py) \
     70 	$(wildcard $(glapi)/*.xml)
     71 
     72 define local-l-to-c
     73 	@mkdir -p $(dir $@)
     74 	@echo "Mesa Lex: $(PRIVATE_MODULE) <= $<"
     75 	$(hide) $(LEX) -o$@ $<
     76 endef
     77 
     78 define local-y-to-c-and-h
     79 	@mkdir -p $(dir $@)
     80 	@echo "Mesa Yacc: $(PRIVATE_MODULE) <= $<"
     81 	$(hide) $(YACC) -o $@ $<
     82 endef
     83 
     84 define es-gen
     85 	@mkdir -p $(dir $@)
     86 	@echo "Gen ES: $(PRIVATE_MODULE) <= $(notdir $(@))"
     87 	$(hide) $(PRIVATE_SCRIPT) $(1) $(PRIVATE_XML) > $@
     88 endef
     89 
     90 $(intermediates)/main/api_exec_%.c: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(LOCAL_PATH)/main/es_generator.py
     91 $(intermediates)/main/api_exec_%.c: PRIVATE_XML := -S $(LOCAL_PATH)/main/APIspec.xml
     92 $(intermediates)/main/api_exec_%_dispatch.h: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(glapi)/gl_table.py
     93 $(intermediates)/main/api_exec_%_dispatch.h: PRIVATE_XML := -f $(glapi)/gl_and_es_API.xml
     94 $(intermediates)/main/api_exec_%_remap_helper.h: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(glapi)/remap_helper.py
     95 $(intermediates)/main/api_exec_%_remap_helper.h: PRIVATE_XML := -f $(glapi)/gl_and_es_API.xml
     96 
     97 $(intermediates)/main/api_exec_es1.c: $(es_src_deps)
     98 	$(call es-gen, -V GLES1.1)
     99 
    100 $(intermediates)/main/api_exec_%_dispatch.h: $(es_hdr_deps)
    101 	$(call es-gen, -c $* -m remap_table)
    102 
    103 $(intermediates)/main/api_exec_%_remap_helper.h: $(es_hdr_deps)
    104 	$(call es-gen, -c $*)
    105 
    106 $(intermediates)/program/program_parse.tab.c: $(LOCAL_PATH)/program/program_parse.y
    107 	$(local-y-to-c-and-h)
    108 
    109 $(intermediates)/program/lex.yy.c: $(LOCAL_PATH)/program/program_lexer.l
    110 	$(local-l-to-c)
    111 
    112 $(intermediates)/main/git_sha1.h:
    113 	@mkdir -p $(dir $@)
    114 	@echo "GIT-SHA1: $(PRIVATE_MODULE) <= git"
    115 	$(hide) touch $@
    116 	$(hide) if which git > /dev/null; then \
    117 			git --git-dir $(PRIVATE_PATH)/../../.git log -n 1 --oneline | \
    118 			sed 's/^\([^ ]*\) .*/#define MESA_GIT_SHA1 "git-\1"/' \
    119 			> $@; \
    120 		fi
    121 
    122 matypes_deps := \
    123 	$(BUILD_OUT_EXECUTABLES)/mesa_gen_matypes$(BUILD_EXECUTABLE_SUFFIX) \
    124 	$(LOCAL_PATH)/main/mtypes.h \
    125 	$(LOCAL_PATH)/tnl/t_context.h
    126 
    127 $(intermediates)/x86/matypes.h: $(matypes_deps) 
    128 	@mkdir -p $(dir $@)
    129 	@echo "MATYPES: $(PRIVATE_MODULE) <= $(notdir $@)"
    130 	$(hide) $< > $@
    131 
    132 $(intermediates)/main/dispatch.h: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(glapi)/gl_table.py
    133 $(intermediates)/main/dispatch.h: PRIVATE_XML := -f $(glapi)/gl_and_es_API.xml
    134 
    135 $(intermediates)/main/dispatch.h: $(es_hdr_deps)
    136 	$(call es-gen, $* -m remap_table)
    137 
    138 $(intermediates)/main/remap_helper.h: PRIVATE_SCRIPT := $(MESA_PYTHON2) $(glapi)/remap_helper.py
    139 $(intermediates)/main/remap_helper.h: PRIVATE_XML := -f $(glapi)/gl_and_es_API.xml
    140 
    141 $(intermediates)/main/remap_helper.h: $(es_hdr_deps)
    142 	$(call es-gen, $*)
    143 
    144 $(intermediates)/main/enums.c: PRIVATE_SCRIPT :=$(MESA_PYTHON2) $(glapi)/gl_enums.py
    145 $(intermediates)/main/enums.c: PRIVATE_XML := -f $(glapi)/gl_and_es_API.xml
    146 
    147 $(intermediates)/main/enums.c: $(es_src_deps)
    148 	$(call es-gen)
    149