1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-23 06:48:16 +00:00

make: remove Makefiles

This commit is contained in:
Jan Pochyla 2017-08-15 21:04:54 +02:00
parent ddd079f131
commit bdc9496ff0
4 changed files with 0 additions and 1223 deletions

View File

@ -1,167 +0,0 @@
# source directories
SRCDIR_MP = vendor/micropython
SRCDIR_FW = embed
# target directory
PROJECT ?= boardloader
BUILD ?= embed/$(PROJECT)/build
# include py core make definitions
include $(SRCDIR_MP)/py/mkenv.mk
# sources
# =====================================
BUILD_MP = $(BUILD)/$(SRCDIR_MP)
BUILD_FW = $(BUILD)/$(SRCDIR_FW)
BUILD_HDR = $(BUILD)/genhdr
CFLAGS_MOD += \
-I$(SRCDIR_FW)/extmod/modtrezorcrypto/trezor-crypto \
-I$(SRCDIR_FW)/extmod/modtrezorcrypto/trezor-crypto/ed25519-donna \
-DAES_128 \
-DAES_192 \
-DUSE_KECCAK=1 \
-DED25519_NO_PRECOMP=1 \
-Wno-sequence-point
# OBJ vendor/micropython
OBJ_MICROPYTHON += $(addprefix $(BUILD_MP)/,\
lib/libc/string0.o \
stmhal/startup_stm32.o \
)
# OBJ vendor/micropython
OBJ_STMHAL += $(addprefix $(BUILD_MP)/,\
stmhal/hal/f4/src/stm32f4xx_hal_adc_ex.o \
stmhal/hal/f4/src/stm32f4xx_hal_adc.o \
stmhal/hal/f4/src/stm32f4xx_hal_can.o \
stmhal/hal/f4/src/stm32f4xx_hal_cortex.o \
stmhal/hal/f4/src/stm32f4xx_hal_dac_ex.o \
stmhal/hal/f4/src/stm32f4xx_hal_dac.o \
stmhal/hal/f4/src/stm32f4xx_hal_dma.o \
stmhal/hal/f4/src/stm32f4xx_hal_flash_ex.o \
stmhal/hal/f4/src/stm32f4xx_hal_flash.o \
stmhal/hal/f4/src/stm32f4xx_hal_gpio.o \
stmhal/hal/f4/src/stm32f4xx_hal_i2c.o \
stmhal/hal/f4/src/stm32f4xx_hal_pcd_ex.o \
stmhal/hal/f4/src/stm32f4xx_hal_pcd.o \
stmhal/hal/f4/src/stm32f4xx_hal_pwr_ex.o \
stmhal/hal/f4/src/stm32f4xx_hal_pwr.o \
stmhal/hal/f4/src/stm32f4xx_hal_rcc_ex.o \
stmhal/hal/f4/src/stm32f4xx_hal_rcc.o \
stmhal/hal/f4/src/stm32f4xx_hal_rng.o \
stmhal/hal/f4/src/stm32f4xx_hal_rtc_ex.o \
stmhal/hal/f4/src/stm32f4xx_hal_rtc.o \
stmhal/hal/f4/src/stm32f4xx_hal_sd.o \
stmhal/hal/f4/src/stm32f4xx_hal_spi.o \
stmhal/hal/f4/src/stm32f4xx_hal_tim_ex.o \
stmhal/hal/f4/src/stm32f4xx_hal_tim.o \
stmhal/hal/f4/src/stm32f4xx_hal_uart.o \
stmhal/hal/f4/src/stm32f4xx_hal.o \
stmhal/hal/f4/src/stm32f4xx_ll_sdmmc.o \
stmhal/hal/f4/src/stm32f4xx_ll_usb.o \
)
# OBJ embed/
OBJ_BOARDLOADER += $(addprefix $(BUILD_FW)/, \
boardloader/main.o \
extmod/modtrezorcrypto/trezor-crypto/ed25519-donna/ed25519.o \
extmod/modtrezorcrypto/trezor-crypto/blake2s.o \
extmod/modtrezorcrypto/trezor-crypto/sha2.o \
extmod/modtrezorui/display.o \
extmod/modtrezorui/font_bitmap.o \
)
OBJ_TREZORHAL += $(addprefix $(BUILD_FW)/, \
trezorhal/common.o \
trezorhal/image.o \
trezorhal/flash.o \
trezorhal/mini_printf.o \
trezorhal/sdcard.o \
trezorhal/stm32_it.o \
trezorhal/stm32_system.o \
trezorhal/hal/stm32f4xx_hal_sram.o \
trezorhal/hal/stm32f4xx_ll_fsmc.o \
)
OBJ = $(OBJ_MICROPYTHON) $(OBJ_STMHAL) $(OBJ_TREZORHAL)
OBJ += $(OBJ_BOARDLOADER)
# comp flags
# =====================================
CROSS_COMPILE = arm-none-eabi-
INC += -I.
INC += -I$(SRCDIR_FW)/$(PROJECT)
INC += -I$(SRCDIR_FW)/extmod/modtrezorui
INC += -I$(SRCDIR_FW)/trezorhal
INC += -I$(SRCDIR_FW)/trezorhal/hal
INC += -I$(SRCDIR_MP)
INC += -I$(SRCDIR_MP)/stmhal
INC += -I$(SRCDIR_MP)/stmhal/cmsis
INC += -I$(SRCDIR_MP)/stmhal/hal/f4/inc
INC += -I$(SRCDIR_MP)/lib/cmsis/inc
INC += -I$(BUILD)
ifeq ($(DEBUG), 1)
CFLAGS += -Os -g3
else
CFLAGS += -Os -DNDEBUG
endif
CFLAGS += $(INC) $(CFLAGS_MOD) $(CFLAGS_EXTRA)
CFLAGS += -std=gnu99 -nostdlib -Wall -Werror -Wdouble-promotion -Wpointer-arith
CFLAGS += -mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -fsingle-precision-constant
CFLAGS += -DSTM32F405xx -DMCU_SERIES_F4
CFLAGS += -DSTM32_HAL_H='<stm32f4xx_hal.h>'
CFLAGS += -DTREZOR_STM32
LIBS = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
LDFLAGS = -nostdlib -T $(SRCDIR_FW)/$(PROJECT)/memory.ld -Map=$@.map --cref
# remove uncalled code from the final image
CFLAGS += -fdata-sections -ffunction-sections
LDFLAGS += --gc-sections
# comp rules
# =====================================
all: $(BUILD)/$(PROJECT).bin
$(BUILD)/$(PROJECT).elf: $(OBJ)
$(ECHO) "LINK $@"
$(Q)$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
$(Q)$(SIZE) $@
$(BUILD)/$(PROJECT).bin: $(BUILD)/$(PROJECT).elf
$(Q)$(OBJCOPY) -O binary -j .header -j .flash -j .data $^ $(BUILD)/$(PROJECT).bin
$(BUILD)/%.o: %.S
$(ECHO) "CC $<"
$(Q)$(CC) $(CFLAGS) -c -o $@ $<
$(BUILD)/%.o: %.s
$(ECHO) "AS $<"
$(Q)$(AS) -o $@ $<
$(BUILD)/%.o: %.c
$(ECHO) "CC $<"
$(Q)$(CC) $(CFLAGS) -c -MD -o $@ $<
OBJ_DIRS = $(sort $(dir $(OBJ)))
$(OBJ): | $(OBJ_DIRS)
$(OBJ_DIRS) $(BUILD_HDR):
$(MKDIR) -p $@
$(OBJ): | $(BUILD_HDR)/qstrdefs.generated.h
$(BUILD_HDR)/qstrdefs.generated.h: | $(BUILD_HDR)
touch $(BUILD_HDR)/qstrdefs.generated.h
clean:
$(RM) -rf $(BUILD)
.PHONY: all clean

View File

@ -1,188 +0,0 @@
# source directories
SRCDIR_MP = vendor/micropython
SRCDIR_FW = embed
# target directory
PROJECT ?= bootloader
BUILD ?= embed/$(PROJECT)/build
# include py core make definitions
include $(SRCDIR_MP)/py/mkenv.mk
# sources
# =====================================
BUILD_MP = $(BUILD)/$(SRCDIR_MP)
BUILD_FW = $(BUILD)/$(SRCDIR_FW)
BUILD_HDR = $(BUILD)/genhdr
CFLAGS_MOD += \
-I$(SRCDIR_FW)/extmod/modtrezorcrypto/trezor-crypto \
-I$(SRCDIR_FW)/extmod/modtrezorcrypto/trezor-crypto/ed25519-donna \
-DAES_128 \
-DAES_192 \
-DUSE_KECCAK=1 \
-DED25519_NO_PRECOMP=1 \
-Wno-sequence-point
# OBJ vendor/micropython
OBJ_MICROPYTHON += $(addprefix $(BUILD_MP)/,\
lib/libc/string0.o \
stmhal/startup_stm32.o \
)
# OBJ vendor/micropython
OBJ_STMHAL += $(addprefix $(BUILD_MP)/,\
stmhal/hal/f4/src/stm32f4xx_hal_adc_ex.o \
stmhal/hal/f4/src/stm32f4xx_hal_adc.o \
stmhal/hal/f4/src/stm32f4xx_hal_can.o \
stmhal/hal/f4/src/stm32f4xx_hal_cortex.o \
stmhal/hal/f4/src/stm32f4xx_hal_dac_ex.o \
stmhal/hal/f4/src/stm32f4xx_hal_dac.o \
stmhal/hal/f4/src/stm32f4xx_hal_dma.o \
stmhal/hal/f4/src/stm32f4xx_hal_flash_ex.o \
stmhal/hal/f4/src/stm32f4xx_hal_flash.o \
stmhal/hal/f4/src/stm32f4xx_hal_gpio.o \
stmhal/hal/f4/src/stm32f4xx_hal_i2c.o \
stmhal/hal/f4/src/stm32f4xx_hal_pcd_ex.o \
stmhal/hal/f4/src/stm32f4xx_hal_pcd.o \
stmhal/hal/f4/src/stm32f4xx_hal_pwr_ex.o \
stmhal/hal/f4/src/stm32f4xx_hal_pwr.o \
stmhal/hal/f4/src/stm32f4xx_hal_rcc_ex.o \
stmhal/hal/f4/src/stm32f4xx_hal_rcc.o \
stmhal/hal/f4/src/stm32f4xx_hal_rng.o \
stmhal/hal/f4/src/stm32f4xx_hal_rtc_ex.o \
stmhal/hal/f4/src/stm32f4xx_hal_rtc.o \
stmhal/hal/f4/src/stm32f4xx_hal_sd.o \
stmhal/hal/f4/src/stm32f4xx_hal_spi.o \
stmhal/hal/f4/src/stm32f4xx_hal_tim_ex.o \
stmhal/hal/f4/src/stm32f4xx_hal_tim.o \
stmhal/hal/f4/src/stm32f4xx_hal_uart.o \
stmhal/hal/f4/src/stm32f4xx_hal.o \
stmhal/hal/f4/src/stm32f4xx_ll_sdmmc.o \
stmhal/hal/f4/src/stm32f4xx_ll_usb.o \
)
# OBJ embed/
OBJ_BOOTLOADER += $(addprefix $(BUILD_FW)/, \
bootloader/header.o \
bootloader/main.o \
bootloader/messages.o \
bootloader/nanopb/pb_common.o \
bootloader/nanopb/pb_decode.o \
bootloader/nanopb/pb_encode.o \
bootloader/protob/messages.pb.o \
bootloader/protob/types.pb.o \
extmod/modtrezorcrypto/trezor-crypto/ed25519-donna/ed25519.o \
extmod/modtrezorcrypto/trezor-crypto/blake2s.o \
extmod/modtrezorcrypto/trezor-crypto/sha2.o \
extmod/modtrezorui/display.o \
extmod/modtrezorui/inflate.o \
extmod/modtrezorui/font_bitmap.o \
extmod/modtrezorui/font_roboto_bold_20.o \
)
CFLAGS_MOD += \
-DTREZOR_FONT_MONO_DISABLE=1 \
-DTREZOR_FONT_NORMAL_DISABLE=1 \
OBJ_TREZORHAL += $(addprefix $(BUILD_FW)/, \
trezorhal/common.o \
trezorhal/image.o \
trezorhal/flash.o \
trezorhal/mini_printf.o \
trezorhal/stm32_it.o \
trezorhal/stm32_system.o \
trezorhal/touch.o \
trezorhal/usb.o \
trezorhal/usbd_conf.o \
trezorhal/usbd_core.o \
trezorhal/usbd_ctlreq.o \
trezorhal/usbd_ioreq.o \
trezorhal/hal/stm32f4xx_hal_sram.o \
trezorhal/hal/stm32f4xx_ll_fsmc.o \
)
OBJ = $(OBJ_MICROPYTHON) $(OBJ_STMHAL) $(OBJ_TREZORHAL)
OBJ += $(OBJ_BOOTLOADER)
# comp flags
# =====================================
CROSS_COMPILE = arm-none-eabi-
INC += -I.
INC += -I$(SRCDIR_FW)/$(PROJECT)
INC += -I$(SRCDIR_FW)/$(PROJECT)/nanopb
INC += -I$(SRCDIR_FW)/$(PROJECT)/protob
INC += -I$(SRCDIR_FW)/extmod/modtrezorui
INC += -I$(SRCDIR_FW)/trezorhal
INC += -I$(SRCDIR_FW)/trezorhal/hal
INC += -I$(SRCDIR_MP)
INC += -I$(SRCDIR_MP)/stmhal
INC += -I$(SRCDIR_MP)/stmhal/cmsis
INC += -I$(SRCDIR_MP)/stmhal/hal/f4/inc
INC += -I$(SRCDIR_MP)/lib/cmsis/inc
INC += -I$(BUILD)
ifeq ($(DEBUG), 1)
CFLAGS += -Os -g3
else
CFLAGS += -Os -DNDEBUG
endif
CFLAGS += $(INC) $(CFLAGS_MOD) $(CFLAGS_EXTRA)
CFLAGS += -std=gnu99 -nostdlib -Wall -Werror -Wdouble-promotion -Wpointer-arith
CFLAGS += -mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -fsingle-precision-constant
CFLAGS += -DSTM32F405xx -DMCU_SERIES_F4
CFLAGS += -DSTM32_HAL_H='<stm32f4xx_hal.h>'
CFLAGS += -DTREZOR_STM32
CFLAGS += -DPB_FIELD_16BIT=1
LIBS = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
LDFLAGS = -nostdlib -T $(SRCDIR_FW)/$(PROJECT)/memory.ld -Map=$@.map --cref
# remove uncalled code from the final image
CFLAGS += -fdata-sections -ffunction-sections
LDFLAGS += --gc-sections
# comp rules
# =====================================
all: $(BUILD)/$(PROJECT).bin
$(BUILD)/$(PROJECT).elf: $(OBJ)
$(ECHO) "LINK $@"
$(Q)$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
$(Q)$(SIZE) $@
$(BUILD)/$(PROJECT).bin: $(BUILD)/$(PROJECT).elf
$(Q)$(OBJCOPY) -O binary -j .header -j .flash -j .data $^ $(BUILD)/$(PROJECT).bin
$(BUILD)/%.o: %.S
$(ECHO) "CC $<"
$(Q)$(CC) $(CFLAGS) -c -o $@ $<
$(BUILD)/%.o: %.s
$(ECHO) "AS $<"
$(Q)$(AS) -o $@ $<
$(BUILD)/%.o: %.c
$(ECHO) "CC $<"
$(Q)$(CC) $(CFLAGS) -c -MD -o $@ $<
OBJ_DIRS = $(sort $(dir $(OBJ)))
$(OBJ): | $(OBJ_DIRS)
$(OBJ_DIRS) $(BUILD_HDR):
$(MKDIR) -p $@
$(OBJ): | $(BUILD_HDR)/qstrdefs.generated.h
$(BUILD_HDR)/qstrdefs.generated.h: | $(BUILD_HDR)
touch $(BUILD_HDR)/qstrdefs.generated.h
clean:
$(RM) -rf $(BUILD)
.PHONY: all clean

View File

@ -1,472 +0,0 @@
# source directories
SRCDIR_MP = vendor/micropython
SRCDIR_FW = embed
# directory containing scripts to be frozen as bytecode
FROZEN_MPY_DIR ?= src
# target directory
PROJECT ?= firmware
BUILD ?= embed/$(PROJECT)/build
# include py core make definitions
include $(SRCDIR_MP)/py/mkenv.mk
MAKE_FROZEN = $(SRCDIR_MP)/tools/make-frozen.py
MPY_CROSS = $(SRCDIR_MP)/mpy-cross/mpy-cross
MPY_TOOL = $(SRCDIR_MP)/tools/mpy-tool.py
# sources
# =====================================
BUILD_MP = $(BUILD)/$(SRCDIR_MP)
BUILD_FW = $(BUILD)/$(SRCDIR_FW)
BUILD_HDR = $(BUILD)/genhdr
MICROPY_PY_TREZORCONFIG = 1
MICROPY_PY_TREZORCRYPTO = 1
MICROPY_PY_TREZORIO = 1
MICROPY_PY_TREZORMSG = 1
MICROPY_PY_TREZORUI = 1
MICROPY_PY_TREZORUTILS = 1
MICROPY_PY_UTIME = 1
# OBJ embed/extmod/modtrezorconfig
ifeq ($(MICROPY_PY_TREZORCONFIG),1)
OBJ_MOD += $(addprefix $(BUILD_FW)/,\
extmod/modtrezorconfig/modtrezorconfig.o \
extmod/modtrezorconfig/norcow.o \
)
endif
# OBJ embed/extmod/modtrezorcrypto
ifeq ($(MICROPY_PY_TREZORCRYPTO),1)
CFLAGS_MOD += \
-I$(SRCDIR_FW)/extmod/modtrezorcrypto/trezor-crypto \
-I$(SRCDIR_FW)/extmod/modtrezorcrypto/trezor-crypto/aes \
-I$(SRCDIR_FW)/extmod/modtrezorcrypto/trezor-crypto/ed25519-donna \
-DAES_128 \
-DAES_192 \
-DUSE_KECCAK=1 \
-Wno-sequence-point
OBJ_MOD += $(addprefix $(BUILD_FW)/,\
extmod/modtrezorcrypto/modtrezorcrypto.o \
extmod/modtrezorcrypto/rand.o \
extmod/modtrezorcrypto/ssss.o \
extmod/modtrezorcrypto/trezor-crypto/address.o \
extmod/modtrezorcrypto/trezor-crypto/aes/aescrypt.o \
extmod/modtrezorcrypto/trezor-crypto/aes/aeskey.o \
extmod/modtrezorcrypto/trezor-crypto/aes/aes_modes.o \
extmod/modtrezorcrypto/trezor-crypto/aes/aestab.o \
extmod/modtrezorcrypto/trezor-crypto/base58.o \
extmod/modtrezorcrypto/trezor-crypto/bignum.o \
extmod/modtrezorcrypto/trezor-crypto/bip32.o \
extmod/modtrezorcrypto/trezor-crypto/bip39.o \
extmod/modtrezorcrypto/trezor-crypto/blake2b.o \
extmod/modtrezorcrypto/trezor-crypto/blake2s.o \
extmod/modtrezorcrypto/trezor-crypto/curves.o \
extmod/modtrezorcrypto/trezor-crypto/ecdsa.o \
extmod/modtrezorcrypto/trezor-crypto/ed25519-donna/ed25519.o \
extmod/modtrezorcrypto/trezor-crypto/hmac.o \
extmod/modtrezorcrypto/trezor-crypto/nist256p1.o \
extmod/modtrezorcrypto/trezor-crypto/pbkdf2.o \
extmod/modtrezorcrypto/trezor-crypto/ripemd160.o \
extmod/modtrezorcrypto/trezor-crypto/secp256k1.o \
extmod/modtrezorcrypto/trezor-crypto/sha2.o \
extmod/modtrezorcrypto/trezor-crypto/sha3.o \
)
endif
# OBJ embed/extmod/modtrezorio
ifeq ($(MICROPY_PY_TREZORIO),1)
OBJ_MOD += $(addprefix $(BUILD_FW)/,\
extmod/modtrezorio/modtrezorio.o \
)
endif
# OBJ embed/extmod/modtrezorui
ifeq ($(MICROPY_PY_TREZORUI),1)
CFLAGS_MOD += -DQR_MAX_VERSION=0
OBJ_MOD += $(addprefix $(BUILD_FW)/,\
extmod/modtrezorui/display.o \
extmod/modtrezorui/inflate.o \
extmod/modtrezorui/font_bitmap.o \
extmod/modtrezorui/font_roboto_bold_20.o \
extmod/modtrezorui/font_roboto_regular_20.o \
extmod/modtrezorui/font_robotomono_regular_20.o \
extmod/modtrezorui/modtrezorui.o \
extmod/modtrezorui/trezor-qrenc/qr_encode.o \
)
endif
# OBJ embed/extmod/modtrezorutils
ifeq ($(MICROPY_PY_TREZORUTILS),1)
OBJ_MOD += $(addprefix $(BUILD_FW)/,\
extmod/modtrezorutils/modtrezorutils.o \
)
endif
# OBJ embed/extmod/modutime
ifeq ($(MICROPY_PY_UTIME),1)
OBJ_MOD += $(addprefix $(BUILD_FW)/,\
firmware/modutime.o \
)
endif
# OBJ vendor/micropython
OBJ_MICROPYTHON += $(addprefix $(BUILD_MP)/,\
\
extmod/modubinascii.o \
extmod/moductypes.o \
extmod/moduheapq.o \
extmod/modutimeq.o \
extmod/moduzlib.o \
extmod/utime_mphal.o \
\
lib/embed/abort_.o \
lib/libc/string0.o \
lib/libm/acoshf.o \
lib/libm/asinfacosf.o \
lib/libm/asinhf.o \
lib/libm/atan2f.o \
lib/libm/atanf.o \
lib/libm/atanhf.o \
lib/libm/ef_rem_pio2.o \
lib/libm/erf_lgamma.o \
lib/libm/fmodf.o \
lib/libm/kf_cos.o \
lib/libm/kf_rem_pio2.o \
lib/libm/kf_sin.o \
lib/libm/kf_tan.o \
lib/libm/log1pf.o \
lib/libm/math.o \
lib/libm/nearbyintf.o \
lib/libm/roundf.o \
lib/libm/sf_cos.o \
lib/libm/sf_erf.o \
lib/libm/sf_frexp.o \
lib/libm/sf_ldexp.o \
lib/libm/sf_modf.o \
lib/libm/sf_sin.o \
lib/libm/sf_tan.o \
lib/libm/thumb_vfp_sqrtf.o \
lib/libm/wf_lgamma.o \
lib/libm/wf_tgamma.o \
lib/mp-readline/readline.o \
lib/utils/interrupt_char.o \
lib/utils/printf.o \
lib/utils/pyexec.o \
lib/utils/stdout_helpers.o \
\
py/argcheck.o \
py/asmarm.o \
py/asmbase.o \
py/asmthumb.o \
py/asmx64.o \
py/asmx86.o \
py/asmxtensa.o \
py/bc.o \
py/binary.o \
py/builtinevex.o \
py/builtinhelp.o \
py/builtinimport.o \
py/compile.o \
py/emitbc.o \
py/emitcommon.o \
py/emitglue.o \
py/emitinlinethumb.o \
py/emitinlinextensa.o \
py/formatfloat.o \
py/frozenmod.o \
py/gc.o \
py/lexer.o \
py/malloc.o \
py/map.o \
py/modarray.o \
py/modbuiltins.o \
py/modcmath.o \
py/modcollections.o \
py/modgc.o \
py/modio.o \
py/modmath.o \
py/modmicropython.o \
py/modstruct.o \
py/modsys.o \
py/modthread.o \
py/moduerrno.o \
py/mpprint.o \
py/mpstate.o \
py/mpz.o \
py/nativeglue.o \
py/nlrsetjmp.o \
py/nlrthumb.o \
py/nlrx64.o \
py/nlrx86.o \
py/nlrxtensa.o \
py/obj.o \
py/objarray.o \
py/objattrtuple.o \
py/objbool.o \
py/objboundmeth.o \
py/objcell.o \
py/objclosure.o \
py/objcomplex.o \
py/objdict.o \
py/objenumerate.o \
py/objexcept.o \
py/objfilter.o \
py/objfloat.o \
py/objfun.o \
py/objgenerator.o \
py/objgetitemiter.o \
py/objint_longlong.o \
py/objint_mpz.o \
py/objint.o \
py/objlist.o \
py/objmap.o \
py/objmodule.o \
py/objnamedtuple.o \
py/objnone.o \
py/objobject.o \
py/objpolyiter.o \
py/objproperty.o \
py/objrange.o \
py/objreversed.o \
py/objset.o \
py/objsingleton.o \
py/objslice.o \
py/objstr.o \
py/objstringio.o \
py/objstrunicode.o \
py/objtuple.o \
py/objtype.o \
py/objzip.o \
py/opmethods.o \
py/parse.o \
py/parsenum.o \
py/parsenumbase.o \
py/persistentcode.o \
py/qstr.o \
py/reader.o \
py/repl.o \
py/runtime_utils.o \
py/runtime.o \
py/scope.o \
py/sequence.o \
py/showbc.o \
py/smallint.o \
py/stackctrl.o \
py/stream.o \
py/unicode.o \
py/vm.o \
py/vstr.o \
py/warning.o \
\
stmhal/gccollect.o \
stmhal/gchelper.o \
stmhal/pendsv.o \
stmhal/startup_stm32.o \
stmhal/systick.o \
)
# OBJ vendor/micropython
OBJ_STMHAL += $(addprefix $(BUILD_MP)/,\
stmhal/hal/f4/src/stm32f4xx_hal_adc_ex.o \
stmhal/hal/f4/src/stm32f4xx_hal_adc.o \
stmhal/hal/f4/src/stm32f4xx_hal_can.o \
stmhal/hal/f4/src/stm32f4xx_hal_cortex.o \
stmhal/hal/f4/src/stm32f4xx_hal_dac_ex.o \
stmhal/hal/f4/src/stm32f4xx_hal_dac.o \
stmhal/hal/f4/src/stm32f4xx_hal_dma.o \
stmhal/hal/f4/src/stm32f4xx_hal_flash_ex.o \
stmhal/hal/f4/src/stm32f4xx_hal_flash.o \
stmhal/hal/f4/src/stm32f4xx_hal_gpio.o \
stmhal/hal/f4/src/stm32f4xx_hal_i2c.o \
stmhal/hal/f4/src/stm32f4xx_hal_pcd_ex.o \
stmhal/hal/f4/src/stm32f4xx_hal_pcd.o \
stmhal/hal/f4/src/stm32f4xx_hal_pwr_ex.o \
stmhal/hal/f4/src/stm32f4xx_hal_pwr.o \
stmhal/hal/f4/src/stm32f4xx_hal_rcc_ex.o \
stmhal/hal/f4/src/stm32f4xx_hal_rcc.o \
stmhal/hal/f4/src/stm32f4xx_hal_rng.o \
stmhal/hal/f4/src/stm32f4xx_hal_rtc_ex.o \
stmhal/hal/f4/src/stm32f4xx_hal_rtc.o \
stmhal/hal/f4/src/stm32f4xx_hal_sd.o \
stmhal/hal/f4/src/stm32f4xx_hal_spi.o \
stmhal/hal/f4/src/stm32f4xx_hal_tim_ex.o \
stmhal/hal/f4/src/stm32f4xx_hal_tim.o \
stmhal/hal/f4/src/stm32f4xx_hal_uart.o \
stmhal/hal/f4/src/stm32f4xx_hal.o \
stmhal/hal/f4/src/stm32f4xx_ll_sdmmc.o \
stmhal/hal/f4/src/stm32f4xx_ll_usb.o \
)
# OBJ embed/
OBJ_FIRMWARE += $(addprefix $(BUILD_FW)/, \
firmware/vendorheader.o \
firmware/header.o \
firmware/main.o \
firmware/mphalport.o \
)
OBJ_TREZORHAL += $(addprefix $(BUILD_FW)/, \
trezorhal/common.o \
trezorhal/flash.o \
trezorhal/mini_printf.o \
trezorhal/rng.o \
trezorhal/sdcard.o \
trezorhal/stm32_it.o \
trezorhal/stm32_system.o \
trezorhal/touch.o \
trezorhal/usb.o \
trezorhal/usbd_conf.o \
trezorhal/usbd_core.o \
trezorhal/usbd_ctlreq.o \
trezorhal/usbd_ioreq.o \
trezorhal/hal/stm32f4xx_hal_sram.o \
trezorhal/hal/stm32f4xx_ll_fsmc.o \
)
# make a list of all the .py files that need compiling and freezing
FROZEN_MPY_PY_FILES := $(shell find -L $(FROZEN_MPY_DIR) -type f -name '*.py' | $(SED) -e 's=^$(FROZEN_MPY_DIR)/==')
FROZEN_MPY_MPY_FILES := $(addprefix $(BUILD)/frozen_mpy/,$(FROZEN_MPY_PY_FILES:.py=.mpy))
OBJ = $(OBJ_MICROPYTHON) $(OBJ_STMHAL) $(OBJ_TREZORHAL)
OBJ += $(OBJ_MOD)
OBJ += $(OBJ_FIRMWARE)
OBJ += $(BUILD)/frozen_mpy.o
SRC_MP = $(patsubst $(BUILD_MP)%.o, $(SRCDIR_MP)%.c, $(OBJ_MICROPYTHON))
SRC_MOD = $(patsubst $(BUILD_FW)%.o, $(SRCDIR_FW)%.c, $(OBJ_MOD))
# comp flags
# =====================================
CROSS_COMPILE = arm-none-eabi-
INC += -I.
INC += -I$(SRCDIR_FW)/$(PROJECT)
INC += -I$(SRCDIR_FW)/extmod/modtrezorui
INC += -I$(SRCDIR_FW)/trezorhal
INC += -I$(SRCDIR_FW)/trezorhal/hal
INC += -I$(SRCDIR_MP)
INC += -I$(SRCDIR_MP)/stmhal
INC += -I$(SRCDIR_MP)/stmhal/cmsis
INC += -I$(SRCDIR_MP)/stmhal/hal/f4/inc
INC += -I$(SRCDIR_MP)/lib/cmsis/inc
INC += -I$(BUILD)
ifeq ($(DEBUG), 1)
CFLAGS += -Os -g3
else
CFLAGS += -Os -DNDEBUG
endif
CFLAGS += $(INC) $(CFLAGS_MOD) $(CFLAGS_EXTRA)
CFLAGS += -std=gnu99 -nostdlib -Wall -Werror -Wdouble-promotion -Wpointer-arith
CFLAGS += -mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -mfpu=fpv4-sp-d16 -mfloat-abi=hard -fsingle-precision-constant
CFLAGS += -DSTM32F405xx -DMCU_SERIES_F4
CFLAGS += -DSTM32_HAL_H='<stm32f4xx_hal.h>'
CFLAGS += -DTREZOR_STM32
CFLAGS += -DMICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool
CFLAGS += -DMICROPY_MODULE_FROZEN_MPY
LIBS = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name)
LDFLAGS = -nostdlib -T $(SRCDIR_FW)/$(PROJECT)/memory.ld -Map=$@.map --cref
# remove uncalled code from the final image
CFLAGS += -fdata-sections -ffunction-sections
LDFLAGS += --gc-sections
# QSTR file locations
QSTR_DEFS = $(SRCDIR_MP)/py/qstrdefs.h
QSTR_DEFS_COLLECTED = $(BUILD_HDR)/qstrdefs.collected.h
# SRC files for QSTR extraction
SRC_QSTR_IGNORE = $(addprefix $(SRCDIR_MP)/py/, \
nlr% emitnx86% emitnx64% emitnthumb% emitnarm% emitnxtensa%)
SRC_QSTR += $(SRC_MOD)
SRC_QSTR += $(filter $(SRCDIR_MP)/lib/%,$(SRC_MP))
SRC_QSTR += $(filter $(SRCDIR_MP)/extmod/%,$(SRC_MP))
# SRC_QSTR += $(filter $(SRCDIR_MP)/stmhal/%,$(filter-out %/gchelper.o,$(SRC_MP)))
SRC_QSTR += $(filter-out $(SRC_QSTR_IGNORE),$(filter $(SRCDIR_MP)/py/%,$(SRC_MP)))
# extra cpp CFLAGS for QSTR extraction
QSTR_GEN_EXTRA_CFLAGS += -DNO_QSTR -DN_X64 -DN_X86 -DN_THUMB -DN_ARM -DN_XTENSA
# comp rules
# =====================================
all: $(BUILD)/$(PROJECT).bin
$(BUILD_FW)/firmware/vendorheader.o: $(SRCDIR_FW)/firmware/vendorheader.bin
$(Q)$(OBJCOPY) -I binary -O elf32-littlearm -B arm \
--rename-section .data=.vendorheader,alloc,load,readonly,contents \
$< $@
$(BUILD)/$(PROJECT).elf: $(OBJ)
$(ECHO) "LINK $@"
$(Q)$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
$(Q)$(SIZE) $@
$(BUILD)/$(PROJECT).bin: $(BUILD)/$(PROJECT).elf
$(Q)$(OBJCOPY) -O binary -j .header -j .flash -j .data $^ $(BUILD)/$(PROJECT).bin
$(BUILD)/%.o: %.S
$(ECHO) "CC $<"
$(Q)$(CC) $(CFLAGS) -c -o $@ $<
$(BUILD)/%.o: %.s
$(ECHO) "AS $<"
$(Q)$(AS) -o $@ $<
$(BUILD)/%.o: %.c
$(ECHO) "CC $<"
$(Q)$(CC) $(CFLAGS) -c -MD -o $@ $<
OBJ_DIRS = $(sort $(dir $(OBJ)))
$(OBJ): | $(OBJ_DIRS)
$(OBJ_DIRS) $(BUILD_HDR):
$(MKDIR) -p $@
$(OBJ): | $(BUILD_HDR)/qstrdefs.generated.h $(BUILD_HDR)/mpversion.h
$(BUILD_HDR)/qstr.i.last: $(SRC_QSTR) | $(BUILD_HDR)/mpversion.h
$(ECHO) "GEN $@"
$(Q)$(CPP) $(QSTR_GEN_EXTRA_CFLAGS) $(CFLAGS) $^ >$(BUILD_HDR)/qstr.i.last; \
$(BUILD_HDR)/qstr.split: $(BUILD_HDR)/qstr.i.last
$(ECHO) "GEN $@"
$(Q)$(PYTHON) $(PY_SRC)/makeqstrdefs.py split $(BUILD_HDR)/qstr.i.last $(BUILD_HDR)/qstr $(QSTR_DEFS_COLLECTED)
$(Q)touch $@
$(QSTR_DEFS_COLLECTED): $(BUILD_HDR)/qstr.split
$(ECHO) "GEN $@"
$(Q)$(PYTHON) $(PY_SRC)/makeqstrdefs.py cat $(BUILD_HDR)/qstr.i.last $(BUILD_HDR)/qstr $(QSTR_DEFS_COLLECTED)
$(BUILD_HDR)/qstrdefs.generated.h: $(QSTR_DEFS) $(QSTR_DEFS_COLLECTED) $(SRCDIR_FW)/firmware/mpconfigport.h | $(BUILD_HDR)
$(ECHO) "GEN $@"
$(Q)cat $(QSTR_DEFS) $(QSTR_DEFS_COLLECTED) \
| $(SED) 's/^Q(.*)/"&"/' \
| $(CPP) $(CFLAGS) - \
| $(SED) 's/^"\(Q(.*)\)"/\1/' \
> $(BUILD_HDR)/qstrdefs.preprocessed.h
$(Q)$(PYTHON) $(PY_SRC)/makeqstrdata.py $(BUILD_HDR)/qstrdefs.preprocessed.h > $@
$(BUILD_HDR)/mpversion.h: | $(BUILD_HDR)
$(Q)$(PYTHON) $(PY_SRC)/makeversionhdr.py $@
$(BUILD)/frozen_mpy/%.mpy: $(FROZEN_MPY_DIR)/%.py
@$(ECHO) "MPY $<"
$(Q)$(MKDIR) -p $(dir $@)
$(Q)$(MPY_CROSS) -o $@ -s $(^:$(FROZEN_MPY_DIR)/%=%) $^
$(BUILD)/frozen_mpy.c: $(FROZEN_MPY_MPY_FILES) $(BUILD)/genhdr/qstrdefs.generated.h
@$(ECHO) "Creating $@"
$(Q)PYTHONPATH=$(SRCDIR_MP)/py $(PYTHON) $(MPY_TOOL) -f -q $(BUILD)/genhdr/qstrdefs.preprocessed.h $(FROZEN_MPY_MPY_FILES) > $@
clean:
$(RM) -rf $(BUILD)
.PHONY: all clean

View File

@ -1,396 +0,0 @@
MICROPY_PY_TREZORCONFIG = 1
MICROPY_PY_TREZORCRYPTO = 1
MICROPY_PY_TREZORIO = 1
MICROPY_PY_TREZORMSG = 1
MICROPY_PY_TREZORUI = 1
MICROPY_PY_TREZORUTILS = 1
TREZOR_NOUI = 0
EXTMOD_DIR = ../../embed/extmod
CFLAGS_EXTRA='-DMP_CONFIGFILE="../../../embed/unix/mpconfigport.h"'
# OBJ embed/extmod/modtrezorconfig
ifeq ($(MICROPY_PY_TREZORCONFIG),1)
SRC_MOD += $(EXTMOD_DIR)/modtrezorconfig/modtrezorconfig.c
SRC_MOD += $(EXTMOD_DIR)/modtrezorconfig/norcow.c
endif
# OBJ embed/extmod/modtrezorcrypto
ifeq ($(MICROPY_PY_TREZORCRYPTO),1)
CFLAGS_MOD += -I../$(EXTMOD_DIR)/modtrezorcrypto/trezor-crypto
CFLAGS_MOD += -I../$(EXTMOD_DIR)/modtrezorcrypto/trezor-crypto/aes
CFLAGS_MOD += -I../$(EXTMOD_DIR)/modtrezorcrypto/trezor-crypto/ed25519-donna
CFLAGS_MOD += -DAES_128
CFLAGS_MOD += -DAES_192
CFLAGS_MOD += -DUSE_KECCAK=1
CFLAGS_MOD += -Wno-sequence-point
SRC_MOD += \
$(EXTMOD_DIR)/modtrezorcrypto/modtrezorcrypto.c \
$(EXTMOD_DIR)/modtrezorcrypto/rand.c \
$(EXTMOD_DIR)/modtrezorcrypto/ssss.c \
$(EXTMOD_DIR)/modtrezorcrypto/trezor-crypto/address.c \
$(EXTMOD_DIR)/modtrezorcrypto/trezor-crypto/aes/aescrypt.c \
$(EXTMOD_DIR)/modtrezorcrypto/trezor-crypto/aes/aeskey.c \
$(EXTMOD_DIR)/modtrezorcrypto/trezor-crypto/aes/aes_modes.c \
$(EXTMOD_DIR)/modtrezorcrypto/trezor-crypto/aes/aestab.c \
$(EXTMOD_DIR)/modtrezorcrypto/trezor-crypto/base58.c \
$(EXTMOD_DIR)/modtrezorcrypto/trezor-crypto/bignum.c \
$(EXTMOD_DIR)/modtrezorcrypto/trezor-crypto/bip32.c \
$(EXTMOD_DIR)/modtrezorcrypto/trezor-crypto/bip39.c \
$(EXTMOD_DIR)/modtrezorcrypto/trezor-crypto/blake2b.c \
$(EXTMOD_DIR)/modtrezorcrypto/trezor-crypto/blake2s.c \
$(EXTMOD_DIR)/modtrezorcrypto/trezor-crypto/curves.c \
$(EXTMOD_DIR)/modtrezorcrypto/trezor-crypto/ecdsa.c \
$(EXTMOD_DIR)/modtrezorcrypto/trezor-crypto/ed25519-donna/ed25519.c \
$(EXTMOD_DIR)/modtrezorcrypto/trezor-crypto/hmac.c \
$(EXTMOD_DIR)/modtrezorcrypto/trezor-crypto/nist256p1.c \
$(EXTMOD_DIR)/modtrezorcrypto/trezor-crypto/pbkdf2.c \
$(EXTMOD_DIR)/modtrezorcrypto/trezor-crypto/ripemd160.c \
$(EXTMOD_DIR)/modtrezorcrypto/trezor-crypto/secp256k1.c \
$(EXTMOD_DIR)/modtrezorcrypto/trezor-crypto/sha2.c \
$(EXTMOD_DIR)/modtrezorcrypto/trezor-crypto/sha3.c
endif
# OBJ embed/extmod/modtrezorio
ifeq ($(MICROPY_PY_TREZORIO),1)
SRC_MOD += $(EXTMOD_DIR)/modtrezorio/modtrezorio.c
endif
# OBJ embed/extmod/modtrezormsg
ifeq ($(MICROPY_PY_TREZORMSG),1)
SRC_MOD += $(EXTMOD_DIR)/../unix/touch.c
SRC_MOD += $(EXTMOD_DIR)/modtrezormsg/modtrezormsg.c
endif
# OBJ embed/extmod/modtrezorui
ifeq ($(MICROPY_PY_TREZORUI),1)
CFLAGS_MOD += -DQR_MAX_VERSION=0
SRC_MOD += \
$(EXTMOD_DIR)/modtrezorui/display.c \
$(EXTMOD_DIR)/modtrezorui/inflate.c \
$(EXTMOD_DIR)/modtrezorui/font_bitmap.c \
$(EXTMOD_DIR)/modtrezorui/font_roboto_bold_20.c \
$(EXTMOD_DIR)/modtrezorui/font_roboto_regular_20.c \
$(EXTMOD_DIR)/modtrezorui/font_robotomono_regular_20.c \
$(EXTMOD_DIR)/modtrezorui/modtrezorui.c \
$(EXTMOD_DIR)/modtrezorui/trezor-qrenc/qr_encode.c
ifeq ($(TREZOR_NOUI),1)
CFLAGS_MOD += -DTREZOR_NOUI=1
else
LDFLAGS_MOD += -lSDL2 -lSDL2_image
endif
endif
# OBJ embed/extmod/modtrezorutils
ifeq ($(MICROPY_PY_TREZORUTILS),1)
SRC_MOD += $(EXTMOD_DIR)/modtrezorutils/modtrezorutils.c
endif
CFLAGS_MOD += -I../$(EXTMOD_DIR)/../unix
SRC_MOD += $(EXTMOD_DIR)/../unix/common.c
#################################################
-include mpconfigport.mk
include ../py/mkenv.mk
FROZEN_DIR = scripts
FROZEN_MPY_DIR = modules
# define main target
PROG = micropython
# qstr definitions (must come before including py.mk)
QSTR_DEFS = qstrdefsport.h
# OS name, for simple autoconfig
UNAME_S := $(shell uname -s)
# include py core make definitions
include ../py/py.mk
INC += -I.
INC += -I..
INC += -I$(BUILD)
# compiler settings
CWARN = -Wall -Werror
CWARN += -Wpointer-arith -Wuninitialized
CFLAGS = $(INC) $(CWARN) -std=gnu99 -DUNIX $(CFLAGS_MOD) $(COPT) $(CFLAGS_EXTRA)
CFLAGS += -DTREZOR_UNIX
# Debugging/Optimization
ifdef DEBUG
CFLAGS += -g
COPT = -Os
else
COPT = -Os -fdata-sections -ffunction-sections #-DNDEBUG
# _FORTIFY_SOURCE is a feature in gcc/glibc which is intended to provide extra
# security for detecting buffer overflows. Some distros (Ubuntu at the very least)
# have it enabled by default.
#
# gcc already optimizes some printf calls to call puts and/or putchar. When
# _FORTIFY_SOURCE is enabled and compiling with -O1 or greater, then some
# printf calls will also be optimized to call __printf_chk (in glibc). Any
# printfs which get redirected to __printf_chk are then no longer synchronized
# with printfs that go through mp_printf.
#
# In MicroPython, we don't want to use the runtime library's printf but rather
# go through mp_printf, so that stdout is properly tied into streams, etc.
# This means that we either need to turn off _FORTIFY_SOURCE or provide our
# own implementation of __printf_chk. We've chosen to turn off _FORTIFY_SOURCE.
# It should also be noted that the use of printf in MicroPython is typically
# quite limited anyways (primarily for debug and some error reporting, etc
# in the unix version).
#
# Information about _FORTIFY_SOURCE seems to be rather scarce. The best I could
# find was this: https://securityblog.redhat.com/2014/03/26/fortify-and-you/
# Original patchset was introduced by
# https://gcc.gnu.org/ml/gcc-patches/2004-09/msg02055.html .
#
# Turning off _FORTIFY_SOURCE is only required when compiling with -O1 or greater
CFLAGS += -U _FORTIFY_SOURCE
endif
# On OSX, 'gcc' is a symlink to clang unless a real gcc is installed.
# The unix port of micropython on OSX must be compiled with clang,
# while cross-compile ports require gcc, so we test here for OSX and
# if necessary override the value of 'CC' set in py/mkenv.mk
ifeq ($(UNAME_S),Darwin)
ifeq ($(MICROPY_FORCE_32BIT),1)
CC = clang -m32
else
CC = clang
endif
# Use clang syntax for map file
LDFLAGS_ARCH = -Wl,-map,$@.map -Wl,-dead_strip
else
# Use gcc syntax for map file
LDFLAGS_ARCH = -Wl,-Map=$@.map,--cref -Wl,--gc-sections
endif
LDFLAGS = $(LDFLAGS_MOD) $(LDFLAGS_ARCH) -lm $(LDFLAGS_EXTRA)
ifeq ($(MICROPY_FORCE_32BIT),1)
# Note: you may need to install i386 versions of dependency packages,
# starting with linux-libc-dev:i386
ifeq ($(MICROPY_PY_FFI),1)
ifeq ($(UNAME_S),Linux)
CFLAGS_MOD += -I/usr/include/i686-linux-gnu
endif
endif
endif
ifeq ($(MICROPY_USE_READLINE),1)
INC += -I../lib/mp-readline
CFLAGS_MOD += -DMICROPY_USE_READLINE=1
LIB_SRC_C_EXTRA += mp-readline/readline.c
endif
ifeq ($(MICROPY_PY_TERMIOS),1)
CFLAGS_MOD += -DMICROPY_PY_TERMIOS=1
SRC_MOD += modtermios.c
endif
ifeq ($(MICROPY_PY_SOCKET),1)
CFLAGS_MOD += -DMICROPY_PY_SOCKET=1
SRC_MOD += modsocket.c
endif
ifeq ($(MICROPY_PY_THREAD),1)
CFLAGS_MOD += -DMICROPY_PY_THREAD=1 -DMICROPY_PY_THREAD_GIL=0
LDFLAGS_MOD += -lpthread
endif
ifeq ($(MICROPY_PY_FFI),1)
ifeq ($(MICROPY_STANDALONE),1)
LIBFFI_CFLAGS_MOD := -I$(shell ls -1d ../lib/libffi/build_dir/out/lib/libffi-*/include)
ifeq ($(MICROPY_FORCE_32BIT),1)
LIBFFI_LDFLAGS_MOD = ../lib/libffi/build_dir/out/lib32/libffi.a
else
LIBFFI_LDFLAGS_MOD = ../lib/libffi/build_dir/out/lib/libffi.a
endif
else
LIBFFI_CFLAGS_MOD := $(shell pkg-config --cflags libffi)
LIBFFI_LDFLAGS_MOD := $(shell pkg-config --libs libffi)
endif
ifeq ($(UNAME_S),Linux)
LIBFFI_LDFLAGS_MOD += -ldl
endif
CFLAGS_MOD += $(LIBFFI_CFLAGS_MOD) -DMICROPY_PY_FFI=1
LDFLAGS_MOD += $(LIBFFI_LDFLAGS_MOD)
SRC_MOD += modffi.c
endif
ifeq ($(MICROPY_PY_JNI),1)
# Path for 64-bit OpenJDK, should be adjusted for other JDKs
CFLAGS_MOD += -I/usr/lib/jvm/java-7-openjdk-amd64/include -DMICROPY_PY_JNI=1
SRC_MOD += modjni.c
endif
# source files
SRC_C = \
main.c \
gccollect.c \
unix_mphal.c \
mpthreadport.c \
input.c \
file.c \
modmachine.c \
modos.c \
moduos_vfs.c \
modtime.c \
moduselect.c \
alloc.c \
coverage.c \
fatfs_port.c \
$(SRC_MOD)
LIB_SRC_C = $(addprefix lib/,\
$(LIB_SRC_C_EXTRA) \
timeutils/timeutils.c \
)
# FatFS VFS support
LIB_SRC_C += $(addprefix lib/,\
oofatfs/ff.c \
oofatfs/option/unicode.c \
)
OBJ = $(PY_O)
OBJ += $(addprefix $(BUILD)/, $(SRC_C:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(LIB_SRC_C:.c=.o))
OBJ += $(addprefix $(BUILD)/, $(STMHAL_SRC_C:.c=.o))
# List of sources for qstr extraction
SRC_QSTR += $(SRC_C) $(LIB_SRC_C)
# Append any auto-generated sources that are needed by sources listed in
# SRC_QSTR
SRC_QSTR_AUTO_DEPS +=
ifneq ($(FROZEN_MPY_DIR),)
# To use frozen bytecode, put your .py files in a subdirectory (eg frozen/) and
# then invoke make with FROZEN_MPY_DIR=frozen (be sure to build from scratch).
CFLAGS += -DMICROPY_QSTR_EXTRA_POOL=mp_qstr_frozen_const_pool
CFLAGS += -DMICROPY_MODULE_FROZEN_MPY
CFLAGS += -DMPZ_DIG_SIZE=16 # force 16 bits to work on both 32 and 64 bit archs
MPY_CROSS_FLAGS += -mcache-lookup-bc
endif
include ../py/mkrules.mk
.PHONY: test
test: $(PROG) ../tests/run-tests
$(eval DIRNAME=$(notdir $(CURDIR)))
cd ../tests && MICROPY_MICROPYTHON=../$(DIRNAME)/$(PROG) ./run-tests
# install micropython in /usr/local/bin
TARGET = micropython
PREFIX = $(DESTDIR)/usr/local
BINDIR = $(PREFIX)/bin
install: micropython
install -d $(BINDIR)
install $(TARGET) $(BINDIR)/$(TARGET)
# uninstall micropython
uninstall:
-rm $(BINDIR)/$(TARGET)
# build synthetically fast interpreter for benchmarking
fast:
$(MAKE) COPT="-O2 -DNDEBUG -fno-crossjumping" CFLAGS_EXTRA='-DMP_CONFIGFILE="<mpconfigport_fast.h>"' BUILD=build-fast PROG=micropython_fast
# build a minimal interpreter
minimal:
$(MAKE) COPT="-Os -DNDEBUG" CFLAGS_EXTRA='-DMP_CONFIGFILE="<mpconfigport_minimal.h>"' \
BUILD=build-minimal PROG=micropython_minimal FROZEN_DIR= FROZEN_MPY_DIR= \
MICROPY_PY_BTREE=0 MICROPY_PY_FFI=0 MICROPY_PY_SOCKET=0 MICROPY_PY_THREAD=0 \
MICROPY_PY_TERMIOS=0 MICROPY_PY_USSL=0 \
MICROPY_USE_READLINE=0
# build interpreter with nan-boxing as object model
nanbox:
$(MAKE) \
CFLAGS_EXTRA='-DMP_CONFIGFILE="<mpconfigport_nanbox.h>"' \
BUILD=build-nanbox \
PROG=micropython_nanbox \
MICROPY_FORCE_32BIT=1 \
MICROPY_PY_USSL=0
freedos:
$(MAKE) \
CC=i586-pc-msdosdjgpp-gcc \
STRIP=i586-pc-msdosdjgpp-strip \
SIZE=i586-pc-msdosdjgpp-size \
CFLAGS_EXTRA='-DMP_CONFIGFILE="<mpconfigport_freedos.h>" -DMICROPY_NLR_SETJMP -Dtgamma=gamma -DMICROPY_EMIT_X86=0 -DMICROPY_NO_ALLOCA=1 -DMICROPY_PY_USELECT_POSIX=0' \
BUILD=build-freedos \
PROG=micropython_freedos \
MICROPY_PY_SOCKET=0 \
MICROPY_PY_FFI=0 \
MICROPY_PY_JNI=0 \
MICROPY_PY_BTREE=0 \
MICROPY_PY_THREAD=0 \
MICROPY_PY_USSL=0
# build an interpreter for coverage testing and do the testing
coverage:
$(MAKE) \
COPT="-O0" CFLAGS_EXTRA='-DMP_CONFIGFILE="<mpconfigport_coverage.h>" \
-fprofile-arcs -ftest-coverage \
-Wdouble-promotion -Wformat -Wmissing-declarations -Wmissing-prototypes -Wsign-compare \
-Wold-style-definition -Wpointer-arith -Wshadow -Wuninitialized -Wunused-parameter \
-DMICROPY_UNIX_COVERAGE' \
LDFLAGS_EXTRA='-fprofile-arcs -ftest-coverage' \
FROZEN_DIR=coverage-frzstr FROZEN_MPY_DIR=coverage-frzmpy \
BUILD=build-coverage PROG=micropython_coverage
coverage_test: coverage
$(eval DIRNAME=$(notdir $(CURDIR)))
cd ../tests && MICROPY_MICROPYTHON=../$(DIRNAME)/micropython_coverage ./run-tests
cd ../tests && MICROPY_MICROPYTHON=../$(DIRNAME)/micropython_coverage ./run-tests -d thread
cd ../tests && MICROPY_MICROPYTHON=../$(DIRNAME)/micropython_coverage ./run-tests --emit native
cd ../tests && MICROPY_MICROPYTHON=../$(DIRNAME)/micropython_coverage ./run-tests --via-mpy -d basics float
gcov -o build-coverage/py ../py/*.c
gcov -o build-coverage/extmod ../extmod/*.c
# Value of configure's --host= option (required for cross-compilation).
# Deduce it from CROSS_COMPILE by default, but can be overridden.
ifneq ($(CROSS_COMPILE),)
CROSS_COMPILE_HOST = --host=$(patsubst %-,%,$(CROSS_COMPILE))
else
CROSS_COMPILE_HOST =
endif
deplibs: libffi axtls
# install-exec-recursive & install-data-am targets are used to avoid building
# docs and depending on makeinfo
libffi:
cd ../lib/libffi; git clean -d -x -f
cd ../lib/libffi; ./autogen.sh
mkdir -p ../lib/libffi/build_dir; cd ../lib/libffi/build_dir; \
../configure $(CROSS_COMPILE_HOST) --prefix=$$PWD/out --disable-structs CC="$(CC)" CXX="$(CXX)" LD="$(LD)" CFLAGS="-Os -fomit-frame-pointer -fstrict-aliasing -ffast-math -fno-exceptions"; \
$(MAKE) install-exec-recursive; $(MAKE) -C include install-data-am
axtls: $(BUILD)/libaxtls.a
$(BUILD)/libaxtls.a: ../lib/axtls/README | $(OBJ_DIRS)
cd ../lib/axtls; cp config/upyconfig config/.config
cd ../lib/axtls; $(MAKE) oldconfig -B
cd ../lib/axtls; $(MAKE) clean
cd ../lib/axtls; $(MAKE) all CC="$(CC)" LD="$(LD)"
cp ../lib/axtls/_stage/libaxtls.a $@
../lib/axtls/README:
@echo "You cloned without --recursive, fetching submodules for you."
(cd ..; git submodule update --init --recursive)