common.mk
1.84 KB
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
80
OUTDIR = Output
EMMOCO-ROOT = /Applications/Development/Em-Builder-IDE/eclipse/emmoco
EMBUILDER ?=
SCHEMAFILE = $(APPNAME).ems
MAIN = $(APPNAME)-Prog
BINFILE = $(OUTDIR)/$(MAIN).bin
HEXFILE = $(OUTDIR)/$(MAIN).hex
OUTFILE = $(OUTDIR)/$(MAIN).out
OBJECTS = $(OUTDIR)/$(MAIN).obj $(OUTDIR)/$(APPNAME).obj $(OUTDIR)/Hal.obj
CC = $(TOOLS)/$(GCCARCH)-gcc
LD = $(TOOLS)/$(GCCARCH)-ld
OBJCOPY = $(TOOLS)/$(GCCARCH)-objcopy
SIZE = $(TOOLS)/$(GCCARCH)-size
CFLAGS = -std=gnu99 -O2 -w -ffunction-sections -fdata-sections -fpack-struct=1 -fno-strict-aliasing -fomit-frame-pointer -c -g -I$(PLATFORM)/Hal -IEm $(COPTS)
load: out-check
$(EXEC)
build: $(OUTDIR) out-remove $(OUTFILE)
$(OUTDIR):
ifeq (,$(findstring Windows,$(OS)))
mkdir $(OUTDIR)
else
cmd /c mkdir $(OUTDIR)
endif
$(OUTDIR)/$(MAIN).obj: $(MAIN).c Em/$(APPNAME).c
$(CC) $< -o $@ $(CFLAGS)
$(OUTDIR)/$(APPNAME).obj: Em/$(APPNAME).c
$(CC) $< -o $@ $(CFLAGS)
$(OUTDIR)/Hal.obj: $(PLATFORM)/Hal/Hal.c
$(CC) $< -o $@ $(CFLAGS)
Em/$(APPNAME).c: $(SCHEMAFILE)
ifneq (,$(EMBUILDER))
$(EMBUILDER) -v --root=$(<D) --outdir=Em --jsondir=Em $<
else
@echo terminating because of prior schema errors 1>&2
@exit 1
endif
local-clean:
ifeq (,$(findstring Windows,$(OS)))
rm -rf $(OUTDIR)
else
ifneq (,$(wildcard $(OUTDIR)))
cmd /c rmdir /q /s $(subst /,\,$(OUTDIR))
endif
endif
clean: local-clean
ifeq (,$(findstring Windows,$(OS)))
rm -rf $(EM)
else
ifneq (,$(wildcard Em))
cmd /c rmdir /q /s $(subst /,\,Em)
endif
endif
out-check:
ifeq (,$(wildcard $(OUTFILE)))
@echo error: $(OUTFILE): No such file or directory 1>&2
@exit 1
endif
out-remove:
ifeq (,$(findstring Windows,$(OS)))
rm -f $(OUTFILE)
else
ifneq (,$(wildcard $(OUTFILE)))
cmd /c del /q $(subst /,\,$(OUTFILE))
endif
endif
.PHONY: all load clean local-clean out-check