forked from G33KatWork/STM32-Toolchain
-
Notifications
You must be signed in to change notification settings - Fork 3
/
stlink.mak
55 lines (43 loc) · 1.89 KB
/
stlink.mak
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
STLINK_BRANCH := master
STLINK_GIT := https://github.com/texane/stlink.git
STLINK_PATCHES :=
# Clone sources
$(TOOLCHAIN_SRCDIR)/stlink-$(STLINK_BRANCH):
$(Q)mkdir -p $(TOOLCHAIN_SRCDIR)
$(call cmd_msg,GITCLONE,$(STLINK_GIT) $(STLINK_BRANCH))
$(Q)git clone -b $(STLINK_BRANCH) $(STLINK_GIT) $(TOOLCHAIN_SRCDIR)/stlink-$(STLINK_BRANCH)
$(call cmd_msg,PATCH,$(subst $(TOOLCHAIN_PATCHDIR)/,,$(STLINK_PATCHES)))
$(Q)$(foreach patch,$(STLINK_PATCHES), \
cd $(TOOLCHAIN_SRCDIR)/stlink-$(STLINK_BRANCH); \
patch -Np1 -i $(patch) $(QOUTPUT); \
)
$(Q)touch $(@)
# Configure
$(TOOLCHAIN_BUILDDIR)/.stlink-configure: $(TOOLCHAIN_SRCDIR)/stlink-$(STLINK_BRANCH)
$(Q)if [ -d "$(TOOLCHAIN_BUILDDIR)/stlink-build" ]; then \
rm -rf $(TOOLCHAIN_BUILDDIR)/stlink-build; \
fi
$(Q)mkdir -p $(TOOLCHAIN_BUILDDIR)/stlink-build
$(call cmd_msg,CONFIG,stlink-$(STLINK_BRANCH) ($(TOOLCHAIN_TARGET)))
$(Q)cd $(TOOLCHAIN_SRCDIR)/stlink-$(STLINK_BRANCH); ./autogen.sh $(QOUTPUT)
$(Q)cd $(TOOLCHAIN_BUILDDIR)/stlink-build; \
$(TOOLCHAIN_SRCDIR)/stlink-$(STLINK_BRANCH)/configure \
--prefix=$(TOOLCHAIN_ROOTDIR) \
$(QOUTPUT)
$(Q)touch $(@)
# Compile
$(TOOLCHAIN_BUILDDIR)/.stlink-compile: $(TOOLCHAIN_BUILDDIR)/.stlink-configure
$(call cmd_msg,COMPILE,stlink-$(STLINK_BRANCH) ($(TOOLCHAIN_TARGET)))
$(Q)cd $(TOOLCHAIN_BUILDDIR)/stlink-build; $(MAKE) $(SUBMAKEFLAGS) $(MAKEFLAGS) all $(QOUTPUT)
$(Q)touch $(@)
# Install
$(TOOLCHAIN_BUILDDIR)/.stlink-install: $(TOOLCHAIN_BUILDDIR)/.stlink-compile
$(call cmd_msg,INSTALL,stlink-$(STLINK_BRANCH) ($(TOOLCHAIN_TARGET)))
$(Q)cd $(TOOLCHAIN_BUILDDIR)/stlink-build; $(MAKE) $(MAKEFLAGS) install $(QOUTPUT)
$(Q)touch $(@)
# Download, build and install stlink to run on the host system.
STLINK_TARGET := $(TOOLCHAIN_BUILDDIR)/.stlink-install
all-stlink: $(STLINK_TARGET)
.PHONY: all-stlink
all: $(STLINK_TARGET)
download: $(TOOLCHAIN_SRCDIR)/stlink-$(STLINK_BRANCH)