-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
120 lines (92 loc) · 2.37 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
# define VERBOSE to see executed commands
TARGET=hyped
MAIN=main.cpp
SRCS_DIR:=src
LIBS_DIR:=lib
OBJS_DIR:=bin
CFLAGS:=-pthread -std=c++11 -O2 -Wall -Wno-unused-result
LFLAGS:=-lpthread -pthread
# default configuration
CROSS=0
NOLINT=0
PROTOBUF=0
ifeq ($(CROSS), 0)
CC:=g++
UNAME=$(shell uname)
ifneq ($(UNAME),Linux)
# assume Windows
UNAME='Windows'
CFLAGS:=$(CFLAGS) -DWIN
endif
ARCH=$(shell uname -m)
ifneq (,$(findstring 64,$(ARCH)))
CFLAGS:=$(CFLAGS) -DARCH_64
endif
else
CC:=hyped-cross-g++
CFLAGS:=$(CFLAGS) -DARCH_32
LFLAGS:= $(LFLAGS) -static
$(info cross-compiling)
endif
# test if compiler is installed
ifeq ($(shell which $(CC)), )
$(error compiler $(CC) is not installed)
endif
LL:=$(CC)
include $(SRCS_DIR)/Source.files
ifeq ($(PROTOBUF), 1)
CFLAGS:=$(CFLAGS) $(shell pkg-config --cflags protobuf)
LFLAGS:=$(LFLAGS) $(shell pkg-config --libs protobuf)
SRCS:=$(SRCS) $(shell find src/telemetry -type f -name '*.cpp' | sed 's|^src/||')
endif
SRCS := $(SRCS) $(MAIN)
OBJS := $(SRCS:.cpp=.o)
SRCS := $(patsubst %,$(SRCS_DIR)/%,$(SRCS))
OBJS := $(patsubst %,$(OBJS_DIR)/%,$(OBJS))
DEP_DIR := $(OBJS_DIR)
DEPFLAGS = -MT $@ -MMD -MP -MF $(DEP_DIR)/$*.d
INC_DIR := -I$(SRCS_DIR) -I$(LIBS_DIR)/eigen-git-mirror
# run "make VERBOSE=1" to see all commands
ifndef VERBOSE
Verb := @
endif
Echo := $(Verb)echo
default: lint $(TARGET)
$(TARGET): $(OBJS)
$(Echo) "Linking executable $(MAIN) into $@"
$(Verb) $(LL) -o $@ $(OBJS) $(LFLAGS)
$(OBJS): $(OBJS_DIR)/%.o: $(SRCS_DIR)/%.cpp
$(Echo) "Compiling $<"
$(Verb) mkdir -p $(dir $@)
$(Verb) $(CC) $(DEPFLAGS) $(CFLAGS) -o $@ -c $(INC_DIR) $<
lint:
ifeq ($(NOLINT), 0)
$(Verb) python2.7 utils/Lint/presubmit.py
endif
clean: cleanlint
$(Verb) rm -rf $(OBJS_DIR)/*
$(Verb) rm -f $(TARGET)
$(Verb) rm -f $(MAINS)
$(Verb) find src | xargs touch
$(Verb) touch Makefile
cleanlint:
$(Verb) rm -f .cpplint-cache
define echo_var
@echo $(1) = $($1)
endef
.PHONY: doc
doc:
$(Verb) doxygen Doxyfile
protoc:
-$(Verb) mkdir -p src/telemetry/telemetrydata
$(Verb) protoc -I=src/telemetry --cpp_out=src/telemetry/telemetrydata message.proto
$(Verb) mv src/telemetry/telemetrydata/message.pb.cc src/telemetry/telemetrydata/message.pb.cpp
info:
$(call echo_var,CC)
$(call echo_var,TOP)
# $(call echo_var,SRCS)
$(call echo_var,OBJS)
# $(call echo_var,MAINS)
$(call echo_var,UNAME)
$(call echo_var,CFLAGS)
-include $(OBJS:.o=.d)