Commit ee0013d2 authored by Dave Hylands's avatar Dave Hylands
Browse files

Update teemsy/Makefile to use py.mk

I also fixed main.c to compile with the new str lexer
parent ea9e441a
# define main target
all: all2
# include py core make definitions
include ../py/py.mk
# program for deletion
RM = /bin/rm
ifeq ($(ARDUINO),)
$(error Please define ARDUINO (where TeensyDuino is installed))
endif
TOOLS_PATH = $(ARDUINO)/hardware/tools
COMPILER_PATH = $(TOOLS_PATH)/arm-none-eabi/bin
CORE_PATH = $(ARDUINO)/hardware/teensy/cores/teensy3
PYSRC=../py
BUILD=build
TARGET=TEENSY
AS = $(COMPILER_PATH)/arm-none-eabi-as
CC = $(COMPILER_PATH)/arm-none-eabi-gcc
......@@ -14,9 +21,9 @@ LD = $(COMPILER_PATH)/arm-none-eabi-ld
OBJCOPY = $(COMPILER_PATH)/arm-none-eabi-objcopy
SIZE = $(COMPILER_PATH)/arm-none-eabi-size
CFLAGS_TEENSY = -DF_CPU=96000000 -DUSB_SERIAL -DLAYOUT_US_ENGLISH -D__MK20DX256__
CFLAGS_TEENSY = -DF_CPU=96000000 -DUSB_SERIAL -D__MK20DX256__
CFLAGS_CORTEX_M4 = -mthumb -mtune=cortex-m4 -mcpu=cortex-m4 -fsingle-precision-constant -Wdouble-promotion $(CFLAGS_TEENSY)
CFLAGS = -I. -I$(PYSRC) -I$(CORE_PATH) -Wall -ansi -std=gnu99 -Os -DNDEBUG $(CFLAGS_CORTEX_M4)
CFLAGS = -I. -I$(PY_SRC) -I$(CORE_PATH) -Wall -ansi -std=gnu99 -Os -DNDEBUG $(CFLAGS_CORTEX_M4) -D$(TARGET)
LDFLAGS = -nostdlib -T mk20dx256.ld
LIBS = -L $(COMPILER_PATH)/../lib/gcc/arm-none-eabi/4.7.2/thumb2 -lgcc
......@@ -36,55 +43,6 @@ STM_SRC_C = \
STM_SRC_S = \
gchelper.s \
PY_O = \
nlrthumb.o \
gc.o \
malloc.o \
qstr.o \
vstr.o \
unicode.o \
lexer.o \
lexerstr.o \
parse.o \
scope.o \
compile.o \
emitcommon.o \
emitpass1.o \
emitbc.o \
asmthumb.o \
emitnthumb.o \
emitinlinethumb.o \
runtime.o \
map.o \
obj.o \
objbool.o \
objboundmeth.o \
objcell.o \
objclass.o \
objclosure.o \
objcomplex.o \
objdict.o \
objexcept.o \
objfloat.o \
objfun.o \
objgenerator.o \
objinstance.o \
objint.o \
objlist.o \
objmodule.o \
objnone.o \
objrange.o \
objset.o \
objslice.o \
objstr.o \
objtuple.o \
objtype.o \
builtin.o \
builtinimport.o \
vm.o \
showbc.o \
repl.o \
SRC_TEENSY = \
mk20dx128.c \
pins_teensy.c \
......@@ -95,36 +53,29 @@ SRC_TEENSY = \
usb_serial.c \
yield.c \
STM_SRC_C_OBJ = $(STM_SRC_C:.c=.o)
STM_SRC_S_OBJ = $(STM_SRC_S:.s=.o)
OBJ = $(addprefix $(BUILD)/, $(SRC_C:.c=.o) $(STM_SRC_C_OBJ) $(STM_SRC_S_OBJ) $(PY_O) $(SRC_TEENSY:.c=.o))
OBJ = $(addprefix $(BUILD)/, $(SRC_C:.c=.o) $(STM_SRC_C:.c=.o) $(STM_SRC_S:.s=.o) $(SRC_TEENSY:.c=.o)) $(PY_O)
#LIB = -lreadline
# the following is needed for BSD
#LIB += -ltermcap
PROG = micropython
all: hex
hex: $(PROG).hex
all2: $(BUILD) hex
hex: $(BUILD)/flash.hex
post_compile: $(PROG).hex
$(TOOLS_PATH)/teensy_post_compile -file="$(basename $<)" -path="$(CURDIR)" -tools="$(TOOLS_PATH)"
post_compile: $(BUILD)/flash.hex
$(TOOLS_PATH)/teensy_post_compile -file="$(basename $<)" -path="$(BUILD)" -tools="$(TOOLS_PATH)"
reboot:
-$(TOOLS_PATH)/teensy_reboot
upload: post_compile reboot
$(PROG).elf: $(BUILD) $(OBJ)
$(CC) $(LDFLAGS) -o "$@" -Wl,-Map,$(PROG).map $(OBJ) $(LIBS)
$(BUILD)/flash.elf: $(OBJ)
$(CC) $(LDFLAGS) -o "$@" -Wl,-Map,$(@:.elf=.map) $(OBJ) $(LIBS)
$(SIZE) $@
%.hex: %.elf
$(SIZE) "$<"
$(BUILD)/%.hex: $(BUILD)/%.elf
$(OBJCOPY) -O ihex -R .eeprom "$<" "$@"
$(BUILD):
mkdir -p $@
$(BUILD)/%.o: %.c
$(CC) $(CFLAGS) -c -o $@ $<
......@@ -134,33 +85,12 @@ $(BUILD)/%.o: ../stm/%.s
$(BUILD)/%.o: ../stm/%.c
$(CC) $(CFLAGS) -c -o $@ $<
$(BUILD)/%.o: $(PYSRC)/%.S
$(CC) $(CFLAGS) -c -o $@ $<
$(BUILD)/%.o: $(PYSRC)/%.c mpconfigport.h
$(CC) $(CFLAGS) -c -o $@ $<
$(BUILD)/%.o: $(CORE_PATH)/%.c
$(CC) $(CFLAGS) -c -o $@ $<
$(BUILD)/emitnthumb.o: $(PYSRC)/emitnative.c $(PYSRC)/emit.h
$(CC) $(CFLAGS) -DN_THUMB -c -o $@ $<
# optimising gc for speed; 5ms down to 4ms
$(BUILD)/gc.o: $(PYSRC)/gc.c
$(CC) $(CFLAGS) -O3 -c -o $@ $<
# optimising vm for speed, adds only a small amount to code size but makes a huge difference to speed (20% faster)
$(BUILD)/vm.o: $(PYSRC)/vm.c
$(CC) $(CFLAGS) -O3 -c -o $@ $<
$(BUILD)/main.o: mpconfigport.h
$(BUILD)/parse.o: $(PYSRC)/grammar.h
$(BUILD)/compile.o: $(PYSRC)/grammar.h
$(BUILD)/emitbc.o: $(PYSRC)/emit.h
clean:
/bin/rm -rf $(BUILD)
/bin/rm -f $(PROG).elf $(PROG).hex $(PROG).map
.PHONY: clean
.PHONY: all all2 clean
......@@ -347,8 +347,7 @@ void do_repl(void) {
}
}
mp_lexer_str_buf_t sb;
mp_lexer_t *lex = mp_lexer_new_from_str_len("<stdin>", vstr_str(&line), vstr_len(&line), false, &sb);
mp_lexer_t *lex = mp_lexer_new_from_str_len("<stdin>", vstr_str(&line), vstr_len(&line), 0);
mp_parse_node_t pn = mp_parse(lex, MP_PARSE_SINGLE_INPUT);
mp_lexer_free(lex);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment