This repository has been archived by the owner on Mar 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 14
/
Makefile.defines
122 lines (107 loc) · 4.71 KB
/
Makefile.defines
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
#*******************************************************************************
# Ledger SDK
# (c) 2017 Ledger
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#*******************************************************************************
#extract TARGET_NAME/TARGET_ID from the SDK to allow for makefile choices
TARGET_ID:=$(shell cat $(BOLOS_SDK)/include/bolos_target.h | grep TARGET_ID | cut -f3 -d' ')
TARGET_NAME:=$(shell cat $(BOLOS_SDK)/include/bolos_target.h | grep TARGET_ | grep -v TARGET_ID | cut -f2 -d' ')
TARGET_VERSION:=$(shell cat $(BOLOS_SDK)/include/bolos_version.h | grep define | cut -f2 -d'"')
$(info TARGET_NAME=$(TARGET_NAME) TARGET_ID=$(TARGET_ID) TARGET_VERSION=$(TARGET_VERSION))
# extra load parameters for loadApp script
ifneq ($(SCP_PRIVKEY),)
PARAM_SCP+=--rootPrivateKey $(SCP_PRIVKEY)
endif
COMMON_LOAD_PARAMS=--tlv --targetId $(TARGET_ID) --targetVersion="$(TARGET_VERSION)" --delete --fileName bin/app.hex --appName $(APPNAME) --appVersion $(APPVERSION) --dataSize $$((0x`cat debug/app.map |grep _envram_data | tr -s ' ' | cut -f2 -d' '|cut -f2 -d'x'` - 0x`cat debug/app.map |grep _nvram_data | tr -s ' ' | cut -f2 -d' '|cut -f2 -d'x'`)) `ICONHEX=\`python3 $(BOLOS_SDK)/icon3.py --hexbitmaponly $(ICONNAME) 2>/dev/null\` ; [ ! -z "$$ICONHEX" ] && echo "--icon $$ICONHEX"` $(PARAM_SCP)
COMMON_DELETE_PARAMS=--targetId $(TARGET_ID) --appName $(APPNAME) $(PARAM_SCP)
### platform definitions
DEFINES += gcc __IO=volatile
# no assert by default
DEFINES += NDEBUG
# default is not to display make commands
log = $(if $(strip $(VERBOSE)),$1,@$1) # kept for retrocompat
L = $(if $(strip $(VERBOSE)),,@)
ifeq ($(CC),)
CC = clang
endif
SYSROOT = $(shell $(GCCPATH)arm-none-eabi-gcc -print-sysroot)
ifeq ($(SYSROOT),)
CFLAGS += -I/usr/include
else
CFLAGS += --sysroot="$(SYSROOT)"
endif
CFLAGS += -gdwarf-2 -gstrict-dwarf
CFLAGS += -O3 -Os
CFLAGS += -fomit-frame-pointer -momit-leaf-frame-pointer
CFLAGS += -mcpu=cortex-m0plus -mthumb
CFLAGS += -fno-common -mtune=cortex-m0plus -mlittle-endian
CFLAGS += -std=gnu99 -Werror=int-to-pointer-cast -Wall -Wextra -Wno-main
CFLAGS += -fdata-sections -ffunction-sections -funsigned-char -fshort-enums
CFLAGS += -mno-unaligned-access
CFLAGS += --target=armv6m-none-eabi
CFLAGS += -fropi
CFLAGS += -fno-jump-tables # avoid jump tables for switch to avoid problems with invalid PIC access
CFLAGS += -nostdlib -nodefaultlibs
AFLAGS += -ggdb2 -O3 -Os -mcpu=cortex-m0plus -fno-common -mtune=cortex-m0plus
LDFLAGS += -gdwarf-2 -gstrict-dwarf
LDFLAGS += -O3 -Os
LDFLAGS += -fomit-frame-pointer
LDFLAGS += -Wall
LDFLAGS += -mcpu=cortex-m0plus -mthumb
LDFLAGS += -fno-common -ffunction-sections -fdata-sections -fwhole-program
LDFLAGS += -mno-unaligned-access
LDFLAGS += -Wl,--gc-sections -Wl,-Map,debug/app.map
ifeq ($(TARGET_NAME),TARGET_NANOX)
CFLAGS += -frwpi
LDFLAGS += -momit-leaf-frame-pointer
LDFLAGS += --target=armv6m-none-eabi
LDFLAGS += -mtune=cortex-m0plus -mlittle-endian
LDFLAGS += -nostdlib -nodefaultlibs #-nostartfiles
LDFLAGS += -mno-movt
LDFLAGS += -L$(BOLOS_SDK)/lib/
else
LDFLAGS += -nostartfiles --specs=nano.specs
endif
ifeq ($(TARGET_NAME),TARGET_NANOX)
# Screen is directly connected to the SE
DEFINES += HAVE_SE_SCREEN
# Button is directly connected to the SE
DEFINES += HAVE_SE_BUTTON
# MCU serial is stored on board of the SE
DEFINES += HAVE_MCU_SERIAL_STORAGE
DEFINES += HAVE_FONTS
# already defined within apps
# DEFINES += HAVE_BLE
DEFINES += HAVE_BATTERY
else
DEFINES += HAVE_SEED_COOKIE
DEFINES += BAGL_WIDTH=128 BAGL_HEIGHT=32
endif
# include builtin CX libs options
-include $(BOLOS_SDK)/Makefile.conf.cx
ifneq ($(BOLOS_ENV),)
$(info BOLOS_ENV=$(BOLOS_ENV))
CLANGPATH := $(BOLOS_ENV)/clang-arm-fropi/bin/
GCCPATH := $(BOLOS_ENV)/gcc-arm-none-eabi-5_3-2016q1/bin/
else
$(info BOLOS_ENV is not set: falling back to CLANGPATH and GCCPATH)
endif
ifeq ($(CLANGPATH),)
$(info CLANGPATH is not set: clang will be used from PATH)
endif
ifeq ($(GCCPATH),)
$(info GCCPATH is not set: arm-none-eabi-* will be used from PATH)
endif
# define the default makefile target (high in include to avoid glyph.h or what not specific target to be the default one when no target passed on the make command line)
all: default