aboutsummaryrefslogtreecommitdiff
path: root/contrib/loaders/reset/espressif/common.mk
blob: 4623583aa65aae0b39a543e9a9acef39dd31762f (plain)
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
# ESP32 Makefile to compile the SoC reset program
# Copyright (C) 2022 Espressif Systems Ltd.
#
# 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 2 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/>

# Pass V=1 to see the commands being executed by make
ifneq ("$(V)","1")
Q = @
endif

BIN2C = ../../../../../src/helper/bin2char.sh

APP = cpu_reset_handler

BUILD_DIR = build

APP_OBJ = $(BUILD_DIR)/$(APP).o
APP_BIN = $(BUILD_DIR)/$(APP)_code.bin
APP_CODE = $(APP)_code.inc

CFLAGS += -mtext-section-literals

.PHONY: all cleanxten

all: $(BUILD_DIR) $(APP_OBJ) $(APP_CODE)

$(BUILD_DIR):
	$(Q) mkdir $@

$(APP_OBJ): $(SRCS)
	@echo "  CC   $^ -> $@"
	$(Q) $(CROSS)gcc -c $(CFLAGS)  -o $@ $^

$(APP_CODE): $(APP_OBJ)
	@echo "  CC   $^ -> $@"
	$(Q) $(CROSS)objcopy -O binary -j.text $^ $(APP_BIN)
	$(Q) $(BIN2C) < $(APP_BIN) > $@

clean:
	$(Q) rm -rf $(BUILD_DIR)