-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
75 lines (57 loc) · 1.57 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
prog=rdabl
.PHONY: default
default: all
srcdir=src
bindir=bin
incdir=inc
libdir=lib
cc=LD_LIBRARY_PATH=$(libdir) gcc
cflags=-I$(incdir) -Wall -g
txtdir=txt
prefix=/usr/local
$(txtdir)/sample_dic: $(txtdir)/cmudic
chmod +x $(srcdir)/parsecmu
cat $< | $(srcdir)/parsecmu > $@
lib = $(libdir)/lib$(prog).so
libsrc=$(srcdir)/table.c $(srcdir)/scan.c
exe=$(bindir)/$(prog)
tstexe=$(bindir)/test$(prog)
tstsrc=$(srcdir)/*test.c $(srcdir)/CuTest.c
all: $(exe)
all: $(tstexe)
$(txtdir)/cmudic:
mkdir -p $(txtdir)
wget http://svn.code.sf.net/p/cmusphinx/code/trunk/cmudict/cmudict-0.7b -O $@
$(lib): $(libsrc)
mkdir -p $(libdir)
$(cc) $(cflags) -o $@ $^ -shared -fPIC
$(exe): $(srcdir)/rdabl.c $(lib)
mkdir -p $(bindir)
$(cc) $(cflags) -L$(libdir) -o $@ $< -l$(prog)
$(srcdir)/sample_dic_test.c: $(txtdir)/sample_dic
xxd -i $< > $@
$(srcdir)/sample_test.c: $(txtdir)/sample.txt
xxd -i $< | sed s/txt_sample_txt/sample_txt/g > $@
$(tstexe): $(tstsrc) $(srcdir)/sample_dic_test.c $(srcdir)/sample_test.c
$(cc) $(cflags) -L$(libdir) -o $@ $^ -l$(prog)
.PHONY: install
install:
cp $(lib) $(prefix)/lib
cp $(exe) $(prefix)/bin
.PHONY: uninstall
uninstall:
rm $(prefix)/lib/lib$(prog).so
rm $(prefix)/bin/$(prog)
.PHONY: clean
clean:
rm -rf $(bindir) $(incdir) $(libdir) $(srcdir) $(txtdir) Makefile *.LICENSE
.PHONY: leaks
leaks:
valgrind --track-origins=yes ./$(bindir)/$(prog) \
-d $(txtdir)/sample_dic $(txtdir)/sample.txt
.PHONY: check
check: $(tstexe)
./$(tstexe)
.PHONY: demo
demo: $(exe)
@LD_LIBRARY_PATH=$(libdir) ./$(exe) -d $(txtdir)/sample_dic $(txtdir)/sample.txt