-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathlibopencm3.mk
60 lines (49 loc) · 1.89 KB
/
libopencm3.mk
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
##
## This file is part of CM-Makefile.
##
## Copyright (C) 2015 Adam Heinrich <[email protected]>
##
## CM-Makefile is free software: you can redistribute it and/or modify
## it under the terms of the GNU Lesser General Public License as published by
## the Free Software Foundation, either version 3 of the License, or
## (at your option) any later version.
##
## CM-Makefile 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 Lesser General Public License for more details.
##
## You should have received a copy of the GNU Lesser General Public License
## along with CM-Makefile. If not, see <http://www.gnu.org/licenses/>.
##
OPENCM3_DIR ?= ./libopencm3
OPENCM3_TARGET ?= stm32/f0
OPENCM3_DEF ?= -DSTM32F0
OPENCM3_PREFIX ?= $(CROSS_COMPILE)
OPENCM3_LIB = libopencm3_$(subst /,,$(OPENCM3_TARGET)).a
OPENCM3_FLAGS = V=$(V)
OPENCM3_FLAGS += PREFIX=$(OPENCM3_PREFIX)
OPENCM3_FLAGS += FP_FLAGS="$(FPFLAGS)"
OPENCM3_FLAGS += DEBUG_FLAGS="$(DBGFLAGS)"
HELP_TEXT += \n\
libopencm3 - Build the libopencm3 library\n\
libopencm3_clean - Remove files built in the libopencm3 folder
# Setup linker flags required by libopencm3:
LDFLAGS += -l$(subst lib,,$(subst .a,,$(OPENCM3_LIB)))
LDFLAGS += -nostartfiles
# Setup macros
DEF += $(OPENCM3_DEF)
# Setup dependencies (to build libopencm3 automatically):
DEPS += libopencm3
DEPS_CLEAN += libopencm3_clean
$(OPENCM3_DIR)/Makefile:
$(error Error: libopencm3 is not available. Run \
`git submodule update --init` to initialize submodules)
$(OPENCM3_DIR)/lib/$(OPENCM3_LIB): $(OPENCM3_DIR)/Makefile
$(CMD_ECHO) $(MAKE) -C $(OPENCM3_DIR) $(OPENCM3_FLAGS) \
lib/$(OPENCM3_TARGET)
.PHONY: libopencm3
libopencm3: $(OPENCM3_DIR)/lib/$(OPENCM3_LIB)
.PHONY: libopencm3_clean
libopencm3_clean:
$(CMD_ECHO) $(MAKE) -C $(OPENCM3_DIR) clean