include ../py/mkenv.mk # qstr definitions (must come before including py.mk) QSTR_DEFS = qstrdefsport.h $(BUILD)/pins_qstr.h # include py core make definitions include ../py/py.mk # If you set USE_ARDUINO_TOOLCHAIN=1 then this makefile will attempt to use # the toolchain that comes with Teensyduino ifeq ($(USE_ARDUINO_TOOLCHAIN),) USE_ARDUINO_TOOLCHAIN = 0 endif ifeq ($(USE_ARDUINO_TOOLCHAIN),1) ifeq ($(ARDUINO),) $(error USE_ARDUINO_TOOLCHAIN requires that ARDUINO be set) endif endif ifeq ($(USE_ARDUINO_TOOLCHAIN),1) $(info Using ARDUINO toolchain) CROSS_COMPILE = $(ARDUINO)/hardware/tools/arm-none-eabi/bin/arm-none-eabi- else $(info Using toolchain from PATH) CROSS_COMPILE = arm-none-eabi- endif CFLAGS_TEENSY = -DF_CPU=96000000 -DUSB_SERIAL -D__MK20DX256__ CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -msoft-float -mfloat-abi=soft -fsingle-precision-constant -Wdouble-promotion $(CFLAGS_TEENSY) INC = -I. INC += -I.. INC += -I../stmhal INC += -I$(BUILD) INC += -Icore CFLAGS = $(INC) -Wall -Wpointer-arith -ansi -std=gnu99 -nostdlib $(CFLAGS_CORTEX_M4) LDFLAGS = -nostdlib -T mk20dx256.ld -msoft-float -mfloat-abi=soft ifeq ($(USE_ARDUINO_TOOLCHAIN),1) LIBGCC_FILE_NAME = $(ARDUINO)/hardware/tools/arm-none-eabi/lib/gcc/arm-none-eabi/4.7.2/thumb2/libgcc.a LIBM_FILE_NAME = $(ARDUINO)/hardware/tools/arm-none-eabi/arm-none-eabi/lib/thumb2/libm.a LIBC_FILE_NAME = $(ARDUINO)/hardware/tools/arm-none-eabi/arm-none-eabi/lib/thumb2/libc.a else LIBGCC_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-libgcc-file-name) LIBM_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-file-name=libm.a) LIBC_FILE_NAME = $(shell $(CC) $(CFLAGS) -print-file-name=libc.a) endif #$(info %%%%% LIBGCC_FILE_NAME = $(LIBGCC_FILE_NAME)) #$(info %%%%% LIBM_FILE_NAME = $(LIBM_FILE_NAME)) #$(info %%%%% LIBC_FILE_NAME = $(LIBC_FILE_NAME)) #$(info %%%%% dirname LIBGCC_FILE_NAME = $(dir $(LIBGCC_FILE_NAME))) #$(info %%%%% dirname LIBM_FILE_NAME = $(dir $(LIBM_FILE_NAME))) #$(info %%%%% dirname LIBC_FILE_NAME = $(dir $(LIBC_FILE_NAME))) LIBS = -L $(dir $(LIBM_FILE_NAME)) -lm LIBS += -L $(dir $(LIBC_FILE_NAME)) -lc LIBS += -L $(dir $(LIBGCC_FILE_NAME)) -lgcc #Debugging/Optimization ifdef DEBUG CFLAGS += -Og -ggdb else CFLAGS += -Os #-DNDEBUG endif CFLAGS += -fdata-sections -ffunction-sections LDFLAGS += -Wl,--gc-sections SRC_C = \ hal_ftm.c \ hal_gpio.c \ help.c \ import.c \ main.c \ lcd.c \ led.c \ lexermemzip.c \ memzip.c \ modpyb.c \ pin_defs_teensy.c \ reg.c \ teensy_hal.c \ timer.c \ uart.c \ usb.c \ STM_SRC_C = $(addprefix stmhal/,\ gccollect.c \ input.c \ irq.c \ pin.c \ pin_named_pins.c \ printf.c \ pyexec.c \ pybstdio.c \ readline.c \ string0.c \ ) STM_SRC_S = $(addprefix stmhal/,\ gchelper.s \ ) SRC_TEENSY = $(addprefix core/,\ mk20dx128.c \ pins_teensy.c \ analog.c \ usb_desc.c \ usb_dev.c \ usb_mem.c \ usb_serial.c \ yield.c \ ) OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o) $(STM_SRC_C:.c=.o) $(STM_SRC_S:.s=.o) $(SRC_TEENSY:.c=.o)) OBJ += $(BUILD)/pins_gen.o all: hex hex: $(BUILD)/micropython-mz.hex ifeq ($(ARDUINO),) post_compile: $(BUILD)/micropython-mz.hex $(ECHO) "Please define ARDUINO (where TeensyDuino is installed)" exit 1 reboot: $(ECHO) "Please define ARDUINO (where TeensyDuino is installed)" exit 1 else TOOLS_PATH = $(ARDUINO)/hardware/tools post_compile: $(BUILD)/micropython-mz.hex $(ECHO) "Preparing $@ for upload" $(Q)$(TOOLS_PATH)/teensy_post_compile -file="$(basename $( $(GEN_PINS_SRC) $(BUILD)/pins_gen.o: $(BUILD)/pins_gen.c $(call compile_c) $(BUILD)/%.pp: $(BUILD)/%.c $(ECHO) "PreProcess $<" $(Q)$(CC) $(CFLAGS) -E -Wp,-C,-dD,-dI -o $@ $< include ../py/mkrules.mk