forked from atmelcorp/atmel-software-package
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.vars
152 lines (131 loc) · 5.29 KB
/
Makefile.vars
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
VERSION = 2.17
DEFAULT_AVAILABLE_TARGETS = sama5d4-generic sama5d4-xplained sama5d4-ek \
sama5d2-generic sama5d2-xplained \
sama5d2-vb-bga196 sama5d2-vb-bga289 \
sama5d27-som1-ek sama5d2-ptc-ek \
sama5d3-generic sama5d3-xplained sama5d3-ek \
sam9g15-generic sam9g25-generic sam9g35-generic \
sam9x25-generic sam9x35-generic \
sam9g15-ek sam9g25-ek sam9g35-ek \
sam9x25-ek sam9x35-ek \
sam9x60-generic \
sam9x60-ek sam9x60-curiosity \
samv71-generic same70-xplained samv71-xplained
AVAILABLE_TARGETS ?= $(DEFAULT_AVAILABLE_TARGETS)
AVAILABLE_VARIANTS ?= sram ddram qspi0 qspi1 flash
VARIANT ?= sram
eq = $(and $(findstring $(1),$(2)),$(findstring $(2),$(1)))
ifndef TARGET
$(error "No TARGET specified.")
endif
ifndef $(or RELEASE,DEBUG)
DEBUG = 5
endif
### Expand '*' available targets from example makefiles
TARGETS := $(subst *,%,$(filter %*,$(AVAILABLE_TARGETS)))
AVAILABLE_TARGETS := $(filter-out %*,$(AVAILABLE_TARGETS))
TARGETS := $(foreach target,$(TARGETS),$(filter $(TARGETS),$(DEFAULT_AVAILABLE_TARGETS)))
AVAILABLE_TARGETS += $(TARGETS)
AVAILABLE_TARGETS := $(sort $(AVAILABLE_TARGETS))
SELECTED_TARGET = $(strip $(foreach target,$(AVAILABLE_TARGETS),$(if $(call eq,$(TARGET),$(target)),$(target))))
###
ifeq ($(SELECTED_TARGET),)
$(info The selected target "$(TARGET)" is not supported or not available)
$(error Please set TARGET to one value from the list above: $(AVAILABLE_TARGETS))
endif
ifeq ($(V),1)
Q :=
ECHO := @true
else
Q := @
ECHO := @echo
endif
#-------------------------------------------------------------------------------
# Create version string using git if possible
#-------------------------------------------------------------------------------
GIT_VERSION = $(shell if git rev-parse --show-toplevel >/dev/null 2>&1 ; \
then git describe --tags --dirty; fi)
ifneq ($(GIT_VERSION),)
SOFTPACK_VERSION := $(VERSION)_$(GIT_VERSION)
else
SOFTPACK_VERSION := $(VERSION)
endif
#-------------------------------------------------------------------------------
# Setup cross-compilation tools
#-------------------------------------------------------------------------------
# Tool suffix when cross-compiling
CROSS_COMPILE ?= arm-none-eabi-
# Compilation tools
CC = $(CROSS_COMPILE)gcc
LD = $(CROSS_COMPILE)ld
SIZE = $(CROSS_COMPILE)size
STRIP = $(CROSS_COMPILE)strip
OBJCOPY = $(CROSS_COMPILE)objcopy
GDB = $(CROSS_COMPILE)gdb
NM = $(CROSS_COMPILE)nm
AR = $(CROSS_COMPILE)ar
# Prepend gdb command with Unix adapter, when available, so that the CTRL-C
# signal, instead of being caught by MinTTY pty or Cygwin sshd, is handled by
# gdb. This allows the user to break into the program.
WINPTY = $(shell if command -v winpty.exe >/dev/null 2>&1 ; \
then command -v winpty.exe; fi)
ifneq ($(WINPTY),)
GDB := $(WINPTY) $(GDB)
endif
#-------------------------------------------------------------------------------
# Setup compilation params
#-------------------------------------------------------------------------------
CFLAGS_OPT ?= -Os
# compiler flags
CFLAGS = -Wall -Wchar-subscripts -Wcomment -Wformat=2 -Wimplicit-int
CFLAGS += -Werror-implicit-function-declaration -Wmain -Wparentheses
CFLAGS += -Wsequence-point -Wreturn-type -Wswitch -Wtrigraphs
CFLAGS += -Wuninitialized -Wunknown-pragmas -Wfloat-equal -Wundef
CFLAGS += -Wshadow -Wpointer-arith -Wbad-function-cast -Wwrite-strings
CFLAGS += -Waggregate-return -Wstrict-prototypes
CFLAGS += -Wmissing-prototypes -Wmissing-declarations
CFLAGS += -Wformat -Wmissing-format-attribute -Wno-deprecated-declarations
CFLAGS += -Wredundant-decls -Wnested-externs -Winline
CFLAGS += -Wunreachable-code -Wno-aggregate-return -Wall -Dprintf=iprintf
CFLAGS += -ffunction-sections -fdata-sections
CFLAGS += -std=gnu99
CFLAGS += $(CFLAGS_OPT)
CFLAGS_ASM = -Wall -D__ASSEMBLY__
CFLAGS_DEFS += -DSOFTPACK_VERSION="\"$(SOFTPACK_VERSION)\""
# Trace level used for compilation
# (can be overriden by adding TRACE_LEVEL=#number to the command-line)
# TRACE_LEVEL_DEBUG 5
# TRACE_LEVEL_INFO 4
# TRACE_LEVEL_WARNING 3
# TRACE_LEVEL_ERROR 2
# TRACE_LEVEL_FATAL 1
# TRACE_LEVEL_NO_TRACE 0
ifdef DEBUG
TRACE_LEVEL ?= 5
CFLAGS_DEFS += -DTRACE_LEVEL=$(TRACE_LEVEL)
CFLAGS += -g3
CFLAGS_ASM += -g3
else
TRACE_LEVEL ?= 4
CFLAGS_DEFS += -DNDEBUG -DTRACE_LEVEL=$(TRACE_LEVEL)
endif
# append variant define
CFLAGS_DEFS += -DVARIANT_$(shell echo $(VARIANT) | tr '[:lower:]' '[:upper:]')
# linker flags
LDFLAGS = --specs=nano.specs -Wl,--cref -Wl,--check-sections -Wl,--gc-sections
LDFLAGS += -Wl,--unresolved-symbols=report-all -Wl,--warn-common
LDFLAGS += -Wl,--sort-section=alignment -lgcc -lc
# include target-specific config
include $(TOP)/scripts/Makefile.vars.sam9xx5
include $(TOP)/scripts/Makefile.vars.sam9x60
include $(TOP)/scripts/Makefile.vars.sama5d2
include $(TOP)/scripts/Makefile.vars.sama5d3
include $(TOP)/scripts/Makefile.vars.sama5d4
include $(TOP)/scripts/Makefile.vars.samv71
# check if variant is compatible with example (AVAILABLE_VARIANTS) and SoC (COMPATIBLE_VARIANTS)
ALL_VARIANTS := $(filter $(AVAILABLE_VARIANTS), $(COMPATIBLE_VARIANTS))
SELECTED_VARIANT := $(strip $(foreach variant,$(ALL_VARIANTS),$(if $(call eq,$(VARIANT),$(variant)),$(variant))))
ifeq ($(SELECTED_VARIANT),)
$(info The selected variant "$(VARIANT)" is not supported or not available)
$(error Please set VARIANT to one value from the list above: $(ALL_VARIANTS))
endif