-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathMakefile
81 lines (59 loc) · 1.89 KB
/
Makefile
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
include build-cfg.mk
OUTDIR = $(shell pwd)/build/out_$(PLATFORM)$(VARIANT)
OBJDIR = $(shell pwd)/build/tmp_$(PLATFORM)$(VARIANT)
BUILDOPTFILE = $(shell pwd)/build/buildopt_$(PLATFORM)$(VARIANT)
BUILDVERSION := $(shell git describe --tags)
MAINFLAGS := -DPLATFORM=\"${PLATFORM}\" -Wall -Wextra -pedantic-errors -fdiagnostics-show-option -Wno-unknown-pragmas -DBUILD_VERSION=\"${BUILDVERSION}\"
ifneq (, ${DEBUG})
MAINFLAGS += -g -rdynamic -DDEBUG
endif
ifneq (, ${DEBUG_SERVER})
MAINFLAGS += -DDEBUG_SERVER
endif
include vendor/${PLATFORM}/toolchain.mk
MODULES := CommandInterface Config Log Seismometer Utils galileo-core
ifeq (${PLATFORM}, raspi)
NOWATCHDOG=y
endif
ifneq (, ${NOWATCHDOG})
MAINFLAGS += -DNOWATCHDOG
else
MODULES += Watchdog
endif
STOREDFLAGS := $(shell cat ${BUILDOPTFILE} 2>/dev/null)
SOURCES := $(MODULES:%=%.cpp)
OBJECTS := $(MODULES:%=${OBJDIR}/%.o)
ci: all
ifeq (${STOREDFLAGS}, ${MAINFLAGS})
all: createdir vendor net ${OUTDIR}/sketch.elf
else
all: clean createdir vendor net ${OUTDIR}/sketch.elf
endif
ifeq (, ${REMOTEHOST})
upload: all
$(error No REMOTEHOST specified)
else
upload: all
scp $(OUTDIR)/sketch.elf root@${REMOTEHOST}:/sketch/sketch.new
ssh root@${REMOTEHOST} "killall sketch.elf; mv /sketch/sketch.new /sketch/sketch.elf && reboot"
endif
createdir:
mkdir -p $(OBJDIR)
mkdir -p $(OUTDIR)
echo -n '${MAINFLAGS}' > $(BUILDOPTFILE)
vendor::
net::
include net/Makefile
include vendor/${PLATFORM}/Makefile
${OBJDIR}/%.o: %.cpp
$(CPP) $(CPPFLAGS) ${MAINFLAGS} -c -o $@ $<
ifeq (, ${DEBUG})
${OUTDIR}/sketch.elf: $(OBJECTS) $(NET_OBJECTS) $(VENDOR_OBJECTS)
${CPP} ${OBJDIR}/*.o ${LFLAGS} ${MAINFLAGS} -o ${OUTDIR}/sketch.elf
${STRIP} ${OUTDIR}/sketch.elf
else
${OUTDIR}/sketch.elf: $(OBJECTS) $(NET_OBJECTS) $(VENDOR_OBJECTS)
${CPP} ${OBJDIR}/*.o ${LFLAGS} ${MAINFLAGS} -o ${OUTDIR}/sketch.elf
endif
clean:
rm -f ${OUTDIR}/* ${OBJDIR}/* $(BUILDOPTFILE)