Merge branch 'master' into glsl2
[mesa.git] / src / mesa / Makefile
1 # src/mesa/Makefile
2
3 TOP = ../..
4 include $(TOP)/configs/current
5
6 MESA_LIBS := libmesa.a libmesagallium.a
7 DEPENDS := depend
8
9 ifeq ($(GLES_OVERLAY),1)
10 ES1_LIBS := libes1gallium.a
11 ES2_LIBS := libes2gallium.a
12 DEPENDS += depend.es1 depend.es2
13 endif
14
15 MESA_OBJ_DIR := .
16 ES1_OBJ_DIR := objs-es1
17 ES2_OBJ_DIR := objs-es2
18
19 MESA_CPPFLAGS := $(API_DEFINES)
20 ES1_CPPFLAGS := -DFEATURE_ES1=1
21 ES2_CPPFLAGS := -DFEATURE_ES2=1
22
23 ifeq ($(MESA_LLVM),1)
24 MESA_CPPFLAGS += $(LLVM_CFLAGS)
25 ES1_CPPFLAGS += $(LLVM_CFLAGS)
26 ES2_CPPFLAGS += $(LLVM_CFLAGS)
27 endif
28
29
30 include sources.mak
31
32 # adjust object dirs
33 ES1_OBJECTS := $(addprefix $(ES1_OBJ_DIR)/, $(MESA_OBJECTS))
34 ES2_OBJECTS := $(addprefix $(ES2_OBJ_DIR)/, $(MESA_OBJECTS))
35 MESA_OBJECTS := $(addprefix $(MESA_OBJ_DIR)/, $(MESA_OBJECTS))
36
37 ES1_GALLIUM_OBJECTS := $(addprefix $(ES1_OBJ_DIR)/, $(MESA_GALLIUM_OBJECTS))
38 ES2_GALLIUM_OBJECTS := $(addprefix $(ES2_OBJ_DIR)/, $(MESA_GALLIUM_OBJECTS))
39 MESA_GALLIUM_OBJECTS := $(addprefix $(MESA_OBJ_DIR)/, $(MESA_GALLIUM_OBJECTS))
40
41 # adjust include dirs
42 MESA_INCLUDES := $(INCLUDE_DIRS)
43 ES1_INCLUDES := -I$(TOP)/src/mapi/es1api $(INCLUDE_DIRS)
44 ES2_INCLUDES := -I$(TOP)/src/mapi/es2api $(INCLUDE_DIRS)
45 MESA_INCLUDES := -I$(TOP)/src/glsl $(MESA_INCLUDES)
46 # For symbol_table.h in glsl compiler headers.
47 MESA_INCLUDES := -I$(TOP)/src/mesa/shader $(MESA_INCLUDES)
48
49 define mesa-cc-c
50 @mkdir -p $(dir $@)
51 $(CC) -c -o $@ $< $($(1)_CPPFLAGS) $($(1)_INCLUDES) $(CFLAGS)
52 endef
53
54 define mesa-cxx-c
55 @mkdir -p $(dir $@)
56 $(CXX) -c -o $@ $< $($(1)_CPPFLAGS) $($(1)_INCLUDES) $(CXXFLAGS)
57 endef
58
59 $(MESA_OBJ_DIR)/%.o: %.c
60 $(call mesa-cc-c,MESA)
61
62 $(MESA_OBJ_DIR)/%.o: %.cpp
63 $(call mesa-cxx-c,MESA)
64
65 $(MESA_OBJ_DIR)/%.o: %.S
66 $(call mesa-cc-c,MESA)
67
68 $(ES1_OBJ_DIR)/%.o: %.c
69 $(call mesa-cc-c,ES1)
70
71 $(ES1_OBJ_DIR)/%.o: %.S
72 $(call mesa-cc-c,ES1)
73
74 $(ES2_OBJ_DIR)/%.o: %.c
75 $(call mesa-cc-c,ES2)
76
77 $(ES2_OBJ_DIR)/%.o: %.S
78 $(call mesa-cc-c,ES2)
79
80
81 # Default: build dependencies, then asm_subdirs, GLSL built-in lib,
82 # then convenience libs (.a) and finally the device drivers:
83 default: $(DEPENDS) asm_subdirs \
84 $(MESA_LIBS) $(ES1_LIBS) $(ES2_LIBS) driver_subdirs
85
86 main/api_exec_es1.c: main/APIspec.xml main/es_generator.py main/APIspecutil.py main/APIspec.py
87 $(PYTHON2) $(PYTHON_FLAGS) main/es_generator.py -S main/APIspec.xml -V GLES1.1 > $@
88
89 main/api_exec_es2.c: main/APIspec.xml main/es_generator.py main/APIspecutil.py main/APIspec.py
90 $(PYTHON2) $(PYTHON_FLAGS) main/es_generator.py -S main/APIspec.xml -V GLES2.0 > $@
91
92 ######################################################################
93 # Helper libraries used by many drivers:
94
95 # Make archive of core mesa object files
96 libmesa.a: $(MESA_OBJECTS) $(GLSL_LIBS)
97 @ $(MKLIB) -o mesa -static $(MESA_OBJECTS) $(GLSL_LIBS)
98
99 libes1.a: $(ES1_OBJECTS) $(GLSL_LIBS)
100 @$(MKLIB) -o es1 -static $(ES1_OBJECTS) $(GLSL_LIBS)
101
102 libes2.a: $(ES2_OBJECTS) $(GLSL_LIBS)
103 @$(MKLIB) -o es2 -static $(ES2_OBJECTS) $(GLSL_LIBS)
104
105 # Make archive of subset of core mesa object files for gallium
106 libmesagallium.a: $(MESA_GALLIUM_OBJECTS) $(GLSL_LIBS)
107 @ $(MKLIB) -o mesagallium -static $(MESA_GALLIUM_OBJECTS) $(GLSL_LIBS)
108
109 libes1gallium.a: $(ES1_GALLIUM_OBJECTS) $(GLSL_LIBS)
110 @$(MKLIB) -o es1gallium -static $(ES1_GALLIUM_OBJECTS) $(GLSL_LIBS)
111
112 libes2gallium.a: $(ES2_GALLIUM_OBJECTS) $(GLSL_LIBS)
113 @$(MKLIB) -o es2gallium -static $(ES2_GALLIUM_OBJECTS) $(GLSL_LIBS)
114
115 ######################################################################
116 # Device drivers
117 driver_subdirs: $(MESA_LIBS)
118 @ (cd drivers && $(MAKE))
119
120
121 ######################################################################
122 # Assembly subdirs
123 asm_subdirs:
124 @ if echo "$(ASM_FLAGS)" | grep -q USE_X86_ASM ; then \
125 (cd x86 && $(MAKE)) || exit 1 ; \
126 fi
127 @ if echo "$(ASM_FLAGS)" | grep -q USE_X86_64_ASM ; then \
128 (cd x86 && $(MAKE)) || exit 1 ; \
129 (cd x86-64 && $(MAKE)) || exit 1 ; \
130 fi
131
132
133 ######################################################################
134 # Dependency generation
135
136 depend: $(ALL_SOURCES)
137 @ echo "running $(MKDEP)"
138 @ touch depend
139 @$(MKDEP) $(MKDEP_OPTIONS) -p$(MESA_OBJ_DIR)/ $(DEFINES) \
140 $(INCLUDE_DIRS) $(ALL_SOURCES) > /dev/null 2>/dev/null
141
142 depend.es1: $(ALL_SOURCES)
143 @echo "running $(MKDEP) for ES1"
144 @touch $@
145 @$(MKDEP) $(MKDEP_OPTIONS) -f$@ -p$(ES1_OBJ_DIR)/ $(DEFINES) \
146 $(ES1_CPPFLAGS) $(ES1_INCLUDES) $(ALL_SOURCES) \
147 > /dev/null 2>/dev/null
148
149 depend.es2: $(ALL_SOURCES)
150 @echo "running $(MKDEP) for ES2"
151 @touch $@
152 @$(MKDEP) $(MKDEP_OPTIONS) -f$@ -p$(ES2_OBJ_DIR)/ $(DEFINES) \
153 $(ES2_CPPFLAGS) $(ES2_INCLUDES) $(ALL_SOURCES) \
154 > /dev/null 2>/dev/null
155
156 ######################################################################
157 # Installation rules
158
159 # this isn't fleshed out yet but is probably the way to go in the future
160 new_install:
161 (cd drivers && $(MAKE) install)
162
163
164 # XXX replace this with new_install above someday
165 install: default
166 @for driver in $(DRIVER_DIRS) ; do \
167 case "$$driver" in \
168 osmesa) if [ "$(DRIVER_DIRS)" = osmesa ]; then \
169 $(MAKE) install-headers install-osmesa || exit 1 ; \
170 else \
171 $(MAKE) install-osmesa || exit 1 ; \
172 fi ;; \
173 dri) $(MAKE) install-libgl install-dri || exit 1 ;; \
174 *) $(MAKE) install-libgl || exit 1 ;; \
175 esac ; \
176 done
177
178 pcedit = \
179 -e 's,@INSTALL_DIR@,$(INSTALL_DIR),' \
180 -e 's,@INSTALL_LIB_DIR@,$(INSTALL_LIB_DIR),' \
181 -e 's,@INSTALL_INC_DIR@,$(INSTALL_INC_DIR),' \
182 -e 's,@VERSION@,$(MESA_MAJOR).$(MESA_MINOR).$(MESA_TINY),' \
183
184
185 gl_pcedit = sed \
186 $(pcedit) \
187 -e 's,@GL_PC_REQ_PRIV@,$(GL_PC_REQ_PRIV),' \
188 -e 's,@GL_PC_LIB_PRIV@,$(GL_PC_LIB_PRIV),' \
189 -e 's,@GL_PC_CFLAGS@,$(GL_PC_CFLAGS),' \
190 -e 's,@GL_LIB@,$(GL_LIB),'
191
192 gl.pc: gl.pc.in
193 $(gl_pcedit) $< > $@
194
195 osmesa_pcedit = sed \
196 $(pcedit) \
197 -e 's,@OSMESA_LIB@,$(OSMESA_LIB),' \
198 -e 's,@OSMESA_PC_REQ@,$(OSMESA_PC_REQ),' \
199 -e 's,@OSMESA_PC_LIB_PRIV@,$(OSMESA_PC_LIB_PRIV),'
200
201 osmesa.pc: osmesa.pc.in
202 $(osmesa_pcedit) $< > $@
203
204 install-headers:
205 $(INSTALL) -d $(DESTDIR)$(INSTALL_INC_DIR)/GL
206 $(INSTALL) -m 644 $(TOP)/include/GL/*.h \
207 $(DESTDIR)$(INSTALL_INC_DIR)/GL
208
209 install-libgl: default gl.pc install-headers
210 $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)
211 $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
212 $(MINSTALL) $(TOP)/$(LIB_DIR)/$(GL_LIB_GLOB) \
213 $(DESTDIR)$(INSTALL_LIB_DIR)
214 $(INSTALL) -m 644 gl.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
215
216 install-osmesa: default osmesa.pc
217 $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)
218 $(INSTALL) -d $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
219 $(MINSTALL) $(TOP)/$(LIB_DIR)/$(OSMESA_LIB_GLOB) \
220 $(DESTDIR)$(INSTALL_LIB_DIR)
221 $(INSTALL) -m 644 osmesa.pc $(DESTDIR)$(INSTALL_LIB_DIR)/pkgconfig
222
223 install-dri: default
224 cd drivers/dri && $(MAKE) install
225
226
227
228 # Emacs tags
229 tags:
230 etags `find . -name \*.[ch]` $(TOP)/include/GL/*.h
231
232 clean-es1:
233 -rm -f $(ES1_LIBS)
234 -rm -rf $(ES1_OBJ_DIR)
235 -rm -f depend.es1 depend.es1.bak
236
237 clean-es2:
238 -rm -f $(ES2_LIBS)
239 -rm -rf $(ES2_OBJ_DIR)
240 -rm -f depend.es2 depend.es2.bak
241
242 clean: clean-es1 clean-es2
243 -rm -f */*.o
244 -rm -f */*/*.o
245 -rm -f depend depend.bak libmesa.a libmesagallium.a
246 -rm -f drivers/*/*.o
247 -rm -f *.pc
248 -@cd drivers/dri && $(MAKE) clean
249 -@cd drivers/x11 && $(MAKE) clean
250 -@cd drivers/osmesa && $(MAKE) clean
251 -@cd x86 && $(MAKE) clean
252 -@cd x86-64 && $(MAKE) clean
253
254
255 -include $(DEPENDS)