blob: 4b9a7462519300cee83eeb5693e5df450df20886 [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
Marc Kupietz6663f112021-03-14 09:20:59 +010028.PHONY: static_lib shared_lib install-static install-shared test
Marc Kupietzad332042021-03-13 18:05:14 +010029
Marc Kupietz6663f112021-03-14 09:20:59 +010030all: static_lib shared_lib test
Marc Kupietzad332042021-03-13 18:05:14 +010031
32install: install-static install-shared
Marc Kupietz28cc53e2017-12-23 17:24:55 +010033
Marc Kupietz6663f112021-03-14 09:20:59 +010034test: bin/basic_test
35
Marc Kupietzc2e43212021-03-13 18:05:14 +010036bin/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 Kupietz678185d2018-06-05 13:37:02 +020039
Marc Kupietzc2e43212021-03-13 18:05:14 +010040bin/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 Kupietz4b799e92018-01-02 11:04:56 +010042
Marc Kupietzc2e43212021-03-13 18:05:14 +010043bin/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 Kupietz3400aa52018-06-05 10:28:55 +020045
Marc Kupietzc2e43212021-03-13 18:05:14 +010046bin/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 Kupietzad332042021-03-13 18:05:14 +010048
Marc Kupietzc2e43212021-03-13 18:05:14 +010049bin/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 Kupietzb5bb1942018-10-07 17:59:43 +020051
Marc Kupietzc2e43212021-03-13 18:05:14 +010052bin/collocatordb: src/collocatordb.cc Makefile
Marc Kupietzad332042021-03-13 18:05:14 +010053 $(CXX) $(CXXFLAGS) -L$(INSTALL_PATH)/lib $@.cc -o$@ -lrocksdb $(PLATFORM_LDFLAGS) $(PLATFORM_CXXFLAGS) $(EXEC_LDFLAGS)
54
Marc Kupietzc2e43212021-03-13 18:05:14 +010055static_lib: lib/libcollocatordb.a
Marc Kupietzad332042021-03-13 18:05:14 +010056
Marc Kupietzc2e43212021-03-13 18:05:14 +010057shared_lib: lib/libcollocatordb.so.$(COLLOCATDB_MAJOR).$(COLLOCATDB_MINOR)
Marc Kupietz28cc53e2017-12-23 17:24:55 +010058
Marc Kupietzc2e43212021-03-13 18:05:14 +010059lib/libcollocatordb.a: $(LIB_OBJECTS)
60 mkdir -p lib
Marc Kupietz4b799e92018-01-02 11:04:56 +010061 $(AM_V_AR)rm -f $@
Marc Kupietzc2e43212021-03-13 18:05:14 +010062 $(AM_V_at)$(AR) $(ARFLAGS) $@ $(LIB_OBJECTS)
Marc Kupietz28cc53e2017-12-23 17:24:55 +010063
Marc Kupietzc2e43212021-03-13 18:05:14 +010064lib/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
67build/collocatordb.o : src/collocatordb.cc
68 mkdir -p build
69 $(CXX) $(CXXFLAGS) -c $< -o$@ $(PLATFORM_CXXFLAGS)
Marc Kupietz4b799e92018-01-02 11:04:56 +010070
Marc Kupietz28cc53e2017-12-23 17:24:55 +010071.cc.o:
Marc Kupietz18375e12017-12-24 10:11:18 +010072 $(CXX) $(CXXFLAGS) -c $< -o$@ $(PLATFORM_CXXFLAGS)
Marc Kupietzd1659762018-06-05 11:22:12 +020073
Marc Kupietzc2e43212021-03-13 18:05:14 +010074install-static: lib/libcollocatordb.a src/collocatordb.h
Marc Kupietzad332042021-03-13 18:05:14 +010075 install -d $(INSTALL_PATH)/include && \
76 install -d $(INSTALL_PATH)/lib && \
Marc Kupietzc2e43212021-03-13 18:05:14 +010077 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 Kupietzd1659762018-06-05 11:22:12 +020079
Marc Kupietzc2e43212021-03-13 18:05:14 +010080install-shared: lib/libcollocatordb.so.$(COLLOCATDB_MAJOR).$(COLLOCATDB_MINOR) src/collocatordb.h
Marc Kupietzad332042021-03-13 18:05:14 +010081 install -d $(INSTALL_PATH)/include && \
82 install -d $(INSTALL_PATH)/lib && \
Marc Kupietzc2e43212021-03-13 18:05:14 +010083 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 Kupietzad332042021-03-13 18:05:14 +010085 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 Kupietz6663f112021-03-14 09:20:59 +010088bin/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 Kupietzad332042021-03-13 18:05:14 +010093clean:
Marc Kupietzc2e43212021-03-13 18:05:14 +010094 rm -rf $(LIB_DIR) $(BUILD_DIR) $(BIN_DIR)
Marc Kupietzad332042021-03-13 18:05:14 +010095 rm -f *.so* *.a *.o c_testcdb collocatordb dumpldafdiff dumppmicubed dumpllr testcdb hello_world