aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/contrib/pi_examples/label_image/Makefile
blob: 19652e581d2403cf8e4dbd7b9e10b7c386959069 (plain)
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
# This Makefile compiles the label_image example for the Raspberry Pi.
# See tensorflow/contrib/pi_examples/README.md for full build instructions.

# Find where we're running from, so we can store generated files here.
SCRIPT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))

# The location of the tensorflow/contrib/makefile directory.
TFMAKEFILE_DIR := $(SCRIPT_DIR)/../../makefile

# Where compiled objects are stored.
GENDIR := $(SCRIPT_DIR)/gen/
OBJDIR := $(GENDIR)obj/
LIBDIR := $(GENDIR)lib/
BINDIR := $(GENDIR)bin/

# The expected locations of the TensorFlow library.
TFLIBDIR := $(TFMAKEFILE_DIR)/gen/lib
TFLIBS := $(TFLIBDIR)/libtensorflow-core.a

# Where the downloads have been stored.
DOWNLOADSDIR := $(TFMAKEFILE_DIR)/downloads

# The location of the compiled protobuf headers generated by TensorFlow.
PBTGENDIR := $(TFMAKEFILE_DIR)/gen/proto_text/
PROTOGENDIR := $(TFMAKEFILE_DIR)/gen/proto/

# The name of the output program we're compiling.
EXECUTABLE_NAME := $(BINDIR)/label_image

# Settings for the target compiler.
CXX := gcc
OPTFLAGS := -O0
CXXFLAGS := --std=c++11 $(OPTFLAGS)
LDFLAGS := \
-L/usr/local/lib \
-L$(TFLIBDIR) \
-Wl,--no-whole-archive
INCLUDES := \
-I/usr/local/include \
-I. \
-I$(DOWNLOADSDIR) \
-I$(DOWNLOADSDIR)/eigen/ \
-I$(PROTOGENDIR) \
-I$(PBTGENDIR)
LIBS := \
-Wl,--allow-multiple-definition \
-Wl,--whole-archive \
-ltensorflow-core \
-Wl,--no-whole-archive \
-lstdc++ \
-lprotobuf \
-ldl \
-lpthread \
-lm \
-ljpeg \
-lz
LIBFLAGS :=

EXECUTABLE_SRCS := tensorflow/contrib/pi_examples/label_image/label_image.cc

# File names of the intermediate files target compilation generates.
EXECUTABLE_OBJS := $(addprefix $(OBJDIR), $(EXECUTABLE_SRCS:.cc=.o))

.PHONY: clean

# The target that's compiled if there's no command-line arguments.
all: $(EXECUTABLE_NAME)

# Rules for target compilation.

$(EXECUTABLE_NAME): $(EXECUTABLE_OBJS) $(TFLIBS)
	@mkdir -p $(dir $@)
	$(CXX) $(CXXFLAGS) $(INCLUDES) \
	-o $(EXECUTABLE_NAME) $(EXECUTABLE_OBJS) \
	$(LIBFLAGS) $(LIB_PATH) $(LDFLAGS) $(LIBS)

# Matches on C++ source files.
$(OBJDIR)%.o: %.cc 
	@mkdir -p $(dir $@)
	$(CXX) $(CXXFLAGS) $(INCLUDES) -c $< -o $@

# Gets rid of all generated files.
clean:
	rm -rf $(GENDIR)