Reordered files
[svmtool++.git] / Makefile
blob199e8fade65edd40fb66b3d6d728912912ebd721
1 LIBRARY=libsvmtool++
2 PROGRAMS=SVMTeval SVMTlearn SVMTagger
4 all: $(LIBRARY).a $(LIBRARY).so $(PROGRAMS)
6 SVMTeval: src/bin/SVMTeval.static.o $(LIBRARY).a $(LIBRARY).so
7 g++ $(LDFLAGS) $(EXTRA_LDFLAGS) $< -o $@ -L. -lsvmtool++ $(LIBS)
9 SVMTlearn: src/bin/SVMTlearn.static.o $(LIBRARY).a $(LIBRARY).so
10 g++ $(LDFLAGS) $(EXTRA_LDFLAGS) $< -o $@ -L. -lsvmtool++ $(LIBS)
12 SVMTagger: src/bin/SVMTagger.static.o $(LIBRARY).a $(LIBRARY).so
13 g++ $(LDFLAGS) $(EXTRA_LDFLAGS) $< -o $@ -L. -lsvmtool++ $(LIBS)
15 MAJOR=0
16 MINOR=0
18 SOURCES = src/learner.cc \
19 src/tagger.cc \
20 src/swindow.cc \
21 src/mapping.cc \
22 src/dict.cc \
23 src/list.cc \
24 src/weight.cc \
25 src/hash.cc \
26 src/stack.cc \
27 src/er.cc \
28 src/common.cc
30 INCLUDE_DIR = include
32 SHARED_OBJS = $(SOURCES:.cc=.shared.o)
33 STATIC_OBJS = $(SOURCES:.cc=.static.o)
35 EXTRA_CFLAGS=-I$(INCLUDE_DIR)
36 STATIC_CFLAGS= -O2 -g -ansi -Wall -Wno-unused-parameter $(EXTRA_CFLAGS)
37 SHARED_CFLAGS= $(STATIC_CFLAGS) -fPIC
39 LDFLAGS= -Wl,-z,defs -Wl,--as-needed -Wl,--no-undefined
40 EXTRA_LDFLAGS=
41 LIBS=
43 $(LIBRARY).so.$(MAJOR).$(MINOR): $(SHARED_OBJS)
44 g++ $(LDFLAGS) $(EXTRA_LDFLAGS) -shared \
45 -Wl,-soname,$(LIBRARY).so.$(MAJOR) \
46 -o $(LIBRARY).so.$(MAJOR).$(MINOR) \
47 $+ -o $@ $(LIBS)
49 $(LIBRARY).so: $(LIBRARY).so.$(MAJOR).$(MINOR)
50 rm -f $@.$(MAJOR)
51 ln -s $@.$(MAJOR).$(MINOR) $@.$(MAJOR)
52 rm -f $@
53 ln -s $@.$(MAJOR) $@
55 $(LIBRARY).a: $(STATIC_OBJS)
56 ar cru $@ $+
58 %.shared.o: %.cpp
59 g++ -o $@ -c $+ $(SHARED_CFLAGS)
61 %.shared.o: %.cc
62 g++ -o $@ -c $+ $(SHARED_CFLAGS)
64 %.shared.o: %.c
65 gcc -o $@ -c $+ $(SHARED_CFLAGS)
67 %.so : %.o
68 g++ $(LDFLAGS) $(EXTRA_LDFLAGS) -shared $^ -o $@
70 %.static.o: %.cpp
71 g++ -o $@ -c $+ $(STATIC_CFLAGS)
73 %.static.o: %.cc
74 g++ -o $@ -c $+ $(STATIC_CFLAGS)
76 %.static.o: %.c
77 gcc -o $@ -c $+ $(STATIC_CFLAGS)
79 S: $(SOURCES:.cc=.S) src/bin/SVMTeval.S src/bin/SVMTlearn.S src/bin/SVMTagger.S
81 %.S: %.cpp
82 g++ -Wall -O0 -o $@ -S $+ $(EXTRA_CFLAGS)
84 %.S: %.cc
85 g++ -Wall -O0 -o $@ -S $+ $(EXTRA_CFLAGS)
87 %.S: %.c
88 gcc -Wall -O0 -o $@ -S $+ $(EXTRA_CFLAGS)
90 clean:
91 rm -fv $(SHARED_OBJS)
92 rm -fv $(STATIC_OBJS)
93 rm -fv $(FIXED_OBJS)
94 rm -fv $(STATIC_FIXED_OBJS)
95 rm -fv $(PROGRAMS)
96 rm -fv *.so *.so* *.a src/*.o src/bin/*.o src/*.S src/bin/*.S *~
98 DESTDIR=
100 install: $(LIBRARY).a $(LIBRARY).so
101 mkdir -p "$(DESTDIR)/usr/lib/"
102 cp -a *.a "$(DESTDIR)/usr/lib/"
103 cp -a *.so* "$(DESTDIR)/usr/lib/"
104 mkdir -p "$(DESTDIR)/usr/include/"
106 find $(INCLUDE_DIR) -name "*.h" | \
107 while read f; do \
108 t=`echo "$$f" | sed -e 's|^$(INCLUDE_DIR)/|/usr/include/%PACKAGE%/|'` ; \
109 d=`dirname "$$t"`; \
110 mkdir -p "$(DESTDIR)/$$d" ; \
111 cp "$$f" "$(DESTDIR)/$$t"; \
112 done