-FLAGS = -O9 -I./libcds/includes/\r
-\r
-OBJECTS=libcds/lib/libcds.a\r
-\r
-all: text_collection XMLTree\r
-\r
-XMLTree: XMLTree.o bp.o darray.o bpcore.o libcds/lib/libcds.a\r
- cp libcds/lib/libcds.a XMLTree.a\r
- ar vrcs XMLTree.a XMLTree.o bp.o darray.o bpcore.o\r
-\r
-\r
-XMLTree.o: bp.c bp.h bpcore.c XMLTree.cpp XMLTree.h\r
- g++ $(FLAGS) -c XMLTree.cpp\r
-\r
-bp.o: bp.c bpcore.c darray.c bp.h darray.h\r
- g++ $(FLAGS) -c bp.c\r
-\r
-darray.o: darray.c darray.h bpcore.c\r
- g++ $(FLAGS) -c darray.c\r
-\r
-bpcore.o: bpcore.c\r
- g++ $(FLAGS) -c bpcore.c\r
-\r
-text_collection:\r
- make -C TextCollection/\r
-\r
-clean:\r
- rm -f *.o
\ No newline at end of file
+POPCOUNT=$(shell grep -q popcnt /proc/cpuinfo && echo 1)
+
+ifeq ($(POPCOUNT), 1)
+ POPCOUNT_FLAG=-DHAS_NATIVE_POPCOUNT
+else
+ POPCOUNT_FLAG=-DPOPCOUNT_TABLE
+endif
+
+ifeq ($(VERBOSE), true)
+ HIDE=
+else
+ HIDE=@
+endif
+
+ifeq ($(DEBUG), true)
+ OPT_FLAGS=-O0 -g $(POPCOUNT_FLAG) -fno-PIC -static
+else
+ OPT_FLAGS=-O4 $(POPCOUNT_FLAG) -fno-PIC -static
+endif
+
+
+
+INC_FLAGS=-I./libcds/includes/ -I.
+CFLAGS= $(INC_FLAGS) $(OPT_FLAGS)
+CXXFLAGS= -std=c++0x $(INC_FLAGS) $(OPT_FLAGS)
+CC=g++
+
+LIBCDS_A=libcds/lib/libcds.a
+OBJECTS_TCO= TextCollection/TextCollection.o \
+ TextCollection/TextCollectionBuilder.o \
+ TextCollection/RLCSABuilder.o \
+ TextCollection/FMIndex.o \
+ TextCollection/FMIndexBuilder.o \
+ TextCollection/Tools.o \
+ TextCollection/TextStorage.o \
+ TextCollection/Query.o \
+ TextCollection/EditDistance.o \
+ TextCollection/ResultSet.o
+
+OBJECTS_XMLTREE=XMLTree.o XMLTreeBuilder.o bp.o darray.o bpcore.o
+
+LIBRLCSA_TCA=TextCollection/incbwt/rlcsa.a
+LIBLZTRIE_TCA=TextCollection/lzindex/lztrie.a
+LIBSWCSA_TCA=TextCollection/swcsa/swcsa.a
+
+
+
+
+all: depend libcds text_collection XMLTree
+
+XMLTree: $(OBJECTS_XMLTREE) $(LIBCDS_A) $(OBJECTS_TCO) \
+ $(LIBRLCSA_TCA) $(LIBLZTRIE_TCA) $(LIBSWCSA_TCA)
+ @echo [XMLTree]
+ $(HIDE) cp libcds/lib/libcds.a libXMLTree.a
+ $(HIDE) rm -rf .objs
+ $(HIDE) mkdir .objs
+ $(HIDE) (cd .objs; ar x ../$(LIBRLCSA_TCA); ar x ../$(LIBLZTRIE_TCA); ar x ../$(LIBSWCSA_TCA))
+ $(HIDE) ar rcs libXMLTree.a $(OBJECTS_XMLTREE) $(OBJECTS_TCO) .objs/*.o
+ $(HIDE) rm -rf .objs
+
+%o: %c
+ @echo [C] $@
+ $(HIDE) $(CC) -c $(CFLAGS) $< -o $@
+
+%o: %cpp
+ @echo [C++] $@
+ $(HIDE) $(CC) -c $(CXXFLAGS) $< -o $@
+
+text_collection:
+ @echo [DEPENDENCY] $@
+ $(HIDE) make -s -C TextCollection/
+
+libcds:
+ @echo [DEPENDENCY] $@
+ $(HIDE) make -s -C libcds/
+
+depend:
+ @echo [DEPEND]
+ $(HIDE) (gcc -MM *.c; g++ -MM -std=c++0x *.cpp) > $@
+
+clean:
+ @echo [CLEAN]
+ $(HIDE) rm -f *.[oa] depend
+
+-include depend
+