Repository navigation
Expand file tree
/
Copy pathdefault_rules.mk
More file actions
101 lines (86 loc) · 2.97 KB
/
Copy pathdefault_rules.mk
File metadata and controls
101 lines (86 loc) · 2.97 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
ifeq ($(KALDI_FLAVOR), dynamic)
ifeq ($(shell uname), Darwin)
XLDLIBS := $(LDLIBS)
ifdef LIBNAME
LIBFILE = lib$(LIBNAME).dylib
#LDLIBS += -l$(LIBNAME)
endif
LDFLAGS += -L$(KALDILIBDIR) -Wl,-rpath -Wl,$(KALDILIBDIR)
XDEPENDS = $(foreach dep,$(ADDLIBS), $(dir $(dep))/lib$(notdir $(basename $(dep))).dylib )
XLDLIBS += $(foreach dep,$(ADDLIBS), -l$(notdir $(basename $(dep))) )
else
ifeq ($(shell uname), Linux)
ifdef LIBNAME
LIBFILE = lib$(LIBNAME).so
#LDLIBS += -l$(LIBNAME)
endif
LDFLAGS += -Wl,-rpath=$(shell readlink -f $(KALDILIBDIR)) -L.
LDFLAGS += $(foreach dep,$(ADDLIBS), -L$(dir $(dep)) )
XDEPENDS = $(foreach dep,$(ADDLIBS), $(dir $(dep))/lib$(notdir $(basename $(dep))).so )
else # Platform not supported
$(error Dynamic libraries not supported on this platform. Run configure with --static flag. )
endif
endif
LDLIBS += $(foreach dep,$(ADDLIBS), -l$(notdir $(basename $(dep))) )
else
ifdef LIBNAME
LIBFILE = $(LIBNAME).a
endif
XDEPENDS = $(ADDLIBS)
endif
all: $(LIBFILE) $(BINFILES)
$(LIBFILE): $(OBJFILES)
$(AR) -cru $(LIBNAME).a $(OBJFILES)
$(RANLIB) $(LIBNAME).a
ifeq ($(KALDI_FLAVOR), dynamic)
ifeq ($(shell uname), Darwin)
$(CXX) -dynamiclib -o $@ -install_name @rpath/$@ -framework Accelerate $(LDFLAGS) $(XLDLIBS) $(OBJFILES) $(LDLIBS)
rm -f $(KALDILIBDIR)/$@; ln -s $(shell pwd)/$@ $(KALDILIBDIR)/$@
else
ifeq ($(shell uname), Linux)
# Building shared library from static (static was compiled with -fPIC)
$(CXX) -shared -o $@ -Wl,--no-undefined -Wl,--as-needed -Wl,-soname=$@,--whole-archive $(LIBNAME).a -Wl,--no-whole-archive $(LDFLAGS) $(XDEPENDS) $(LDLIBS)
rm -f $(KALDILIBDIR)/$@; ln -s $(shell pwd)/$@ $(KALDILIBDIR)/$@
#cp $@ $(KALDILIBDIR)
else # Platform not supported
$(error Dynamic libraries not supported on this platform. Run configure with --static flag. )
endif
endif
endif
$(BINFILES): $(LIBFILE) $(XDEPENDS)
# Rule below would expand to, e.g.:
# ../base/kaldi-base.a:
# make -c ../base kaldi-base.a
# -c option to make is same as changing directory.
%.a:
$(MAKE) -C ${@D} ${@F}
%.so:
$(MAKE) -C ${@D} ${@F}
clean:
-rm -f *.o *.a *.so $(TESTFILES) $(BINFILES) $(TESTOUTPUTS) tmp* *.tmp *.testlog
$(TESTFILES): $(LIBFILE) $(XDEPENDS)
test_compile: $(TESTFILES)
test: test_compile
@{ result=0; \
for x in $(TESTFILES); do \
printf "Running $$x ..."; \
./$$x >$$x.testlog 2>&1; \
if [ $$? -ne 0 ]; then \
echo "... FAIL $$x"; \
result=1; \
if [ -n "$TRAVIS" ] && [ -f core ] && command -v gdb >/dev/null 2>&1; then \
gdb $$x core -ex "thread apply all bt" -batch >>$$x.testlog 2>&1; \
rm -rf core; \
fi; \
else \
echo "... SUCCESS"; \
rm -f $$x.testlog; \
fi; \
done; \
exit $$result; }
.valgrind: $(BINFILES) $(TESTFILES)
depend:
-$(CXX) -M $(CXXFLAGS) *.cc > .depend.mk
# removing automatic making of "depend" as it's quite slow.
#.depend.mk: depend
-include .depend.mk