Fixed mods to 644 again
[svmtool++.git] / Makefile
blob74dbecbde7c948f0789082d780469f6341cd52bb
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 = $(shell find src -maxdepth 1 -name "*.cc")
19 INCLUDE_DIR = include
21 SHARED_OBJS = $(SOURCES:.cc=.shared.o)
22 STATIC_OBJS = $(SOURCES:.cc=.static.o)
24 CFLAGS= -O2 -g -std=c++0x -Wall -Wno-unused-parameter -Werror
25 EXTRA_CFLAGS=-I$(INCLUDE_DIR)
26 STATIC_CFLAGS= $(CFLAGS) $(EXTRA_CFLAGS)
27 SHARED_CFLAGS= $(STATIC_CFLAGS) -fPIC
29 LDFLAGS= -Wl,-z,defs -Wl,--as-needed -Wl,--no-undefined
30 EXTRA_LDFLAGS=
31 LIBS=
33 $(LIBRARY).so.$(MAJOR).$(MINOR): $(SHARED_OBJS)
34 g++ $(LDFLAGS) $(EXTRA_LDFLAGS) -shared \
35 -Wl,-soname,$(LIBRARY).so.$(MAJOR) \
36 -o $(LIBRARY).so.$(MAJOR).$(MINOR) \
37 $+ -o $@ $(LIBS)
39 $(LIBRARY).so: $(LIBRARY).so.$(MAJOR).$(MINOR)
40 rm -f $@.$(MAJOR)
41 ln -s $@.$(MAJOR).$(MINOR) $@.$(MAJOR)
42 rm -f $@
43 ln -s $@.$(MAJOR) $@
45 $(LIBRARY).a: $(STATIC_OBJS)
46 ar cru $@ $+
48 %.shared.o: %.cpp
49 g++ -o $@ -c $+ $(SHARED_CFLAGS)
51 %.shared.o: %.cc
52 g++ -o $@ -c $+ $(SHARED_CFLAGS)
54 %.shared.o: %.c
55 gcc -o $@ -c $+ $(SHARED_CFLAGS)
57 %.so : %.o
58 g++ $(LDFLAGS) $(EXTRA_LDFLAGS) -shared $^ -o $@
60 %.static.o: %.cpp
61 g++ -o $@ -c $+ $(STATIC_CFLAGS)
63 %.static.o: %.cc
64 g++ -o $@ -c $+ $(STATIC_CFLAGS)
66 %.static.o: %.c
67 gcc -o $@ -c $+ $(STATIC_CFLAGS)
69 S: $(SOURCES:.cc=.S) src/bin/SVMTeval.S src/bin/SVMTlearn.S src/bin/SVMTagger.S
71 %.S: %.cpp
72 g++ -Wall -O0 -o $@ -S $+ $(EXTRA_CFLAGS)
74 %.S: %.cc
75 g++ -Wall -O0 -o $@ -S $+ $(EXTRA_CFLAGS)
77 %.S: %.c
78 gcc -Wall -O0 -o $@ -S $+ $(EXTRA_CFLAGS)
80 clean:
81 rm -fv $(SHARED_OBJS)
82 rm -fv $(STATIC_OBJS)
83 rm -fv $(FIXED_OBJS)
84 rm -fv $(STATIC_FIXED_OBJS)
85 rm -fv $(PROGRAMS)
86 rm -fv *.so *.so* *.a src/*.o src/bin/*.o src/*.S src/bin/*.S *~
88 DESTDIR=
90 install: $(LIBRARY).a $(LIBRARY).so
91 mkdir -p "$(DESTDIR)/usr/lib/"
92 cp -a *.a "$(DESTDIR)/usr/lib/"
93 cp -a *.so* "$(DESTDIR)/usr/lib/"
94 mkdir -p "$(DESTDIR)/usr/include/"
96 find $(INCLUDE_DIR) -name "*.h" | \
97 while read f; do \
98 t=`echo "$$f" | sed -e 's|^$(INCLUDE_DIR)/|/usr/include/%PACKAGE%/|'` ; \
99 d=`dirname "$$t"`; \
100 mkdir -p "$(DESTDIR)/$$d" ; \
101 cp "$$f" "$(DESTDIR)/$$t"; \
102 done