Makefile 2.5 KB
Newer Older
1 2 3 4 5 6
# This file is part of the MicroPython port to LEON platforms
# Copyright (c) 2015-2016 George Robotics Limited
#
# Provided to the European Space Agency as part of the project "Porting of
# MicroPython to LEON platforms", contract number 4000114080/15/NL/FE/as.
#
7
# This Makefile builds an example of a LEON port with multiple tasks.
8

9
# the location of the MicroPython LEON support code
10 11 12 13 14 15 16 17 18 19 20
LEON_COMMON = leon-common
LEON_COMMON_FROM_HERE = ../$(LEON_COMMON)

include ../py/mkenv.mk

# qstr definitions (must come before including py.mk)
QSTR_DEFS = $(LEON_COMMON_FROM_HERE)/qstrdefsport.h

# include py core make definitions
include ../py/py.mk

21 22
# include LEON common makefile settings
include $(LEON_COMMON_FROM_HERE)/mkenv.mk
23 24 25 26 27 28 29

INC =
INC += -I. -I.. -I$(BUILD) -I$(LEON_COMMON_FROM_HERE)

CFLAGS += $(INC) -Wall -Werror -ansi -std=gnu99 $(COPT) -mcpu=v8

# Use this to optimise the static hash tables
30
#CFLAGS += -no-integrated-cpp -B$(shell pwd)/../tools
31 32 33 34 35 36 37 38

# Debugging/Optimization
ifeq ($(DEBUG), 1)
CFLAGS += -O0 -ggdb
else
CFLAGS += -Os -DNDEBUG
endif

39
LIBS += -lm
40 41 42 43

SRC_C = \
	main.c \
	lib/libc/string0.c \
44
	$(LEON_COMMON)/sparcisr.c \
45
	$(LEON_COMMON)/leonprintf.c \
46 47 48 49 50 51
	$(LEON_COMMON)/mputil.c \
	$(LEON_COMMON)/mphalport.c \
	$(LEON_COMMON)/modtime.c \
	$(LEON_COMMON)/modrtems.c \
	$(LEON_COMMON)/modrtemstask.c \
	$(LEON_COMMON)/modrtemsqueue.c \
52
	$(LEON_COMMON)/modrtemssem.c \
53
	$(LEON_COMMON)/modmem.c \
54 55

SRC_S = \
56
	$(LEON_COMMON)/sparcjmp.s \
57 58 59 60 61 62
	$(LEON_COMMON)/gchelper.s \

# these are the example Python scripts to compile
# they are executed in separate tasks
SRC_PY = ex1.py ex2.py ex3.py ex4.py

63
OBJ = $(PY_O) $(addprefix $(BUILD)/, $(SRC_C:.c=.o) $(SRC_S:.s=.o) $(SRC_RTEMS:.c=.o))
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84

all: $(BUILD)/firmware.elf $(BUILD)/firmware.srec $(BUILD)/firmware.tab $(BUILD)/scripts.srec

run: $(BUILD)/firmware.srec $(BUILD)/firmware.tab $(BUILD)/scripts.srec
	$(Q)cat cmd.txt | leon2-emu

$(BUILD)/firmware.elf: $(OBJ)
	$(ECHO) "LINK $@"
	$(Q)$(LD) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
	$(Q)$(SIZE) $@

$(BUILD)/firmware.srec: $(BUILD)/firmware.elf
	$(ECHO) "SREC $@"
	$(Q)$(OBJCOPY) -O srec $< $@

$(BUILD)/firmware.tab: $(BUILD)/firmware.elf
	$(ECHO) "TAB $@"
	$(Q)$(OBJDUMP) --syms $< > $@   

$(BUILD)/%.mpy: %.py
	$(ECHO) "PY $<"
85
	$(Q)../mpy-cross/mpy-cross -o $@ $<
86 87 88 89 90 91 92 93 94 95

$(BUILD)/scripts.srec: $(addprefix $(BUILD)/, $(SRC_PY:.py=.mpy))
	$(ECHO) "MPY $@"
	$(Q)../tools/mpytool.py tosrec \
	    0x40100000 $(BUILD)/ex1.mpy \
	    0x40110000 $(BUILD)/ex2.mpy \
	    0x40120000 $(BUILD)/ex3.mpy \
	    0x40130000 $(BUILD)/ex4.mpy > $@

include ../py/mkrules.mk