target: add Espressif ESP32 basic support
[fw/openocd] / contrib / loaders / reset / espressif / common.mk
1 # ESP32 Makefile to compile the SoC reset program
2 # Copyright (C) 2022 Espressif Systems Ltd.
3 #
4 # This program is free software; you can redistribute it and/or modify
5 # it under the terms of the GNU General Public License as published by
6 # the Free Software Foundation; either version 2 of the License, or
7 # (at your option) any later version.
8 #
9 # This program is distributed in the hope that it will be useful,
10 # but WITHOUT ANY WARRANTY; without even the implied warranty of
11 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 # GNU General Public License for more details.
13 #
14 # You should have received a copy of the GNU General Public License
15 # along with this program.  If not, see <http://www.gnu.org/licenses/>
16
17 # Pass V=1 to see the commands being executed by make
18 ifneq ("$(V)","1")
19 Q = @
20 endif
21
22 BIN2C = ../../../../../src/helper/bin2char.sh
23
24 APP = cpu_reset_handler
25
26 BUILD_DIR = build
27
28 APP_OBJ = $(BUILD_DIR)/$(APP).o
29 APP_BIN = $(BUILD_DIR)/$(APP)_code.bin
30 APP_CODE = $(APP)_code.inc
31
32 CFLAGS += -mtext-section-literals
33
34 .PHONY: all cleanxten
35
36 all: $(BUILD_DIR) $(APP_OBJ) $(APP_CODE)
37
38 $(BUILD_DIR):
39         $(Q) mkdir $@
40
41 $(APP_OBJ): $(SRCS)
42         @echo "  CC   $^ -> $@"
43         $(Q) $(CROSS)gcc -c $(CFLAGS)  -o $@ $^
44
45 $(APP_CODE): $(APP_OBJ)
46         @echo "  CC   $^ -> $@"
47         $(Q) $(CROSS)objcopy -O binary -j.text $^ $(APP_BIN)
48         $(Q) $(BIN2C) < $(APP_BIN) > $@
49
50 clean:
51         $(Q) rm -rf $(BUILD_DIR)