@ -13,14 +13,18 @@
# limitations under the License.
#
#extract TARGET_ID from the SDK to allow for makefile choices
i f e q ( $( BOLOS_SDK ) , )
$( error Environment variable BOLOS_SDK is not set )
e n d i f
i n c l u d e $( BOLOS_SDK ) / M a k e f i l e . d e f i n e s
APPNAME = "OpenPGP"
APPVERSION = "1.0RC1"
TARGET_ID = 0x31100002
$( info TARGET_ID =$ ( TARGET_ID ) )
APP_LOAD_PARAMS = --appFlags 0x40 --path "2152157255" --curve secp256k1 $( COMMON_LOAD_PARAMS)
APP_LOAD_PARAMS = --appFlags 0 --path "2152157255" --curve secp256k1
LOADFLAGS = --params --appVersion $( APPVERSION)
APPVERSION_M = 1
APPVERSION_N = 0
APPVERSION_P = RC2
APPVERSION = $( APPVERSION_M) .$( APPVERSION_N) .$( APPVERSION_P)
ICONNAME = icon_pgp.gif
@ -28,33 +32,11 @@ ICONNAME=icon_pgp.gif
################
# Default rule #
################
all : default
# consider every intermediate target as final to avoid deleting intermediate files
.SECONDARY :
# disable builtin rules that overload the build process (and the debug log !!)
.SUFFIXES :
MAKEFLAGS += -r
SHELL = /bin/bash
#.ONESHELL:
############
# Platform #
############
PROG := token
CONFIG_PRODUCTIONS := bin/$( PROG)
SOURCE_PATH := src $( BOLOS_SDK) /src $( dir $( shell find $( BOLOS_SDK) /lib_stusb* | grep " \.c $$ " ) )
SOURCE_FILES := $( foreach path, $( SOURCE_PATH) ,$( shell find $( path) | grep " \.c $$ " ) )
INCLUDES_PATH := $( dir $( shell find $( BOLOS_SDK) /lib_stusb* | grep " \.h $$ " ) ) include src $( BOLOS_SDK) /include $( BOLOS_SDK) /include/arm
### platform definitions
DEFINES := ST31 gcc __IO = volatile
DEFINES += OS_IO_SEPROXYHAL IO_SEPROXYHAL_BUFFER_SIZE_B = 128
DEFINES += HAVE_BAGL HAVE_PRINTF HAVE_SPRINTF
@ -64,113 +46,39 @@ DEFINES += HAVE_USB_CLASS_CCID
DEFINES += $( GPG_CONFIG) GPG_VERSION = $( APPVERSION) GPG_NAME = $( APPNAME)
##############
# Compiler #
# Compiler #
##############
GCCPATH := $( BOLOS_ENV) /gcc-arm-none-eabi-5_3-2016q1/bin/
CLANGPATH := $( BOLOS_ENV) /clang-arm-fropi/bin
CC := $( CLANGPATH) /clang
CFLAGS :=
CFLAGS += -gdwarf-2 -gstrict-dwarf
#CFLAGS += -O0
#CFLAGS += -O0 -g3
CFLAGS += -O3 -Os
CFLAGS += -mcpu= cortex-m0 -mthumb
CFLAGS += -fno-common -mtune= cortex-m0 -mlittle-endian
CFLAGS += -std= gnu99 -Werror= int-to-pointer-cast -Wall -Wextra -Wno-unused-variable #-save-temps
CFLAGS += -fdata-sections -ffunction-sections -funsigned-char -fshort-enums
CFLAGS += -mno-unaligned-access
CFLAGS += -Wno-unused-parameter -Wno-duplicate-decl-specifier
CFLAGS += -fropi --target= armv6m-none-eabi
#CFLAGS += -finline-limit-0 -funsigned-bitfields
AS := $( GCCPATH) /arm-none-eabi-gcc
AFLAGS += -ggdb2 -O3 -Os -mcpu= cortex-m0 -fno-common -mtune= cortex-m0
# NOT SUPPORTED BY STM3L152 CFLAGS += -fpack-struct
#-pg --coverage
LD := $( GCCPATH) /arm-none-eabi-gcc
LDFLAGS :=
LDFLAGS += -gdwarf-2 -gstrict-dwarf
LDFLAGS += -O0 -g3
#LDFLAGS += -O3 -Os
#LDFLAGS += -O0
LDFLAGS += -Wall
LDFLAGS += -mcpu= cortex-m0 -mthumb
LDFLAGS += -fno-common -ffunction-sections -fdata-sections -fwhole-program -nostartfiles
LDFLAGS += -mno-unaligned-access
#LDFLAGS += -nodefaultlibs
#LDFLAGS += -nostdlib -nostdinc
LDFLAGS += -T$( BOLOS_SDK) /script.ld -Wl,--gc-sections -Wl,-Map,debug/$( PROG) .map,--cref
LDLIBS += -Wl,--library-path -Wl,$( GCCPATH) /../lib/armv6-m/
#LDLIBS += -Wl,--start-group
LDLIBS += -lm -lgcc -lc
#LDLIBS += -Wl,--end-group
# -mno-unaligned-access
#-pg --coverage
### computed variables
VPATH := $( dir $( SOURCE_FILES) )
OBJECT_FILES := $( sort $( addprefix obj/, $( addsuffix .o, $( basename $( notdir $( SOURCE_FILES) ) ) ) ) )
DEPEND_FILES := $( sort $( addprefix dep/, $( addsuffix .d, $( basename $( notdir $( SOURCE_FILES) ) ) ) ) )
#GCCPATH := $(BOLOS_ENV)/gcc-arm-none-eabi-5_3-2016q1/bin/
#CLANGPATH := $(BOLOS_ENV)/clang-arm-fropi/bin/
CC := $( CLANGPATH) clang
i f e q ( $( filter clean ,$ ( MAKECMDGOALS ) ) , )
- i n c l u d e $( DEPEND_FILES )
e n d i f
#CFLAGS += -O0 -gdwarf-2 -gstrict-dwarf
CFLAGS += -O3 -Os
clean :
rm -fr obj bin debug dep
AS := $( GCCPATH) arm-none-eabi-gcc
prepare :
@mkdir -p bin obj debug dep
LD := $( GCCPATH) arm-none-eabi-gcc
#LDFLAGS += -O0 -gdwarf-2 -gstrict-dwarf
LDFLAGS += -O3 -Os
LDLIBS += -lm -lgcc -lc
.SECONDEXPANSION :
# import rules to compile glyphs(/pone)
i n c l u d e $( BOLOS_SDK ) / M a k e f i l e . g l y p h s
# default is not to display make commands
log = $( if $( strip $( VERBOSE) ) ,$1 ,@$1 )
### computed variables
APP_SOURCE_PATH += src
SDK_SOURCE_PATH += lib_stusb lib_stusb_impl
default : prepare bin /$( PROG )
load : default
python -m ledgerblue.loadApp --targetId $( TARGET_ID) --fileName bin/$( PROG) .hex --appName $( APPNAME) --icon ` python $( BOLOS_SDK) /icon.py $( ICONNAME) hexbitmaponly` $( LOADFLAGS) $( APP_LOAD_PARAMS)
load : all
python -m ledgerblue.loadApp $( APP_LOAD_PARAMS)
delete :
python -m ledgerblue.deleteApp --targetId $( TARGET_ID) --appName $( APPNAME)
bin/$(PROG) : $( OBJECT_FILES ) $( BOLOS_SDK ) /script .ld
@echo " [LINK] $@ "
$( call log,$( call link_cmdline,$( OBJECT_FILES) $( LDLIBS) ,$@ ) )
$( call log,$( GCCPATH) /arm-none-eabi-objcopy -O ihex -S bin/$( PROG) bin/$( PROG) .hex)
$( call log,mv bin/$( PROG) bin/$( PROG) .elf)
$( call log,cp bin/$( PROG) .elf obj)
$( call log,$( GCCPATH) /arm-none-eabi-objdump -S -d bin/$( PROG) .elf > debug/$( PROG) .asm)
dep/%.d : %.c Makefile
@echo " [DEP] $@ "
@mkdir -p dep
$( call log,$( call dep_cmdline,$( INCLUDES_PATH) , $( DEFINES) ,$<,$@ ) )
obj/%.o : %.c dep /%.d
@echo " [CC] $@ "
$( call log,$( call cc_cmdline,$( INCLUDES_PATH) , $( DEFINES) ,$<,$@ ) )
obj/%.o : %.s
@echo " [CC] $@ "
$( call log,$( call as_cmdline,$( INCLUDES_PATH) , $( DEFINES) ,$<,$@ ) )
### BEGIN GCC COMPILER RULES
# link_cmdline(objects,dest) Macro that is used to format arguments for the linker
link_cmdline = $( LD) $( LDFLAGS) -o $( 2) $( 1)
# dep_cmdline(include,defines,src($<),dest($@)) Macro that is used to format arguments for the dependency creator
dep_cmdline = $( CC) -M $( CFLAGS) $( addprefix -D,$( 2) ) $( addprefix -I,$( 1) ) $( 3) | sed 's/\($*\)\.o[ :]*/obj\/\1.o: /g' | sed -e 's/[:\t ][^ ]\+\.c//g' > dep/$( basename $( notdir $( 4) ) ) .d 2>/dev/null
python -m ledgerblue.deleteApp $( COMMON_DELETE_PARAMS)
# cc_cmdline(include,defines,src,dest) Macro that is used to format arguments for the compiler
cc_cmdline = $( CC) -c $( CFLAGS) $( addprefix -D,$( 2) ) $( addprefix -I,$( 1) ) -o $( 4) $( 3)
# import generic rules from the sdk
i n c l u d e $( BOLOS_SDK ) / M a k e f i l e . r u l e s
as_cmdline = $( AS) -c $( AFLAGS) $( addprefix -D,$( 2) ) $( addprefix -I,$( 1) ) -o $( 4) $( 3)
#add dependency on custom makefile filename
dep/%.d : %.c Makefile .genericwallet
### END GCC COMPILER RULES