aboutsummaryrefslogtreecommitdiffstats
path: root/micropython/Makefile
blob: c1f560560592bf12c4b8d93a5d461d57d31d90dc (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
PYS		:=
BOOTPY		:= boot.py
MAINPY		:= main.py
MAINPYDIR	:=
GSDS		:=
CONFS		:=

SRCDIR		:=
BUILDDIR	:=

MARCH		:= xtensawin
MPYCROSS_OPTS	:= -O0
GSDPARSER_OPTS	:= --dump-strip --dump-notext --dump-noextuserprmdata

MPYCROSS	:= mpy-cross
GSDPARSER	:= $(SRCDIR)/gsdparser
MKDIR		:= mkdir
CP		:= cp
RM		:= rm

_MPYS		= $(sort $(patsubst %.py,$(2)/%.mpy,$(1)))
_GSDMPYS	= $(sort $(patsubst %.gsd,$(2)/%_gsd.mpy,$(1)))
_GSDPYS		= $(sort $(patsubst %.gsd,$(2)/%_gsd.py,$(1)))
_CONFS		= $(sort $(patsubst %.conf,$(2)/%.conf,$(1)))
_MPYCROSS	= $(MPYCROSS) "$(1)" -s "$(2)" -march="$(MARCH)" $(MPYCROSS_OPTS) -o "$(3)"

all: $(call _MPYS,$(PYS),$(BUILDDIR)) \
     $(call _GSDMPYS,$(GSDS),$(BUILDDIR)) \
     $(call _CONFS,$(CONFS),$(BUILDDIR)) \
     $(BUILDDIR)/$(BOOTPY) \
     $(BUILDDIR)/$(MAINPY)

$(BUILDDIR)/%.mpy: %.py
	@$(MKDIR) -p "$(dir $@)"
	$(call _MPYCROSS,$<,$(shell basename "$<"),$@)

$(BUILDDIR)/%_gsd.mpy: %.gsd
	@$(MKDIR) -p "$(dir $@)"
	$(GSDPARSER) -D $(GSDPARSER_OPTS) -o "$(call _GSDPYS,$<,$(BUILDDIR))" "$<"
	$(call _MPYCROSS,$(call _GSDPYS,$<,$(BUILDDIR)),$(shell basename "$(call _GSDPYS,$<,$(BUILDDIR))"),$@)
	$(RM) "$(call _GSDPYS,$<,$(BUILDDIR))"

$(BUILDDIR)/%.conf: %.conf
	@$(MKDIR) -p "$(dir $@)"
	$(CP) "$<" "$@"

$(BUILDDIR)/$(BOOTPY) $(BUILDDIR)/$(MAINPY): $(BUILDDIR)/%.py: $(MAINPYDIR)/%.py
	@$(MKDIR) -p "$(dir $@)"
	$(CP) "$<" "$@"

clean:
	$(RM) -rf $(BUILDDIR)

.PHONY: all clean
bues.ch cgit interface