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_MODULE_TAGS := optional
23LOCAL_MODULE_OWNER := invensense
24
25LOCAL_CFLAGS := -DLOG_TAG=\"Sensors\" -Werror -Wall
26
27# ANDROID version check
28$(info YD>>PLATFORM_VERSION=$(PLATFORM_VERSION))
29MAJOR_VERSION :=$(shell echo $(PLATFORM_VERSION) | cut -f1 -d.)
30MINOR_VERSION :=$(shell echo $(PLATFORM_VERSION) | cut -f2 -d.)
31VERSION_KK :=$(shell test $(MAJOR_VERSION) -eq 4 -a $(MINOR_VERSION) -gt 3 && echo true)
32VERSION_L  :=$(shell test $(MAJOR_VERSION) -eq 5 -a $(MINOR_VERSION) -eq 0 && echo true)
33
34#
35# Invensense uses the OS version to determine whether to include batch support,
36# but implemented it in a way that requires modifying the code each time we move
37# to a newer OS version.  I will fix this problem in a subsequent change, but for now,
38# hardcode to saying we're ANDROID_L so we can isolate this checkin to being
39# only changes coming from Invensense.
40#
41# Setting ANDROID_L to true is perfectly safe even on ANDROID_M because the code
42# just requires "ANDROID_L or newer"
43#
44VERSION_L :=true
45
46$(info YD>>ANDRIOD VERSION=$(MAJOR_VERSION).$(MINOR_VERSION))
47$(info YD>>VERSION_L=$(VERSION_L), VERSION_KK=$(VERSION_KK))
48#ANDROID version check END
49
50ifeq ($(VERSION_KK),true)
51LOCAL_CFLAGS += -DANDROID_KITKAT
52else
53LOCAL_CFLAGS += -DANDROID_LOLLIPOP
54endif
55
56ifneq (,$(filter $(TARGET_BUILD_VARIANT),eng userdebug user))
57ifneq ($(COMPILE_INVENSENSE_COMPASS_CAL),0)
58LOCAL_CFLAGS += -DINVENSENSE_COMPASS_CAL
59endif
60ifeq ($(COMPILE_THIRD_PARTY_ACCEL),1)
61LOCAL_CFLAGS += -DTHIRD_PARTY_ACCEL
62endif
63else # release builds, default
64LOCAL_CFLAGS += -DINVENSENSE_COMPASS_CAL
65endif
66
67LOCAL_SRC_FILES += SensorBase.cpp
68LOCAL_SRC_FILES += MPLSensor.cpp
69LOCAL_SRC_FILES += MPLSupport.cpp
70LOCAL_SRC_FILES += InputEventReader.cpp
71LOCAL_SRC_FILES += PressureSensor.IIO.secondary.cpp
72
73ifneq (,$(filter $(TARGET_BUILD_VARIANT),eng userdebug user))
74ifeq ($(COMPILE_INVENSENSE_COMPASS_CAL),0)
75LOCAL_SRC_FILES += AkmSensor.cpp
76LOCAL_SRC_FILES += CompassSensor.AKM.cpp
77else ifeq ($(COMPILE_INVENSENSE_SENSOR_ON_PRIMARY_BUS), 1)
78LOCAL_SRC_FILES += CompassSensor.IIO.primary.cpp
79LOCAL_CFLAGS += -DSENSOR_ON_PRIMARY_BUS
80else
81LOCAL_SRC_FILES += CompassSensor.IIO.9150.cpp
82endif
83else # release builds, default
84LOCAL_SRC_FILES += CompassSensor.IIO.9150.cpp
85endif # eng, userdebug & user builds
86
87LOCAL_C_INCLUDES += $(LOCAL_PATH)/software/core/mllite
88LOCAL_C_INCLUDES += $(LOCAL_PATH)/software/core/mllite/linux
89LOCAL_C_INCLUDES += $(LOCAL_PATH)/software/core/driver/include
90LOCAL_C_INCLUDES += $(LOCAL_PATH)/software/core/driver/include/linux
91
92LOCAL_SHARED_LIBRARIES := liblog
93LOCAL_SHARED_LIBRARIES += libcutils
94LOCAL_SHARED_LIBRARIES += libutils
95LOCAL_SHARED_LIBRARIES += libdl
96LOCAL_SHARED_LIBRARIES += libmllite
97
98# Additions for SysPed
99LOCAL_SHARED_LIBRARIES += libmplmpu
100LOCAL_C_INCLUDES += $(LOCAL_PATH)/software/core/mpl
101LOCAL_CPPFLAGS += -DLINUX=1
102
103LOCAL_SHARED_LIBRARIES += libmllite
104LOCAL_C_INCLUDES += $(LOCAL_PATH)/software/core/mllite
105LOCAL_CPPFLAGS += -DLINUX=1
106
107include $(BUILD_SHARED_LIBRARY)
108
109# Build a temporary HAL that links the InvenSense .so
110include $(CLEAR_VARS)
111ifeq ($(filter eng, userdebug, user, $(TARGET_BUILD_VARIANT)),)
112ifneq ($(filter manta full_grouper tilapia, $(TARGET_PRODUCT)),)
113LOCAL_MODULE := sensors.full_grouper
114LOCAL_MODULE_OWNER := invensense
115else
116ifneq ($(filter aosp_hammerhead, $(TARGET_PRODUCT)),)
117LOCAL_MODULE := sensors.hammerhead
118LOCAL_MODULE_OWNER := invensense
119else
120ifneq ($(filter aosp_flounder, $(TARGET_PRODUCT)),)
121LOCAL_MODULE := sensors.flounder
122LOCAL_MODULE_OWNER := invensense
123endif
124endif
125ifneq ($(filter dory guppy, $(TARGET_DEVICE)),)
126LOCAL_MODULE := sensors.invensense
127LOCAL_MODULE_OWNER := invensense
128endif
129endif
130else    # eng, user, & userdebug builds
131LOCAL_MODULE := sensors.invensense
132endif   # eng, user & userdebug builds
133$(info YD>>LOCAL_MODULE=$(LOCAL_MODULE))
134
135ifdef TARGET_2ND_ARCH
136LOCAL_MODULE_RELATIVE_PATH := hw
137else
138LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
139endif
140
141LOCAL_SHARED_LIBRARIES += libmplmpu
142LOCAL_C_INCLUDES += $(LOCAL_PATH)/software/core/mllite
143LOCAL_C_INCLUDES += $(LOCAL_PATH)/software/core/mllite/linux
144LOCAL_C_INCLUDES += $(LOCAL_PATH)/software/core/mpl
145LOCAL_C_INCLUDES += $(LOCAL_PATH)/software/core/driver/include
146LOCAL_C_INCLUDES += $(LOCAL_PATH)/software/core/driver/include/linux
147
148LOCAL_MODULE_TAGS := optional
149LOCAL_CFLAGS := -DLOG_TAG=\"Sensors\" -Werror -Wall
150
151ifeq ($(VERSION_KK),true)
152LOCAL_CFLAGS += -DANDROID_KITKAT
153else
154LOCAL_CFLAGS += -DANDROID_LOLLIPOP
155endif
156
157ifneq (,$(filter $(TARGET_BUILD_VARIANT),eng userdebug user))
158ifneq ($(COMPILE_INVENSENSE_COMPASS_CAL),0)
159LOCAL_CFLAGS += -DINVENSENSE_COMPASS_CAL
160endif
161ifeq ($(COMPILE_THIRD_PARTY_ACCEL),1)
162LOCAL_CFLAGS += -DTHIRD_PARTY_ACCEL
163endif
164ifeq ($(COMPILE_INVENSENSE_SENSOR_ON_PRIMARY_BUS), 1)
165LOCAL_SRC_FILES += CompassSensor.IIO.primary.cpp
166LOCAL_CFLAGS += -DSENSOR_ON_PRIMARY_BUS
167else
168LOCAL_SRC_FILES += CompassSensor.IIO.9150.cpp
169endif
170else # release builds, default
171LOCAL_SRC_FILES += CompassSensor.IIO.9150.cpp
172endif # eng, userdebug & user
173
174ifeq (,$(filter $(TARGET_BUILD_VARIANT),eng userdebug user))
175ifneq ($(filter manta grouper tilapia, $(TARGET_DEVICE)),)
176# it's already defined in some other Makefile for production builds
177#LOCAL_SRC_FILES := sensors_mpl.cpp
178else
179LOCAL_SRC_FILES := sensors_mpl.cpp
180endif
181else    # eng, userdebug & user builds
182LOCAL_SRC_FILES := sensors_mpl.cpp
183endif   # eng, userdebug & user builds
184
185LOCAL_SHARED_LIBRARIES := libinvensense_hal
186LOCAL_SHARED_LIBRARIES += libcutils
187LOCAL_SHARED_LIBRARIES += libutils
188LOCAL_SHARED_LIBRARIES += libdl
189LOCAL_SHARED_LIBRARIES += liblog
190LOCAL_SHARED_LIBRARIES += libmllite
191LOCAL_SHARED_LIBRARIES += libhardware_legacy
192$(info YD>>LOCAL_MODULE=$(LOCAL_MODULE), LOCAL_SRC_FILES=$(LOCAL_SRC_FILES), LOCAL_SHARED_LIBRARIES=$(LOCAL_SHARED_LIBRARIES))
193include $(BUILD_SHARED_LIBRARY)
194
195include $(CLEAR_VARS)
196LOCAL_MODULE := libmplmpu
197LOCAL_SRC_FILES := libmplmpu.so
198LOCAL_MODULE_TAGS := optional
199LOCAL_MODULE_OWNER := invensense
200LOCAL_MODULE_SUFFIX := .so
201LOCAL_MODULE_CLASS := SHARED_LIBRARIES
202LOCAL_MODULE_PATH := $(TARGET_OUT)/lib
203OVERRIDE_BUILT_MODULE_PATH := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)
204LOCAL_STRIP_MODULE := true
205include $(BUILD_PREBUILT)
206
207include $(CLEAR_VARS)
208LOCAL_MODULE := libmllite
209LOCAL_SRC_FILES := libmllite.so
210LOCAL_MODULE_TAGS := optional
211LOCAL_MODULE_OWNER := invensense
212LOCAL_MODULE_SUFFIX := .so
213LOCAL_MODULE_CLASS := SHARED_LIBRARIES
214LOCAL_MODULE_PATH := $(TARGET_OUT)/lib
215OVERRIDE_BUILT_MODULE_PATH := $(TARGET_OUT_INTERMEDIATE_LIBRARIES)
216LOCAL_STRIP_MODULE := true
217include $(BUILD_PREBUILT)
218
219