Merge remote-tracking branch 'mareko/r300g-draw-instanced' into pipe-video
[profile/ivi/mesa.git] / src / glsl / Makefile
1
2 #src/glsl/pp/Makefile
3
4 TOP = ../..
5
6 include $(TOP)/configs/current
7
8 LIBNAME = glsl
9
10 LIBGLCPP_SOURCES = \
11         glcpp/glcpp-lex.c \
12         glcpp/glcpp-parse.c \
13         glcpp/pp.c
14
15 GLCPP_SOURCES = \
16         $(LIBGLCPP_SOURCES) \
17         ralloc.c \
18         glcpp/glcpp.c
19
20 C_SOURCES = \
21         strtod.c \
22         ralloc.c \
23         $(LIBGLCPP_SOURCES)
24
25 CXX_SOURCES = \
26         ast_expr.cpp \
27         ast_function.cpp \
28         ast_to_hir.cpp \
29         ast_type.cpp \
30         glsl_lexer.cpp \
31         glsl_parser.cpp \
32         glsl_parser_extras.cpp \
33         glsl_types.cpp \
34         glsl_symbol_table.cpp \
35         hir_field_selection.cpp \
36         ir_basic_block.cpp \
37         ir_clone.cpp \
38         ir_constant_expression.cpp \
39         ir.cpp \
40         ir_expression_flattening.cpp \
41         ir_function_can_inline.cpp \
42         ir_function.cpp \
43         ir_hierarchical_visitor.cpp \
44         ir_hv_accept.cpp \
45         ir_import_prototypes.cpp \
46         ir_print_visitor.cpp \
47         ir_reader.cpp \
48         ir_rvalue_visitor.cpp \
49         ir_set_program_inouts.cpp \
50         ir_validate.cpp \
51         ir_variable.cpp \
52         ir_variable_refcount.cpp \
53         linker.cpp \
54         link_functions.cpp \
55         loop_analysis.cpp \
56         loop_controls.cpp \
57         loop_unroll.cpp \
58         lower_discard.cpp \
59         lower_if_to_cond_assign.cpp \
60         lower_instructions.cpp \
61         lower_jumps.cpp \
62         lower_mat_op_to_vec.cpp \
63         lower_noise.cpp \
64         lower_texture_projection.cpp \
65         lower_variable_index_to_cond_assign.cpp \
66         lower_vec_index_to_cond_assign.cpp \
67         lower_vec_index_to_swizzle.cpp \
68         lower_vector.cpp \
69         opt_algebraic.cpp \
70         opt_constant_folding.cpp \
71         opt_constant_propagation.cpp \
72         opt_constant_variable.cpp \
73         opt_copy_propagation.cpp \
74         opt_copy_propagation_elements.cpp \
75         opt_dead_code.cpp \
76         opt_dead_code_local.cpp \
77         opt_dead_functions.cpp \
78         opt_discard_simplification.cpp \
79         opt_function_inlining.cpp \
80         opt_if_simplification.cpp \
81         opt_noop_swizzle.cpp \
82         opt_redundant_jumps.cpp \
83         opt_structure_splitting.cpp \
84         opt_swizzle_swizzle.cpp \
85         opt_tree_grafting.cpp \
86         s_expression.cpp
87
88 LIBS = \
89         $(TOP)/src/glsl/libglsl.a
90
91 APPS = glsl_compiler glcpp/glcpp
92
93 GLSL2_C_SOURCES = \
94         ../mesa/program/hash_table.c \
95         ../mesa/program/symbol_table.c
96 GLSL2_CXX_SOURCES = \
97         main.cpp
98
99 GLSL2_OBJECTS = \
100         $(GLSL2_C_SOURCES:.c=.o) \
101         $(GLSL2_CXX_SOURCES:.cpp=.o)
102
103 ### Basic defines ###
104
105 DEFINES += \
106         $(LIBRARY_DEFINES) \
107         $(API_DEFINES)
108
109 GLCPP_OBJECTS = \
110         $(GLCPP_SOURCES:.c=.o) \
111         ../mesa/program/hash_table.o
112
113 OBJECTS = \
114         $(C_SOURCES:.c=.o) \
115         $(CXX_SOURCES:.cpp=.o)
116
117 DRICORE_OBJ_DIR = obj-visible
118 OBJECTS_DRICORE = $(addprefix $(DRICORE_OBJ_DIR)/,$(OBJECTS))
119
120 INCLUDES = \
121         -I. \
122         -I../mesa \
123         -I../mapi \
124         -I../../include \
125         $(LIBRARY_INCLUDES)
126
127 ALL_SOURCES = \
128         $(C_SOURCES) \
129         $(CXX_SOURCES) \
130         $(GLSL2_CXX_SOURCES) \
131         $(GLSL2_C_SOURCES)
132
133 ##### TARGETS #####
134
135 default: depend lib$(LIBNAME).a $(APPS) $(DRICORE_GLSL_LIBS)
136
137 $(TOP)/$(LIB_DIR)/libglsl.so: $(OBJECTS_DRICORE) builtin_function.o Makefile $(TOP)/src/glsl/Makefile.template
138         $(MKLIB) -o $@ -linker '$(CXX)' -ldflags '$(LDFLAGS)' \
139                 -cplusplus -noprefix \
140                 -install $(TOP)/$(LIB_DIR) -id $(INSTALL_LIB_DIR)/$@.dylib \
141                 $(OBJECTS_DRICORE) builtin_function.o
142
143 lib$(LIBNAME).a: $(OBJECTS) builtin_function.o Makefile $(TOP)/src/glsl/Makefile.template
144         $(MKLIB) -cplusplus -o $(LIBNAME) -static $(OBJECTS) builtin_function.o
145
146 depend: $(ALL_SOURCES) Makefile
147         rm -f depend
148         touch depend
149         $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(ALL_SOURCES) 2> /dev/null
150
151 # Remove .o and backup files
152 clean: clean-dricore
153         rm -f $(GLCPP_OBJECTS) $(GLSL2_OBJECTS) $(OBJECTS) lib$(LIBNAME).a depend depend.bak builtin_function.cpp builtin_function.o builtin_stubs.o builtin_compiler
154         -rm -f $(APPS)
155
156 clean-dricore:
157         -rm -f $(DRICORE_OBJ_DIR) $(TOP)/$(LIB_DIR)/libglsl.so libglsl.so
158
159 ifneq (,$(DRICORE_GLSL_LIBS))
160 DRICORE_INSTALL_TARGET = install-dricore
161 endif
162
163 # Dummy target
164 install: $(DRICORE_INSTALL_TARGET)
165         @echo -n ""
166
167 install-dricore: default
168         $(INSTALL) -d $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR)
169         $(INSTALL) -m 755 $(DRICORE_GLSL_LIBS) $(DESTDIR)$(DRI_DRIVER_INSTALL_DIR)
170
171 ##### RULES #####
172
173 glsl_compiler: $(GLSL2_OBJECTS) libglsl.a builtin_stubs.o
174         $(APP_CXX) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(GLSL2_OBJECTS) builtin_stubs.o $(LIBS) -o $@
175
176 glcpp: glcpp/glcpp
177 glcpp/glcpp: $(GLCPP_OBJECTS)
178         $(APP_CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(GLCPP_OBJECTS) -o $@
179
180 .cpp.o:
181         $(CXX) -c $(INCLUDES) $(CXXFLAGS) $(DEFINES) $< -o $@
182
183 .c.o:
184         $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
185
186 $(DRICORE_OBJ_DIR)/%.o : %.cpp
187         @mkdir -p $(dir $@)
188         $(CXX) -c $(INCLUDES) $(DRI_CXXFLAGS) $(DEFINES) $< -o $@
189
190 $(DRICORE_OBJ_DIR)/%.o : %.c
191         @mkdir -p $(dir $@)
192         $(CC) -c $(INCLUDES) $(DRI_CFLAGS) $(DEFINES) $< -o $@
193
194 glsl_lexer.cpp: glsl_lexer.ll
195         $(FLEX) --nounistd -o$@  $<
196
197 glsl_parser.cpp: glsl_parser.yy
198         $(BISON) -v -o "$@" -p "_mesa_glsl_" --defines=glsl_parser.h $<
199
200 glcpp/glcpp-lex.c: glcpp/glcpp-lex.l
201         $(FLEX) --nounistd -o$@  $<
202
203 glcpp/glcpp-parse.c: glcpp/glcpp-parse.y
204         $(BISON) -v -o "$@" --defines=glcpp/glcpp-parse.h $<
205
206 builtin_compiler: $(GLSL2_OBJECTS) $(OBJECTS) builtin_stubs.o
207         $(APP_CXX) $(INCLUDES) $(CXXFLAGS) $(LDFLAGS) $(OBJECTS) $(GLSL2_OBJECTS) builtin_stubs.o -o $@
208
209 builtin_function.cpp: builtins/profiles/* builtins/ir/* builtins/tools/generate_builtins.py builtins/tools/texture_builtins.py builtin_compiler
210         @echo Regenerating builtin_function.cpp...
211         $(PYTHON2) $(PYTHON_FLAGS) builtins/tools/generate_builtins.py ./builtin_compiler > builtin_function.cpp || rm -f builtin_function.cpp
212
213 -include depend