-
Notifications
You must be signed in to change notification settings - Fork 116
/
Copy pathMakefile.linux
76 lines (56 loc) · 2.1 KB
/
Makefile.linux
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
# Static build ?
# STATIC_BUILD=1
# If static build fails on ubuntu / debian try this.
# UBUNTU_STATIC=1
COMMON_FLAGS += $(TUNE)
LDFLAGS := -pthread -rdynamic
LIBS := -lm -lrt -ldl
DCNN_LIBS := -lcaffe -lopenblas -lboost_system -lglog -lstdc++ $(LIBS)
ifdef STATIC_BUILD
# Which type of caffe package do you have ?
# Regular caffe package is fine but pulls in hdf5 (+deps) which we don't need
# and requires --whole-archive for static linking. This makes binaries unnecessarily
# bloated. Choose normal, nohdf5, or mini (mini is best)
# mini source: https://github.com/lemonsqueeze/caffe/tree/mini
CAFFE=normal
ifeq ($(CAFFE), normal)
HDF5_LIBS = -lhdf5_serial_hl -lhdf5_serial -lsz -laec -lz
endif
ifeq ($(CAFFE), mini)
# Force linking of caffe layer factory, will pull in layers we need.
EXTRA_DCNN_OBJS := layer_factory.o
CAFFE_STATIC_LIB = -lcaffe
else
CAFFE_STATIC_LIB = -Wl,--whole-archive -l:libcaffe.a -Wl,--no-whole-archive
endif
ifdef UBUNTU_STATIC
LIBS += libunwind.a -llzma
EXTRA_DEPS += libunwind.a
endif
LDFLAGS := -pthread -static
DCNN_LIBS := $(CAFFE_STATIC_LIB) -lglog -lgflags -lprotobuf -lboost_system -lboost_thread -lopenblas $(HDF5_LIBS) -lstdc++ $(LIBS)
endif
strip: FORCE
cd distribute && strip pachi
#####################################################################################
# Extra rules for static linking
ifdef STATIC_BUILD
# caffe static link: pull layer_factory.o from libcaffe.a
layer_factory.o: $(CAFFE_PREFIX)/lib/libcaffe.a
@echo "[AR] $@"
@ar x $< $@
endif
ifdef UBUNTU_STATIC
LIBUNWIND_OBJS = SetGR.o GetIPInfo.o SetIP.o GetLanguageSpecificData.o GetRegionStart.o \
GetDataRelBase.o GetTextRelBase.o RaiseException.o Resume.o Resume_or_Rethrow.o \
DeleteException.o
# Ubuntu libunwind madness ...
libunwind.a:
-@ rm -rf libunwind.a libunwind 2>/dev/null
-@ mkdir libunwind
@ echo "[AR] libunwind.a"
@ cd libunwind; \
ar x /usr/lib/*-linux-gnu/libunwind.a; \
rm $(LIBUNWIND_OBJS); \
ar cr ../libunwind.a *.o
endif