forked from LedgerHQ/app-bitcoin-new
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
196 lines (156 loc) · 6.49 KB
/
Makefile
File metadata and controls
196 lines (156 loc) · 6.49 KB
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
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
# ****************************************************************************
# Ledger App for Bitcoin
# (c) 2025 Ledger SAS.
#
# 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.
# ****************************************************************************
ifeq ($(BOLOS_SDK),)
$(error Environment variable BOLOS_SDK is not set)
endif
# Application allowed derivation curves.
CURVE_APP_LOAD_PARAMS = secp256k1
# Allowed SLIP21 paths
PATH_SLIP21_APP_LOAD_PARAMS = "LEDGER-Wallet policy"
# Application version
APPVERSION_M = 2
APPVERSION_N = 4
APPVERSION_P = 5
APPVERSION_SUFFIX = # if not empty, appended at the end. Do not add a dash.
ifeq ($(APPVERSION_SUFFIX),)
APPVERSION = "$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)"
else
APPVERSION = "$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)-$(strip $(APPVERSION_SUFFIX))"
endif
# If set, the app will automatically approve all requests without user interaction. Useful for performance tests.
# It is critical that no such app is ever deployed in production.
AUTOAPPROVE_FOR_PERF_TESTS ?= 0
ifneq ($(AUTOAPPROVE_FOR_PERF_TESTS),0)
DEFINES += HAVE_AUTOAPPROVE_FOR_PERF_TESTS
endif
# Setting to allow building variant applications
VARIANT_PARAM = COIN
VARIANT_VALUES = bitcoin_testnet bitcoin bitcoin_recovery
# simplify for tests
ifndef COIN
COIN=bitcoin_testnet
endif
########################################
# Application custom permissions #
########################################
HAVE_APPLICATION_FLAG_GLOBAL_PIN = 1
HAVE_APPLICATION_FLAG_BOLOS_SETTINGS = 1
HAVE_APPLICATION_FLAG_LIBRARY = 1
ifeq ($(COIN),bitcoin_testnet)
# Application allowed derivation paths (testnet) + exception for Electrum + BIP-45 whole tree
PATH_APP_LOAD_PARAMS = "*/1'" "4541509'" "45'"
# Bitcoin testnet, no legacy support
DEFINES += BIP32_PUBKEY_VERSION=0x043587CF
DEFINES += BIP44_COIN_TYPE=1
DEFINES += COIN_P2PKH_VERSION=111
DEFINES += COIN_P2SH_VERSION=196
DEFINES += COIN_NATIVE_SEGWIT_PREFIX=\"tb\"
DEFINES += COIN_COINID_SHORT=\"TEST\"
APPNAME = "Bitcoin Test"
else ifeq ($(COIN),bitcoin)
# Application allowed derivation paths (mainnet) + exception for Electrum + BIP-45 whole tree
PATH_APP_LOAD_PARAMS = "*/0'" "4541509'" "45'"
# the version for performance tests automatically approves all requests
# there is no reason to ever compile the mainnet app with this flag
ifneq ($(AUTOAPPROVE_FOR_PERF_TESTS),0)
$(error Use testnet app for performance tests)
endif
# Bitcoin mainnet, no legacy support
DEFINES += BIP32_PUBKEY_VERSION=0x0488B21E
DEFINES += BIP44_COIN_TYPE=0
DEFINES += COIN_P2PKH_VERSION=0
DEFINES += COIN_P2SH_VERSION=5
DEFINES += COIN_NATIVE_SEGWIT_PREFIX=\"bc\"
DEFINES += COIN_COINID_SHORT=\"BTC\"
APPNAME = "Bitcoin"
else ifeq ($(COIN),bitcoin_recovery)
# Application allowed derivation paths (all paths are permitted).
PATH_APP_LOAD_PARAMS = ""
HAVE_APPLICATION_FLAG_DERIVE_MASTER = 1
# the version for performance tests automatically approves all requests
# there is no reason to ever compile the mainnet app with this flag
ifneq ($(AUTOAPPROVE_FOR_PERF_TESTS),0)
$(error Use testnet app for performance tests)
endif
# Bitcoin mainnet, no legacy support
DEFINES += BIP32_PUBKEY_VERSION=0x0488B21E
DEFINES += BIP44_COIN_TYPE=0
DEFINES += COIN_P2PKH_VERSION=0
DEFINES += COIN_P2SH_VERSION=5
DEFINES += COIN_NATIVE_SEGWIT_PREFIX=\"bc\"
DEFINES += COIN_COINID_SHORT=\"BTC\"
DEFINES += BITCOIN_RECOVERY
APPNAME = "Bitcoin Recovery"
else
ifeq ($(filter clean,$(MAKECMDGOALS)),)
$(error Unsupported COIN - use bitcoin_testnet, bitcoin)
endif
endif
ifneq (,$(filter-out clean,$(MAKECMDGOALS)))
ifeq ($(TARGET_NAME),TARGET_NANOS)
$(error This branch is not compatible with the Nano S device. Checkout the 'nanos' branch for the latest code for Nano S.)
endif
endif
ENABLE_NBGL_FOR_NANO_DEVICES = 1
# Application icons following guidelines:
# https://developers.ledger.com/docs/embedded-app/design-requirements/#device-icon
ICON_NANOX = icons/nanox_app_bitcoin.gif
ICON_NANOSP = icons/nanox_app_bitcoin.gif
ICON_STAX = icons/stax_app_bitcoin.gif
ICON_FLEX = icons/flex_app_bitcoin.gif
ICON_APEX_P = icons/apex_p_app_bitcoin.png
########################################
# Application communication interfaces #
########################################
ENABLE_BLUETOOTH = 1
########################################
# NBGL custom features #
########################################
ENABLE_NBGL_QRCODE = 1
########################################
# Features disablers #
########################################
# Don't use standard app file to avoid conflicts for now
DISABLE_STANDARD_APP_FILES = 1
# Don't use default IO_SEPROXY_BUFFER_SIZE to use another
# value for NANOS for an unknown reason.
DISABLE_DEFAULT_IO_SEPROXY_BUFFER_SIZE = 1
DEFINES += HAVE_BOLOS_APP_STACK_CANARY
DEFINES += IO_SEPROXYHAL_BUFFER_SIZE_B=300
# debugging helper functions and macros
CFLAGS += -include debug-helpers/debug.h
# DEFINES += HAVE_PRINT_STACK_POINTER
ifeq ($(DEBUG),10)
$(warning Using semihosted PRINTF. Only run with speculos!)
DEFINES += HAVE_PRINTF HAVE_SEMIHOSTED_PRINTF PRINTF=semihosted_printf
endif
# Needed to be able to include the definition of G_cx
INCLUDES_PATH += $(BOLOS_SDK)/lib_cxng/src
# Application source files
APP_SOURCE_PATH += src
# Allow usage of function from lib_standard_app/crypto_helpers.c
APP_SOURCE_FILES += ${BOLOS_SDK}/lib_standard_app/crypto_helpers.c
########################################
# Features enablers #
########################################
# Converting build warnings to errors
CFLAGS += -Werror
include $(BOLOS_SDK)/Makefile.standard_app
# Makes a detailed report of code and data size in debug/size-report.txt
# More useful for production builds with DEBUG=0
size-report: bin/app.elf
arm-none-eabi-nm --print-size --size-sort --radix=d bin/app.elf >debug/size-report.txt