glsl: Fix parallel build.
[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 ralloc.c \
17 glcpp/glcpp.c
18
19 C_SOURCES = \
20 strtod.c \
21 ralloc.c \
22 $(LIBGLCPP_SOURCES)
23
24 CXX_SOURCES = \
25 ast_expr.cpp \
26 ast_function.cpp \
27 ast_to_hir.cpp \
28 ast_type.cpp \
29 glsl_lexer.cpp \
30 glsl_parser.cpp \
31 glsl_parser_extras.cpp \
32 glsl_types.cpp \
33 glsl_symbol_table.cpp \
34 hir_field_selection.cpp \
35 ir_basic_block.cpp \
36 ir_clone.cpp \
37 ir_constant_expression.cpp \
38 ir.cpp \
39 ir_expression_flattening.cpp \
40 ir_function_can_inline.cpp \
41 ir_function.cpp \
42 ir_hierarchical_visitor.cpp \
43 ir_hv_accept.cpp \
44 ir_import_prototypes.cpp \
45 ir_print_visitor.cpp \
46 ir_reader.cpp \
47 ir_rvalue_visitor.cpp \
48 ir_set_program_inouts.cpp \
49 ir_validate.cpp \
50 ir_variable.cpp \
51 ir_variable_refcount.cpp \
52 linker.cpp \
53 link_functions.cpp \
54 loop_analysis.cpp \
55 loop_controls.cpp \
56 loop_unroll.cpp \
57 lower_discard.cpp \
58 lower_if_to_cond_assign.cpp \
59 lower_instructions.cpp \
60 lower_jumps.cpp \
61 lower_mat_op_to_vec.cpp \
62 lower_noise.cpp \
63 lower_texture_projection.cpp \
64 lower_variable_index_to_cond_assign.cpp \
65 lower_vec_index_to_cond_assign.cpp \
66 lower_vec_index_to_swizzle.cpp \
67 lower_vector.cpp \
68 opt_algebraic.cpp \
69 opt_constant_folding.cpp \
70 opt_constant_propagation.cpp \
71 opt_constant_variable.cpp \
72 opt_copy_propagation.cpp \
73 opt_copy_propagation_elements.cpp \
74 opt_dead_code.cpp \
75 opt_dead_code_local.cpp \
76 opt_dead_functions.cpp \
77 opt_discard_simplification.cpp \
78 opt_function_inlining.cpp \
79 opt_if_simplification.cpp \
80 opt_noop_swizzle.cpp \
81 opt_redundant_jumps.cpp \
82 opt_structure_splitting.cpp \
83 opt_swizzle_swizzle.cpp \
84 opt_tree_grafting.cpp \
85 s_expression.cpp
86
87 LIBS = \
88 $(TOP)/src/glsl/libglsl.a
89
90 APPS = glsl_compiler glcpp/glcpp
91
92 GLSL2_C_SOURCES = \
93 ../mesa/program/hash_table.c \
94 ../mesa/program/symbol_table.c
95 GLSL2_CXX_SOURCES = \
96 main.cpp
97
98 GLSL2_OBJECTS = \
99 $(GLSL2_C_SOURCES:.c=.o) \
100 $(GLSL2_CXX_SOURCES:.cpp=.o)
101
102 ### Basic defines ###
103
104 DEFINES += \
105 $(LIBRARY_DEFINES) \
106 $(API_DEFINES)
107
108 GLCPP_OBJECTS = \
109 $(GLCPP_SOURCES:.c=.o) \
110 ../mesa/program/hash_table.o
111
112 OBJECTS = \
113 $(C_SOURCES:.c=.o) \
114 $(CXX_SOURCES:.cpp=.o)
115
116 INCLUDES = \
117 -I. \
118 -I../mesa \
119 -I../mapi \
120 -I../../include \
121 $(LIBRARY_INCLUDES)
122
123 ALL_SOURCES = \
124 $(C_SOURCES) \
125 $(CXX_SOURCES) \
126 $(GLSL2_CXX_SOURCES) \
127 $(GLSL2_C_SOURCES)
128
129 ##### TARGETS #####
130
131 default: depend lib$(LIBNAME).a $(APPS)
132
133 lib$(LIBNAME).a: $(OBJECTS) builtin_function.o Makefile $(TOP)/src/glsl/Makefile.template
134 $(MKLIB) -cplusplus -o $(LIBNAME) -static $(OBJECTS) builtin_function.o
135
136 depend: $(ALL_SOURCES) Makefile
137 rm -f depend
138 touch depend
139 $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(ALL_SOURCES) 2> /dev/null
140
141 # Remove .o and backup files
142 clean:
143 rm -f $(GLCPP_OBJECTS) $(GLSL2_OBJECTS) $(OBJECTS) lib$(LIBNAME).a depend depend.bak builtin_function.cpp builtin_function.o builtin_stubs.o builtin_compiler
144 -rm -f $(APPS)
145
146 # Dummy target
147 install:
148 @echo -n ""
149
150
151 ##### RULES #####
152
153 glsl_compiler: $(GLSL2_OBJECTS) libglsl.a builtin_stubs.o
154 $(APP_CXX) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(GLSL2_OBJECTS) builtin_stubs.o $(LIBS) -o $@
155
156 glcpp: glcpp/glcpp
157 glcpp/glcpp: $(GLCPP_OBJECTS)
158 $(APP_CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(GLCPP_OBJECTS) -o $@
159
160 .cpp.o:
161 $(CXX) -c $(INCLUDES) $(CXXFLAGS) $(DEFINES) $< -o $@
162
163 .c.o:
164 $(CC) -c $(INCLUDES) $(CFLAGS) $(DEFINES) $< -o $@
165
166 glsl_lexer.cpp: glsl_lexer.lpp
167 flex --nounistd -o$@ $<
168
169 glsl_parser.cpp: glsl_parser.ypp
170 bison -v -o "$@" -p "_mesa_glsl_" --defines=glsl_parser.h $<
171
172 glcpp/glcpp-lex.c: glcpp/glcpp-lex.l
173 flex --nounistd -o$@ $<
174
175 glcpp/glcpp-parse.c: glcpp/glcpp-parse.y
176 bison -v -o "$@" --defines=glcpp/glcpp-parse.h $<
177
178 builtin_compiler: $(GLSL2_OBJECTS) $(OBJECTS) builtin_stubs.o
179 $(APP_CXX) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(OBJECTS) $(GLSL2_OBJECTS) builtin_stubs.o -o $@
180
181 builtin_function.cpp: builtins/profiles/* builtins/ir/* builtins/tools/generate_builtins.py builtins/tools/texture_builtins.py builtin_compiler
182 @echo Regenerating builtin_function.cpp...
183 $(PYTHON2) $(PYTHON_FLAGS) builtins/tools/generate_builtins.py $(PWD)/builtin_compiler > builtin_function.cpp
184
185 -include depend