Home | History | Annotate | Download | only in compiler
      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 glsl Android.mk for source generation
     25 
     26 ifeq ($(LOCAL_MODULE_CLASS),)
     27 LOCAL_MODULE_CLASS := STATIC_LIBRARIES
     28 endif
     29 
     30 intermediates := $(call local-generated-sources-dir)
     31 prebuilt_intermediates := $(MESA_TOP)/prebuilt-intermediates
     32 
     33 LOCAL_SRC_FILES := $(LOCAL_SRC_FILES)
     34 
     35 LOCAL_C_INCLUDES += \
     36 	$(intermediates)/glsl \
     37 	$(intermediates)/glsl/glcpp \
     38 	$(LOCAL_PATH)/glsl \
     39 	$(LOCAL_PATH)/glsl/glcpp \
     40 
     41 LOCAL_GENERATED_SOURCES += $(addprefix $(intermediates)/, \
     42 	$(LIBGLCPP_GENERATED_FILES) \
     43 	$(LIBGLSL_GENERATED_FILES))
     44 
     45 LOCAL_EXPORT_C_INCLUDE_DIRS += \
     46 	$(intermediates)/glsl \
     47 
     48 # Modules using libmesa_nir must set LOCAL_GENERATED_SOURCES to this
     49 MESA_GEN_GLSL_H := $(addprefix $(call local-generated-sources-dir)/, \
     50 	glsl/ir_expression_operation.h \
     51 	glsl/ir_expression_operation_constant.h \
     52 	glsl/ir_expression_operation_strings.h)
     53 
     54 define local-l-or-ll-to-c-or-cpp
     55 	@mkdir -p $(dir $@)
     56 	@echo "Mesa Lex: $(PRIVATE_MODULE) <= $<"
     57 	$(hide) $(LEX) --nounistd -o$@ $<
     58 endef
     59 
     60 define glsl_local-y-to-c-and-h
     61 	@mkdir -p $(dir $@)
     62 	@echo "Mesa Yacc: $(PRIVATE_MODULE) <= $<"
     63 	$(hide) $(YACC) -o $@ -p "glcpp_parser_" $<
     64 endef
     65 
     66 YACC_HEADER_SUFFIX := .hpp
     67 
     68 define local-yy-to-cpp-and-h
     69 	@mkdir -p $(dir $@)
     70 	@echo "Mesa Yacc: $(PRIVATE_MODULE) <= $<"
     71 	$(hide) $(YACC) -p "_mesa_glsl_" -o $@ $<
     72 	touch $(@:$1=$(YACC_HEADER_SUFFIX))
     73 	echo '#ifndef '$(@F:$1=_h) > $(@:$1=.h)
     74 	echo '#define '$(@F:$1=_h) >> $(@:$1=.h)
     75 	cat $(@:$1=$(YACC_HEADER_SUFFIX)) >> $(@:$1=.h)
     76 	echo '#endif' >> $(@:$1=.h)
     77 	rm -f $(@:$1=$(YACC_HEADER_SUFFIX))
     78 endef
     79 
     80 $(intermediates)/glsl/glsl_lexer.cpp: $(LOCAL_PATH)/glsl/glsl_lexer.ll
     81 	$(call local-l-or-ll-to-c-or-cpp)
     82 
     83 $(intermediates)/glsl/glsl_parser.cpp: $(LOCAL_PATH)/glsl/glsl_parser.yy
     84 	$(call local-yy-to-cpp-and-h,.cpp)
     85 
     86 $(intermediates)/glsl/glsl_parser.h: $(intermediates)/glsl/glsl_parser.cpp
     87 
     88 $(intermediates)/glsl/glcpp/glcpp-lex.c: $(LOCAL_PATH)/glsl/glcpp/glcpp-lex.l
     89 	$(call local-l-or-ll-to-c-or-cpp)
     90 
     91 $(intermediates)/glsl/glcpp/glcpp-parse.c: $(LOCAL_PATH)/glsl/glcpp/glcpp-parse.y
     92 	$(call glsl_local-y-to-c-and-h)
     93 
     94 $(LOCAL_PATH)/glsl/ir.h: $(intermediates)/glsl/ir_expression_operation.h
     95 
     96 $(intermediates)/glsl/ir_expression_operation.h: $(prebuilt_intermediates)/glsl/ir_expression_operation.h
     97 	cp -a $< $@
     98 
     99 $(intermediates)/glsl/ir_expression_operation_constant.h: $(prebuilt_intermediates)/glsl/ir_expression_operation_constant.h
    100 	cp -a $< $@
    101 
    102 $(intermediates)/glsl/ir_expression_operation_strings.h: $(prebuilt_intermediates)/glsl/ir_expression_operation_strings.h
    103 	cp -a $< $@
    104