-
Notifications
You must be signed in to change notification settings - Fork 85
/
Makefile
93 lines (71 loc) · 2.69 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
# this is licensed software, @see LICENSE file.
# OpenCV & Tensorflow recommended flags for performance..
CFLAGS = -fPIC -Ofast -march=native -fno-trapping-math -fassociative-math -funsafe-math-optimizations -Wall -pthread
LDFLAGS = -lrt -ldl
# Version
VERSION=$(shell git describe --all --long --always --dirty)
# default if outside a git repo..
ifeq ($(VERSION),)
VERSION=v0.2.0-no-git
endif
CFLAGS += -D DEEPSEG_VERSION=$(VERSION) -I.
# TensorFlow
TENSORFLOW=tensorflow
TFLITE=$(TENSORFLOW)/tensorflow/lite/tools/make
TFDOWN=$(TFLITE)/downloads/cpuinfo
TFLIBS=$(TFLITE)/gen/linux_x86_64/lib
TFCFLAGS += -I $(TENSORFLOW) -I $(TFLITE)/downloads/absl -I $(TFLITE)/downloads/flatbuffers/include -ggdb
TFLDFLAGS += -L $(TFLIBS) -ltensorflow-lite -ldl
# OpenCV
ifeq ($(shell pkg-config --exists opencv; echo $$?), 0)
CFLAGS += $(shell pkg-config --cflags opencv)
LDFLAGS += $(shell pkg-config --libs opencv)
else ifeq ($(shell pkg-config --exists opencv4; echo $$?), 0)
CFLAGS += $(shell pkg-config --cflags opencv4)
LDFLAGS += $(shell pkg-config --libs opencv4)
else
$(error Couldn\'t find OpenCV)
endif
# Output folder
BIN=bin
# Default target
all: $(BIN) $(BIN)/backscrub
clean:
-rm -rf $(BIN)
$(BIN):
-mkdir -p $(BIN)
# Primary binaries - special deps
$(BIN)/backscrub: app/deepseg.cc $(BIN)/libbackscrub.a $(BIN)/libvideoio.a $(TFLIBS)/libtensorflow-lite.a
g++ $^ ${CFLAGS} ${TFCFLAGS} ${LDFLAGS} ${TFLDFLAGS} -o $@
# Backscrub library, must be linked with libtensorflow-lite.a
$(BIN)/libbackscrub.a: $(BIN)/libbackscrub.o $(BIN)/transpose_conv_bias.o
ar rv $@ $^
# Video I/O library - this is a Linux/v4l2loopback only target for now but replaceable later..
$(BIN)/libvideoio.a: $(BIN)/loopback.o
ar rv $@ $^
# Compile rules for various source directories
$(BIN)/%.o: lib/%.cc $(TFDOWN)
g++ $< ${CFLAGS} ${TFCFLAGS} -c -o $@
$(BIN)/%.o: videoio/%.cc $(TFDOWN)
g++ $< ${CFLAGS} ${TFCFLAGS} -c -o $@
$(BIN)/%.o: app/%.cc $(TFDOWN)
g++ $< ${CFLAGS} ${TFCFLAGS} -c -o $@
# As cloned, TFLite needs building into a static library, as per:
# https://github.com/tensorflow/tensorflow/tree/master/tensorflow/lite/tools/make
# we split this into download (pre-compile) and build (pre-link)
$(TFDOWN): $(TFLITE)
cd $(TFLITE) && ./download_dependencies.sh
$(TFLIBS)/libtensorflow-lite.a: $(TFDOWN)
cd $(TFLITE) && ./build_lib.sh
$(TFLITE):
git submodule update --init --recursive
# Single file test progs - OpenCV deps only
$(BIN)/%: %.cc $(BIN)
g++ -o $@ $(CFLAGS) $< $(LDFLAGS)
$(BIN)/%: %.cpp $(BIN)
g++ -o $@ $(CFLAGS) $< $(LDFLAGS)
$(BIN)/%: %.c $(BIN)
g++ -o $@ $(CFLAGS) $< $(LDFLAGS)
# transparent video viewer helper tool
tv: attic/transparent_viewer.c
g++ -o $@ $^ -lX11 -lGL $(CFLAGS) $(LDFLAGS)