android: make DRM optional
[mesa.git] / Android.mk
1 # Mesa 3-D graphics library
2 #
3 # Copyright (C) 2010-2011 Chia-I Wu <olvaffe@gmail.com>
4 # Copyright (C) 2010-2011 LunarG Inc.
5 #
6 # Permission is hereby granted, free of charge, to any person obtaining a
7 # copy of this software and associated documentation files (the "Software"),
8 # to deal in the Software without restriction, including without limitation
9 # the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 # and/or sell copies of the Software, and to permit persons to whom the
11 # Software is furnished to do so, subject to the following conditions:
12 #
13 # The above copyright notice and this permission notice shall be included
14 # in all copies or substantial portions of the Software.
15 #
16 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 # DEALINGS IN THE SOFTWARE.
23
24 # BOARD_GPU_DRIVERS should be defined. The valid values are
25 #
26 # classic drivers:
27 # gallium drivers: swrast i915g nouveau r300g r600g vmwgfx
28 #
29 # The main target is libGLES_mesa. There is no classic drivers yet.
30
31 MESA_TOP := $(call my-dir)
32 MESA_COMMON_MK := $(MESA_TOP)/Android.common.mk
33 MESA_PYTHON2 := python
34
35 DRM_TOP := external/drm
36 DRM_GRALLOC_TOP := hardware/drm_gralloc
37
38 classic_drivers :=
39 gallium_drivers := swrast i915g nouveau r300g r600g vmwgfx
40
41 MESA_GPU_DRIVERS := $(strip $(BOARD_GPU_DRIVERS))
42
43 # warn about invalid drivers
44 invalid_drivers := $(filter-out \
45 $(classic_drivers) $(gallium_drivers), $(MESA_GPU_DRIVERS))
46 ifneq ($(invalid_drivers),)
47 $(warning invalid GPU drivers: $(invalid_drivers))
48 # tidy up
49 MESA_GPU_DRIVERS := $(filter-out $(invalid_drivers), $(MESA_GPU_DRIVERS))
50 endif
51
52 # host and target must be the same arch to generate matypes.h
53 ifeq ($(TARGET_ARCH),$(HOST_ARCH))
54 MESA_ENABLE_ASM := true
55 else
56 MESA_ENABLE_ASM := false
57 endif
58
59 ifneq ($(filter $(classic_drivers), $(MESA_GPU_DRIVERS)),)
60 MESA_BUILD_CLASSIC := true
61 else
62 MESA_BUILD_CLASSIC := false
63 endif
64
65 ifneq ($(filter $(gallium_drivers), $(MESA_GPU_DRIVERS)),)
66 MESA_BUILD_GALLIUM := true
67 else
68 MESA_BUILD_GALLIUM := false
69 endif
70
71 ifneq ($(strip $(MESA_GPU_DRIVERS)),)
72
73 SUBDIRS := \
74 src/mapi \
75 src/glsl \
76 src/mesa \
77 src/egl/main
78
79 ifeq ($(strip $(MESA_BUILD_GALLIUM)),true)
80 SUBDIRS += src/gallium
81 endif
82
83 # ---------------------------------------
84 # Build libGLES_mesa
85 # ---------------------------------------
86
87 LOCAL_PATH := $(MESA_TOP)
88
89 include $(CLEAR_VARS)
90
91 LOCAL_SRC_FILES :=
92 LOCAL_CFLAGS :=
93 LOCAL_C_INCLUDES :=
94
95 LOCAL_STATIC_LIBRARIES :=
96 LOCAL_WHOLE_STATIC_LIBRARIES := libmesa_egl
97
98 LOCAL_SHARED_LIBRARIES := \
99 libglapi \
100 libdl \
101 libhardware \
102 liblog \
103 libcutils
104
105 # hardware drivers require DRM
106 ifneq ($(MESA_GPU_DRIVERS),swrast)
107 LOCAL_SHARED_LIBRARIES += libdrm
108 endif
109
110 ifeq ($(strip $(MESA_BUILD_GALLIUM)),true)
111
112 gallium_DRIVERS :=
113
114 # swrast
115 gallium_DRIVERS += libmesa_pipe_softpipe libmesa_winsys_sw_android
116
117 # i915g
118 ifneq ($(filter i915g, $(MESA_GPU_DRIVERS)),)
119 gallium_DRIVERS += libmesa_winsys_i915 libmesa_pipe_i915
120 LOCAL_SHARED_LIBRARIES += libdrm_intel
121 endif
122
123 # nouveau
124 ifneq ($(filter nouveau, $(MESA_GPU_DRIVERS)),)
125 gallium_DRIVERS += \
126 libmesa_winsys_nouveau \
127 libmesa_pipe_nvc0 \
128 libmesa_pipe_nv50 \
129 libmesa_pipe_nvfx \
130 libmesa_pipe_nouveau
131 LOCAL_SHARED_LIBRARIES += libdrm_nouveau
132 endif
133
134 # r300g/r600g
135 ifneq ($(filter r300g r600g, $(MESA_GPU_DRIVERS)),)
136 gallium_DRIVERS += libmesa_winsys_radeon
137 ifneq ($(filter r300g, $(MESA_GPU_DRIVERS)),)
138 gallium_DRIVERS += libmesa_pipe_r300
139 endif
140 ifneq ($(filter r600g, $(MESA_GPU_DRIVERS)),)
141 gallium_DRIVERS += libmesa_pipe_r600 libmesa_winsys_r600
142 endif
143 endif
144
145 # vmwgfx
146 ifneq ($(filter vmwgfx, $(MESA_GPU_DRIVERS)),)
147 gallium_DRIVERS += libmesa_winsys_svga libmesa_pipe_svga
148 endif
149
150 #
151 # Notes about the order here:
152 #
153 # * libmesa_st_egl depends on libmesa_winsys_sw_android in $(gallium_DRIVERS)
154 # * libmesa_pipe_r300 in $(gallium_DRIVERS) depends on libmesa_st_mesa and
155 # libmesa_glsl
156 # * libmesa_st_mesa depends on libmesa_glsl
157 # * libmesa_glsl depends on libmesa_glsl_utils
158 #
159 LOCAL_STATIC_LIBRARIES := \
160 libmesa_egl_gallium \
161 libmesa_st_egl \
162 $(gallium_DRIVERS) \
163 libmesa_st_mesa \
164 libmesa_glsl \
165 libmesa_glsl_utils \
166 libmesa_gallium \
167 $(LOCAL_STATIC_LIBRARIES)
168
169 endif # MESA_BUILD_GALLIUM
170
171 LOCAL_MODULE := libGLES_mesa
172 LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/egl
173
174 include $(MESA_COMMON_MK)
175 include $(BUILD_SHARED_LIBRARY)
176
177 mkfiles := $(patsubst %,$(MESA_TOP)/%/Android.mk,$(SUBDIRS))
178 include $(mkfiles)
179
180 endif # MESA_GPU_DRIVERS