Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
136 lines (113 loc) · 7.5 KB
/
Copy pathMakefile
File metadata and controls
136 lines (113 loc) · 7.5 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#Linux Recon Makefile
#Author: Bryan Poling
#Copyright (c) 2020 Sentek Systems, LLC. All rights reserved.
CC = gcc
#CC = g++
#CC = clang++-3.5
#Build Type: Acceptable values are Debug and Release
BUILD_TYPE = Release
ifeq ($(BUILD_TYPE),Release)
OPTFLAGS = -O3 -march=broadwell -fopenmp
DEBUGFLAGS =
else
OPTFLAGS = -O0 -march=core2 -fopenmp
DEBUGFLAGS = -g
endif
# **************************************************** LibTorch Flags ***************************************************
# The LibTorch pre-built folder should be unpacked to the same directory that contains the Recon folder
LIBTORCH_FOLDERNAME = libtorch-cxx11-abi-shared-with-deps-1.8.1+cpu
LIBTORCH_LINKFLAGS = -ltorch -ltorch_cpu -lc10
#LIBTORCH_FOLDERNAME = libtorch-cxx11-abi-shared-with-deps-latest
#LIBTORCH_LINKFLAGS = -ltorch -ltorch_cuda -ltorch_cpu -lc10 -lc10_cuda
# **************************************************** Include Paths ****************************************************
RECON_INCLUDE_FLAGS1 = -I.. -I../eigen -I../Flexible-Raster-Format -I../imgui -I../restclient-cpp/include -I../cereal/include
RECON_INCLUDE_FLAGS2 = `pkg-config --cflags freetype2 libcurl gtk+-3.0 python3` -I../glfw/include -I../imgui/examples/libs/gl3w -I../nativefiledialog/src/include
RECON_INCLUDE_FLAGS3 = -I../$(LIBTORCH_FOLDERNAME)/libtorch/include/
RECON_INCLUDE_FLAGS4 = -I../$(LIBTORCH_FOLDERNAME)/libtorch/include/torch/csrc/api/include/ -I../serial/include -I../tacopie/includes
RECON_INCLUDE_FLAGS5 = -I../soloud/include
RECON_INCLUDE_FLAGS = $(RECON_INCLUDE_FLAGS1) $(RECON_INCLUDE_FLAGS2) $(RECON_INCLUDE_FLAGS3) $(RECON_INCLUDE_FLAGS4) $(RECON_INCLUDE_FLAGS5)
# **************************** Set C++ Standard, profiling and linker trim flags and Defines ****************************
STANDARDFLAGS = -std=c++17
PROFILEFLAGS =
# PROFILEFLAGS = -pg
LINKER_TRIM_FLAGS = -Wl,-no-undefined -Wl,--no-as-needed
#LINKER_TRIM_FLAGS = -Wl,--gc-sections -Wl,--strip-all
DEFINE_FLAGS = -DGSL_USE_STD_BYTE -DLOADGLFWICON -DIMGUIAPP_USE_FAS -DWITH_ALSA
# ****************************************** Combine all Compile and Link Flags *****************************************
COMPILE_WARNING_FLAGS = -Wall -Wno-unused-variable -Wno-unused-but-set-variable -Wno-unused-function -Wno-strict-aliasing \
-Wno-ignored-attributes -Wno-misleading-indentation
COMPILE_DEPGEN_FLAGS = -MT $@ -MMD -MP -MF DEP/$(*F).d
ELF_FLAGS = -fdata-sections -ffunction-sections
COMPILE_FLAGS = -c -fdiagnostics-color=auto -pthread $(COMPILE_WARNING_FLAGS) $(RECON_INCLUDE_FLAGS) $(COMPILE_DEPGEN_FLAGS) \
$(DEBUGFLAGS) $(PROFILEFLAGS) $(LINKER_TRIM_FLAGS) $(DEFINE_FLAGS) $(STANDARDFLAGS) $(OPTFLAGS) $(ELF_FLAGS) `pkg-config --cflags opencv4`
LINK_FLAGS = -fdiagnostics-color=auto -static-libstdc++ -static-libgcc -lstdc++ -lstdc++fs -Wl,-Bdynamic -lpthread -lm -ldl -luuid -fopenmp \
`pkg-config --static --libs freetype2 libcurl gtk+-3.0 python3` ../glfw/Release/src/libglfw3.a `pkg-config --libs opencv4` \
-lGL -lGLEW -lGLU ../tacopie/build/lib/libtacopie.a -lasound -L../$(LIBTORCH_FOLDERNAME)/libtorch/lib/ $(LIBTORCH_LINKFLAGS) \
'-Wl,-rpath,$$ORIGIN/../../$(LIBTORCH_FOLDERNAME)/libtorch/lib'
# ********************************************** Populate Source File Lists *********************************************
#Populate source files that are part of Recon project
RECON_SRCFILES = $(wildcard SRC/*.cpp) $(wildcard SRC/UI/*.cpp) $(wildcard SRC/Maps/*.cpp) $(wildcard SRC/Modules/DJI-Drone-Interface/*.cpp) \
$(wildcard SRC/Modules/Guidance/*.cpp) $(wildcard SRC/Modules/Shadow-Detection/*.cpp) $(wildcard SRC/Modules/Shadow-Propagation/*.cpp) \
$(wildcard SRC/Modules/GNSS-Receiver/*.cpp) $(wildcard SRC/Modules/Coverage-planning/Navigation/*.cpp)
#Build list of additional (external) source files.
EXTERNAL_SRCFILES = ../restclient-cpp/source/connection.cc \
../restclient-cpp/source/helpers.cc \
../restclient-cpp/source/restclient.cc \
../imgui/imgui_widgets.cpp \
../imgui/imgui_draw.cpp \
../imgui/imgui_demo.cpp \
../imgui/imgui.cpp \
../imgui/misc/cpp/imgui_stdlib.cpp \
../imgui/misc/freetype/imgui_freetype.cpp \
../imgui/examples/imgui_impl_glfw.cpp \
../imgui/examples/imgui_impl_opengl3.cpp \
../imgui/examples/libs/gl3w/GL/gl3w.c \
../imgui/app/ImGuiApp.cpp \
../imgui/app/imconfig.cpp \
../imgui/app/main_GL.cpp \
../nativefiledialog/src/nfd_common.c \
../nativefiledialog/src/nfd_gtk.c \
../Flexible-Raster-Format/FRF.cpp \
../handycpp/Handy.cpp \
../serial/src/serial.cc \
../serial/src/impl/unix.cc \
../implot/implot.cpp \
../implot/implot_items.cpp \
$(wildcard ../soloud/src/core/*.cpp) \
$(wildcard ../soloud/src/backend/alsa/*.cpp) \
$(wildcard ../soloud/src/audiosource/wav/*.cpp) \
$(wildcard ../soloud/src/audiosource/wav/*.c)
# ********************************************** Populate Object File Lists *********************************************
RECON_OBJFILES = $(patsubst SRC/%.cpp,OBJ/%.o,$(RECON_SRCFILES))
EXTERNAL_OBJFILES = $(addprefix OBJ/External/,$(addsuffix .o,$(basename $(notdir $(EXTERNAL_SRCFILES)))))
OBJFILES = $(RECON_OBJFILES) $(EXTERNAL_OBJFILES)
# ***************************************************** Build Rules *****************************************************
#Top-level rule (default build rule)
all: recon
recon: folders $(OBJFILES)
$(CC) -Wall $(DEBUGFLAGS) $(PROFILEFLAGS) $(LINKER_TRIM_FLAGS) -L/usr/local/lib -o BIN/Recon $(OBJFILES) $(LINK_FLAGS)
#Reproduce the folder structure of SRC in OBJ and create an External sub-directory for external object files
folders:
@mkdir -p DEP
@mkdir -p OBJ/External
@find SRC/ -type d -printf '%P\n' | sed 's/^/OBJ\//' | xargs mkdir -p
#Object file build rules
$(RECON_OBJFILES):
@echo ""
@echo "\033[1;34mCompiling file: \033[0m" $(shell echo $(RECON_SRCFILES) | grep -Eo '\<$(basename $(patsubst OBJ/%,SRC/%,$@))\.[^[:space:]]*|[[:space:]]$(basename $(patsubst OBJ/%,SRC/%,$@))\.[^[:space:]]*')
@echo "\033[1;34mTarget Object: \033[0m" $@
$(CC) $(COMPILE_FLAGS) -o $@ $(shell echo $(RECON_SRCFILES) | grep -Eo '\<$(basename $(patsubst OBJ/%,SRC/%,$@))\.[^[:space:]]*|[[:space:]]$(basename $(patsubst OBJ/%,SRC/%,$@))\.[^[:space:]]*')
$(EXTERNAL_OBJFILES):
@echo ""
@echo "\033[1;34mCompiling file: \033[0m" $(shell echo $(EXTERNAL_SRCFILES) | grep -Eo '\<$(*F)\.[^[:space:]]*|[[:space:]]$(*F)\.[^[:space:]]*|[^[:space:]]*/$(*F)\.[^[:space:]]*')
@echo "\033[1;34mTarget Object: \033[0m" $@
$(CC) $(COMPILE_FLAGS) -o $@ $(shell echo $(EXTERNAL_SRCFILES) | grep -Eo '\<$(*F)\.[^[:space:]]*|[[:space:]]$(*F)\.[^[:space:]]*|[^[:space:]]*/$(*F)\.[^[:space:]]*')
#Clean build rule *************************************************************************************
clean:
/bin/rm -f -r OBJ/*
/bin/rm -f DEP/*.d
/bin/rm -f BIN/Recon
#Dependency file include directive ********************************************************************
-include DEP/*.d
#Variable inspection rule: make print-VAR
print-% : ; @echo $* = $($*)