-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile
More file actions
101 lines (77 loc) · 2.78 KB
/
makefile
File metadata and controls
101 lines (77 loc) · 2.78 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#*************************************************************************************************/
#*-------------------------------------------PROLOGUE--------------------------------------------*/
#*
#* Makefile: For Bouy Bot
#*
#*************************************************************************************************/
#*-------------------------------------------INCLUDES--------------------------------------------*/
#*************************************************************************************************/
#*------------------------------------------VARIABLES--------------------------------------------*/
#Compiler defines
CCpp = arm-linux-gnueabihf-g++
CLEAN := rm -rf
#Location for created files
OBJ_DIR = ./DEBUG/obj
#Create the output directories in case they don't exist
$(shell mkdir -p $(OBJ_DIR))
#Libraries and Paths
LIB_PATHS =
LIBS = -lpthread
#Set the Warnings level
WARNINGS = -Wall
#-MMD: Create a .d file and strip away all the directory information
#-MP: Create phony header files in case one has been removed and the makefile doesn't match yet
CPP_FLAGS = -static $(INC_PATHS) $(WARNINGS) -O0 -g3 -std=c++11 -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)"
#Set include paths and files
INC_PATHS = -I./inc -I./external_libs
BUILD_NAME = ROBO
#Get the source cpp files listed for building
SRC_CPP = \
src/BusDevice.cpp \
src/distance.cpp \
src/I2CDevice.cpp \
src/main.cpp \
src/orientation.cpp \
src/drive.cpp \
src/pid.cpp \
src/test.cpp \
src/input_thread.cpp
SRC_C = \
external_libs/bme280.c \
src/bme280_stubs.c
OBJ_C := $(patsubst %.c, %.o, $(SRC_C))
DEP_C := $(patsubst %.c, %.d, $(SRC_C))
OBJ_CPP := $(patsubst %.cpp, %.o, $(SRC_CPP))
DEP_CPP := $(patsubst %.cpp, %.d, $(SRC_CPP))
#Now we add the two together to simplify
OBJ_CPP += $(OBJ_C)
DEP_C += $(DEP_C)
#List where the object files should be placed/ are placed
OBJ_LOCATION := $(patsubst %.o, $(OBJ_DIR)/%.o, $(notdir $(OBJ_CPP)))
DEPENDENCIES := $(patsubst %.cpp, $(OBJ_DIR)/%.d, $(notdir $(SRC_CPP)))
#Tell make where to look for source files
vpath %.cpp ./src/
vpath %.c ./external_libs/ \
./src/
all:
$(MAKE) $(BUILD_NAME)
#Build the executable
$(BUILD_NAME): $(OBJ_LOCATION)
@echo 'Building: $@'
$(CCpp) -static $(LIB_PATHS) -o "DEBUG/$(BUILD_NAME)" $(OBJ_LOCATION) $(LIBS)
@echo 'Finished Building $@'
#Build the cpp sources
$(OBJ_DIR)/%.o: %.cpp
@echo 'Building: $@'
$(CCpp) $(CPP_FLAGS) -Dcpp -c $< -o $(OBJ_DIR)/$(notdir $@)
@echo 'Finished Building $@'
#Build the c sources
$(OBJ_DIR)/%.o: %.c
@echo 'Building: $@'
$(CCpp) $(CPP_FLAGS) -Dcpp -c $< -o $(OBJ_DIR)/$(notdir $@)
@echo 'Finished Building $@'
clean:
-$(CLEAN) $(OBJ_LOCATION) $(DEPENDENCIES) DEBUG/$(BUILD_NAME)
run:
$(OBJ_DIR)/$(BUILD_NAME).exe
-include $(DEPENDENCIES)