/
targets.mk
79 lines (55 loc) · 2.04 KB
/
targets.mk
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# APPPATH is the path to the application code, i.e. this directory
APPPATH=$(TOPDIR)/src/app/esp32
# APPLOADFILE is the top-level "Forth load file" for the application code.
APPLOADFILE = app.fth
# APPSRCS is a list of Forth source files that the application uses,
# i.e. the list of files that APPLOADFILE floads. It's for dependency checking.
APPSRCS = $(wildcard $(APPPATH)/*.fth)
# Makefile fragment for the final target application
SRC=$(TOPDIR)/src
# Target compiler definitions
CROSS ?= /Volumes/case-sensitive/esp-open-sdk/xtensa-lx106-elf/bin/xtensa-lx106-elf-
TCC=$(CROSS)gcc
TLD=$(CROSS)ld
TOBJDUMP=$(CROSS)objdump
TOBJCOPY=$(CROSS)objcopy
LIBDIRS=-L$(dir $(shell $(TCC) $(TCFLAGS) -print-libgcc-file-name))
VPATH += $(SRC)/cforth
VPATH += $(SRC)/lib
VPATH += $(APPPATH)
INCS += -I$(APPPATH)
include $(SRC)/common.mk
include $(SRC)/cforth/targets.mk
OPTIMIZE = -O2
TCFLAGS += \
-g \
-fno-inline-functions \
-nostdlib \
-mlongcalls \
-mtext-section-literals \
-DXTENSA
DUMPFLAGS = --disassemble -z -x -s
# Platform-specific object files for low-level startup and platform I/O
ttmain.o: vars.h
PLAT_OBJS += ttmain.o
PLAT_OBJS += tfileio.o
# Object files for the Forth system and application-specific extensions
FORTH_OBJS = tembed.o textend.o
# Recipe for linking the final image
DICTIONARY=ROM
DICTSIZE=0x4000
app.o: tdate.o
@echo Linking $@ ...
@$(TLD) -o $@ -r $(PLAT_OBJS) $(FORTH_OBJS) tdate.o
# This rule builds a date stamp object that you can include in the image
# if you wish.
tdate.o: $(PLAT_OBJS) $(FORTH_OBJS)
@(echo "`git rev-parse --verify --short HEAD``if git diff-index --exit-code --name-only HEAD >/dev/null; then echo '-dirty'; fi`" || echo UNKNOWN) >version
@echo 'const char version[] = "'`cat version`'";' >tdate.c
@echo 'const char build_date[] = "'`date --utc +%F\ %R`'";' >>tdate.c
@cat tdate.c
@echo TCC $@
@$(TCC) -c tdate.c -o $@
EXTRA_CLEAN += *.elf *.dump *.nm *.img date.c $(FORTH_OBJS) $(PLAT_OBJS) tdate.c version
PREFIX += CBP=$(realpath $(TOPDIR)/src)
include $(SRC)/cforth/embed/targets.mk