Add some directory structure
Change-Id: I052849c6aff9fd0f311984de67c35a306735c9a9
diff --git a/Makefile b/Makefile
index b7f49f1..51e2646 100644
--- a/Makefile
+++ b/Makefile
@@ -9,7 +9,7 @@
PLATFORM=OS_LINUX
PLATFORM_LDFLAGS= -L$(INSTALL_PATH)/lib -Wl,-rpath=$(INSTALL_PATH)/lib -lpthread -lrt -lsnappy -lz -lbz2 -llz4 -lzstd
-CXXFLAGS = -Wall -Wno-reorder -I/usr/local/include -g -std=c++11 -Ofast
+CXXFLAGS = -Wall -Wno-reorder -I/usr/local/include -g -std=c++11
CFLAGS = -Wall -I/usr/local/rocksdb -I$(INSTALL_PATH)/include -g -std=gnu99 -O2
ARFLAGS = ${EXTRA_ARFLAGS} rs
@@ -17,64 +17,75 @@
ifneq ($(USE_RTTI), 1)
CXXFLAGS += -fno-rtti
endif
-LIB_SOURCES = collocatordb.cc
+SOURCE_DIR := src
+BUILD_DIR := build
+BIN_DIR := bin
+LIB_DIR := lib
+LIB_SOURCES = src/collocatordb.cc
-LIBOBJECTS = $(LIB_SOURCES:.cc=.o)
+LIB_OBJECTS := $(subst $(SOURCE_DIR),$(BUILD_DIR),$(LIB_SOURCES:.cc=.o))
.PHONY: static_lib shared_lib install-static install-shared
-all: static_lib shared_lib dumpllr c_testcdb
+all: static_lib shared_lib
install: install-static install-shared
-hello_world: hello_world.c collocatordb.h collocatordb.o Makefile
- $(CC) $(CFLAGS) -L. -L$(INSTALL_PATH)/lib $@.c -o$@ collocatordb.o --std=gnu99 -lstdc++ -lm $(PLATFORM_LDFLAGS) $(PLATFORM_CCFLAGS) $(EXEC_LDFLAGS) -lrocksdb
+bin/hello_world: examples/hello_world.c src/collocatordb.h build/collocatordb.o Makefile
+ mkdir -p bin
+ $(CC) $(CFLAGS) -L. -L$(INSTALL_PATH)/lib examples/hello_world.c -o$@ build/collocatordb.o --std=gnu99 -lstdc++ -lm $(PLATFORM_LDFLAGS) $(PLATFORM_CCFLAGS) $(EXEC_LDFLAGS) -lrocksdb
-testcdb: testcdb.cc collocatordb.h collocatordb.o Makefile
- $(CXX) $(CXXFLAGS) -L. -L$(INSTALL_PATH)/lib $@.cc -o$@ collocatordb.o -lrocksdb $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS)
+bin/testcdb: src/testcdb.cc src/collocatordb.h build/collocatordb.o Makefile
+ $(CXX) $(CXXFLAGS) -L. -L$(INSTALL_PATH)/lib $@.cc -o$@ build/collocatordb.o -lrocksdb $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS)
-dumpllr: dumpllr.cc collocatordb.h collocatordb.o Makefile
- $(CXX) $(CXXFLAGS) -L. -L$(INSTALL_PATH)/lib $@.cc -fopenmp -o$@ collocatordb.o $(INSTALL_PATH)/lib/librocksdb.a $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS)
+bin/dumpllr: examples/dumpllr.cc src/collocatordb.h build/collocatordb.o Makefile
+ $(CXX) $(CXXFLAGS) -L. -L$(INSTALL_PATH)/lib $@.cc -fopenmp -o$@ build/collocatordb.o $(INSTALL_PATH)/lib/librocksdb.a $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS)
-dumppmicubed: dumppmicubed.cc collocatordb.h collocatordb.o Makefile
- $(CXX) $(CXXFLAGS) -L. -L$(INSTALL_PATH)/lib $@.cc -fopenmp -o$@ collocatordb.o -lrocksdb $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS)
+bin/dumppmicubed: examples/dumppmicubed.cc src/collocatordb.h build/collocatordb.o Makefile
+ $(CXX) $(CXXFLAGS) -L. -L$(INSTALL_PATH)/lib $@.cc -fopenmp -o$@ build/collocatordb.o -lrocksdb $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS)
-dumpldafdiff: dumpldafdiff.cc collocatordb.h collocatordb.o Makefile
- $(CXX) $(CXXFLAGS) -D_GLIBCXX_PARALLEL -L. -L$(INSTALL_PATH)/lib $@.cc -fopenmp -o$@ collocatordb.o /vol/work/kupietz/rocksdb/librocksdb.a $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS)
+bin/dumpldafdiff: dumpldafdiff.cc src/collocatordb.h build/collocatordb.o Makefile
+ $(CXX) $(CXXFLAGS) -D_GLIBCXX_PARALLEL -L. -L$(INSTALL_PATH)/lib $@.cc -fopenmp -o$@ build/collocatordb.o /vol/work/kupietz/rocksdb/librocksdb.a $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS)
-c_testcdb: c_testcdb.c collocatordb.h collocatordb.o Makefile
- $(CC) $(CFLAGS) -L. -L$(INSTALL_PATH)/lib $@.c -o$@ collocatordb.o -std=gnu99 -lstdc++ -lm -lrocksdb $(PLATFORM_LDFLAGS) $(PLATFORM_CCFLAGS) $(EXEC_LDFLAGS)
+bin/c_testcdb: examples/c_testcdb.c src/collocatordb.h build/collocatordb.o Makefile
+ $(CC) $(CFLAGS) -L. -L$(INSTALL_PATH)/lib $@.c -o$@ build/collocatordb.o -std=gnu99 -lstdc++ -lm -lrocksdb $(PLATFORM_LDFLAGS) $(PLATFORM_CCFLAGS) $(EXEC_LDFLAGS)
-collocatordb: collocatordb.cc Makefile
+bin/collocatordb: src/collocatordb.cc Makefile
$(CXX) $(CXXFLAGS) -L$(INSTALL_PATH)/lib $@.cc -o$@ -lrocksdb $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS)
-static_lib: libcollocatordb.a
+static_lib: lib/libcollocatordb.a
-shared_lib: libcollocatordb.so.$(COLLOCATDB_MAJOR).$(COLLOCATDB_MINOR)
+shared_lib: lib/libcollocatordb.so.$(COLLOCATDB_MAJOR).$(COLLOCATDB_MINOR)
-libcollocatordb.a: $(LIBOBJECTS)
+lib/libcollocatordb.a: $(LIB_OBJECTS)
+ mkdir -p lib
$(AM_V_AR)rm -f $@
- $(AM_V_at)$(AR) $(ARFLAGS) $@ $(LIBOBJECTS)
+ $(AM_V_at)$(AR) $(ARFLAGS) $@ $(LIB_OBJECTS)
-libcollocatordb.so.$(COLLOCATDB_MAJOR).$(COLLOCATDB_MINOR): collocatordb.cc
- $(CXX) $(CXXFLAGS) -Wall -D_GLIBCXX_PARALLEL -fopenmp -c collocatordb.cc -Wl,-soname=libcollocatordb.so.1 -Wl,--version-script=collocatordb.exmap -shared -fPIC -o libcollocatordb.so.$(COLLOCATDB_MAJOR).$(COLLOCATDB_MINOR)
+lib/libcollocatordb.so.$(COLLOCATDB_MAJOR).$(COLLOCATDB_MINOR): $(LIB_SOURCES)
+ $(CXX) $(CXXFLAGS) -Wall -D_GLIBCXX_PARALLEL -fopenmp -c $< -Wl,-soname=libcollocatordb.so.1 -Wl,--version-script=collocatordb.exmap -shared -fPIC -o $@
+
+build/collocatordb.o : src/collocatordb.cc
+ mkdir -p build
+ $(CXX) $(CXXFLAGS) -c $< -o$@ $(PLATFORM_CXXFLAGS)
.cc.o:
$(CXX) $(CXXFLAGS) -c $< -o$@ $(PLATFORM_CXXFLAGS)
-install-static: libcollocatordb.a collocatordb.h
+install-static: lib/libcollocatordb.a src/collocatordb.h
install -d $(INSTALL_PATH)/include && \
install -d $(INSTALL_PATH)/lib && \
- install -t $(INSTALL_PATH)/include -D -C -m 644 collocatordb.h $ && \
- install -t $(INSTALL_PATH)/lib -C -D -m 755 libcollocatordb.a
+ install -t $(INSTALL_PATH)/include -D -C -m 644 src/collocatordb.h $ && \
+ install -t $(INSTALL_PATH)/lib -C -D -m 755 lib/libcollocatordb.a
-install-shared: libcollocatordb.so.$(COLLOCATDB_MAJOR).$(COLLOCATDB_MINOR) collocatordb.h
+install-shared: lib/libcollocatordb.so.$(COLLOCATDB_MAJOR).$(COLLOCATDB_MINOR) src/collocatordb.h
install -d $(INSTALL_PATH)/include && \
install -d $(INSTALL_PATH)/lib && \
- install -Dt $(INSTALL_PATH)/include -C -m 644 collocatordb.h && \
- install -Dt $(INSTALL_PATH)/lib -C -m 755 libcollocatordb.so.$(COLLOCATDB_MAJOR).$(COLLOCATDB_MINOR) && \
+ install -Dt $(INSTALL_PATH)/include -C -m 644 src/collocatordb.h && \
+ install -Dt $(INSTALL_PATH)/lib -C -m 755 lib/libcollocatordb.so.$(COLLOCATDB_MAJOR).$(COLLOCATDB_MINOR) && \
ln -fs $(INSTALL_PATH)/lib/libcollocatordb.so.$(COLLOCATDB_MAJOR).$(COLLOCATDB_MINOR) $(INSTALL_PATH)/lib/libcollocatordb.so.$(COLLOCATDB_MAJOR) && \
ln -fs $(INSTALL_PATH)/lib/libcollocatordb.so.$(COLLOCATDB_MAJOR) $(INSTALL_PATH)/lib/libcollocatordb.so
clean:
+ rm -rf $(LIB_DIR) $(BUILD_DIR) $(BIN_DIR)
rm -f *.so* *.a *.o c_testcdb collocatordb dumpldafdiff dumppmicubed dumpllr testcdb hello_world
diff --git a/c_testcdb.c b/examples/c_testcdb.c
similarity index 89%
rename from c_testcdb.c
rename to examples/c_testcdb.c
index 5a86cc8..b143ccd 100644
--- a/c_testcdb.c
+++ b/examples/c_testcdb.c
@@ -1,7 +1,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
-#include "collocatordb.h"
+#include "../src/collocatordb.h"
int main() {
COLLOCATORDB *cdb = open_collocatordb_for_write("/tmp/test.rocksdb");
diff --git a/dumpllr.cc b/examples/dumpllr.cc
similarity index 96%
rename from dumpllr.cc
rename to examples/dumpllr.cc
index 00158a5..69a9389 100644
--- a/dumpllr.cc
+++ b/examples/dumpllr.cc
@@ -3,7 +3,7 @@
#include <memory>
#include <iostream>
#include <stdint.h>
-#include "collocatordb.h"
+#include "../src/collocatordb.h"
#include <thread>
#include <chrono>
#include <sstream> // for ostringstream
diff --git a/dumppmicubed.cc b/examples/dumppmicubed.cc
similarity index 96%
rename from dumppmicubed.cc
rename to examples/dumppmicubed.cc
index 33f5314..8c3bf56 100644
--- a/dumppmicubed.cc
+++ b/examples/dumppmicubed.cc
@@ -3,7 +3,7 @@
#include <memory>
#include <iostream>
#include <stdint.h>
-#include "collocatordb.h"
+#include "../src/collocatordb.h"
#include <thread>
#include <chrono>
#include <sstream> // for ostringstream
diff --git a/hello_world.c b/examples/hello_world.c
similarity index 95%
rename from hello_world.c
rename to examples/hello_world.c
index 74aed60..fb4c5d1 100644
--- a/hello_world.c
+++ b/examples/hello_world.c
@@ -2,7 +2,7 @@
#include <stdlib.h>
#include <string.h>
#include <math.h>
-#include "collocatordb.h"
+#include "../src/collocatordb.h"
char dbpath[] = "../models/dereko-2021-i";
const int testword = 431; // Grund
diff --git a/testcdb.cc b/examples/testcdb.cc
similarity index 97%
rename from testcdb.cc
rename to examples/testcdb.cc
index 08da83f..64e9304 100644
--- a/testcdb.cc
+++ b/examples/testcdb.cc
@@ -3,7 +3,7 @@
#include <memory>
#include <iostream>
#include <stdint.h>
-#include "collocatordb.h"
+#include "../src/collocatordb.h"
using namespace rocksdb;
void dumpDb(Collocators& counters) {
diff --git a/ccdbknn.py b/extras/ccdbknn.py
similarity index 100%
rename from ccdbknn.py
rename to extras/ccdbknn.py
diff --git a/collocatordb.cc b/src/collocatordb.cc
similarity index 100%
rename from collocatordb.cc
rename to src/collocatordb.cc
diff --git a/collocatordb.h b/src/collocatordb.h
similarity index 100%
rename from collocatordb.h
rename to src/collocatordb.h
diff --git a/merge_operators.h b/src/merge_operators.h
similarity index 100%
rename from merge_operators.h
rename to src/merge_operators.h