forked from igrr/esptool-ck
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
91 lines (74 loc) · 1.94 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
CFLAGS += -std=gnu99 -Os -Wall
CXXFLAGS += -std=c++11 -Os -Wall
ifeq ($(OS),Windows_NT)
TARGET_OS := WINDOWS
DIST_SUFFIX := windows
ARCHIVE_CMD := 7z a
ARCHIVE_EXTENSION := zip
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
TARGET_OS := LINUX
UNAME_M := $(shell uname -m)
ifeq ($(UNAME_M),x86_64)
DIST_SUFFIX := linux64
endif
ifeq ($(UNAME_M),i686)
DIST_SUFFIX := linux32
endif
ifeq ($(UNAME_M),armv6l)
DIST_SUFFIX := linux-armhf
endif
endif
ifeq ($(UNAME_S),Darwin)
TARGET_OS := OSX
DIST_SUFFIX := osx
endif
ifeq ($(UNAME_S),FreeBSD)
TARGET_OS := FREEBSD
DIST_SUFFIX := freebsd
endif
ARCHIVE_CMD := tar czf
ARCHIVE_EXTENSION := tar.gz
endif
VERSION ?= $(shell git describe --always)
MODULES := infohelper elf binimage argparse serialport espcomm
-include local/Makefile.local.$(TARGET_OS)
OBJECTS := \
argparse/argparse.o \
argparse/argparse_binimagecmd.o \
argparse/argparse_commcmd.o \
argparse/argparse_elfcmd.o \
binimage/esptool_binimage.o \
elf/esptool_elf.o \
elf/esptool_elf_object.o \
espcomm/delay.o \
espcomm/espcomm.o \
espcomm/espcomm_boards.o \
infohelper/infohelper.o \
serialport/serialport.o \
main.o
INCLUDES := $(addprefix -I,$(MODULES))
CFLAGS += $(TARGET_CFLAGS)
CXXFLAGS += $(TARGET_CXXFLAGS)
LDFLAGS += $(TARGET_LDFLAGS)
CPPFLAGS += $(INCLUDES) $(SDK_INCLUDES) -D$(TARGET_OS) -DVERSION=\"$(VERSION)\"
DIST_NAME := esptool-$(VERSION)-$(DIST_SUFFIX)
DIST_DIR := $(DIST_NAME)
DIST_ARCHIVE := $(DIST_NAME).$(ARCHIVE_EXTENSION)
.PHONY: all checkdirs clean dist
all: $(TARGET)
dist: $(TARGET) $(DIST_DIR)
cp $(TARGET) $(DIST_DIR)/
$(ARCHIVE_CMD) $(DIST_ARCHIVE) $(DIST_DIR)
$(TARGET): $(OBJECTS)
$(CC) $^ -o $@ $(LDFLAGS)
strip $(TARGET)
$(BUILD_DIR):
@mkdir -p $@
$(DIST_DIR):
@mkdir -p $@
clean:
@rm -f $(OBJECTS)
@rm -f $(TARGET)
@rm -rf esptool-*