glsl2: Add pass to remove redundant jumps
[profile/ivi/mesa.git] / src / glsl / Makefile
1 #src/glsl/pp/Makefile
2
3 TOP = ../..
4
5 include $(TOP)/configs/current
6
7 LIBNAME = glsl
8
9 LIBGLCPP_SOURCES = \
10         glcpp/glcpp-lex.c \
11         glcpp/glcpp-parse.c \
12         glcpp/pp.c
13
14 GLCPP_SOURCES = \
15         $(LIBGLCPP_SOURCES) \
16         glcpp/glcpp.c
17
18 C_SOURCES = \
19         $(LIBGLCPP_SOURCES)
20
21 CXX_SOURCES = \
22         ast_expr.cpp \
23         ast_function.cpp \
24         ast_to_hir.cpp \
25         ast_type.cpp \
26         builtin_function.cpp \
27         glsl_lexer.cpp \
28         glsl_parser.cpp \
29         glsl_parser_extras.cpp \
30         glsl_types.cpp \
31         glsl_symbol_table.cpp \
32         hir_field_selection.cpp \
33         ir_algebraic.cpp \
34         ir_basic_block.cpp \
35         ir_clone.cpp \
36         ir_constant_expression.cpp \
37         ir_constant_folding.cpp \
38         ir_constant_propagation.cpp \
39         ir_constant_variable.cpp \
40         ir_copy_propagation.cpp \
41         ir.cpp \
42         ir_dead_code.cpp \
43         ir_dead_code_local.cpp \
44         ir_dead_functions.cpp \
45         ir_div_to_mul_rcp.cpp \
46         ir_explog_to_explog2.cpp \
47         ir_expression_flattening.cpp \
48         ir_function_can_inline.cpp \
49         ir_function.cpp \
50         ir_function_inlining.cpp \
51         ir_hierarchical_visitor.cpp \
52         ir_hv_accept.cpp \
53         ir_if_simplification.cpp \
54         ir_if_to_cond_assign.cpp \
55         ir_import_prototypes.cpp \
56         ir_lower_jumps.cpp \
57         ir_mat_op_to_vec.cpp \
58         ir_mod_to_fract.cpp \
59         ir_noop_swizzle.cpp \
60         ir_print_visitor.cpp \
61         ir_reader.cpp \
62         ir_rvalue_visitor.cpp \
63         ir_set_program_inouts.cpp \
64         ir_structure_splitting.cpp \
65         ir_sub_to_add_neg.cpp \
66         ir_swizzle_swizzle.cpp \
67         ir_tree_grafting.cpp \
68         ir_validate.cpp \
69         ir_variable.cpp \
70         ir_variable_refcount.cpp \
71         ir_vec_index_to_cond_assign.cpp \
72         ir_vec_index_to_swizzle.cpp \
73         linker.cpp \
74         link_functions.cpp \
75         loop_analysis.cpp \
76         loop_controls.cpp \
77         loop_unroll.cpp \
78         lower_noise.cpp \
79         opt_redundant_jumps.cpp \
80         s_expression.cpp
81
82 LIBS = \
83         $(TOP)/src/glsl/libglsl.a \
84         $(TALLOC_LIBS)
85
86 APPS = glsl_compiler glcpp/glcpp
87
88 GLSL2_C_SOURCES = \
89         ../mesa/program/hash_table.c \
90         ../mesa/program/symbol_table.c
91 GLSL2_CXX_SOURCES = \
92         main.cpp
93
94 GLSL2_OBJECTS = \
95         $(GLSL2_C_SOURCES:.c=.o) \
96         $(GLSL2_CXX_SOURCES:.cpp=.o)
97
98 ### Basic defines ###
99
100 DEFINES += \
101         $(LIBRARY_DEFINES) \
102         $(API_DEFINES)
103
104 GLCPP_OBJECTS = \
105         $(GLCPP_SOURCES:.c=.o) \
106         ../mesa/program/hash_table.o
107
108 OBJECTS = \
109         $(C_SOURCES:.c=.o) \
110         $(CXX_SOURCES:.cpp=.o)
111
112 INCLUDES = \
113         $(TALLOC_CFLAGS) \
114         -I. \
115         -I../mesa \
116         -I../mapi \
117         -I../../include \
118         $(LIBRARY_INCLUDES)
119
120 ALL_SOURCES = \
121         $(C_SOURCES) \
122         $(CXX_SOURCES) \
123         $(GLSL2_CXX_SOURCES) \
124         $(GLSL2_C_SOURCES)
125
126 ##### TARGETS #####
127
128 default: depend lib$(LIBNAME).a $(APPS)
129
130 lib$(LIBNAME).a: $(OBJECTS) Makefile $(TOP)/src/glsl/Makefile.template
131         $(MKLIB) -cplusplus -o $(LIBNAME) -static $(OBJECTS)
132
133 depend: $(ALL_SOURCES) Makefile
134         rm -f depend
135         touch depend
136         $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(ALL_SOURCES) 2> /dev/null
137
138 # Remove .o and backup files
139 clean:
140         rm -f $(GLCPP_OBJECTS) $(GLSL2_OBJECTS) $(OBJECTS) lib$(LIBNAME).a depend depend.bak
141         -rm -f $(APPS)
142
143 # Dummy target
144 install:
145         @echo -n ""
146
147
148 ##### RULES #####
149
150 glsl_compiler: $(GLSL2_OBJECTS) libglsl.a
151         $(APP_CXX) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(GLSL2_OBJECTS) $(LIBS) -o $@
152
153 glcpp/glcpp: $(GLCPP_OBJECTS) libglsl.a
154         $(APP_CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(GLCPP_OBJECTS) $(LIBS) -o $@
155
156 .cpp.o:
157         $(CXX) -c $(INCLUDES) $(CXXFLAGS) $(DEFINES) $< -o $@
158
159 .c.o:
160         $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
161
162 glsl_lexer.cpp: glsl_lexer.lpp
163         flex --nounistd -o$@  $<
164
165 glsl_parser.cpp: glsl_parser.ypp
166         bison -v -o "$@" -p "_mesa_glsl_" --defines=glsl_parser.h $<
167
168 glcpp/glcpp-lex.c: glcpp/glcpp-lex.l
169         flex --nounistd -o$@  $<
170
171 glcpp/glcpp-parse.c: glcpp/glcpp-parse.y
172         bison -v -o "$@" --defines=glcpp/glcpp-parse.h $<
173
174 builtins: builtin_function.cpp builtins/profiles/* builtins/ir/* builtins/tools/generate_builtins.py builtins/tools/texture_builtins.py
175         @echo Bootstrapping the compiler...
176         cp builtins/tools/builtin_function.cpp .
177         make glsl_compiler
178         @echo Regenerating builtin_function.cpp...
179         ./builtins/tools/generate_builtins.py > builtin_function.cpp
180         @echo Rebuilding the real compiler...
181         make glsl_compiler
182
183 -include depend