Create branch library-split
[SXSI/XMLTree.git] / Makefile
1 POPCOUNT=$(shell grep -q popcnt /proc/cpuinfo && echo 1)
2
3 ifeq ($(POPCOUNT), 1)
4         POPCOUNT_FLAG=-DHAS_NATIVE_POPCOUNT
5 else
6         POPCOUNT_FLAG=-DPOPCOUNT_TABLE
7 endif
8
9 ifeq ($(VERBOSE), true)
10         HIDE=
11 else
12         HIDE=@
13 endif
14
15 ifeq ($(DEBUG), true)
16         OPT_FLAGS=-O0 -g $(POPCOUNT_FLAG) -fno-PIC -static
17 else
18         OPT_FLAGS=-O4 $(POPCOUNT_FLAG) -fno-PIC -static
19 endif
20
21
22
23 INC_FLAGS=-I./libcds/includes/ -I.
24 CFLAGS= $(INC_FLAGS) $(OPT_FLAGS)
25 CXXFLAGS= -std=c++0x $(INC_FLAGS) $(OPT_FLAGS)
26 CC=g++
27
28 LIBCDS_A=libcds/lib/libcds.a
29 OBJECTS_TCO= TextCollection/TextCollection.o \
30              TextCollection/TextCollectionBuilder.o \
31              TextCollection/RLCSABuilder.o \
32              TextCollection/FMIndex.o \
33              TextCollection/FMIndexBuilder.o \
34              TextCollection/Tools.o \
35              TextCollection/TextStorage.o \
36              TextCollection/Query.o \
37              TextCollection/EditDistance.o \
38              TextCollection/ResultSet.o
39
40 OBJECTS_XMLTREE=XMLTree.o XMLTreeBuilder.o bp.o darray.o bpcore.o
41
42 LIBRLCSA_TCA=TextCollection/incbwt/rlcsa.a
43 LIBLZTRIE_TCA=TextCollection/lzindex/lztrie.a
44 LIBSWCSA_TCA=TextCollection/swcsa/swcsa.a
45
46
47
48
49 all: depend libcds text_collection XMLTree
50
51 XMLTree: $(OBJECTS_XMLTREE) $(LIBCDS_A) $(OBJECTS_TCO) \
52          $(LIBRLCSA_TCA) $(LIBLZTRIE_TCA) $(LIBSWCSA_TCA)
53         @echo [XMLTree]
54         $(HIDE) cp libcds/lib/libcds.a libXMLTree.a
55         $(HIDE) rm -rf .objs
56         $(HIDE) mkdir .objs
57         $(HIDE) (cd .objs; ar x ../$(LIBRLCSA_TCA); ar x ../$(LIBLZTRIE_TCA); ar x ../$(LIBSWCSA_TCA))
58         $(HIDE) ar rcs libXMLTree.a $(OBJECTS_XMLTREE) $(OBJECTS_TCO) .objs/*.o
59         $(HIDE) rm -rf .objs
60
61 %o: %c
62         @echo [C] $@
63         $(HIDE) $(CC) -c $(CFLAGS) $< -o $@
64
65 %o: %cpp
66         @echo [C++] $@
67         $(HIDE) $(CC) -c $(CXXFLAGS)  $< -o $@
68
69 text_collection:
70         @echo [DEPENDENCY] $@
71         $(HIDE) make -s -C TextCollection/
72
73 libcds:
74         @echo [DEPENDENCY] $@
75         $(HIDE) make -s -C libcds/
76
77 depend:
78         @echo [DEPEND]
79         $(HIDE) (gcc -MM *.c; g++ -MM -std=c++0x *.cpp) > $@
80
81 clean:
82         @echo [CLEAN]
83         $(HIDE) rm -f *.[oa] depend
84
85 -include depend
86