1LOCAL_PATH:= $(call my-dir)
2
3COMMON_SWIFTSHADER_RELATIVE_PATH := $(if $(BOARD_SWIFTSHADER_RELATIVE_PATH),$(BOARD_SWIFTSHADER_RELATIVE_PATH),egl)
4
5COMMON_CFLAGS := \
6	-DLOG_TAG=\"libGLES_CM_swiftshader\" \
7	-std=c++11 \
8	-fno-operator-names \
9	-msse2 \
10	-D__STDC_CONSTANT_MACROS \
11	-D__STDC_LIMIT_MACROS \
12	-DEGLAPI= \
13	-DGL_API= \
14	-DGL_APICALL= \
15	-DGL_GLEXT_PROTOTYPES \
16	-Wall \
17	-Werror \
18	-Wno-format \
19	-Wno-format-extra-args \
20	-Wno-unused-parameter \
21	-Wno-unused-variable \
22	-Wno-implicit-exception-spec-mismatch \
23	-Wno-implicit-fallthrough \
24	-Wno-overloaded-virtual \
25	-Wno-attributes \
26	-Wno-unknown-attributes \
27	-Wno-unknown-warning-option \
28	-DANDROID_PLATFORM_SDK_VERSION=$(PLATFORM_SDK_VERSION)
29
30ifneq (16,${PLATFORM_SDK_VERSION})
31COMMON_CFLAGS += -Xclang -fuse-init-array
32else
33COMMON_CFLAGS += -D__STDC_INT64__
34endif
35
36COMMON_SRC_FILES := \
37	Buffer.cpp \
38	Context.cpp \
39	Device.cpp \
40	Framebuffer.cpp \
41	IndexDataManager.cpp \
42	libGLES_CM.cpp \
43	main.cpp \
44	Renderbuffer.cpp \
45	ResourceManager.cpp \
46	Texture.cpp \
47	utilities.cpp \
48	VertexDataManager.cpp \
49	../../Common/SharedLibrary.cpp
50
51COMMON_C_INCLUDES := \
52	bionic \
53	$(LOCAL_PATH)/../../../include \
54	$(LOCAL_PATH)/../ \
55	$(LOCAL_PATH)/../../ \
56	$(LOCAL_PATH)/../../Renderer/ \
57	$(LOCAL_PATH)/../../Common/ \
58	$(LOCAL_PATH)/../../Shader/ \
59	$(LOCAL_PATH)/../../Main/
60
61COMMON_STATIC_LIBRARIES := libLLVM_swiftshader
62
63COMMON_SHARED_LIBRARIES := \
64	libdl \
65	liblog \
66	libcutils \
67	libhardware
68
69# Project Treble is introduced from Oreo MR1
70ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 27 && echo OreoMR1),OreoMR1)
71COMMON_SHARED_LIBRARIES += libnativewindow
72COMMON_STATIC_LIBRARIES += libarect
73COMMON_HEADER_LIBRARIES := libnativebase_headers
74endif
75
76# gralloc1 is introduced from N MR1
77ifeq ($(shell test $(PLATFORM_SDK_VERSION) -ge 25 && echo NMR1),NMR1)
78COMMON_CFLAGS += -DHAVE_GRALLOC1
79COMMON_SHARED_LIBRARIES += libsync
80endif
81
82# Marshmallow does not have stlport, but comes with libc++ by default
83ifeq ($(shell test $(PLATFORM_SDK_VERSION) -lt 23 && echo PreMarshmallow),PreMarshmallow)
84COMMON_SHARED_LIBRARIES += libstlport
85COMMON_C_INCLUDES += external/stlport/stlport
86endif
87
88COMMON_LDFLAGS := \
89	-Wl,--version-script=$(LOCAL_PATH)/libGLES_CM.lds \
90	-Wl,--gc-sections \
91	-Wl,--hash-style=sysv
92
93include $(CLEAR_VARS)
94LOCAL_MODULE := libGLESv1_CM_swiftshader_debug
95
96ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true)
97LOCAL_MULTILIB := first
98endif
99
100ifeq (HasRelativePath,$(shell test $(PLATFORM_SDK_VERSION) -ge 21 && echo HasRelativePath))
101LOCAL_MODULE_RELATIVE_PATH := $(COMMON_SWIFTSHADER_RELATIVE_PATH)
102else
103LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/$(COMMON_SWIFTSHADER_RELATIVE_PATH)
104endif
105
106LOCAL_VENDOR_MODULE := true
107LOCAL_MODULE_TAGS := optional
108LOCAL_CLANG := true
109LOCAL_SRC_FILES += $(COMMON_SRC_FILES)
110LOCAL_C_INCLUDES += $(COMMON_C_INCLUDES)
111LOCAL_STATIC_LIBRARIES += swiftshader_top_debug $(COMMON_STATIC_LIBRARIES)
112LOCAL_SHARED_LIBRARIES += $(COMMON_SHARED_LIBRARIES)
113LOCAL_HEADER_LIBRARIES := $(COMMON_HEADER_LIBRARIES)
114LOCAL_LDFLAGS += $(COMMON_LDFLAGS)
115LOCAL_CFLAGS += $(COMMON_CFLAGS) -UNDEBUG -g -O0
116include $(BUILD_SHARED_LIBRARY)
117
118include $(CLEAR_VARS)
119LOCAL_MODULE := libGLESv1_CM_swiftshader
120
121ifeq ($(TARGET_TRANSLATE_2ND_ARCH),true)
122LOCAL_MULTILIB := first
123endif
124
125ifeq (HasRelativePath,$(shell test $(PLATFORM_SDK_VERSION) -ge 21 && echo HasRelativePath))
126LOCAL_MODULE_RELATIVE_PATH := $(COMMON_SWIFTSHADER_RELATIVE_PATH)
127else
128LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/$(COMMON_SWIFTSHADER_RELATIVE_PATH)
129endif
130
131LOCAL_VENDOR_MODULE := true
132LOCAL_MODULE_TAGS := optional
133LOCAL_CLANG := true
134LOCAL_SRC_FILES += $(COMMON_SRC_FILES)
135LOCAL_C_INCLUDES += $(COMMON_C_INCLUDES)
136LOCAL_STATIC_LIBRARIES += swiftshader_top_release $(COMMON_STATIC_LIBRARIES)
137LOCAL_SHARED_LIBRARIES += $(COMMON_SHARED_LIBRARIES)
138LOCAL_HEADER_LIBRARIES := $(COMMON_HEADER_LIBRARIES)
139LOCAL_LDFLAGS += $(COMMON_LDFLAGS)
140LOCAL_CFLAGS += \
141	$(COMMON_CFLAGS) \
142	-fomit-frame-pointer \
143	-ffunction-sections \
144	-fdata-sections \
145	-DANGLE_DISABLE_TRACE
146include $(BUILD_SHARED_LIBRARY)
147