Build a standalone glcpp binary.
[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 glcpp/xtalloc.c
14
15 GLCPP_SOURCES = \
16 $(LIBGLCPP_SOURCES) \
17 glcpp/glcpp.c
18
19 C_SOURCES = \
20 $(LIBGLCPP_SOURCES)
21
22 CXX_SOURCES = \
23 ast_expr.cpp \
24 ast_function.cpp \
25 ast_to_hir.cpp \
26 ast_type.cpp \
27 builtin_function.cpp \
28 glsl_lexer.cpp \
29 glsl_parser.cpp \
30 glsl_parser_extras.cpp \
31 glsl_types.cpp \
32 hir_field_selection.cpp \
33 ir_basic_block.cpp \
34 ir_clone.cpp \
35 ir_constant_expression.cpp \
36 ir_constant_folding.cpp \
37 ir_constant_variable.cpp \
38 ir_copy_propagation.cpp \
39 ir.cpp \
40 ir_dead_code.cpp \
41 ir_dead_code_local.cpp \
42 ir_div_to_mul_rcp.cpp \
43 ir_expression_flattening.cpp \
44 ir_function_can_inline.cpp \
45 ir_function.cpp \
46 ir_function_inlining.cpp \
47 ir_hierarchical_visitor.cpp \
48 ir_hv_accept.cpp \
49 ir_if_return.cpp \
50 ir_if_simplification.cpp \
51 ir_if_to_cond_assign.cpp \
52 ir_mat_op_to_vec.cpp \
53 ir_mod_to_fract.cpp \
54 ir_print_visitor.cpp \
55 ir_reader.cpp \
56 ir_swizzle_swizzle.cpp \
57 ir_validate.cpp \
58 ir_variable.cpp \
59 ir_vec_index_to_cond_assign.cpp \
60 ir_vec_index_to_swizzle.cpp \
61 linker.cpp \
62 link_functions.cpp \
63 s_expression.cpp
64
65 LIBS = \
66 $(TOP)/src/glsl/libglsl.a \
67 $(shell pkg-config --libs talloc)
68
69 APPS = glsl_compiler glcpp/glcpp
70
71 GLSL2_C_SOURCES = \
72 ../mesa/shader/hash_table.c \
73 ../mesa/shader/symbol_table.c
74 GLSL2_CXX_SOURCES = \
75 main.cpp
76
77 GLSL2_OBJECTS = \
78 $(GLSL2_C_SOURCES:.c=.o) \
79 $(GLSL2_CXX_SOURCES:.cpp=.o)
80
81 ### Basic defines ###
82
83 GLCPP_OBJECTS = \
84 $(GLCPP_SOURCES:.c=.o) \
85 ../mesa/shader/hash_table.o
86
87 OBJECTS = \
88 $(C_SOURCES:.c=.o) \
89 $(CXX_SOURCES:.cpp=.o)
90
91 INCLUDES = \
92 -I. \
93 -I../mesa \
94 -I../mapi \
95 -I../mesa/shader \
96 $(LIBRARY_INCLUDES)
97
98 ALL_SOURCES = \
99 $(C_SOURCES) \
100 $(CXX_SOURCES) \
101 $(GLSL2_CXX_SOURCES) \
102 $(GLSL2_C_SOURCES)
103
104 ##### TARGETS #####
105
106 default: depend lib$(LIBNAME).a $(APPS)
107
108 lib$(LIBNAME).a: $(OBJECTS) Makefile $(TOP)/src/glsl/Makefile.template
109 $(MKLIB) -cplusplus -o $(LIBNAME) -static $(OBJECTS)
110
111 depend: $(ALL_SOURCES) Makefile
112 rm -f depend
113 touch depend
114 $(MKDEP) $(MKDEP_OPTIONS) $(INCLUDES) $(ALL_SOURCES) 2> /dev/null
115
116 # Remove .o and backup files
117 clean:
118 rm -f $(OBJECTS) lib$(LIBNAME).a depend depend.bak
119 -rm -f $(APPS)
120
121 # Dummy target
122 install:
123 @echo -n ""
124
125
126 ##### RULES #####
127
128 glsl_compiler: $(GLSL2_OBJECTS) libglsl.a
129 $(APP_CXX) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(GLSL2_OBJECTS) $(LIBS) -o $@
130
131 glcpp/glcpp: $(GLCPP_OBJECTS) libglsl.a
132 $(APP_CC) $(INCLUDES) $(CFLAGS) $(LDFLAGS) $(GLCPP_OBJECTS) $(LIBS) -o $@
133
134 .cpp.o:
135 $(CXX) -c $(INCLUDES) $(CXXFLAGS) $(LIBRARY_DEFINES) $< -o $@
136
137 .c.o:
138 $(CC) -c $(INCLUDES) $(CFLAGS) $(LIBRARY_DEFINES) $< -o $@
139
140 glsl_lexer.cpp: glsl_lexer.lpp
141 flex --never-interactive --outfile="$@" $<
142
143 glsl_parser.cpp: glsl_parser.ypp
144 bison -v -o "$@" --defines=glsl_parser.h $<
145
146 glcpp/glcpp-lex.c: glcpp/glcpp-lex.l
147 flex --never-interactive --outfile="$@" $<
148
149 glcpp/glcpp-parse.c: glcpp/glcpp-parse.y
150 bison -v -o "$@" --defines=glcpp/glcpp-parse.h $<
151
152 builtin_function.cpp: builtins/*/*
153 ./builtins/tools/generate_builtins.pl > builtin_function.cpp
154
155 -include depend