-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile.gmake
200 lines (154 loc) · 5.84 KB
/
Makefile.gmake
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
#
# Copyright (C) 2018-2021, Thomas Maier-Komor
# Atrium Firmware Package for ESP
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# no default project set - Set to a filename in projects directory.
#PROJECT=
# place following variables in settings.mk or use setupenv.sh to create it
# IDF_ESP8266
# IDF_ESP32
# XTOOLS_ESP32
# XTOOLS_ESP8266
# WFC
ifeq ("$(wildcard settings.mk)","settings.mk")
include settings.mk
else
$(error run setupenv.sh or create settings.mk with IDF_ESP8266,IDF_ESP32,XTOOLS_ESP8266,XTOOLS_ESP32,WFC)
exit
endif
#####
CXXFLAGS=-g
PWD=$(shell pwd)
ifneq ($(MAKECMDGOALS),atriumcfg)
ifneq ($(MAKECMDGOALS),mkromfs)
ifneq ("$(wildcard projects/$(PROJECT))","projects/")
SDKCONFIG=$(PWD)/projects/$(PROJECT)
-include $(SDKCONFIG) # needed for romfs .bin generation
else
$(warning unable to find project file "projects/$(PROJECT)")
endif
endif
endif
# some defaults for romfs-flash in case no PROJECT is given
CONFIG_ESPTOOLPY_PORT?=/dev/ttyUSB0
PROJECT_NAME = atrium
CHIP =$(shell grep ESP8266 projects/$(PROJECT) 2>&1 > /dev/null && echo ESP8266 || echo ESP32)
IDF_PATH :=$(IDF_$(CHIP))
ESPTOOL :=$(IDF_PATH)/components/esptool_py/esptool/esptool.py
PARTTOOL :=$(IDF_PATH)/components/partition_table/parttool.py
FLASH_PORT :=$(CONFIG_ESPTOOLPY_PORT)
ROMFS =
ROMFS_LST =romfs/$(ROMFS).lst
ROMFS_FILE =$(ROMFS_LST:%.lst=%.romfs)
ROMFS_FILES =$(shell cat $(ROMFS_LST) 2>/dev/null)
ROMFS_ADDR =$(CONFIG_ROMFS_ADDR)
IDF_VER :=$(shell cd $(IDF_PATH); git describe --tags 2>/dev/null | sed 's/\.//;s/v//;s/-.*//;s/\..*//')
# shell call to remove ""
WFC_TARGET =$(shell echo $(CONFIG_WFC_TARGET))
CPPFLAGS =-DIDF_VERSION=$(IDF_VER) -D$(CHIP) -DFWCFG=\"$(PROJECT)\" -DWFC_TARGET=$(WFC_TARGET) -I$(BUILD_DIR_BASE)/config
BUILD_DIR_BASE =$(PWD)/build.$(PROJECT)
PROJECT_ROOT =$(PWD)
WFCINC =$(WFCDIR)/include
PROJECT_VER =$(shell bin/mkversion.sh)
MEMFILES =$(shell cd data; ls -1 man/*.man)
ROMFS_PARTITION =storage
CFG_CXX =tools/atriumcfg.cpp components/wfc/hwcfg_pc.cpp components/wfc/swcfg_pc.cpp components/wfc/wfccore_pc.cpp
PATH :=$(PATH_$(CHIP)):$(PATH)
IDF_PYTHON_ENV_PATH =$(IDF_PYTHON_ENV_PATH_$(CHIP))
ifneq ($(ROMFS_FILES),)
ESPTOOL_ALL_FLASH_ARGS=$(ROMFS_ADDR) build.$(PROJECT)/romfs.bin
endif
.PHONY: prepare settings
export BUILD_DIR_BASE CHIP CPPFLAGS PROJECT_NAME IDF_PATH IDF_VER PATH PTABLE PROJECT_ROOT PROJECT SDKCONFIG WFC WFCDIR ESPTOOL_ALL_FLASH_ARGS CXXFLAGS PROJECT_VER MEMFILES CONFIG_INTEGRATED_HELP WFC_TARGET
romfs/%.romfs: prepare
bin/mkromfs -c data -o $@ $(ROMFS_FILES) version.txt
default: all
settings:
@echo SDKCONFIG=$(SDKCONFIG)
@echo BUILD=build.$(PROJECT)
@echo CHIP=$(CHIP)
@echo CONFIG_ROMFS_FILES=$(CONFIG_ROMFS_FILES)
@echo ROMFS_FILES=$(ROMFS_FILES)
@echo ROMFS_ADDR=$(ROMFS_ADDR)
@echo PATH=$(PATH)
@echo IDF_PATH=$(IDF_PATH)
@echo IDF_VER=$(IDF_VER)
@echo CPPFLAGS=$(CPPFLAGS)
tools: mkromfs atriumcfg font-tool
$(IDF_PATH):
@echo please run setupenv.sh before running make
exit 1
prepare: $(IDF_PATH)
BUILD_DIR=$(BUILD_DIR_BASE) bash bin/prebuild.sh
all: prepare
+$(MAKE) -f $(CHIP).mk all
app2: prepare
+$(MAKE) -f $(CHIP).mk app2
app-flash: prepare
+$(MAKE) -f $(CHIP).mk app-flash
flash: prepare
+$(MAKE) -f $(CHIP).mk flash
fflash:
+$(MAKE) -f $(CHIP).mk flash
ota: prepare
-rm $(BUILD_DIR_BASE)/$(PROJECT_NAME).elf $(BUILD_DIR_BASE)/esp8266/esp8266_out.ld
+$(MAKE) -f $(CHIP).mk app2
cp $(BUILD_DIR_BASE)/$(PROJECT_NAME).bin $(BUILD_DIR_BASE)/$(PROJECT_NAME).app2
-rm $(BUILD_DIR_BASE)/$(PROJECT_NAME).elf $(BUILD_DIR_BASE)/esp8266/esp8266_out.ld
+$(MAKE) -f $(CHIP).mk all
cp $(BUILD_DIR_BASE)/$(PROJECT_NAME).bin $(BUILD_DIR_BASE)/$(PROJECT_NAME).app1
menuconfig:
+$(MAKE) -f $(CHIP).mk menuconfig
oldconfig: prepare
+$(MAKE) -f $(CHIP).mk oldconfig
size-symbols: prepare
+$(MAKE) -f $(CHIP).mk size-symbols
size: prepare
+$(MAKE) -f $(CHIP).mk size
monitor: #prepare
+$(MAKE) -f $(CHIP).mk monitor
help:
+$(MAKE) -f $(CHIP).mk help
erase:
$(ESPTOOL) --port $(FLASH_PORT) erase_flash
erase-nvs:
$(PARTTOOL) --port $(FLASH_PORT) erase_partition --partition-name=nvs
bin:
mkdir $@
bin/mkromfs$(EXEEXT): bin tools/mkromfs.cpp
g++ -g tools/mkromfs.cpp -o $@
mkromfs: bin/mkromfs$(EXEEXT)
build.$(PROJECT):
-mkdir $@
build.$(PROJECT)/romfs.bin: prepare bin/mkromfs $(ROMFS_FILE:%=romfs/%) build.$(PROJECT)
if [ "" != "$(ROMFS_FILE)" ]; then bin/mkromfs -o $@ data/version.txt $(ROMFS_FILE:%=romfs/%); else rm -f $@; fi
romfs: $(ROMFS_FILE)
romfs-flash: $(ROMFS_FILE)
if [ -f $< -a "" != "$(ROMFS_PARTITION)" ]; then $(PARTTOOL) --port $(FLASH_PORT) write_partition --partition-name=$(ROMFS_PARTITION) --input=$^; fi
build.$(PROJECT)/spiffs.bin: $(ROMFS_FILES:%=data/%)
if [ "" != "$(ROMFS_FILES)" ]; then mkspiffs -o $@ $(ROMFS_FILES:%=data/%); else rm -f $@; fi
atriumcfg: bin/atriumcfg$(EXEEXT)
bin/atriumcfg$(EXEEXT): $(CFG_CXX) tools/version.h tools/pcconfig.h
g++ -g -DWFC_TARGET=pc -Imain -Icomponents/wfc -Itools $(CFG_CXX) -ledit -lmd -o $@
font-tool: bin/font-tool$(EXEEXT)
bin/font-tool$(EXEEXT): tools/font-tool.c
gcc -g -I/usr/include/freetype2 tools/font-tool.c -o bin/font-tool -lfreetype
always:
tools/version.h: always
bash bin/mkversion.sh $@
tools/pcconfig.h: main/Kconfig
grep '^config ' main/Kconfig | sed 's/^config /#define CONFIG_/' > $@
echo "#define CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG" >> $@