-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathMakefile
58 lines (45 loc) · 1.63 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
CC=cc
CXX=clang++
RM=rm -f
ifeq (, $(shell which $(CXX)))
$(info $(CXX) compiler not found, trying g++...)
CXX=g++
endif
ifeq (, $(shell which $(CXX)))
$(info $(CXX) compiler not found, trying c++...)
CXX=c++
endif
ifeq (, $(shell which $(CXX)))
$(error No compiler found)
endif
CPPFLAGS= -g -std=c++14 -DSIL -c -I src -I src/lib
LDFLAGS= -g
LDLIBS=
BUILDDIR = build
OBJDIR = $(BUILDDIR)/obj
FIRMWAREDIR = $(BUILDDIR)/stripped-firmware
EMPTY_FW_FILE = ./sample_firmware/empty.cc
CODEFILES = code0 code1 code2 code3 code4
SRCS= $(shell find src -type f -name '*.cc') $(addprefix $(FIRMWAREDIR)/,$(addsuffix .cc,$(CODEFILES)))
OBJS= $(addprefix $(OBJDIR)/, $(subst .cc,.o,$(SRCS)))
all: builddir $(CODEFILES) $(BUILDDIR)/sil $(BUILDDIR)/terminal
$(BUILDDIR)/sil: $(OBJS)
$(CXX) $(LDFLAGS) -o $(BUILDDIR)/sil $(OBJS) $(LDLIBS)
$(BUILDDIR)/terminal: tools/terminal.cc
$(CXX) -o $@ $<
$(OBJDIR)/%.o: %.cc
$(CXX) $(CPPFLAGS) -o $@ $<
# After the objdir so that those files won't be caught
code%: # Rebuilds every time because the codeN could change values
$(if $($@), \
@echo "================Processing $@ ($($@))=================" && python ./process_firmware.py $(FIRMWAREDIR) $@ $($@), \
@echo "================Using default file ($(EMPTY_FW_FILE)) for unset $@=================" && python ./process_firmware.py $(FIRMWAREDIR) $@ $(EMPTY_FW_FILE) \
)
@cmp --silent $(FIRMWAREDIR)/$@.cc $(FIRMWAREDIR)/$@.cc.new && echo "$@ unchanged..." || cp $(FIRMWAREDIR)/$@.cc.new $(FIRMWAREDIR)/$@.cc
builddir:
@mkdir -p $(BUILDDIR)
@mkdir -p $(OBJDIR)
@mkdir -p $(FIRMWAREDIR)
@$(foreach file,$(dir $(OBJS)),mkdir -p $(file);)
clean:
$(RM) -r $(BUILDDIR)