1# Copyright (C) 2015 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
15#
16# Nanohub sensor HAL usage instructions:
17#
18# Add the following to your device.mk file.
19#
20# # Enable the nanohub sensor HAL
21# TARGET_USES_NANOHUB_SENSORHAL := true
22#
23# # Nanohub sensor list source file
24# NANOHUB_SENSORHAL_SENSORLIST := $(LOCAL_PATH)/sensorhal/sensorlist.cpp
25#
26# # Sensor HAL name override (optional)
27# NANOHUB_SENSORHAL_NAME_OVERRIDE := sensors.nanohub
28#
29# # Enable lid-state reporting (optional)
30# NANOHUB_SENSORHAL_LID_STATE_ENABLED := true
31#
32# # Enable mag-bias reporting (optional)
33# NANOHUB_SENSORHAL_USB_MAG_BIAS_ENABLED := true
34#
35
36LOCAL_PATH := $(call my-dir)
37
38ifeq ($(TARGET_USES_NANOHUB_SENSORHAL), true)
39
40COMMON_CFLAGS := -Wall -Werror -Wextra
41
42################################################################################
43
44include $(CLEAR_VARS)
45
46ifeq ($(NANOHUB_SENSORHAL_NAME_OVERRIDE),)
47ifeq ($(TARGET_DEVICE),angler_treble)
48LOCAL_MODULE := sensors.angler
49else
50ifeq ($(TARGET_DEVICE),bullhead_treble)
51LOCAL_MODULE := sensors.bullhead
52else
53LOCAL_MODULE := sensors.$(TARGET_DEVICE)
54endif
55endif
56else
57LOCAL_MODULE := $(NANOHUB_SENSORHAL_NAME_OVERRIDE)
58endif
59
60LOCAL_MODULE_RELATIVE_PATH := hw
61LOCAL_MODULE_TAGS := optional
62LOCAL_MODULE_OWNER := google
63LOCAL_PROPRIETARY_MODULE := true
64
65LOCAL_CFLAGS += $(COMMON_CFLAGS)
66
67LOCAL_C_INCLUDES += \
68	device/google/contexthub/firmware/os/inc \
69	device/google/contexthub/util/common
70
71LOCAL_SRC_FILES := \
72	sensors.cpp \
73	../../../../$(NANOHUB_SENSORHAL_SENSORLIST)
74
75LOCAL_HEADER_LIBRARIES := \
76    libhardware_headers
77
78LOCAL_SHARED_LIBRARIES := \
79	liblog \
80	libcutils \
81	libhubconnection \
82	libstagefright_foundation \
83	libutils
84
85ifeq ($(NANOHUB_SENSORHAL_DIRECT_REPORT_ENABLED), true)
86LOCAL_CFLAGS += -DDIRECT_REPORT_ENABLED
87endif
88
89ifeq ($(NANOHUB_SENSORHAL_DYNAMIC_SENSOR_EXT_ENABLED), true)
90LOCAL_CFLAGS += -DDYNAMIC_SENSOR_EXT_ENABLED
91LOCAL_SHARED_LIBRARIES += libdynamic_sensor_ext
92endif
93
94ifeq ($(NANOHUB_SENSORHAL_LEFTY_SERVICE_ENABLED), true)
95LOCAL_CFLAGS += -DLEFTY_SERVICE_ENABLED
96LOCAL_SHARED_LIBRARIES += liblefty_service_nanohub
97endif
98
99include $(BUILD_SHARED_LIBRARY)
100
101################################################################################
102
103include $(CLEAR_VARS)
104
105LOCAL_MODULE := libhubconnection
106LOCAL_MODULE_TAGS := optional
107LOCAL_MODULE_OWNER := google
108LOCAL_PROPRIETARY_MODULE := true
109
110LOCAL_CFLAGS += $(COMMON_CFLAGS)
111
112ifeq ($(NANOHUB_SENSORHAL_LID_STATE_ENABLED), true)
113LOCAL_CFLAGS += -DLID_STATE_REPORTING_ENABLED
114endif
115
116ifeq ($(NANOHUB_SENSORHAL_USB_MAG_BIAS_ENABLED), true)
117LOCAL_CFLAGS += -DUSB_MAG_BIAS_REPORTING_ENABLED
118endif
119
120ifeq ($(NANOHUB_SENSORHAL_DOUBLE_TOUCH_ENABLED), true)
121LOCAL_CFLAGS += -DDOUBLE_TOUCH_ENABLED
122endif
123
124ifeq ($(NANOHUB_SENSORHAL_DIRECT_REPORT_ENABLED), true)
125LOCAL_CFLAGS += -DDIRECT_REPORT_ENABLED
126endif
127
128LOCAL_C_INCLUDES += \
129    device/google/contexthub/firmware/os/inc
130
131LOCAL_SRC_FILES := \
132    hubconnection.cpp \
133    directchannel.cpp
134
135LOCAL_STATIC_LIBRARIES := \
136    libhubutilcommon
137
138LOCAL_SHARED_LIBRARIES := \
139    libcutils \
140    libhardware \
141    libhardware_legacy \
142    liblog \
143    libstagefright_foundation \
144    libutils \
145
146include $(BUILD_SHARED_LIBRARY)
147
148################################################################################
149
150endif
151