build: reorg makefiles

pull/25/head
Pavol Rusnak 7 years ago
parent 2c1e0b8253
commit 1c4fbd02b4
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D

@ -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

@ -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:

@ -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 $<"

@ -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:

Loading…
Cancel
Save