1# Copyright (C) 2014 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7#      http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14# Modified 2011 by InvenSense, Inc
15
16LOCAL_PATH := $(call my-dir)
17
18# InvenSense fragment of the HAL
19include $(CLEAR_VARS)
20
21LOCAL_MODULE := libinvensense_hal
22LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-GPL-2.0 legacy_by_exception_only
23LOCAL_LICENSE_CONDITIONS := by_exception_only notice restricted
24LOCAL_MODULE_TAGS := optional
25LOCAL_MODULE_OWNER := invensense
26
27LOCAL_CFLAGS := -DLOG_TAG=\"Sensors\" -Werror -Wall
28
29# ANDROID version check
30$(info YD>>PLATFORM_VERSION=$(PLATFORM_VERSION))
31MAJOR_VERSION :=$(shell echo $(PLATFORM_VERSION) | cut -f1 -d.)
32MINOR_VERSION :=$(shell echo $(PLATFORM_VERSION) | cut -f2 -d.)
33VERSION_KK :=$(shell test $(MAJOR_VERSION) -eq 4 -a $(MINOR_VERSION) -gt 3 && echo true)
34VERSION_L  :=$(shell test $(MAJOR_VERSION) -eq 5 -a $(MINOR_VERSION) -eq 0 && echo true)
35
36#
37# Invensense uses the OS version to determine whether to include batch support,
38# but implemented it in a way that requires modifying the code each time we move
39# to a newer OS version.  I will fix this problem in a subsequent change, but for now,
40# hardcode to saying we're ANDROID_L so we can isolate this checkin to being
41# only changes coming from Invensense.
42#
43# Setting ANDROID_L to true is perfectly safe even on ANDROID_M because the code
44# just requires "ANDROID_L or newer"
45#
46VERSION_L :=true
47
48$(info YD>>ANDRIOD VERSION=$(MAJOR_VERSION).$(MINOR_VERSION))
49$(info YD>>VERSION_L=$(VERSION_L), VERSION_KK=$(VERSION_KK))
50#ANDROID version check END
51
52ifeq ($(VERSION_KK),true)
53LOCAL_CFLAGS += -DANDROID_KITKAT
54else
55LOCAL_CFLAGS += -DANDROID_LOLLIPOP
56endif
57
58ifneq (,$(filter $(TARGET_BUILD_VARIANT),eng userdebug user))
59ifneq ($(COMPILE_INVENSENSE_COMPASS_CAL),0)
60LOCAL_CFLAGS += -DINVENSENSE_COMPASS_CAL
61endif
62ifeq ($(COMPILE_THIRD_PARTY_ACCEL),1)
63LOCAL_CFLAGS += -DTHIRD_PARTY_ACCEL
64endif
65else # release builds, default
66LOCAL_CFLAGS += -DINVENSENSE_COMPASS_CAL
67endif
68
69LOCAL_SRC_FILES += SensorBase.cpp
70LOCAL_SRC_FILES += MPLSensor.cpp
71LOCAL_SRC_FILES += MPLSupport.cpp
72LOCAL_SRC_FILES += InputEventReader.cpp
73LOCAL_SRC_FILES += PressureSensor.IIO.secondary.cpp
74
75ifneq (,$(filter $(TARGET_BUILD_VARIANT),eng userdebug user))
76ifeq ($(COMPILE_INVENSENSE_COMPASS_CAL),0)
77LOCAL_SRC_FILES += AkmSensor.cpp
78LOCAL_SRC_FILES += CompassSensor.AKM.cpp
79else ifeq ($(COMPILE_INVENSENSE_SENSOR_ON_PRIMARY_BUS), 1)
80LOCAL_SRC_FILES += CompassSensor.IIO.primary.cpp
81LOCAL_CFLAGS += -DSENSOR_ON_PRIMARY_BUS
82else
83LOCAL_SRC_FILES += CompassSensor.IIO.9150.cpp
84endif
85else # release builds, default
86LOCAL_SRC_FILES += CompassSensor.IIO.9150.cpp
87endif # eng, userdebug & user builds
88
89LOCAL_C_INCLUDES += $(LOCAL_PATH)/software/core/mllite
90LOCAL_C_INCLUDES += $(LOCAL_PATH)/software/core/mllite/linux
91LOCAL_C_INCLUDES += $(LOCAL_PATH)/software/core/driver/include
92LOCAL_C_INCLUDES += $(LOCAL_PATH)/software/core/driver/include/linux
93
94LOCAL_SHARED_LIBRARIES := liblog
95LOCAL_SHARED_LIBRARIES += libcutils
96LOCAL_SHARED_LIBRARIES += libutils
97LOCAL_SHARED_LIBRARIES += libdl
98LOCAL_SHARED_LIBRARIES += libmllite
99
100# Additions for SysPed
101LOCAL_SHARED_LIBRARIES += libmplmpu
102LOCAL_C_INCLUDES += $(LOCAL_PATH)/software/core/mpl
103LOCAL_CPPFLAGS += -DLINUX=1
104
105LOCAL_SHARED_LIBRARIES += libmllite
106LOCAL_C_INCLUDES += $(LOCAL_PATH)/software/core/mllite
107LOCAL_CPPFLAGS += -DLINUX=1
108
109include $(BUILD_SHARED_LIBRARY)
110
111# Build a temporary HAL that links the InvenSense .so
112include $(CLEAR_VARS)
113ifeq ($(filter eng, userdebug, user, $(TARGET_BUILD_VARIANT)),)
114ifneq ($(filter manta full_grouper tilapia, $(TARGET_PRODUCT)),)
115LOCAL_MODULE := sensors.full_grouper
116LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-GPL-2.0 legacy_by_exception_only
117LOCAL_LICENSE_CONDITIONS := by_exception_only notice restricted
118LOCAL_MODULE_OWNER := invensense
119else
120ifneq ($(filter aosp_hammerhead, $(TARGET_PRODUCT)),)
121LOCAL_MODULE := sensors.hammerhead
122LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-GPL-2.0 legacy_by_exception_only
123LOCAL_LICENSE_CONDITIONS := by_exception_only notice restricted
124LOCAL_MODULE_OWNER := invensense
125else
126ifneq ($(filter aosp_flounder, $(TARGET_PRODUCT)),)
127LOCAL_MODULE := sensors.flounder
128LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-GPL-2.0 legacy_by_exception_only
129LOCAL_LICENSE_CONDITIONS := by_exception_only notice restricted
130LOCAL_MODULE_OWNER := invensense
131endif
132endif
133ifneq ($(filter dory guppy, $(TARGET_DEVICE)),)
134LOCAL_MODULE := sensors.invensense
135LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-GPL-2.0 legacy_by_exception_only
136LOCAL_LICENSE_CONDITIONS := by_exception_only notice restricted
137LOCAL_MODULE_OWNER := invensense
138endif
139endif
140else    # eng, user, & userdebug builds
141LOCAL_MODULE := sensors.invensense
142LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-GPL-2.0 legacy_by_exception_only
143LOCAL_LICENSE_CONDITIONS := by_exception_only notice restricted
144endif   # eng, user & userdebug builds
145$(info YD>>LOCAL_MODULE=$(LOCAL_MODULE))
146
147ifdef TARGET_2ND_ARCH
148LOCAL_MODULE_RELATIVE_PATH := hw
149else
150LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
151endif
152
153LOCAL_SHARED_LIBRARIES += libmplmpu
154LOCAL_C_INCLUDES += $(LOCAL_PATH)/software/core/mllite
155LOCAL_C_INCLUDES += $(LOCAL_PATH)/software/core/mllite/linux
156LOCAL_C_INCLUDES += $(LOCAL_PATH)/software/core/mpl
157LOCAL_C_INCLUDES += $(LOCAL_PATH)/software/core/driver/include
158LOCAL_C_INCLUDES += $(LOCAL_PATH)/software/core/driver/include/linux
159
160LOCAL_MODULE_TAGS := optional
161LOCAL_CFLAGS := -DLOG_TAG=\"Sensors\" -Werror -Wall
162
163ifeq ($(VERSION_KK),true)
164LOCAL_CFLAGS += -DANDROID_KITKAT
165else
166LOCAL_CFLAGS += -DANDROID_LOLLIPOP
167endif
168
169ifneq (,$(filter $(TARGET_BUILD_VARIANT),eng userdebug user))
170ifneq ($(COMPILE_INVENSENSE_COMPASS_CAL),0)
171LOCAL_CFLAGS += -DINVENSENSE_COMPASS_CAL
172endif
173ifeq ($(COMPILE_THIRD_PARTY_ACCEL),1)
174LOCAL_CFLAGS += -DTHIRD_PARTY_ACCEL
175endif
176ifeq ($(COMPILE_INVENSENSE_SENSOR_ON_PRIMARY_BUS), 1)
177LOCAL_SRC_FILES += CompassSensor.IIO.primary.cpp
178LOCAL_CFLAGS += -DSENSOR_ON_PRIMARY_BUS
179else
180LOCAL_SRC_FILES += CompassSensor.IIO.9150.cpp
181endif
182else # release builds, default
183LOCAL_SRC_FILES += CompassSensor.IIO.9150.cpp
184endif # eng, userdebug & user
185
186ifeq (,$(filter $(TARGET_BUILD_VARIANT),eng userdebug user))
187ifneq ($(filter manta grouper tilapia, $(TARGET_DEVICE)),)
188# it's already defined in some other Makefile for production builds
189#LOCAL_SRC_FILES := sensors_mpl.cpp
190else
191LOCAL_SRC_FILES := sensors_mpl.cpp
192endif
193else    # eng, userdebug & user builds
194LOCAL_SRC_FILES := sensors_mpl.cpp
195endif   # eng, userdebug & user builds
196
197LOCAL_SHARED_LIBRARIES := libinvensense_hal
198LOCAL_SHARED_LIBRARIES += libcutils
199LOCAL_SHARED_LIBRARIES += libutils
200LOCAL_SHARED_LIBRARIES += libdl
201LOCAL_SHARED_LIBRARIES += liblog
202LOCAL_SHARED_LIBRARIES += libmllite
203LOCAL_SHARED_LIBRARIES += libhardware_legacy
204$(info YD>>LOCAL_MODULE=$(LOCAL_MODULE), LOCAL_SRC_FILES=$(LOCAL_SRC_FILES), LOCAL_SHARED_LIBRARIES=$(LOCAL_SHARED_LIBRARIES))
205include $(BUILD_SHARED_LIBRARY)
206
207include $(CLEAR_VARS)
208LOCAL_MODULE := libmplmpu
209LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-GPL-2.0 legacy_by_exception_only
210LOCAL_LICENSE_CONDITIONS := by_exception_only notice restricted
211LOCAL_SRC_FILES := libmplmpu.so
212LOCAL_MODULE_TAGS := optional
213LOCAL_MODULE_OWNER := invensense
214LOCAL_MODULE_SUFFIX := .so
215LOCAL_MODULE_CLASS := SHARED_LIBRARIES
216LOCAL_MODULE_PATH := $(TARGET_OUT)/lib
217OVERRIDE_BUILT_MODULE_PATH := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)
218LOCAL_STRIP_MODULE := true
219include $(BUILD_PREBUILT)
220
221include $(CLEAR_VARS)
222LOCAL_MODULE := libmllite
223LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-GPL-2.0 legacy_by_exception_only
224LOCAL_LICENSE_CONDITIONS := by_exception_only notice restricted
225LOCAL_SRC_FILES := libmllite.so
226LOCAL_MODULE_TAGS := optional
227LOCAL_MODULE_OWNER := invensense
228LOCAL_MODULE_SUFFIX := .so
229LOCAL_MODULE_CLASS := SHARED_LIBRARIES
230LOCAL_MODULE_PATH := $(TARGET_OUT)/lib
231OVERRIDE_BUILT_MODULE_PATH := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)
232LOCAL_STRIP_MODULE := true
233include $(BUILD_PREBUILT)
234