From 5d3cf61b638ec9ab313f24c419aca0f7ddedc1de Mon Sep 17 00:00:00 2001 From: John Ericson Date: Thu, 22 Jul 2021 19:58:06 +0000 Subject: [PATCH 1/2] Improve support for custom tools --- Makefile.defines | 24 ++++++++++++++++++------ Makefile.rules_generic | 4 ++-- 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/Makefile.defines b/Makefile.defines index 47d9a1c1..5ca8891e 100644 --- a/Makefile.defines +++ b/Makefile.defines @@ -41,11 +41,16 @@ ifeq ($(CC),) CC = clang endif -SYSROOT = $(shell $(GCCPATH)arm-none-eabi-gcc -print-sysroot) -ifeq ($(SYSROOT),) -CFLAGS += -I/usr/include -else -CFLAGS += --sysroot="$(SYSROOT)" +TOOL_PREFIX ?= arm-none-eabi- +USE_SYSROOT ?= 1 + +ifneq ($(USE_SYSROOT),) +SYSROOT = $(shell $(GCCPATH)$(TOOL_PREFIX)gcc -print-sysroot) + ifeq ($(SYSROOT),) + CFLAGS += -I/usr/include + else + CFLAGS += --sysroot="$(SYSROOT)" + endif endif CFLAGS += -gdwarf-2 -gstrict-dwarf @@ -101,7 +106,14 @@ 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) +$(info GCCPATH is not set: $(TOOL_PREFIX)* will be used from PATH) +endif + +ifeq ($(OBJCOPY),) +OBJCOPY = $(GCCPATH)$(TOOL_PREFIX)objcopy +endif +ifeq ($(OBJDUMP),) +OBJDUMP = $(GCCPATH)$(TOOL_PREFIX)objdump 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) diff --git a/Makefile.rules_generic b/Makefile.rules_generic index 1d4a0de0..73a23315 100644 --- a/Makefile.rules_generic +++ b/Makefile.rules_generic @@ -71,9 +71,9 @@ obj/%.o: %.s bin/app.elf: $(OBJECT_FILES) $(SCRIPT_LD) @echo "[LINK] $@" $(call log,$(call link_cmdline,$(OBJECT_FILES) $(LDLIBS),$@)) - $(call log,$(GCCPATH)arm-none-eabi-objcopy -O ihex -S bin/app.elf bin/app.hex) + $(call log,$(OBJCOPY) -O ihex -S bin/app.elf bin/app.hex) $(call log,cp bin/app.elf obj) - $(call log,$(GCCPATH)arm-none-eabi-objdump -S -d bin/app.elf > debug/app.asm) + $(call log,$(OBJDUMP) -S -d bin/app.elf > debug/app.asm) bin/app.apdu bin/app.sha256: bin/app.elf python3 -m ledgerblue.loadApp $(APP_LOAD_PARAMS) --offline bin/app.apdu | grep "Application" | cut -f5 -d' ' > bin/app.sha256 From 0a3b0d61a6446e4c6f708eb6441262c9f4c8d5f2 Mon Sep 17 00:00:00 2001 From: John Ericson Date: Wed, 29 Sep 2021 23:57:14 +0000 Subject: [PATCH 2/2] Fix mistaka in merge The second one is objdump, not objcopy. --- Makefile.rules_generic | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.rules_generic b/Makefile.rules_generic index 071af465..02f5d128 100644 --- a/Makefile.rules_generic +++ b/Makefile.rules_generic @@ -79,7 +79,7 @@ bin/app.elf: $(OBJECT_FILES) $(SCRIPT_LD) $(L)$(call link_cmdline,$(OBJECT_FILES) $(LDLIBS),$@) $(L)$(OBJCOPY) -O ihex -S bin/app.elf bin/app.hex $(L)cp bin/app.elf obj - $(L)$(OBJCOPY) -S -d bin/app.elf > debug/app.asm + $(L)$(OBJDUMP) -S -d bin/app.elf > debug/app.asm bin/app.apdu bin/app.sha256: bin/app.elf $(L)python3 -m ledgerblue.loadApp $(APP_LOAD_PARAMS) --offline bin/app.apdu | grep "Application" | cut -f5 -d' ' > bin/app.sha256