Marc Kupietz | ad33204 | 2021-03-13 18:05:14 +0100 | [diff] [blame] | 1 | COLLOCATDB_MAJOR=1 |
| 2 | COLLOCATDB_MINOR=2 |
| 3 | COLLOCATDB_PATCH=0 |
| 4 | |
| 5 | INSTALL_PATH ?= /usr/local |
| 6 | |
Marc Kupietz | 28cc53e | 2017-12-23 17:24:55 +0100 | [diff] [blame] | 7 | PLATFORM_CCFLAGS= -DROCKSDB_PLATFORM_POSIX -DROCKSDB_LIB_IO_POSIX -DOS_LINUX -fno-builtin-memcmp -DROCKSDB_FALLOCATE_PRESENT -DSNAPPY -DGFLAGS=1 -DZLIB -DBZIP2 -DLZ4 -DZSTD -DROCKSDB_MALLOC_USABLE_SIZE -DROCKSDB_PTHREAD_ADAPTIVE_MUTEX -DROCKSDB_BACKTRACE -DROCKSDB_RANGESYNC_PRESENT -DROCKSDB_SCHED_GETCPU_PRESENT -march=native -DROCKSDB_SUPPORT_THREAD_LOCAL |
| 8 | PLATFORM_CXXFLAGS=-std=c++11 -DROCKSDB_PLATFORM_POSIX -DROCKSDB_LIB_IO_POSIX -DOS_LINUX -fno-builtin-memcmp -DROCKSDB_FALLOCATE_PRESENT -DSNAPPY -DGFLAGS=1 -DZLIB -DBZIP2 -DLZ4 -DZSTD -DROCKSDB_MALLOC_USABLE_SIZE -DROCKSDB_PTHREAD_ADAPTIVE_MUTEX -DROCKSDB_BACKTRACE -DROCKSDB_RANGESYNC_PRESENT -DROCKSDB_SCHED_GETCPU_PRESENT -march=native -DROCKSDB_SUPPORT_THREAD_LOCAL |
| 9 | PLATFORM=OS_LINUX |
Marc Kupietz | ad33204 | 2021-03-13 18:05:14 +0100 | [diff] [blame] | 10 | PLATFORM_LDFLAGS= -L$(INSTALL_PATH)/lib -Wl,-rpath=$(INSTALL_PATH)/lib -lpthread -lrt -lsnappy -lz -lbz2 -llz4 -lzstd |
Marc Kupietz | 28cc53e | 2017-12-23 17:24:55 +0100 | [diff] [blame] | 11 | |
Marc Kupietz | c2e4321 | 2021-03-13 18:05:14 +0100 | [diff] [blame] | 12 | CXXFLAGS = -Wall -Wno-reorder -I/usr/local/include -g -std=c++11 |
Marc Kupietz | ad33204 | 2021-03-13 18:05:14 +0100 | [diff] [blame] | 13 | CFLAGS = -Wall -I/usr/local/rocksdb -I$(INSTALL_PATH)/include -g -std=gnu99 -O2 |
Marc Kupietz | 4b799e9 | 2018-01-02 11:04:56 +0100 | [diff] [blame] | 14 | |
| 15 | ARFLAGS = ${EXTRA_ARFLAGS} rs |
Marc Kupietz | 18375e1 | 2017-12-24 10:11:18 +0100 | [diff] [blame] | 16 | |
Marc Kupietz | 28cc53e | 2017-12-23 17:24:55 +0100 | [diff] [blame] | 17 | ifneq ($(USE_RTTI), 1) |
| 18 | CXXFLAGS += -fno-rtti |
| 19 | endif |
Marc Kupietz | c2e4321 | 2021-03-13 18:05:14 +0100 | [diff] [blame] | 20 | SOURCE_DIR := src |
| 21 | BUILD_DIR := build |
| 22 | BIN_DIR := bin |
| 23 | LIB_DIR := lib |
| 24 | LIB_SOURCES = src/collocatordb.cc |
Marc Kupietz | 28cc53e | 2017-12-23 17:24:55 +0100 | [diff] [blame] | 25 | |
Marc Kupietz | c2e4321 | 2021-03-13 18:05:14 +0100 | [diff] [blame] | 26 | LIB_OBJECTS := $(subst $(SOURCE_DIR),$(BUILD_DIR),$(LIB_SOURCES:.cc=.o)) |
Marc Kupietz | ad33204 | 2021-03-13 18:05:14 +0100 | [diff] [blame] | 27 | |
Marc Kupietz | 6663f11 | 2021-03-14 09:20:59 +0100 | [diff] [blame^] | 28 | .PHONY: static_lib shared_lib install-static install-shared test |
Marc Kupietz | ad33204 | 2021-03-13 18:05:14 +0100 | [diff] [blame] | 29 | |
Marc Kupietz | 6663f11 | 2021-03-14 09:20:59 +0100 | [diff] [blame^] | 30 | all: static_lib shared_lib test |
Marc Kupietz | ad33204 | 2021-03-13 18:05:14 +0100 | [diff] [blame] | 31 | |
| 32 | install: install-static install-shared |
Marc Kupietz | 28cc53e | 2017-12-23 17:24:55 +0100 | [diff] [blame] | 33 | |
Marc Kupietz | 6663f11 | 2021-03-14 09:20:59 +0100 | [diff] [blame^] | 34 | test: bin/basic_test |
| 35 | |
Marc Kupietz | c2e4321 | 2021-03-13 18:05:14 +0100 | [diff] [blame] | 36 | bin/hello_world: examples/hello_world.c src/collocatordb.h build/collocatordb.o Makefile |
| 37 | mkdir -p bin |
| 38 | $(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 |
Marc Kupietz | 678185d | 2018-06-05 13:37:02 +0200 | [diff] [blame] | 39 | |
Marc Kupietz | c2e4321 | 2021-03-13 18:05:14 +0100 | [diff] [blame] | 40 | bin/testcdb: src/testcdb.cc src/collocatordb.h build/collocatordb.o Makefile |
| 41 | $(CXX) $(CXXFLAGS) -L. -L$(INSTALL_PATH)/lib $@.cc -o$@ build/collocatordb.o -lrocksdb $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS) |
Marc Kupietz | 4b799e9 | 2018-01-02 11:04:56 +0100 | [diff] [blame] | 42 | |
Marc Kupietz | c2e4321 | 2021-03-13 18:05:14 +0100 | [diff] [blame] | 43 | bin/dumpllr: examples/dumpllr.cc src/collocatordb.h build/collocatordb.o Makefile |
| 44 | $(CXX) $(CXXFLAGS) -L. -L$(INSTALL_PATH)/lib $@.cc -fopenmp -o$@ build/collocatordb.o $(INSTALL_PATH)/lib/librocksdb.a $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS) |
Marc Kupietz | 3400aa5 | 2018-06-05 10:28:55 +0200 | [diff] [blame] | 45 | |
Marc Kupietz | c2e4321 | 2021-03-13 18:05:14 +0100 | [diff] [blame] | 46 | bin/dumppmicubed: examples/dumppmicubed.cc src/collocatordb.h build/collocatordb.o Makefile |
| 47 | $(CXX) $(CXXFLAGS) -L. -L$(INSTALL_PATH)/lib $@.cc -fopenmp -o$@ build/collocatordb.o -lrocksdb $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS) |
Marc Kupietz | ad33204 | 2021-03-13 18:05:14 +0100 | [diff] [blame] | 48 | |
Marc Kupietz | c2e4321 | 2021-03-13 18:05:14 +0100 | [diff] [blame] | 49 | bin/dumpldafdiff: dumpldafdiff.cc src/collocatordb.h build/collocatordb.o Makefile |
| 50 | $(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) |
Marc Kupietz | b5bb194 | 2018-10-07 17:59:43 +0200 | [diff] [blame] | 51 | |
Marc Kupietz | c2e4321 | 2021-03-13 18:05:14 +0100 | [diff] [blame] | 52 | bin/collocatordb: src/collocatordb.cc Makefile |
Marc Kupietz | ad33204 | 2021-03-13 18:05:14 +0100 | [diff] [blame] | 53 | $(CXX) $(CXXFLAGS) -L$(INSTALL_PATH)/lib $@.cc -o$@ -lrocksdb $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS) |
| 54 | |
Marc Kupietz | c2e4321 | 2021-03-13 18:05:14 +0100 | [diff] [blame] | 55 | static_lib: lib/libcollocatordb.a |
Marc Kupietz | ad33204 | 2021-03-13 18:05:14 +0100 | [diff] [blame] | 56 | |
Marc Kupietz | c2e4321 | 2021-03-13 18:05:14 +0100 | [diff] [blame] | 57 | shared_lib: lib/libcollocatordb.so.$(COLLOCATDB_MAJOR).$(COLLOCATDB_MINOR) |
Marc Kupietz | 28cc53e | 2017-12-23 17:24:55 +0100 | [diff] [blame] | 58 | |
Marc Kupietz | c2e4321 | 2021-03-13 18:05:14 +0100 | [diff] [blame] | 59 | lib/libcollocatordb.a: $(LIB_OBJECTS) |
| 60 | mkdir -p lib |
Marc Kupietz | 4b799e9 | 2018-01-02 11:04:56 +0100 | [diff] [blame] | 61 | $(AM_V_AR)rm -f $@ |
Marc Kupietz | c2e4321 | 2021-03-13 18:05:14 +0100 | [diff] [blame] | 62 | $(AM_V_at)$(AR) $(ARFLAGS) $@ $(LIB_OBJECTS) |
Marc Kupietz | 28cc53e | 2017-12-23 17:24:55 +0100 | [diff] [blame] | 63 | |
Marc Kupietz | c2e4321 | 2021-03-13 18:05:14 +0100 | [diff] [blame] | 64 | lib/libcollocatordb.so.$(COLLOCATDB_MAJOR).$(COLLOCATDB_MINOR): $(LIB_SOURCES) |
| 65 | $(CXX) $(CXXFLAGS) -Wall -D_GLIBCXX_PARALLEL -fopenmp -c $< -Wl,-soname=libcollocatordb.so.1 -Wl,--version-script=collocatordb.exmap -shared -fPIC -o $@ |
| 66 | |
| 67 | build/collocatordb.o : src/collocatordb.cc |
| 68 | mkdir -p build |
| 69 | $(CXX) $(CXXFLAGS) -c $< -o$@ $(PLATFORM_CXXFLAGS) |
Marc Kupietz | 4b799e9 | 2018-01-02 11:04:56 +0100 | [diff] [blame] | 70 | |
Marc Kupietz | 28cc53e | 2017-12-23 17:24:55 +0100 | [diff] [blame] | 71 | .cc.o: |
Marc Kupietz | 18375e1 | 2017-12-24 10:11:18 +0100 | [diff] [blame] | 72 | $(CXX) $(CXXFLAGS) -c $< -o$@ $(PLATFORM_CXXFLAGS) |
Marc Kupietz | d165976 | 2018-06-05 11:22:12 +0200 | [diff] [blame] | 73 | |
Marc Kupietz | c2e4321 | 2021-03-13 18:05:14 +0100 | [diff] [blame] | 74 | install-static: lib/libcollocatordb.a src/collocatordb.h |
Marc Kupietz | ad33204 | 2021-03-13 18:05:14 +0100 | [diff] [blame] | 75 | install -d $(INSTALL_PATH)/include && \ |
| 76 | install -d $(INSTALL_PATH)/lib && \ |
Marc Kupietz | c2e4321 | 2021-03-13 18:05:14 +0100 | [diff] [blame] | 77 | install -t $(INSTALL_PATH)/include -D -C -m 644 src/collocatordb.h $ && \ |
| 78 | install -t $(INSTALL_PATH)/lib -C -D -m 755 lib/libcollocatordb.a |
Marc Kupietz | d165976 | 2018-06-05 11:22:12 +0200 | [diff] [blame] | 79 | |
Marc Kupietz | c2e4321 | 2021-03-13 18:05:14 +0100 | [diff] [blame] | 80 | install-shared: lib/libcollocatordb.so.$(COLLOCATDB_MAJOR).$(COLLOCATDB_MINOR) src/collocatordb.h |
Marc Kupietz | ad33204 | 2021-03-13 18:05:14 +0100 | [diff] [blame] | 81 | install -d $(INSTALL_PATH)/include && \ |
| 82 | install -d $(INSTALL_PATH)/lib && \ |
Marc Kupietz | c2e4321 | 2021-03-13 18:05:14 +0100 | [diff] [blame] | 83 | install -Dt $(INSTALL_PATH)/include -C -m 644 src/collocatordb.h && \ |
| 84 | install -Dt $(INSTALL_PATH)/lib -C -m 755 lib/libcollocatordb.so.$(COLLOCATDB_MAJOR).$(COLLOCATDB_MINOR) && \ |
Marc Kupietz | ad33204 | 2021-03-13 18:05:14 +0100 | [diff] [blame] | 85 | ln -fs $(INSTALL_PATH)/lib/libcollocatordb.so.$(COLLOCATDB_MAJOR).$(COLLOCATDB_MINOR) $(INSTALL_PATH)/lib/libcollocatordb.so.$(COLLOCATDB_MAJOR) && \ |
| 86 | ln -fs $(INSTALL_PATH)/lib/libcollocatordb.so.$(COLLOCATDB_MAJOR) $(INSTALL_PATH)/lib/libcollocatordb.so |
| 87 | |
Marc Kupietz | 6663f11 | 2021-03-14 09:20:59 +0100 | [diff] [blame^] | 88 | bin/basic_test: tests/basic_test.c build/collocatordb.o |
| 89 | mkdir -p bin |
| 90 | $(CC) $(CFLAGS) -L. -L$(INSTALL_PATH)/lib $< -o$@ build/collocatordb.o --std=gnu99 -lstdc++ -lm $(PLATFORM_LDFLAGS) $(PLATFORM_CCFLAGS) $(EXEC_LDFLAGS) -lrocksdb |
| 91 | $@ |
| 92 | |
Marc Kupietz | ad33204 | 2021-03-13 18:05:14 +0100 | [diff] [blame] | 93 | clean: |
Marc Kupietz | c2e4321 | 2021-03-13 18:05:14 +0100 | [diff] [blame] | 94 | rm -rf $(LIB_DIR) $(BUILD_DIR) $(BIN_DIR) |
Marc Kupietz | ad33204 | 2021-03-13 18:05:14 +0100 | [diff] [blame] | 95 | rm -f *.so* *.a *.o c_testcdb collocatordb dumpldafdiff dumppmicubed dumpllr testcdb hello_world |