blob: 51e26464541f73f118b2c1679d473551a6578a6f [file] [log] [blame]
Marc Kupietzad332042021-03-13 18:05:14 +01001COLLOCATDB_MAJOR=1
2COLLOCATDB_MINOR=2
3COLLOCATDB_PATCH=0
4
5INSTALL_PATH ?= /usr/local
6
Marc Kupietz28cc53e2017-12-23 17:24:55 +01007PLATFORM_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
8PLATFORM_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
9PLATFORM=OS_LINUX
Marc Kupietzad332042021-03-13 18:05:14 +010010PLATFORM_LDFLAGS= -L$(INSTALL_PATH)/lib -Wl,-rpath=$(INSTALL_PATH)/lib -lpthread -lrt -lsnappy -lz -lbz2 -llz4 -lzstd
Marc Kupietz28cc53e2017-12-23 17:24:55 +010011
Marc Kupietzc2e43212021-03-13 18:05:14 +010012CXXFLAGS = -Wall -Wno-reorder -I/usr/local/include -g -std=c++11
Marc Kupietzad332042021-03-13 18:05:14 +010013CFLAGS = -Wall -I/usr/local/rocksdb -I$(INSTALL_PATH)/include -g -std=gnu99 -O2
Marc Kupietz4b799e92018-01-02 11:04:56 +010014
15ARFLAGS = ${EXTRA_ARFLAGS} rs
Marc Kupietz18375e12017-12-24 10:11:18 +010016
Marc Kupietz28cc53e2017-12-23 17:24:55 +010017ifneq ($(USE_RTTI), 1)
18 CXXFLAGS += -fno-rtti
19endif
Marc Kupietzc2e43212021-03-13 18:05:14 +010020SOURCE_DIR := src
21BUILD_DIR := build
22BIN_DIR := bin
23LIB_DIR := lib
24LIB_SOURCES = src/collocatordb.cc
Marc Kupietz28cc53e2017-12-23 17:24:55 +010025
Marc Kupietzc2e43212021-03-13 18:05:14 +010026LIB_OBJECTS := $(subst $(SOURCE_DIR),$(BUILD_DIR),$(LIB_SOURCES:.cc=.o))
Marc Kupietzad332042021-03-13 18:05:14 +010027
28.PHONY: static_lib shared_lib install-static install-shared
29
Marc Kupietzc2e43212021-03-13 18:05:14 +010030all: static_lib shared_lib
Marc Kupietzad332042021-03-13 18:05:14 +010031
32install: install-static install-shared
Marc Kupietz28cc53e2017-12-23 17:24:55 +010033
Marc Kupietzc2e43212021-03-13 18:05:14 +010034bin/hello_world: examples/hello_world.c src/collocatordb.h build/collocatordb.o Makefile
35 mkdir -p bin
36 $(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 Kupietz678185d2018-06-05 13:37:02 +020037
Marc Kupietzc2e43212021-03-13 18:05:14 +010038bin/testcdb: src/testcdb.cc src/collocatordb.h build/collocatordb.o Makefile
39 $(CXX) $(CXXFLAGS) -L. -L$(INSTALL_PATH)/lib $@.cc -o$@ build/collocatordb.o -lrocksdb $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS)
Marc Kupietz4b799e92018-01-02 11:04:56 +010040
Marc Kupietzc2e43212021-03-13 18:05:14 +010041bin/dumpllr: examples/dumpllr.cc src/collocatordb.h build/collocatordb.o Makefile
42 $(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 Kupietz3400aa52018-06-05 10:28:55 +020043
Marc Kupietzc2e43212021-03-13 18:05:14 +010044bin/dumppmicubed: examples/dumppmicubed.cc src/collocatordb.h build/collocatordb.o Makefile
45 $(CXX) $(CXXFLAGS) -L. -L$(INSTALL_PATH)/lib $@.cc -fopenmp -o$@ build/collocatordb.o -lrocksdb $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS)
Marc Kupietzad332042021-03-13 18:05:14 +010046
Marc Kupietzc2e43212021-03-13 18:05:14 +010047bin/dumpldafdiff: dumpldafdiff.cc src/collocatordb.h build/collocatordb.o Makefile
48 $(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 Kupietzb5bb1942018-10-07 17:59:43 +020049
Marc Kupietzc2e43212021-03-13 18:05:14 +010050bin/c_testcdb: examples/c_testcdb.c src/collocatordb.h build/collocatordb.o Makefile
51 $(CC) $(CFLAGS) -L. -L$(INSTALL_PATH)/lib $@.c -o$@ build/collocatordb.o -std=gnu99 -lstdc++ -lm -lrocksdb $(PLATFORM_LDFLAGS) $(PLATFORM_CCFLAGS) $(EXEC_LDFLAGS)
Marc Kupietzc8ddf452018-01-07 21:33:12 +010052
Marc Kupietzc2e43212021-03-13 18:05:14 +010053bin/collocatordb: src/collocatordb.cc Makefile
Marc Kupietzad332042021-03-13 18:05:14 +010054 $(CXX) $(CXXFLAGS) -L$(INSTALL_PATH)/lib $@.cc -o$@ -lrocksdb $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS)
55
Marc Kupietzc2e43212021-03-13 18:05:14 +010056static_lib: lib/libcollocatordb.a
Marc Kupietzad332042021-03-13 18:05:14 +010057
Marc Kupietzc2e43212021-03-13 18:05:14 +010058shared_lib: lib/libcollocatordb.so.$(COLLOCATDB_MAJOR).$(COLLOCATDB_MINOR)
Marc Kupietz28cc53e2017-12-23 17:24:55 +010059
Marc Kupietzc2e43212021-03-13 18:05:14 +010060lib/libcollocatordb.a: $(LIB_OBJECTS)
61 mkdir -p lib
Marc Kupietz4b799e92018-01-02 11:04:56 +010062 $(AM_V_AR)rm -f $@
Marc Kupietzc2e43212021-03-13 18:05:14 +010063 $(AM_V_at)$(AR) $(ARFLAGS) $@ $(LIB_OBJECTS)
Marc Kupietz28cc53e2017-12-23 17:24:55 +010064
Marc Kupietzc2e43212021-03-13 18:05:14 +010065lib/libcollocatordb.so.$(COLLOCATDB_MAJOR).$(COLLOCATDB_MINOR): $(LIB_SOURCES)
66 $(CXX) $(CXXFLAGS) -Wall -D_GLIBCXX_PARALLEL -fopenmp -c $< -Wl,-soname=libcollocatordb.so.1 -Wl,--version-script=collocatordb.exmap -shared -fPIC -o $@
67
68build/collocatordb.o : src/collocatordb.cc
69 mkdir -p build
70 $(CXX) $(CXXFLAGS) -c $< -o$@ $(PLATFORM_CXXFLAGS)
Marc Kupietz4b799e92018-01-02 11:04:56 +010071
Marc Kupietz28cc53e2017-12-23 17:24:55 +010072.cc.o:
Marc Kupietz18375e12017-12-24 10:11:18 +010073 $(CXX) $(CXXFLAGS) -c $< -o$@ $(PLATFORM_CXXFLAGS)
Marc Kupietzd1659762018-06-05 11:22:12 +020074
Marc Kupietzc2e43212021-03-13 18:05:14 +010075install-static: lib/libcollocatordb.a src/collocatordb.h
Marc Kupietzad332042021-03-13 18:05:14 +010076 install -d $(INSTALL_PATH)/include && \
77 install -d $(INSTALL_PATH)/lib && \
Marc Kupietzc2e43212021-03-13 18:05:14 +010078 install -t $(INSTALL_PATH)/include -D -C -m 644 src/collocatordb.h $ && \
79 install -t $(INSTALL_PATH)/lib -C -D -m 755 lib/libcollocatordb.a
Marc Kupietzd1659762018-06-05 11:22:12 +020080
Marc Kupietzc2e43212021-03-13 18:05:14 +010081install-shared: lib/libcollocatordb.so.$(COLLOCATDB_MAJOR).$(COLLOCATDB_MINOR) src/collocatordb.h
Marc Kupietzad332042021-03-13 18:05:14 +010082 install -d $(INSTALL_PATH)/include && \
83 install -d $(INSTALL_PATH)/lib && \
Marc Kupietzc2e43212021-03-13 18:05:14 +010084 install -Dt $(INSTALL_PATH)/include -C -m 644 src/collocatordb.h && \
85 install -Dt $(INSTALL_PATH)/lib -C -m 755 lib/libcollocatordb.so.$(COLLOCATDB_MAJOR).$(COLLOCATDB_MINOR) && \
Marc Kupietzad332042021-03-13 18:05:14 +010086 ln -fs $(INSTALL_PATH)/lib/libcollocatordb.so.$(COLLOCATDB_MAJOR).$(COLLOCATDB_MINOR) $(INSTALL_PATH)/lib/libcollocatordb.so.$(COLLOCATDB_MAJOR) && \
87 ln -fs $(INSTALL_PATH)/lib/libcollocatordb.so.$(COLLOCATDB_MAJOR) $(INSTALL_PATH)/lib/libcollocatordb.so
88
89clean:
Marc Kupietzc2e43212021-03-13 18:05:14 +010090 rm -rf $(LIB_DIR) $(BUILD_DIR) $(BIN_DIR)
Marc Kupietzad332042021-03-13 18:05:14 +010091 rm -f *.so* *.a *.o c_testcdb collocatordb dumpldafdiff dumppmicubed dumpllr testcdb hello_world