This repository has been archived by the owner on Nov 30, 2023. It is now read-only.
forked from STMicroelectronics/STMems_Android_Sensor_HAL_IIO
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
147 lines (122 loc) · 4.77 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#
# Copyright (C) 2017 STMicroelectronics
# Denis Ciocca - Motion MEMS Product Div.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
.PHONY: sensors-defconfig sensors-menuconfig sensors-cleanconf
CURRENT_DIRECTORY := $(shell pwd)
# Check AOSP version
ifeq ($(PLATFORM_VERSION),)
# ANDROID_BUILD_TOP is deprecated
ifeq ($(ANDROID_BUILD_TOP),)
VERSION_DEFAULT := $(.)/build/core/version_defaults.mk
else # ANDROID_BUILD_TOP
VERSION_DEFAULT := $(ANDROID_BUILD_TOP)/build/core/version_defaults.mk
endif # ANDROID_BUILD_TOP
PLATFORM_COMMAND_VERSION := $(shell grep "PLATFORM_VERSION := " $(VERSION_DEFAULT))
PLATFORM_VERSION := $(shell echo $(PLATFORM_COMMAND_VERSION) | awk -F':= ' '{print $$2}')
endif # PLATFORM_VERSION
MAJOR_VERSION := $(shell echo $(PLATFORM_VERSION) | cut -f1 -d.)
MINOR_VERSION := $(shell echo $(PLATFORM_VERSION) | cut -f2 -d.)
VERSION_KK := $(shell test $(MAJOR_VERSION) -eq 4 -a $(MINOR_VERSION) -eq 4 && echo true)
VERSION_L := $(shell test $(MAJOR_VERSION) -eq 5 && echo true)
VERSION_M := $(shell test $(MAJOR_VERSION) -eq 6 && echo true)
VERSION_N := $(shell test $(MAJOR_VERSION) -eq 7 && echo true)
VERSION_O := $(shell test $(MAJOR_VERSION) -eq 8 && echo true)
VERSION_P := $(shell test $(MAJOR_VERSION) -eq 9 && echo true)
VERSION_Q := $(shell test $(MAJOR_VERSION) -eq 10 && echo true)
VERSION_R := $(shell test $(MAJOR_VERSION) -eq 11 && echo true)
ifeq ($(VERSION_KK),true)
ST_HAL_ANDROID_VERSION=0
DEFCONFIG := android_KK_defconfig
endif # VERSION_KK
ifeq ($(VERSION_L),true)
ST_HAL_ANDROID_VERSION=1
DEFCONFIG := android_L_defconfig
endif # VERSION_L
ifeq ($(VERSION_M),true)
ST_HAL_ANDROID_VERSION=2
DEFCONFIG := android_M_defconfig
endif # VERSION_M
ifeq ($(VERSION_N),true)
ST_HAL_ANDROID_VERSION=3
DEFCONFIG := android_N_defconfig
endif # VERSION_N
ifeq ($(VERSION_O),true)
ST_HAL_ANDROID_VERSION=4
DEFCONFIG := android_O_defconfig
endif # VERSION_O
ifeq ($(VERSION_P),true)
ST_HAL_ANDROID_VERSION=5
DEFCONFIG := android_P_defconfig
endif # VERSION_P
ifeq ($(VERSION_Q),true)
ST_HAL_ANDROID_VERSION=6
DEFCONFIG := android_Q_defconfig
endif # VERSION_Q
ifeq ($(VERSION_R),true)
ST_HAL_ANDROID_VERSION=7
DEFCONFIG := android_R_defconfig
endif # VERSION_R
ifeq ($(DEFCONFIG),)
$(error ${\n}${\n}${\space}${\n}AOSP Version Unknown${\n})
endif # DEFCONFIG
ifneq ("$(wildcard $(CURRENT_DIRECTORY)/lib/FUFD_CustomTilt/FUFD_CustomTilt*)","")
ST_HAL_HAS_FDFD_LIB=y
else
ST_HAL_HAS_FDFD_LIB=n
endif
ifneq ("$(wildcard $(CURRENT_DIRECTORY)/lib/iNemoEngine_gbias_Estimation/iNemoEngine_gbias_Estimation*)","")
ST_HAL_HAS_GBIAS_LIB=y
else
ST_HAL_HAS_GBIAS_LIB=n
endif
ifneq ("$(wildcard $(CURRENT_DIRECTORY)/lib/iNemoEngine_GeoMag_Fusion/iNemoEngine_GeoMag*)","")
ST_HAL_HAS_GEOMAG_LIB=y
else
ST_HAL_HAS_GEOMAG_LIB=n
endif
ifneq ("$(wildcard $(CURRENT_DIRECTORY)/lib/iNemoEnginePRO/iNemoEnginePRO*)","")
ST_HAL_HAS_9X_6X_LIB=y
else
ST_HAL_HAS_9X_6X_LIB=n
endif
ifneq ("$(wildcard $(CURRENT_DIRECTORY)/lib/STMagCalibration/STMagCalibration*)","")
ST_HAL_HAS_MAGN_CALIB_LIB=y
else
ST_HAL_HAS_MAGN_CALIB_LIB=n
endif
ifneq ("$(wildcard $(CURRENT_DIRECTORY)/lib/STAccCalibration/STAccCalibration*)","")
ST_HAL_HAS_ACCEL_CALIB_LIB=y
else
ST_HAL_HAS_ACCEL_CALIB_LIB=n
endif
# Export to config tools
export ST_HAL_HAS_ACCEL_CALIB_LIB ST_HAL_HAS_MAGN_CALIB_LIB ST_HAL_HAS_9X_6X_LIB ST_HAL_HAS_GEOMAG_LIB ST_HAL_HAS_GBIAS_LIB ST_HAL_HAS_FDFD_LIB
export ST_HAL_ANDROID_VERSION
export DEFCONFIG
export KCONFIG_CONFIG_HAL=$(CURRENT_DIRECTORY)/hal_config
export ST_HAL_PATH=$(CURRENT_DIRECTORY)
configfile:
$(if $(wildcard $(KCONFIG_CONFIG_HAL)), , $(warning ${\n}${\n}${\space}${\n}defconfig file not found. Used default one: `$(DEFCONFIG)`.${\n}${\space}${\n}) @$(MAKE) sensors-defconfig > /dev/null)
sensors-defconfig:
cp $(CURRENT_DIRECTORY)/src/$(DEFCONFIG) $(KCONFIG_CONFIG_HAL)
$(CURRENT_DIRECTORY)/tools/mkconfig $(CURRENT_DIRECTORY)/ > $(CURRENT_DIRECTORY)/configuration.h
sensors-menuconfig: configfile
$(CURRENT_DIRECTORY)/tools/kconfig-mconf $(CURRENT_DIRECTORY)/Kconfig
$(CURRENT_DIRECTORY)/tools/mkconfig $(CURRENT_DIRECTORY)/ > $(CURRENT_DIRECTORY)/configuration.h
sensors-cleanconf:
$(if $(wildcard $(KCONFIG_CONFIG_HAL)), rm $(KCONFIG_CONFIG_HAL), )
$(if $(wildcard $(KCONFIG_CONFIG_HAL).old), rm $(KCONFIG_CONFIG_HAL).old, )
$(if $(wildcard $(CURRENT_DIRECTORY)/configuration.h), rm $(CURRENT_DIRECTORY)/configuration.h, )