From 1c4fbd02b4a0e549328ea47a730f73f87c31e6f6 Mon Sep 17 00:00:00 2001 From: Pavol Rusnak Date: Mon, 20 Mar 2017 17:45:40 +0100 Subject: [PATCH] build: reorg makefiles --- Makefile | 34 ++++++++++++++++++++-------------- Makefile.bootloader | 14 +++++++------- Makefile.firmware | 9 +++++---- Makefile.loader | 14 +++++++------- 4 files changed, 39 insertions(+), 32 deletions(-) diff --git a/Makefile b/Makefile index dcaf29ec5..7a0755060 100644 --- a/Makefile +++ b/Makefile @@ -20,7 +20,19 @@ vendor: ## update git submodules res: ## update resources ./tools/res_collect -build: build_firmware build_unix build_cross ## build firmware, unix and mpy-cross micropython ports +run: ## run unix port + cd src ; ../vendor/micropython/unix/micropython + +emu: ## run emulator + ./emu.sh + +test: ## run unit tests + cd tests ; ./run_tests.sh + +testpy: ## run selected unit tests from python-trezor + cd tests ; ./run_tests_python_trezor.sh + +build: build_firmware build_bootloader build_loader build_unix build_cross ## build all build_firmware: vendor res build_cross ## build firmware with frozen modules $(MAKE) -f Makefile.firmware $(TREZORHAL_PORT_OPTS) @@ -43,17 +55,17 @@ build_unix_debug: vendor ## build unix port with debug symbols build_cross: vendor ## build mpy-cross port $(MAKE) -C vendor/micropython/mpy-cross $(CROSS_PORT_OPTS) -run: ## run unix port - cd src ; ../vendor/micropython/unix/micropython - -emu: ## run emulator - ./emu.sh - -clean: clean_firmware clean_unix clean_cross ## clean all builds +clean: clean_firmware clean_bootloader clean_loader clean_unix clean_cross ## clean all clean_firmware: ## clean firmware build $(MAKE) -f Makefile.firmware clean $(TREZORHAL_PORT_OPTS) +clean_bootloader: ## clean bootloader build + $(MAKE) -f Makefile.bootloader clean $(TREZORHAL_PORT_OPTS) + +clean_loader: ## clean loader build + $(MAKE) -f Makefile.loader clean $(TREZORHAL_PORT_OPTS) + clean_unix: ## clean unix build $(MAKE) -f ../../../micropython/unix/Makefile -C vendor/micropython/unix clean $(UNIX_PORT_OPTS) # workaround for relative paths containing ../.. in unix Makefile @@ -85,9 +97,3 @@ openocd: ## start openocd which connects to the device gdb: ## start remote gdb session which connects to the openocd arm-none-eabi-gdb $(FIRMWARE_BUILD_DIR)/firmware.elf -ex 'target remote localhost:3333' - -test: ## run unit tests - cd tests ; ./run_tests.sh - -testpy: ## run selected unit tests from python-trezor - cd tests ; ./run_tests_python_trezor.sh diff --git a/Makefile.bootloader b/Makefile.bootloader index 088b2a3a5..56783e40d 100644 --- a/Makefile.bootloader +++ b/Makefile.bootloader @@ -1,5 +1,6 @@ # target directory BUILD ?= micropython/bootloader/build +TARGET ?= bootloader # include py core make definitions include vendor/micropython/py/mkenv.mk @@ -136,15 +137,15 @@ LDFLAGS += --gc-sections # comp rules # ===================================== -all: $(BUILD)/bootloader.bin +all: $(BUILD)/$(TARGET).bin -$(BUILD)/bootloader.elf: $(OBJ) +$(BUILD)/$(TARGET).elf: $(OBJ) $(ECHO) "LINK $@" $(Q)$(LD) $(LDFLAGS) -o $@ $^ $(LIBS) $(Q)$(SIZE) $@ -$(BUILD)/bootloader.bin: $(BUILD)/bootloader.elf - $(Q)$(OBJCOPY) -O binary -j .flash -j .data $^ $(BUILD)/bootloader.bin +$(BUILD)/$(TARGET).bin: $(BUILD)/$(TARGET).elf + $(Q)$(OBJCOPY) -O binary -j .flash -j .data $^ $(BUILD)/$(TARGET).bin $(BUILD)/%.o: %.S $(ECHO) "CC $<" @@ -160,13 +161,12 @@ $(BUILD)/%.o: %.c OBJ_DIRS = $(sort $(dir $(OBJ))) $(OBJ): | $(OBJ_DIRS) -$(OBJ_DIRS): +$(OBJ_DIRS) $(BUILD_HDR): $(MKDIR) -p $@ $(OBJ): | $(BUILD_HDR)/qstrdefs.generated.h -$(BUILD_HDR)/qstrdefs.generated.h: - $(MKDIR) -p $(BUILD_HDR) +$(BUILD_HDR)/qstrdefs.generated.h: | $(BUILD_HDR) touch $(BUILD_HDR)/qstrdefs.generated.h clean: diff --git a/Makefile.firmware b/Makefile.firmware index b5c3be5d6..346182377 100644 --- a/Makefile.firmware +++ b/Makefile.firmware @@ -3,6 +3,7 @@ FROZEN_MPY_DIR ?= src # target directory BUILD ?= micropython/firmware/build +TARGET ?= firmware # include py core make definitions include vendor/micropython/py/mkenv.mk @@ -394,15 +395,15 @@ QSTR_GEN_EXTRA_CFLAGS += -DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB -DN_ARM -DN_XTENSA # comp rules # ===================================== -all: $(BUILD)/firmware.bin +all: $(BUILD)/$(TARGET).bin -$(BUILD)/firmware.elf: $(OBJ) +$(BUILD)/$(TARGET).elf: $(OBJ) $(ECHO) "LINK $@" $(Q)$(LD) $(LDFLAGS) -o $@ $^ $(LIBS) $(Q)$(SIZE) $@ -$(BUILD)/firmware.bin: $(BUILD)/firmware.elf - $(Q)$(OBJCOPY) -O binary -j .flash -j .data $^ $(BUILD)/firmware.bin +$(BUILD)/$(TARGET).bin: $(BUILD)/$(TARGET).elf + $(Q)$(OBJCOPY) -O binary -j .flash -j .data $^ $(BUILD)/$(TARGET).bin $(BUILD)/%.o: %.S $(ECHO) "CC $<" diff --git a/Makefile.loader b/Makefile.loader index 2d31fc991..76488abdb 100644 --- a/Makefile.loader +++ b/Makefile.loader @@ -1,5 +1,6 @@ # target directory BUILD ?= micropython/loader/build +TARGET ?= loader # include py core make definitions include vendor/micropython/py/mkenv.mk @@ -134,15 +135,15 @@ LDFLAGS += --gc-sections # comp rules # ===================================== -all: $(BUILD)/loader.bin +all: $(BUILD)/$(TARGET).bin -$(BUILD)/loader.elf: $(OBJ) +$(BUILD)/$(TARGET).elf: $(OBJ) $(ECHO) "LINK $@" $(Q)$(LD) $(LDFLAGS) -o $@ $^ $(LIBS) $(Q)$(SIZE) $@ -$(BUILD)/loader.bin: $(BUILD)/loader.elf - $(Q)$(OBJCOPY) -O binary -j .flash -j .data $^ $(BUILD)/loader.bin +$(BUILD)/$(TARGET).bin: $(BUILD)/$(TARGET).elf + $(Q)$(OBJCOPY) -O binary -j .flash -j .data $^ $(BUILD)/$(TARGET).bin $(BUILD)/%.o: %.S $(ECHO) "CC $<" @@ -158,13 +159,12 @@ $(BUILD)/%.o: %.c OBJ_DIRS = $(sort $(dir $(OBJ))) $(OBJ): | $(OBJ_DIRS) -$(OBJ_DIRS): +$(OBJ_DIRS) $(BUILD_HDR): $(MKDIR) -p $@ $(OBJ): | $(BUILD_HDR)/qstrdefs.generated.h -$(BUILD_HDR)/qstrdefs.generated.h: - $(MKDIR) -p $(BUILD_HDR) +$(BUILD_HDR)/qstrdefs.generated.h: | $(BUILD_HDR) touch $(BUILD_HDR)/qstrdefs.generated.h clean: