1848b8605Smrg# Mesa 3-D graphics library
2848b8605Smrg#
3848b8605Smrg# Copyright (C) 2010-2011 Chia-I Wu <olvaffe@gmail.com>
4848b8605Smrg# Copyright (C) 2010-2011 LunarG Inc.
5848b8605Smrg#
6848b8605Smrg# Permission is hereby granted, free of charge, to any person obtaining a
7848b8605Smrg# copy of this software and associated documentation files (the "Software"),
8848b8605Smrg# to deal in the Software without restriction, including without limitation
9848b8605Smrg# the rights to use, copy, modify, merge, publish, distribute, sublicense,
10848b8605Smrg# and/or sell copies of the Software, and to permit persons to whom the
11848b8605Smrg# Software is furnished to do so, subject to the following conditions:
12848b8605Smrg#
13848b8605Smrg# The above copyright notice and this permission notice shall be included
14848b8605Smrg# in all copies or substantial portions of the Software.
15848b8605Smrg#
16848b8605Smrg# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17848b8605Smrg# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18848b8605Smrg# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
19848b8605Smrg# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20848b8605Smrg# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21848b8605Smrg# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22848b8605Smrg# DEALINGS IN THE SOFTWARE.
23848b8605Smrg
24848b8605Smrg# BOARD_GPU_DRIVERS should be defined.  The valid values are
25848b8605Smrg#
26848b8605Smrg#   classic drivers: i915 i965
27b8e80941Smrg#   gallium drivers: swrast freedreno i915g nouveau kmsro r300g r600g radeonsi vc4 virgl vmwgfx etnaviv iris lima
28848b8605Smrg#
29848b8605Smrg# The main target is libGLES_mesa.  For each classic driver enabled, a DRI
30848b8605Smrg# module will also be built.  DRI modules will be loaded by libGLES_mesa.
31848b8605Smrg
32848b8605SmrgMESA_TOP := $(call my-dir)
33848b8605Smrg
34848b8605SmrgMESA_ANDROID_MAJOR_VERSION := $(word 1, $(subst ., , $(PLATFORM_VERSION)))
35b8e80941Smrgifneq ($(filter 2 4, $(MESA_ANDROID_MAJOR_VERSION)),)
36b8e80941Smrg$(error "Android 4.4 and earlier not supported")
37b8e80941Smrgendif
38b8e80941Smrg
39b8e80941SmrgMESA_DRI_MODULE_REL_PATH := dri
40b8e80941SmrgMESA_DRI_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/$(MESA_DRI_MODULE_REL_PATH)
41b8e80941SmrgMESA_DRI_MODULE_UNSTRIPPED_PATH := $(TARGET_OUT_SHARED_LIBRARIES_UNSTRIPPED)/$(MESA_DRI_MODULE_REL_PATH)
42b8e80941SmrgMESA_DRI_LDFLAGS := -Wl,--build-id=sha1
43848b8605Smrg
44848b8605SmrgMESA_COMMON_MK := $(MESA_TOP)/Android.common.mk
45848b8605SmrgMESA_PYTHON2 := python
46848b8605Smrg
47b8e80941Smrg# Lists to convert driver names to boolean variables
48b8e80941Smrg# in form of <driver name>.<boolean make variable>
49b8e80941Smrgclassic_drivers := i915.HAVE_I915_DRI i965.HAVE_I965_DRI
50b8e80941Smrggallium_drivers := \
51b8e80941Smrg	swrast.HAVE_GALLIUM_SOFTPIPE \
52b8e80941Smrg	freedreno.HAVE_GALLIUM_FREEDRENO \
53b8e80941Smrg	i915g.HAVE_GALLIUM_I915 \
54b8e80941Smrg	nouveau.HAVE_GALLIUM_NOUVEAU \
55b8e80941Smrg	kmsro.HAVE_GALLIUM_KMSRO \
56b8e80941Smrg	r300g.HAVE_GALLIUM_R300 \
57b8e80941Smrg	r600g.HAVE_GALLIUM_R600 \
58b8e80941Smrg	radeonsi.HAVE_GALLIUM_RADEONSI \
59b8e80941Smrg	vmwgfx.HAVE_GALLIUM_VMWGFX \
60b8e80941Smrg	vc4.HAVE_GALLIUM_VC4 \
61b8e80941Smrg	virgl.HAVE_GALLIUM_VIRGL \
62b8e80941Smrg	etnaviv.HAVE_GALLIUM_ETNAVIV \
63b8e80941Smrg	iris.HAVE_GALLIUM_IRIS \
64b8e80941Smrg	lima.HAVE_GALLIUM_LIMA
65b8e80941Smrg
66b8e80941Smrgifeq ($(BOARD_GPU_DRIVERS),all)
67b8e80941SmrgMESA_BUILD_CLASSIC := $(filter HAVE_%, $(subst ., , $(classic_drivers)))
68b8e80941SmrgMESA_BUILD_GALLIUM := $(filter HAVE_%, $(subst ., , $(gallium_drivers)))
69b8e80941Smrgelse
70b8e80941Smrg# Warn if we have any invalid driver names
71b8e80941Smrg$(foreach d, $(BOARD_GPU_DRIVERS), \
72b8e80941Smrg	$(if $(findstring $(d).,$(classic_drivers) $(gallium_drivers)), \
73b8e80941Smrg		, \
74b8e80941Smrg		$(warning invalid GPU driver: $(d)) \
75b8e80941Smrg	) \
76b8e80941Smrg)
77b8e80941SmrgMESA_BUILD_CLASSIC := $(strip $(foreach d, $(BOARD_GPU_DRIVERS), $(patsubst $(d).%,%, $(filter $(d).%, $(classic_drivers)))))
78b8e80941SmrgMESA_BUILD_GALLIUM := $(strip $(foreach d, $(BOARD_GPU_DRIVERS), $(patsubst $(d).%,%, $(filter $(d).%, $(gallium_drivers)))))
79b8e80941Smrgendif
80b8e80941Smrgifeq ($(filter x86%,$(TARGET_ARCH)),)
81b8e80941Smrg	MESA_BUILD_CLASSIC :=
82848b8605Smrgendif
83848b8605Smrg
84b8e80941Smrg$(foreach d, $(MESA_BUILD_CLASSIC) $(MESA_BUILD_GALLIUM), $(eval $(d) := true))
85b8e80941Smrg
86848b8605Smrg# host and target must be the same arch to generate matypes.h
87848b8605Smrgifeq ($(TARGET_ARCH),$(HOST_ARCH))
88848b8605SmrgMESA_ENABLE_ASM := true
89848b8605Smrgelse
90848b8605SmrgMESA_ENABLE_ASM := false
91848b8605Smrgendif
92848b8605Smrg
93b8e80941Smrgifneq ($(filter true, $(HAVE_GALLIUM_RADEONSI)),)
94b8e80941SmrgMESA_ENABLE_LLVM := true
95848b8605Smrgendif
96848b8605Smrg
97b8e80941Smrgdefine mesa-build-with-llvm
98b8e80941Smrg  $(if $(filter $(MESA_ANDROID_MAJOR_VERSION), 4 5), \
99b8e80941Smrg    $(warning Unsupported LLVM version in Android $(MESA_ANDROID_MAJOR_VERSION)),) \
100b8e80941Smrg  $(if $(filter 6,$(MESA_ANDROID_MAJOR_VERSION)), \
101b8e80941Smrg    $(eval LOCAL_CFLAGS += -DHAVE_LLVM=0x0307 -DMESA_LLVM_VERSION_STRING=\"3.7\")) \
102b8e80941Smrg  $(if $(filter 7,$(MESA_ANDROID_MAJOR_VERSION)), \
103b8e80941Smrg    $(eval LOCAL_CFLAGS += -DHAVE_LLVM=0x0308 -DMESA_LLVM_VERSION_STRING=\"3.8\")) \
104b8e80941Smrg  $(if $(filter 8,$(MESA_ANDROID_MAJOR_VERSION)), \
105b8e80941Smrg    $(eval LOCAL_CFLAGS += -DHAVE_LLVM=0x0309 -DMESA_LLVM_VERSION_STRING=\"3.9\")) \
106b8e80941Smrg  $(if $(filter P,$(MESA_ANDROID_MAJOR_VERSION)), \
107b8e80941Smrg    $(eval LOCAL_CFLAGS += -DHAVE_LLVM=0x0309 -DMESA_LLVM_VERSION_STRING=\"3.9\")) \
108b8e80941Smrg  $(eval LOCAL_SHARED_LIBRARIES += libLLVM)
109b8e80941Smrgendef
110848b8605Smrg
111848b8605Smrg# add subdirectories
112848b8605SmrgSUBDIRS := \
113b8e80941Smrg	src/freedreno \
114b8e80941Smrg	src/gbm \
115848b8605Smrg	src/loader \
116848b8605Smrg	src/mapi \
117b8e80941Smrg	src/compiler \
118848b8605Smrg	src/mesa \
119848b8605Smrg	src/util \
120b8e80941Smrg	src/egl \
121b8e80941Smrg	src/amd \
122b8e80941Smrg	src/broadcom \
123b8e80941Smrg	src/intel \
124b8e80941Smrg	src/mesa/drivers/dri \
125b8e80941Smrg	src/vulkan
126b8e80941Smrg
127b8e80941SmrgINC_DIRS := $(call all-named-subdir-makefiles,$(SUBDIRS))
128b8e80941SmrgINC_DIRS += $(call all-named-subdir-makefiles,src/gallium)
129b8e80941Smrginclude $(INC_DIRS)
130