-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathMakefile
76 lines (58 loc) · 1.93 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
#
# Makefile for rBoot sample project
# https://github.com/raburton/esp8266
#
# use wifi settings from environment or hard code them here
WIFI_SSID ?= ""
WIFI_PWD ?= ""
SDK_BASE ?= /opt/esp-open-sdk/sdk
SDK_LIBDIR = lib
SDK_INCDIR = include
ESPTOOL2 ?= ../esptool2/esptool2
FW_SECTS = .text .data .rodata
FW_USER_ARGS = -quiet -bin -boot2
ifndef XTENSA_BINDIR
CC := xtensa-lx106-elf-gcc
LD := xtensa-lx106-elf-gcc
else
CC := $(addprefix $(XTENSA_BINDIR)/,xtensa-lx106-elf-gcc)
LD := $(addprefix $(XTENSA_BINDIR)/,xtensa-lx106-elf-gcc)
endif
BUILD_DIR = build
FIRMW_DIR = firmware
SDK_LIBDIR := $(addprefix $(SDK_BASE)/,$(SDK_LIBDIR))
SDK_INCDIR := $(addprefix -I$(SDK_BASE)/,$(SDK_INCDIR))
LIBS = c gcc hal phy net80211 lwip wpa main pp crypto
CFLAGS = -Os -g -O2 -Wpointer-arith -Wundef -Werror -Wno-implicit -Wl,-EL -fno-inline-functions -nostdlib -mlongcalls -mtext-section-literals -D__ets__ -DICACHE_FLASH
LDFLAGS = -nostdlib -Wl,--no-check-sections -u call_user_start -Wl,-static
SRC := $(wildcard *.c)
OBJ := $(patsubst %.c,$(BUILD_DIR)/%.o,$(SRC))
LIBS := $(addprefix -l,$(LIBS))
ifneq ($(WIFI_SSID), "")
CFLAGS += -DWIFI_SSID=\"$(WIFI_SSID)\"
endif
ifneq ($(WIFI_PWD), "")
CFLAGS += -DWIFI_PWD=\"$(WIFI_PWD)\"
endif
.SECONDARY:
.PHONY: all clean
C_FILES = $(wildcard *.c)
O_FILES = $(patsubst %.c,$(BUILD_DIR)/%.o,$(C_FILES))
all: $(BUILD_DIR) $(FIRMW_DIR) $(FIRMW_DIR)/rom0.bin $(FIRMW_DIR)/rom1.bin
$(BUILD_DIR)/%.o: %.c %.h
@echo "CC $<"
@$(CC) -I. $(SDK_INCDIR) $(CFLAGS) -o $@ -c $<
$(BUILD_DIR)/%.elf: $(O_FILES)
@echo "LD $(notdir $@)"
@$(LD) -L$(SDK_LIBDIR) -T$(notdir $(basename $@)).ld $(LDFLAGS) -Wl,--start-group $(LIBS) $^ -Wl,--end-group -o $@
$(FIRMW_DIR)/%.bin: $(BUILD_DIR)/%.elf
@echo "FW $(notdir $@)"
@$(ESPTOOL2) $(FW_USER_ARGS) $^ $@ $(FW_SECTS)
$(BUILD_DIR):
@mkdir -p $@
$(FIRMW_DIR):
@mkdir -p $@
clean:
@echo "RM $(BUILD_DIR) $(FIRMW_DIR)"
@rm -rf $(BUILD_DIR)
@rm -rf $(FIRMW_DIR)