forked from LedgerHQ/nanos-secure-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.defines
109 lines (94 loc) · 4.27 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
#*******************************************************************************
# 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)
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-m0 -mthumb
CFLAGS += -fno-common -mtune=cortex-m0 -mlittle-endian
CFLAGS += -std=gnu99 -Werror=int-to-pointer-cast -Wall -Wextra #-save-temps
CFLAGS += -fdata-sections -ffunction-sections -funsigned-char -fshort-enums
CFLAGS += -mno-unaligned-access
CFLAGS += -Wno-unused-parameter -Wno-duplicate-decl-specifier
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-m0 -fno-common -mtune=cortex-m0
LDFLAGS += -gdwarf-2 -gstrict-dwarf
LDFLAGS += -O3 -Os
LDFLAGS += -I/usr/include
LDFLAGS += -fomit-frame-pointer
LDFLAGS += -Wall
LDFLAGS += -mcpu=cortex-m0 -mthumb
LDFLAGS += -fno-common -ffunction-sections -fdata-sections -fwhole-program
LDFLAGS += -mno-unaligned-access
ifndef SCRIPT_LD
SCRIPT_LD:=$(BOLOS_SDK)/script.ld
endif
LDFLAGS += -T$(SCRIPT_LD) -Wl,--gc-sections -Wl,-Map,debug/app.map #,--cref
ifeq ($(TARGET_NAME),TARGET_NANOX)
CFLAGS += -frwpi
LDFLAGS += -momit-leaf-frame-pointer
LDFLAGS += --target=armv6m-none-eabi
LDFLAGS += -mtune=cortex-m0 -mlittle-endian
LDFLAGS += -nostdlib -nodefaultlibs #-nostartfiles
LDFLAGS += -mno-movt
LDFLAGS += -L$(BOLOS_SDK)/lib/
else
LDFLAGS += -nostartfiles
endif
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