1# Copyright © 2017 Intel Corporation
2#
3# Permission is hereby granted, free of charge, to any person obtaining a
4# copy of this software and associated documentation files (the "Software"),
5# to deal in the Software without restriction, including without limitation
6# the rights to use, copy, modify, merge, publish, distribute, sublicense,
7# and/or sell copies of the Software, and to permit persons to whom the
8# Software is furnished to do so, subject to the following conditions:
9#
10# The above copyright notice and this permission notice shall be included
11# in all copies or substantial portions of the Software.
12#
13# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
16# THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
19# DEALINGS IN THE SOFTWARE.
20
21LOCAL_PATH := $(call my-dir)
22
23include $(CLEAR_VARS)
24include $(LOCAL_PATH)/Makefile.sources
25
26ANV_ENTRYPOINTS_GEN_SCRIPT := $(LOCAL_PATH)/vulkan/anv_entrypoints_gen.py
27ANV_EXTENSIONS_GEN_SCRIPT := $(LOCAL_PATH)/vulkan/anv_extensions_gen.py
28ANV_EXTENSIONS_SCRIPT := $(LOCAL_PATH)/vulkan/anv_extensions.py
29VULKAN_API_XML := $(MESA_TOP)/src/vulkan/registry/vk.xml
30
31VULKAN_COMMON_INCLUDES := \
32	$(MESA_TOP)/include \
33	$(MESA_TOP)/src/mapi \
34	$(MESA_TOP)/src/gallium/auxiliary \
35	$(MESA_TOP)/src/gallium/include \
36	$(MESA_TOP)/src/mesa \
37	$(MESA_TOP)/src/vulkan/wsi \
38	$(MESA_TOP)/src/vulkan/util \
39	$(MESA_TOP)/src/intel \
40	$(MESA_TOP)/src/intel/vulkan \
41	$(MESA_TOP)/src/compiler \
42	frameworks/native/vulkan/include
43
44ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 27; echo $$?), 0)
45VULKAN_COMMON_INCLUDES += \
46	frameworks/native/vulkan/include \
47	frameworks/native/libs/nativebase/include \
48	frameworks/native/libs/nativewindow/include \
49	frameworks/native/libs/arect/include
50
51VULKAN_COMMON_HEADER_LIBRARIES := \
52	libcutils_headers \
53	libhardware_headers
54endif
55
56# libmesa_anv_entrypoints with header and dummy.c
57#
58# This static library is built to pull entrypoints header
59# for multiple gen specific build targets below. The c file
60# is generated separately for libmesa_vulkan_common to avoid
61# duplicate symbols when linking the anv libraries.
62
63include $(CLEAR_VARS)
64LOCAL_MODULE := libmesa_anv_entrypoints
65LOCAL_MODULE_CLASS := STATIC_LIBRARIES
66
67intermediates := $(call local-generated-sources-dir)
68
69LOCAL_C_INCLUDES := \
70	$(VULKAN_COMMON_INCLUDES)
71
72LOCAL_GENERATED_SOURCES += $(intermediates)/vulkan/anv_entrypoints.h
73LOCAL_GENERATED_SOURCES += $(intermediates)/vulkan/dummy.c
74LOCAL_GENERATED_SOURCES += $(intermediates)/vulkan/anv_extensions.h
75
76$(intermediates)/vulkan/dummy.c:
77	@mkdir -p $(dir $@)
78	@echo "Gen Dummy: $(PRIVATE_MODULE) <= $(notdir $(@))"
79	$(hide) touch $@
80
81$(intermediates)/vulkan/anv_entrypoints.h: $(intermediates)/vulkan/dummy.c \
82					   $(ANV_ENTRYPOINTS_GEN_SCRIPT) \
83					   $(ANV_EXTENSIONS_SCRIPT) \
84					   $(VULKAN_API_XML)
85	$(MESA_PYTHON2) $(ANV_ENTRYPOINTS_GEN_SCRIPT) \
86		--outdir $(dir $@) \
87		--xml $(VULKAN_API_XML)
88
89$(intermediates)/vulkan/anv_extensions.h: $(ANV_ENTRYPOINTS_GEN_SCRIPT) \
90					  $(ANV_EXTENSIONS_SCRIPT) \
91					  $(VULKAN_API_XML)
92	@mkdir -p $(dir $@)
93	$(MESA_PYTHON2) $(ANV_EXTENSIONS_GEN_SCRIPT) \
94		--xml $(VULKAN_API_XML) \
95		--out-h $@
96
97LOCAL_EXPORT_C_INCLUDE_DIRS := \
98        $(intermediates)
99
100LOCAL_SHARED_LIBRARIES := libdrm
101
102include $(MESA_COMMON_MK)
103include $(BUILD_STATIC_LIBRARY)
104
105ANV_INCLUDES := \
106	$(VULKAN_COMMON_INCLUDES) \
107	$(call generated-sources-dir-for,STATIC_LIBRARIES,libmesa_anv_entrypoints,,)/vulkan \
108	$(call generated-sources-dir-for,STATIC_LIBRARIES,libmesa_nir,,)/nir \
109	$(call generated-sources-dir-for,STATIC_LIBRARIES,libmesa_vulkan_common,,)/vulkan \
110	$(call generated-sources-dir-for,STATIC_LIBRARIES,libmesa_vulkan_util,,)/util
111
112ANV_SHARED_LIBRARIES := libdrm
113
114ifeq ($(filter $(MESA_ANDROID_MAJOR_VERSION), 4 5 6 7),)
115ANV_SHARED_LIBRARIES += libnativewindow
116endif
117
118#
119# libanv for gen7
120#
121
122include $(CLEAR_VARS)
123LOCAL_MODULE := libmesa_anv_gen7
124LOCAL_MODULE_CLASS := STATIC_LIBRARIES
125
126LOCAL_SRC_FILES := $(VULKAN_GEN7_FILES)
127LOCAL_CFLAGS := -DGEN_VERSIONx10=70
128
129LOCAL_C_INCLUDES := $(ANV_INCLUDES)
130
131LOCAL_WHOLE_STATIC_LIBRARIES := libmesa_anv_entrypoints libmesa_genxml
132
133LOCAL_SHARED_LIBRARIES := $(ANV_SHARED_LIBRARIES)
134LOCAL_HEADER_LIBRARIES += $(VULKAN_COMMON_HEADER_LIBRARIES)
135
136include $(MESA_COMMON_MK)
137include $(BUILD_STATIC_LIBRARY)
138
139#
140# libanv for gen75
141#
142
143include $(CLEAR_VARS)
144LOCAL_MODULE := libmesa_anv_gen75
145LOCAL_MODULE_CLASS := STATIC_LIBRARIES
146
147LOCAL_SRC_FILES := $(VULKAN_GEN75_FILES)
148LOCAL_CFLAGS := -DGEN_VERSIONx10=75
149
150LOCAL_C_INCLUDES := $(ANV_INCLUDES)
151
152LOCAL_WHOLE_STATIC_LIBRARIES := libmesa_anv_entrypoints libmesa_genxml
153
154LOCAL_SHARED_LIBRARIES := $(ANV_SHARED_LIBRARIES)
155LOCAL_HEADER_LIBRARIES += $(VULKAN_COMMON_HEADER_LIBRARIES)
156
157include $(MESA_COMMON_MK)
158include $(BUILD_STATIC_LIBRARY)
159
160#
161# libanv for gen8
162#
163
164include $(CLEAR_VARS)
165LOCAL_MODULE := libmesa_anv_gen8
166LOCAL_MODULE_CLASS := STATIC_LIBRARIES
167
168LOCAL_SRC_FILES := $(VULKAN_GEN8_FILES)
169LOCAL_CFLAGS := -DGEN_VERSIONx10=80
170
171LOCAL_C_INCLUDES := $(ANV_INCLUDES)
172
173LOCAL_WHOLE_STATIC_LIBRARIES := libmesa_anv_entrypoints libmesa_genxml
174
175LOCAL_SHARED_LIBRARIES := $(ANV_SHARED_LIBRARIES)
176LOCAL_HEADER_LIBRARIES += $(VULKAN_COMMON_HEADER_LIBRARIES)
177
178include $(MESA_COMMON_MK)
179include $(BUILD_STATIC_LIBRARY)
180
181#
182# libanv for gen9
183#
184
185include $(CLEAR_VARS)
186LOCAL_MODULE := libmesa_anv_gen9
187LOCAL_MODULE_CLASS := STATIC_LIBRARIES
188
189LOCAL_SRC_FILES := $(VULKAN_GEN9_FILES)
190LOCAL_CFLAGS := -DGEN_VERSIONx10=90
191
192LOCAL_C_INCLUDES := $(ANV_INCLUDES)
193
194LOCAL_WHOLE_STATIC_LIBRARIES := libmesa_anv_entrypoints libmesa_genxml
195
196LOCAL_SHARED_LIBRARIES := $(ANV_SHARED_LIBRARIES)
197LOCAL_HEADER_LIBRARIES += $(VULKAN_COMMON_HEADER_LIBRARIES)
198
199include $(MESA_COMMON_MK)
200include $(BUILD_STATIC_LIBRARY)
201
202#
203# libanv for gen10
204#
205
206include $(CLEAR_VARS)
207LOCAL_MODULE := libmesa_anv_gen10
208LOCAL_MODULE_CLASS := STATIC_LIBRARIES
209
210LOCAL_SRC_FILES := $(VULKAN_GEN10_FILES)
211LOCAL_CFLAGS := -DGEN_VERSIONx10=100
212
213LOCAL_C_INCLUDES := $(ANV_INCLUDES)
214
215LOCAL_WHOLE_STATIC_LIBRARIES := libmesa_anv_entrypoints libmesa_genxml
216
217LOCAL_SHARED_LIBRARIES := $(ANV_SHARED_LIBRARIES)
218LOCAL_HEADER_LIBRARIES += $(VULKAN_COMMON_HEADER_LIBRARIES)
219
220include $(MESA_COMMON_MK)
221include $(BUILD_STATIC_LIBRARY)
222
223#
224# libanv for gen11
225#
226
227include $(CLEAR_VARS)
228LOCAL_MODULE := libmesa_anv_gen11
229LOCAL_MODULE_CLASS := STATIC_LIBRARIES
230
231LOCAL_SRC_FILES := $(VULKAN_GEN11_FILES)
232LOCAL_CFLAGS := -DGEN_VERSIONx10=110
233
234LOCAL_C_INCLUDES := $(ANV_INCLUDES)
235
236LOCAL_WHOLE_STATIC_LIBRARIES := libmesa_anv_entrypoints libmesa_genxml
237
238LOCAL_SHARED_LIBRARIES := $(ANV_SHARED_LIBRARIES)
239LOCAL_HEADER_LIBRARIES += $(VULKAN_COMMON_HEADER_LIBRARIES)
240
241include $(MESA_COMMON_MK)
242include $(BUILD_STATIC_LIBRARY)
243
244#
245# libmesa_vulkan_common
246#
247
248include $(CLEAR_VARS)
249LOCAL_MODULE := libmesa_vulkan_common
250LOCAL_MODULE_CLASS := STATIC_LIBRARIES
251
252intermediates := $(call local-generated-sources-dir)
253
254LOCAL_SRC_FILES := $(VULKAN_FILES)
255
256LOCAL_C_INCLUDES := \
257	$(ANV_INCLUDES) \
258	$(MESA_TOP)/src/compiler
259
260LOCAL_WHOLE_STATIC_LIBRARIES := \
261	libmesa_anv_entrypoints \
262	libmesa_genxml \
263	libmesa_git_sha1 \
264	libmesa_vulkan_util \
265	libmesa_util
266
267# The rule generates both C and H files, but due to some strange
268# reason generating the files once leads to link-time issues.
269# Work around create them here as well - we're safe from race
270# conditions since they are stored in another location.
271
272LOCAL_GENERATED_SOURCES += $(intermediates)/vulkan/anv_entrypoints.c
273LOCAL_GENERATED_SOURCES += $(intermediates)/vulkan/anv_extensions.c
274
275$(intermediates)/vulkan/anv_entrypoints.c: $(ANV_ENTRYPOINTS_GEN_SCRIPT) \
276					   $(ANV_EXTENSIONS_SCRIPT) \
277					   $(VULKAN_API_XML)
278	@mkdir -p $(dir $@)
279	$(MESA_PYTHON2) $(ANV_ENTRYPOINTS_GEN_SCRIPT) \
280		--xml $(VULKAN_API_XML) \
281		--outdir $(dir $@)
282
283$(intermediates)/vulkan/anv_extensions.c: $(ANV_EXTENSIONS_GEN_SCRIPT) \
284					  $(ANV_EXTENSIONS_SCRIPT) \
285					  $(VULKAN_API_XML)
286	@mkdir -p $(dir $@)
287	$(MESA_PYTHON2) $(ANV_EXTENSIONS_GEN_SCRIPT) \
288		--xml $(VULKAN_API_XML) \
289		--out-c $@
290
291LOCAL_SHARED_LIBRARIES := $(ANV_SHARED_LIBRARIES)
292LOCAL_HEADER_LIBRARIES += $(VULKAN_COMMON_HEADER_LIBRARIES)
293
294include $(MESA_COMMON_MK)
295include $(BUILD_STATIC_LIBRARY)
296
297
298#
299# libvulkan_intel
300#
301
302include $(CLEAR_VARS)
303
304LOCAL_MODULE := vulkan.$(TARGET_BOARD_PLATFORM)
305LOCAL_MODULE_CLASS := SHARED_LIBRARIES
306LOCAL_PROPRIETARY_MODULE := true
307LOCAL_MODULE_RELATIVE_PATH := hw
308
309LOCAL_LDFLAGS += -Wl,--build-id=sha1
310
311LOCAL_SRC_FILES := \
312	$(VULKAN_GEM_FILES) \
313	$(VULKAN_ANDROID_FILES)
314
315LOCAL_C_INCLUDES := \
316	$(VULKAN_COMMON_INCLUDES) \
317	$(call generated-sources-dir-for,STATIC_LIBRARIES,libmesa_anv_entrypoints,,)/vulkan \
318	$(call generated-sources-dir-for,STATIC_LIBRARIES,libmesa_vulkan_common,,)/vulkan
319
320LOCAL_EXPORT_C_INCLUDE_DIRS := $(MESA_TOP)/src/intel/vulkan
321
322LOCAL_WHOLE_STATIC_LIBRARIES := \
323	libmesa_nir \
324	libmesa_isl \
325	libmesa_glsl \
326	libmesa_util \
327	libmesa_blorp \
328	libmesa_compiler \
329	libmesa_intel_common \
330	libmesa_intel_dev \
331	libmesa_vulkan_common \
332	libmesa_anv_gen7 \
333	libmesa_anv_gen75 \
334	libmesa_anv_gen8 \
335	libmesa_anv_gen9 \
336	libmesa_anv_gen10 \
337	libmesa_anv_gen11 \
338	libmesa_intel_compiler \
339	libmesa_anv_entrypoints
340
341LOCAL_SHARED_LIBRARIES := $(ANV_SHARED_LIBRARIES) libz libsync liblog
342LOCAL_HEADER_LIBRARIES += $(VULKAN_COMMON_HEADER_LIBRARIES)
343
344# If Android version >=8 MESA should static link libexpat else should dynamic link
345ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 27; echo $$?), 0)
346LOCAL_STATIC_LIBRARIES := \
347       libexpat
348else
349 LOCAL_SHARED_LIBRARIES += \
350        libexpat
351endif
352
353include $(MESA_COMMON_MK)
354include $(BUILD_SHARED_LIBRARY)
355