-
Notifications
You must be signed in to change notification settings - Fork 17
/
Makefile
224 lines (176 loc) · 6.69 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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
ifeq ($(EXAMPLE), )
EXAMPLE := helper_project
endif
ifeq ($(SOC), )
SOC := esp32
endif
# $(1): Files list with path
# $(2): Target directory
define copy_files
$(foreach f,$(1),cp $(f) $(2) && ) .
endef
# $(1): File with path
# $(2): Stripped macros list in file
define strip_macros
$(foreach m,$(2),sed -i "/$(m)/d" $(1) &&) .
endef
PRJ_DIR := $(shell pwd)
IDF_VER_T := $(shell cd ${IDF_PATH} && \
git describe --always --tags --dirty && \
git log -n 1 | grep "commit")
# Local options
VERISON_FILE := version
INCS_DIR := $(PRJ_DIR)/include
LIBS_DIR := $(PRJ_DIR)/libs/$(SOC)
SOC_INCS_DIR := $(PRJ_DIR)/include/$(SOC)
# SoC
SOC_HFS := $(IDF_PATH)/components/esp_wifi/$(SOC)/include/phy_init_data.h
ifeq ($(SOC), esp32)
SDKCONFIG_RMS := CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ \
CONFIG_ESP32_TRACEMEM_RESERVE_DRAM \
CONFIG_PTHREAD_STACK_MIN
else ifeq ($(SOC), esp32c3)
SDKCONFIG_RMS := CONFIG_ESP32C3_DEFAULT_CPU_FREQ_MHZ \
CONFIG_PTHREAD_STACK_MIN
else
$(error soc=$(SOC) is not supported)
endif
# Libs
IDF_COMPONENTS := wpa_supplicant
GEN_LIBS := $(foreach c,$(IDF_COMPONENTS),$(PRJ_DIR)/$(EXAMPLE)/build/esp-idf/$(c)/lib$(c).a)
WIFI_LIBS := $(IDF_PATH)/components/esp_wifi/lib/$(SOC)/*
ifeq ($(SOC), esp32)
BT_LIBS := $(IDF_PATH)/components/bt/controller/lib_esp32/esp32/*
else ifeq ($(SOC), esp32c3)
BT_LIBS := $(IDF_PATH)/components/bt/controller/lib_esp32c3_family/esp32c3/*
else
$(error "No BT libraries")
endif
IDF_LIBS := $(GEN_LIBS) $(WIFI_LIBS) $(BT_LIBS)
# Types
TYPES_DIR := patch
TYPES_HFS := $(TYPES_DIR)/espidf_types.h \
$(TYPES_DIR)/espidf_wifi.h
# Wi-Fi
WIFI_DIR := $(IDF_PATH)/components/esp_wifi/include
WIFI_SRC_HFS := $(WIFI_DIR)/esp_wifi.h \
$(WIFI_DIR)/esp_wifi_default.h \
$(WIFI_DIR)/esp_phy_init.h \
$(WIFI_DIR)/esp_wifi_types.h \
$(WIFI_DIR)/phy.h \
$(WIFI_DIR)/esp_wifi_crypto_types.h \
$(WIFI_DIR)/esp_smartconfig.h \
$(WIFI_DIR)/esp_coexist_adapter.h \
$(WIFI_DIR)/esp_coexist_internal.h \
$(WIFI_DIR)/esp_coexist.h
# Wi-Fi Private
WIFI_PRIV_DIR := $(WIFI_DIR)/esp_private
WIFI_PRIV_DST_DIR := $(INCS_DIR)/esp_private
WIFI_PRIV_SRC_HFS := $(WIFI_PRIV_DIR)/wifi_os_adapter.h \
$(WIFI_PRIV_DIR)/wifi.h \
$(WIFI_PRIV_DIR)/esp_wifi_types_private.h \
$(WIFI_PRIV_DIR)/esp_wifi_private.h \
$(WIFI_PRIV_DIR)/wifi_types.h
WIFI_PRIV_WIFI_DST_HF := $(WIFI_PRIV_DST_DIR)/wifi.h
WIFI_PRIV_WIFI_HF_RMS := freertos\/queue.h \
freertos\/FreeRTOS.h
WIFI_PRIV_WIFI_PRIV_DST_HF := $(WIFI_PRIV_DST_DIR)/esp_wifi_private.h
WIFI_PRIV_WIFI_PRIV_HF_RMS := freertos\/queue.h \
freertos\/FreeRTOS.h
# Common
COMMON_DIR := $(IDF_PATH)/components/esp_common/include
COMMON_SRC_HFS := $(COMMON_DIR)/esp_err.h \
$(COMMON_DIR)/esp_compiler.h \
$(COMMON_DIR)/esp_interface.h
# Event
EVENT_DIR := $(IDF_PATH)/components/esp_event/include
EVENT_SRC_HFS := $(EVENT_DIR)/esp_event_base.h \
$(EVENT_DIR)/esp_event.h \
$(EVENT_DIR)/esp_event_legacy.h
EVENT_DST_HF := $(INCS_DIR)/esp_event.h
EVENT_DST_RM := freertos\/FreeRTOS.h \
freertos\/task.h \
freertos\/queue.h \
freertos\/semphr.h
EVENT_LEGACY_DST_HF := $(INCS_DIR)/esp_event_legacy.h
EVENT_LEGACY_HF_RMS := esp_netif.h \
system_event_ap_staipassigned_t \
system_event_sta_got_ip_t \
system_event_got_ip6_t
# NVS
NVS_DIR := $(IDF_PATH)/components/nvs_flash/include
NVS_SRC_HF := $(NVS_DIR)/nvs.h
NVS_DST_HF := $(INCS_DIR)/nvs.h
NVS_HF_RMS := esp_attr.h
# WPA
WPA_DIR := $(IDF_PATH)/components/wpa_supplicant/include/esp_supplicant
WPA_SRC_HFS := $(WPA_DIR)/esp_wpa.h \
$(WPA_DIR)/esp_wpa2.h
# ESP_Timer
ESPTIMER_DIR := $(IDF_PATH)/components/esp_timer/include
ESPTIMER_SRC_HF := $(ESPTIMER_DIR)/esp_timer.h
# ESP_System
ESPSYSTEM_DIR := $(IDF_PATH)/components/esp_system/include
ESPSYSTEM_SRC_HF := $(ESPSYSTEM_DIR)/esp_system.h
ESPSYSTEM_DST_HF := $(INCS_DIR)/esp_system.h
ESPSYSTEM_HF_RMS := esp_attr.h \
esp_bit_defs.h \
esp_idf_version.h
# SDKCONFIG
SDKCONFIG_DST_HF := $(SOC_INCS_DIR)/sdkconfig.h
SDKCONFIG_SRC_HF := $(PRJ_DIR)/$(EXAMPLE)/build/config/sdkconfig.h
SDKCONFIG_PTH_HF := $(PRJ_DIR)/patch/$(SOC)/sdkconfig.h
# BT/BLE
BT_SRC_HF := $(IDF_PATH)/components/bt/include/$(SOC)/include/esp_bt.h
BT_DST_HF := $(SOC_INCS_DIR)/esp_bt.h
BT_HF_RMS := esp_task.h
.PHONY: all clean build copy_libs copy_hfiles
all: copy_libs copy_hfiles
@echo $(IDF_VER_T) > $(VERISON_FILE)
clean:
@cd $(PRJ_DIR)/$(EXAMPLE) && rm build sdkconfig sdkconfig.old -rf
@rm $(LIBS_DIR) $(INCS_DIR) $(SOC_INCS_DIR) -rf
build:
@cd $(PRJ_DIR)/$(EXAMPLE) && rm build sdkconfig sdkconfig.old -rf && idf.py -DIDF_TARGET=$(SOC) build
copy_libs: build
@mkdir -p $(LIBS_DIR)
@$(call copy_files,$(IDF_LIBS),$(LIBS_DIR))
inc_dirs: build
@mkdir -p $(INCS_DIR)
config_files: inc_dirs
@$(call copy_files,$(TYPES_HFS),$(INCS_DIR))
wifi_files: inc_dirs
@mkdir -p $(INCS_DIR)/esp_private
@$(call copy_files,$(WIFI_SRC_HFS),$(INCS_DIR))
@$(call copy_files,$(WIFI_PRIV_SRC_HFS),$(WIFI_PRIV_DST_DIR))
@$(call strip_macros,$(WIFI_PRIV_WIFI_DST_HF),$(WIFI_PRIV_WIFI_HF_RMS))
@$(call strip_macros,$(WIFI_PRIV_WIFI_PRIV_DST_HF),$(WIFI_PRIV_WIFI_PRIV_HF_RMS))
common_files: inc_dirs
@$(call copy_files,$(COMMON_SRC_HFS),$(INCS_DIR))
event_files:
@$(call copy_files,$(EVENT_SRC_HFS),$(INCS_DIR))
@$(call strip_macros,$(EVENT_DST_HF),$(EVENT_DST_RM))
@$(call strip_macros,$(EVENT_LEGACY_DST_HF),$(EVENT_LEGACY_HF_RMS))
nvs_files:
@$(call copy_files,$(NVS_SRC_HF),$(INCS_DIR))
@$(call strip_macros,$(NVS_DST_HF),$(NVS_HF_RMS))
wpa_files:
@$(call copy_files,$(WPA_SRC_HFS),$(INCS_DIR))
esptimer_files:
@$(call copy_files,$(ESPTIMER_SRC_HF),$(INCS_DIR))
espsystem_files:
@$(call copy_files,$(ESPSYSTEM_SRC_HF),$(INCS_DIR))
@$(call strip_macros,$(ESPSYSTEM_DST_HF),$(ESPSYSTEM_HF_RMS))
soc_files:
@mkdir -p $(SOC_INCS_DIR)
@$(call copy_files,$(SOC_HFS),$(SOC_INCS_DIR))
@cp $(SDKCONFIG_SRC_HF) $(SOC_INCS_DIR)
@cat $(SDKCONFIG_PTH_HF) >> $(SDKCONFIG_DST_HF)
@$(call strip_macros,$(SDKCONFIG_DST_HF),$(SDKCONFIG_RMS))
bt_files:
@mkdir -p $(SOC_INCS_DIR)
@$(call copy_files,$(BT_SRC_HF),$(SOC_INCS_DIR))
@$(call strip_macros,$(BT_DST_HF),$(BT_HF_RMS))
copy_hfiles: config_files wifi_files common_files event_files \
wpa_files nvs_files esptimer_files espsystem_files \
soc_files bt_files