-
Notifications
You must be signed in to change notification settings - Fork 116
/
Makefile.msys2
79 lines (61 loc) · 2.52 KB
/
Makefile.msys2
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
# Try static build ?
# STATIC_BUILD=1
# For dcnn build, caffe msys2 package is probably in the repos now.
# Otherwise get one from https://github.com/lemonsqueeze/mingw-caffe
# ('mini' / 'nohdf5' releases allow for smaller static builds)
WIN_HAVE_NO_REGEX_SUPPORT=1
COMMON_FLAGS += $(TUNE)
LDFLAGS := -pthread -L$(CAFFE_PREFIX)/bin -L$(MINGW_PREFIX)/bin
LIBS := -lws2_32 -lshlwapi
CXXFLAGS += -I$(MINGW_PREFIX)/include/OpenBLAS
# Enable mingw-w64 C99 printf() / scanf() layer ?
COMMON_FLAGS += -D__USE_MINGW_ANSI_STDIO
ifdef WIN_HAVE_NO_REGEX_SUPPORT
COMMON_FLAGS += -DHAVE_NO_REGEX_SUPPORT
else
LIBS += -lregex -ltre -lintl -liconv # Oh, dear...
endif
DCNN_LIBS := -lcaffe -lopenblas -lboost_system-mt -lglog -lstdc++ $(LIBS)
ifdef STATIC_BUILD # Static build, good luck
# 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)
CAFFE=normal
ifeq ($(CAFFE), normal)
HDF5_LIBS = -lhdf5_hl -lhdf5 -lszip -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
DCNN_LIBS := -Wl,-Bstatic $(CAFFE_STATIC_LIB) \
-lboost_system-mt -lboost_thread-mt -lopenblas $(HDF5_LIBS) -lgflags_static \
-lglog -lprotobuf -lstdc++ -lwinpthread -lws2_32 -Wl,-Bdynamic -lshlwapi
# glog / gflags headers really shouldn't __declspec(dllexport) symbols for us,
# static linking will fail with undefined __imp__xxx symbols.
# Normally this works around it.
CXXFLAGS += -DGOOGLE_GLOG_DLL_DECL="" -DGFLAGS_DLL_DECL=""
endif
strip: FORCE
cd distribute && strip pachi.exe
@echo "packing exe ..."
@cd distribute && upx -o p.exe pachi.exe && mv p.exe pachi.exe
ifndef MSYS2_STATIC
@echo "copying dlls ..."
@cd distribute; \
mingw=`echo $$MINGW_PREFIX | tr '/' '.' `; \
dlls_list="../$${mingw}_dlls"; \
cp `cat $$dlls_list` .
endif
#####################################################################################
# Extra rules for static linking
ifdef STATIC_BUILD
# caffe static link: pull layer_factory.o from libcaffe.a
layer_factory.o: $(MINGW_PREFIX)/lib/libcaffe.a
@echo "[AR] $@"
@ar x $< $@
endif