1# Copyright (c) 2011 The LevelDB Authors. All rights reserved.
2# Use of this source code is governed by a BSD-style license that can be
3# found in the LICENSE file. See the AUTHORS file for names of contributors.
4
5# Inherit some settings from environment variables, if available
6
7#-----------------------------------------------
8
9BASH_EXISTS := $(shell which bash)
10SHELL := $(shell which bash)
11# Default to python3. Some distros like CentOS 8 do not have `python`.
12ifeq ($(origin PYTHON), undefined)
13	PYTHON := $(shell which python3 || which python || echo python3)
14endif
15export PYTHON
16
17CLEAN_FILES = # deliberately empty, so we can append below.
18CFLAGS += ${EXTRA_CFLAGS}
19CXXFLAGS += ${EXTRA_CXXFLAGS}
20LDFLAGS += $(EXTRA_LDFLAGS)
21MACHINE ?= $(shell uname -m)
22ARFLAGS = ${EXTRA_ARFLAGS} rs
23STRIPFLAGS = -S -x
24
25# Transform parallel LOG output into something more readable.
26perl_command = perl -n \
27  -e '@a=split("\t",$$_,-1); $$t=$$a[8];'				\
28  -e '$$t =~ /.*if\s\[\[\s"(.*?\.[\w\/]+)/ and $$t=$$1;'		\
29  -e '$$t =~ s,^\./,,;'							\
30  -e '$$t =~ s, >.*,,; chomp $$t;'					\
31  -e '$$t =~ /.*--gtest_filter=(.*?\.[\w\/]+)/ and $$t=$$1;'		\
32  -e 'printf "%7.3f %s %s\n", $$a[3], $$a[6] == 0 ? "PASS" : "FAIL", $$t'
33quoted_perl_command = $(subst ','\'',$(perl_command))
34
35# DEBUG_LEVEL can have three values:
36# * DEBUG_LEVEL=2; this is the ultimate debug mode. It will compile rocksdb
37# without any optimizations. To compile with level 2, issue `make dbg`
38# * DEBUG_LEVEL=1; debug level 1 enables all assertions and debug code, but
39# compiles rocksdb with -O2 optimizations. this is the default debug level.
40# `make all` or `make <binary_target>` compile RocksDB with debug level 1.
41# We use this debug level when developing RocksDB.
42# * DEBUG_LEVEL=0; this is the debug level we use for release. If you're
43# running rocksdb in production you most definitely want to compile RocksDB
44# with debug level 0. To compile with level 0, run `make shared_lib`,
45# `make install-shared`, `make static_lib`, `make install-static` or
46# `make install`
47
48# Set the default DEBUG_LEVEL to 1
49DEBUG_LEVEL?=1
50
51# LIB_MODE says whether or not to use/build "shared" or "static" libraries.
52# Mode "static" means to link against static libraries (.a)
53# Mode "shared" means to link against shared libraries (.so, .sl, .dylib, etc)
54#
55# Set the default LIB_MODE to static
56LIB_MODE?=static
57
58# OBJ_DIR is where the object files reside.  Default to the current directory
59OBJ_DIR?=.
60
61# Check the MAKECMDGOALS to set the DEBUG_LEVEL and LIB_MODE appropriately
62
63ifneq ($(filter clean release install, $(MAKECMDGOALS)),)
64	DEBUG_LEVEL=0
65endif
66ifneq ($(filter dbg, $(MAKECMDGOALS)),)
67	DEBUG_LEVEL=2
68else ifneq ($(filter shared_lib install-shared, $(MAKECMDGOALS)),)
69	DEBUG_LEVEL=0
70	LIB_MODE=shared
71else ifneq ($(filter static_lib install-static, $(MAKECMDGOALS)),)
72	DEBUG_LEVEL=0
73	LIB_MODE=static
74else ifneq ($(filter jtest rocksdbjava%, $(MAKECMDGOALS)),)
75	OBJ_DIR=jl
76	LIB_MODE=shared
77	ifneq ($(findstring rocksdbjavastatic, $(MAKECMDGOALS)),)
78		OBJ_DIR=jls
79		ifneq ($(DEBUG_LEVEL),2)
80			DEBUG_LEVEL=0
81		endif
82		ifeq ($(MAKECMDGOALS),rocksdbjavastaticpublish)
83			DEBUG_LEVEL=0
84		endif
85	endif
86endif
87
88$(info $$DEBUG_LEVEL is ${DEBUG_LEVEL})
89
90# Lite build flag.
91LITE ?= 0
92ifeq ($(LITE), 0)
93ifneq ($(filter -DROCKSDB_LITE,$(OPT)),)
94  # Be backward compatible and support older format where OPT=-DROCKSDB_LITE is
95  # specified instead of LITE=1 on the command line.
96  LITE=1
97endif
98else ifeq ($(LITE), 1)
99ifeq ($(filter -DROCKSDB_LITE,$(OPT)),)
100	OPT += -DROCKSDB_LITE
101endif
102endif
103
104# Figure out optimize level.
105ifneq ($(DEBUG_LEVEL), 2)
106ifeq ($(LITE), 0)
107	OPTIMIZE_LEVEL ?= -O2
108else
109	OPTIMIZE_LEVEL ?= -Os
110endif
111endif
112# `OPTIMIZE_LEVEL` is empty when the user does not set it and `DEBUG_LEVEL=2`.
113# In that case, the compiler default (`-O0` for gcc and clang) will be used.
114OPT += $(OPTIMIZE_LEVEL)
115
116# compile with -O2 if debug level is not 2
117ifneq ($(DEBUG_LEVEL), 2)
118OPT += -fno-omit-frame-pointer
119# Skip for archs that don't support -momit-leaf-frame-pointer
120ifeq (,$(shell $(CXX) -fsyntax-only -momit-leaf-frame-pointer -xc /dev/null 2>&1))
121OPT += -momit-leaf-frame-pointer
122endif
123endif
124
125ifeq (,$(shell $(CXX) -fsyntax-only -maltivec -xc /dev/null 2>&1))
126CXXFLAGS += -DHAS_ALTIVEC
127CFLAGS += -DHAS_ALTIVEC
128HAS_ALTIVEC=1
129endif
130
131ifeq (,$(shell $(CXX) -fsyntax-only -mcpu=power8 -xc /dev/null 2>&1))
132CXXFLAGS += -DHAVE_POWER8
133CFLAGS +=  -DHAVE_POWER8
134HAVE_POWER8=1
135endif
136
137ifeq (,$(shell $(CXX) -fsyntax-only -march=armv8-a+crc+crypto -xc /dev/null 2>&1))
138CXXFLAGS += -march=armv8-a+crc+crypto
139CFLAGS += -march=armv8-a+crc+crypto
140ARMCRC_SOURCE=1
141endif
142
143# if we're compiling for shared libraries, add the shared flags
144ifeq ($(LIB_MODE),shared)
145CXXFLAGS += $(PLATFORM_SHARED_CFLAGS) -DROCKSDB_DLL
146CFLAGS +=  $(PLATFORM_SHARED_CFLAGS) -DROCKSDB_DLL
147endif
148
149# if we're compiling for release, compile without debug code (-DNDEBUG)
150ifeq ($(DEBUG_LEVEL),0)
151OPT += -DNDEBUG
152
153ifneq ($(USE_RTTI), 1)
154	CXXFLAGS += -fno-rtti
155else
156	CXXFLAGS += -DROCKSDB_USE_RTTI
157endif
158else
159ifneq ($(USE_RTTI), 0)
160	CXXFLAGS += -DROCKSDB_USE_RTTI
161else
162	CXXFLAGS += -fno-rtti
163endif
164
165ifdef ASSERT_STATUS_CHECKED
166# For ASC, turn off constructor elision, preventing the case where a constructor returned
167# by a method may pass the ASC check if the status is checked in the inner method.  Forcing
168# the copy constructor to be invoked disables the optimization and will cause the calling method
169# to check the status in order to prevent an error from being raised.
170PLATFORM_CXXFLAGS += -fno-elide-constructors
171ifeq ($(filter -DROCKSDB_ASSERT_STATUS_CHECKED,$(OPT)),)
172	OPT += -DROCKSDB_ASSERT_STATUS_CHECKED
173endif
174endif
175
176$(warning Warning: Compiling in debug mode. Don't use the resulting binary in production)
177endif
178
179# `USE_LTO=1` enables link-time optimizations. Among other things, this enables
180# more devirtualization opportunities and inlining across translation units.
181# This can save significant overhead introduced by RocksDB's pluggable
182# interfaces/internal abstractions, like in the iterator hierarchy. It works
183# better when combined with profile-guided optimizations (not currently
184# supported natively in Makefile).
185ifeq ($(USE_LTO), 1)
186	CXXFLAGS += -flto
187	LDFLAGS += -flto -fuse-linker-plugin
188endif
189
190#-----------------------------------------------
191include src.mk
192
193AM_DEFAULT_VERBOSITY ?= 0
194
195AM_V_GEN = $(am__v_GEN_$(V))
196am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
197am__v_GEN_0 = @echo "  GEN     " $@;
198am__v_GEN_1 =
199AM_V_at = $(am__v_at_$(V))
200am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
201am__v_at_0 = @
202am__v_at_1 =
203
204AM_V_CC = $(am__v_CC_$(V))
205am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
206am__v_CC_0 = @echo "  CC      " $@;
207am__v_CC_1 =
208
209AM_V_CCLD = $(am__v_CCLD_$(V))
210am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
211ifneq ($(SKIP_LINK), 1)
212am__v_CCLD_0 = @echo "  CCLD    " $@;
213am__v_CCLD_1 =
214else
215am__v_CCLD_0 = @echo "  !CCLD   " $@; true skip
216am__v_CCLD_1 = true skip
217endif
218AM_V_AR = $(am__v_AR_$(V))
219am__v_AR_ = $(am__v_AR_$(AM_DEFAULT_VERBOSITY))
220am__v_AR_0 = @echo "  AR      " $@;
221am__v_AR_1 =
222
223ifdef ROCKSDB_USE_LIBRADOS
224LIB_SOURCES += utilities/env_librados.cc
225TEST_MAIN_SOURCES += utilities/env_librados_test.cc
226LDFLAGS += -lrados
227endif
228
229AM_LINK = $(AM_V_CCLD)$(CXX) -L. $(patsubst lib%.a, -l%, $(patsubst lib%.$(PLATFORM_SHARED_EXT), -l%, $^)) $(EXEC_LDFLAGS) -o $@ $(LDFLAGS) $(COVERAGEFLAGS)
230AM_SHARE = $(AM_V_CCLD) $(CXX) $(PLATFORM_SHARED_LDFLAGS)$@ -L. $(patsubst lib%.$(PLATFORM_SHARED_EXT), -l%, $^) $(LDFLAGS) -o $@
231
232# Detect what platform we're building on.
233# Export some common variables that might have been passed as Make variables
234# instead of environment variables.
235#dummy := $(shell (export ROCKSDB_ROOT="$(CURDIR)"; \
236#                  export CXXFLAGS="$(EXTRA_CXXFLAGS)"; \
237#                  export LDFLAGS="$(EXTRA_LDFLAGS)"; \
238#                  export COMPILE_WITH_ASAN="$(COMPILE_WITH_ASAN)"; \
239#                  export COMPILE_WITH_TSAN="$(COMPILE_WITH_TSAN)"; \
240#                  export COMPILE_WITH_UBSAN="$(COMPILE_WITH_UBSAN)"; \
241#                  export PORTABLE="$(PORTABLE)"; \
242#                  export ROCKSDB_NO_FBCODE="$(ROCKSDB_NO_FBCODE)"; \
243#                  export USE_CLANG="$(USE_CLANG)"; \
244#                  "$(CURDIR)/build_tools/build_detect_platform" "$(CURDIR)/make_config.mk"))
245# this file is generated by the previous line to set build flags and sources
246include make_config.mk
247
248ROCKSDB_PLUGIN_MKS = $(foreach plugin, $(ROCKSDB_PLUGINS), plugin/$(plugin)/*.mk)
249include $(ROCKSDB_PLUGIN_MKS)
250ROCKSDB_PLUGIN_SOURCES = $(foreach plugin, $(ROCKSDB_PLUGINS), $(foreach source, $($(plugin)_SOURCES), plugin/$(plugin)/$(source)))
251ROCKSDB_PLUGIN_HEADERS = $(foreach plugin, $(ROCKSDB_PLUGINS), $(foreach header, $($(plugin)_HEADERS), plugin/$(plugin)/$(header)))
252PLATFORM_LDFLAGS += $(foreach plugin, $(ROCKSDB_PLUGINS), $($(plugin)_LDFLAGS))
253
254export JAVAC_ARGS
255CLEAN_FILES += make_config.mk rocksdb.pc
256
257ifeq ($(V), 1)
258$(info $(shell uname -a))
259$(info $(shell $(CC) --version))
260$(info $(shell $(CXX) --version))
261endif
262
263missing_make_config_paths := $(shell				\
264	grep "\./\S*\|/\S*" -o $(CURDIR)/make_config.mk | 	\
265	while read path;					\
266		do [ -e $$path ] || echo $$path; 		\
267	done | sort | uniq)
268
269$(foreach path, $(missing_make_config_paths), \
270	$(warning Warning: $(path) does not exist))
271
272ifeq ($(PLATFORM), OS_AIX)
273# no debug info
274else ifneq ($(PLATFORM), IOS)
275CFLAGS += -g
276CXXFLAGS += -g
277else
278# no debug info for IOS, that will make our library big
279OPT += -DNDEBUG
280endif
281
282ifeq ($(PLATFORM), OS_AIX)
283ARFLAGS = -X64 rs
284STRIPFLAGS = -X64 -x
285endif
286
287ifeq ($(PLATFORM), OS_SOLARIS)
288	PLATFORM_CXXFLAGS += -D _GLIBCXX_USE_C99
289endif
290ifneq ($(filter -DROCKSDB_LITE,$(OPT)),)
291	# found
292	CFLAGS += -fno-exceptions
293	CXXFLAGS += -fno-exceptions
294	# LUA is not supported under ROCKSDB_LITE
295	LUA_PATH =
296endif
297
298ifeq ($(LIB_MODE),shared)
299# So that binaries are executable from build location, in addition to install location
300EXEC_LDFLAGS += -Wl,-rpath -Wl,'$$ORIGIN'
301endif
302
303# ASAN doesn't work well with jemalloc. If we're compiling with ASAN, we should use regular malloc.
304ifdef COMPILE_WITH_ASAN
305	DISABLE_JEMALLOC=1
306	EXEC_LDFLAGS += -fsanitize=address
307	PLATFORM_CCFLAGS += -fsanitize=address
308	PLATFORM_CXXFLAGS += -fsanitize=address
309endif
310
311# TSAN doesn't work well with jemalloc. If we're compiling with TSAN, we should use regular malloc.
312ifdef COMPILE_WITH_TSAN
313	DISABLE_JEMALLOC=1
314	EXEC_LDFLAGS += -fsanitize=thread
315	PLATFORM_CCFLAGS += -fsanitize=thread -fPIC -DFOLLY_SANITIZE_THREAD
316	PLATFORM_CXXFLAGS += -fsanitize=thread -fPIC -DFOLLY_SANITIZE_THREAD
317        # Turn off -pg when enabling TSAN testing, because that induces
318        # a link failure.  TODO: find the root cause
319	PROFILING_FLAGS =
320	# LUA is not supported under TSAN
321	LUA_PATH =
322	# Limit keys for crash test under TSAN to avoid error:
323	# "ThreadSanitizer: DenseSlabAllocator overflow. Dying."
324	CRASH_TEST_EXT_ARGS += --max_key=1000000
325endif
326
327# AIX doesn't work with -pg
328ifeq ($(PLATFORM), OS_AIX)
329	PROFILING_FLAGS =
330endif
331
332# USAN doesn't work well with jemalloc. If we're compiling with USAN, we should use regular malloc.
333ifdef COMPILE_WITH_UBSAN
334	DISABLE_JEMALLOC=1
335	# Suppress alignment warning because murmurhash relies on casting unaligned
336	# memory to integer. Fixing it may cause performance regression. 3-way crc32
337	# relies on it too, although it can be rewritten to eliminate with minimal
338	# performance regression.
339	EXEC_LDFLAGS += -fsanitize=undefined -fno-sanitize-recover=all
340	PLATFORM_CCFLAGS += -fsanitize=undefined -fno-sanitize-recover=all -DROCKSDB_UBSAN_RUN
341	PLATFORM_CXXFLAGS += -fsanitize=undefined -fno-sanitize-recover=all -DROCKSDB_UBSAN_RUN
342endif
343
344ifdef ROCKSDB_VALGRIND_RUN
345	PLATFORM_CCFLAGS += -DROCKSDB_VALGRIND_RUN
346	PLATFORM_CXXFLAGS += -DROCKSDB_VALGRIND_RUN
347endif
348ifdef ROCKSDB_FULL_VALGRIND_RUN
349	# Some tests are slow when run under valgrind and are only run when
350	# explicitly requested via the ROCKSDB_FULL_VALGRIND_RUN compiler flag.
351	PLATFORM_CCFLAGS += -DROCKSDB_VALGRIND_RUN -DROCKSDB_FULL_VALGRIND_RUN
352	PLATFORM_CXXFLAGS += -DROCKSDB_VALGRIND_RUN -DROCKSDB_FULL_VALGRIND_RUN
353endif
354
355ifndef DISABLE_JEMALLOC
356	ifdef JEMALLOC
357		PLATFORM_CXXFLAGS += -DROCKSDB_JEMALLOC -DJEMALLOC_NO_DEMANGLE
358		PLATFORM_CCFLAGS  += -DROCKSDB_JEMALLOC -DJEMALLOC_NO_DEMANGLE
359	endif
360	ifdef WITH_JEMALLOC_FLAG
361		PLATFORM_LDFLAGS += -ljemalloc
362		JAVA_LDFLAGS += -ljemalloc
363	endif
364	EXEC_LDFLAGS := $(JEMALLOC_LIB) $(EXEC_LDFLAGS)
365	PLATFORM_CXXFLAGS += $(JEMALLOC_INCLUDE)
366	PLATFORM_CCFLAGS += $(JEMALLOC_INCLUDE)
367endif
368
369ifndef USE_FOLLY_DISTRIBUTED_MUTEX
370	USE_FOLLY_DISTRIBUTED_MUTEX=0
371endif
372
373ifndef GTEST_THROW_ON_FAILURE
374	export GTEST_THROW_ON_FAILURE=1
375endif
376ifndef GTEST_HAS_EXCEPTIONS
377	export GTEST_HAS_EXCEPTIONS=1
378endif
379
380GTEST_DIR = third-party/gtest-1.8.1/fused-src
381# AIX: pre-defined system headers are surrounded by an extern "C" block
382ifeq ($(PLATFORM), OS_AIX)
383	PLATFORM_CCFLAGS += -I$(GTEST_DIR)
384	PLATFORM_CXXFLAGS += -I$(GTEST_DIR)
385else
386	PLATFORM_CCFLAGS += -isystem $(GTEST_DIR)
387	PLATFORM_CXXFLAGS += -isystem $(GTEST_DIR)
388endif
389
390ifeq ($(USE_FOLLY_DISTRIBUTED_MUTEX),1)
391	FOLLY_DIR = ./third-party/folly
392	# AIX: pre-defined system headers are surrounded by an extern "C" block
393	ifeq ($(PLATFORM), OS_AIX)
394		PLATFORM_CCFLAGS += -I$(FOLLY_DIR)
395		PLATFORM_CXXFLAGS += -I$(FOLLY_DIR)
396	else
397		PLATFORM_CCFLAGS += -isystem $(FOLLY_DIR)
398		PLATFORM_CXXFLAGS += -isystem $(FOLLY_DIR)
399	endif
400endif
401
402ifdef TEST_CACHE_LINE_SIZE
403  PLATFORM_CCFLAGS += -DTEST_CACHE_LINE_SIZE=$(TEST_CACHE_LINE_SIZE)
404  PLATFORM_CXXFLAGS += -DTEST_CACHE_LINE_SIZE=$(TEST_CACHE_LINE_SIZE)
405endif
406ifdef TEST_UINT128_COMPAT
407  PLATFORM_CCFLAGS += -DTEST_UINT128_COMPAT=1
408  PLATFORM_CXXFLAGS += -DTEST_UINT128_COMPAT=1
409endif
410ifdef ROCKSDB_MODIFY_NPHASH
411  PLATFORM_CCFLAGS += -DROCKSDB_MODIFY_NPHASH=1
412  PLATFORM_CXXFLAGS += -DROCKSDB_MODIFY_NPHASH=1
413endif
414
415# This (the first rule) must depend on "all".
416default: all
417
418WARNING_FLAGS = -W -Wextra -Wall -Wsign-compare -Wshadow \
419  -Wunused-parameter
420
421ifeq (,$(filter amd64, $(MACHINE)))
422	C_WARNING_FLAGS = -Wstrict-prototypes
423endif
424
425ifdef USE_CLANG
426	# Used by some teams in Facebook
427	WARNING_FLAGS += -Wshift-sign-overflow
428endif
429
430ifeq ($(PLATFORM), OS_OPENBSD)
431	WARNING_FLAGS += -Wno-unused-lambda-capture
432endif
433
434ifndef DISABLE_WARNING_AS_ERROR
435	WARNING_FLAGS += -Werror
436endif
437
438
439ifdef LUA_PATH
440
441ifndef LUA_INCLUDE
442LUA_INCLUDE=$(LUA_PATH)/include
443endif
444
445LUA_INCLUDE_FILE=$(LUA_INCLUDE)/lualib.h
446
447ifeq ("$(wildcard $(LUA_INCLUDE_FILE))", "")
448# LUA_INCLUDE_FILE does not exist
449$(error Cannot find lualib.h under $(LUA_INCLUDE).  Try to specify both LUA_PATH and LUA_INCLUDE manually)
450endif
451LUA_FLAGS = -I$(LUA_INCLUDE) -DLUA -DLUA_COMPAT_ALL
452CFLAGS += $(LUA_FLAGS)
453CXXFLAGS += $(LUA_FLAGS)
454
455ifndef LUA_LIB
456LUA_LIB = $(LUA_PATH)/lib/liblua.a
457endif
458ifeq ("$(wildcard $(LUA_LIB))", "") # LUA_LIB does not exist
459$(error $(LUA_LIB) does not exist.  Try to specify both LUA_PATH and LUA_LIB manually)
460endif
461EXEC_LDFLAGS += $(LUA_LIB)
462
463endif
464
465ifeq ($(NO_THREEWAY_CRC32C), 1)
466	CXXFLAGS += -DNO_THREEWAY_CRC32C
467endif
468
469CFLAGS += $(C_WARNING_FLAGS) $(WARNING_FLAGS) -I. -I./include $(PLATFORM_CCFLAGS) $(OPT)
470CXXFLAGS += $(WARNING_FLAGS) -I. -I./include $(PLATFORM_CXXFLAGS) $(OPT) -Woverloaded-virtual -Wnon-virtual-dtor -Wno-missing-field-initializers
471
472LDFLAGS += $(PLATFORM_LDFLAGS)
473
474LIB_OBJECTS = $(patsubst %.cc, $(OBJ_DIR)/%.o, $(LIB_SOURCES))
475LIB_OBJECTS += $(patsubst %.cc, $(OBJ_DIR)/%.o, $(ROCKSDB_PLUGIN_SOURCES))
476ifeq ($(HAVE_POWER8),1)
477LIB_OBJECTS += $(patsubst %.c, $(OBJ_DIR)/%.o, $(LIB_SOURCES_C))
478LIB_OBJECTS += $(patsubst %.S, $(OBJ_DIR)/%.o, $(LIB_SOURCES_ASM))
479endif
480
481ifeq ($(USE_FOLLY_DISTRIBUTED_MUTEX),1)
482  LIB_OBJECTS += $(patsubst %.cpp, $(OBJ_DIR)/%.o, $(FOLLY_SOURCES))
483endif
484
485# range_tree is not compatible with non GNU libc on ppc64
486# see https://jira.percona.com/browse/PS-7559
487ifneq ($(PPC_LIBC_IS_GNU),0)
488  LIB_OBJECTS += $(patsubst %.cc, $(OBJ_DIR)/%.o, $(RANGE_TREE_SOURCES))
489endif
490
491GTEST = $(OBJ_DIR)/$(GTEST_DIR)/gtest/gtest-all.o
492TESTUTIL = $(OBJ_DIR)/test_util/testutil.o
493TESTHARNESS = $(OBJ_DIR)/test_util/testharness.o $(TESTUTIL) $(GTEST)
494VALGRIND_ERROR = 2
495VALGRIND_VER := $(join $(VALGRIND_VER),valgrind)
496
497VALGRIND_OPTS = --error-exitcode=$(VALGRIND_ERROR) --leak-check=full
498# Not yet supported: --show-leak-kinds=definite,possible,reachable --errors-for-leak-kinds=definite,possible,reachable
499
500TEST_OBJECTS = $(patsubst %.cc, $(OBJ_DIR)/%.o, $(TEST_LIB_SOURCES) $(MOCK_LIB_SOURCES)) $(GTEST)
501BENCH_OBJECTS = $(patsubst %.cc, $(OBJ_DIR)/%.o, $(BENCH_LIB_SOURCES))
502CACHE_BENCH_OBJECTS = $(patsubst %.cc, $(OBJ_DIR)/%.o, $(CACHE_BENCH_LIB_SOURCES))
503TOOL_OBJECTS = $(patsubst %.cc, $(OBJ_DIR)/%.o, $(TOOL_LIB_SOURCES))
504ANALYZE_OBJECTS = $(patsubst %.cc, $(OBJ_DIR)/%.o, $(ANALYZER_LIB_SOURCES))
505STRESS_OBJECTS =  $(patsubst %.cc, $(OBJ_DIR)/%.o, $(STRESS_LIB_SOURCES))
506
507# Exclude build_version.cc -- a generated source file -- from all sources.  Not needed for dependencies
508ALL_SOURCES  = $(filter-out util/build_version.cc, $(LIB_SOURCES)) $(TEST_LIB_SOURCES) $(MOCK_LIB_SOURCES) $(GTEST_DIR)/gtest/gtest-all.cc
509ALL_SOURCES += $(TOOL_LIB_SOURCES) $(BENCH_LIB_SOURCES) $(CACHE_BENCH_LIB_SOURCES) $(ANALYZER_LIB_SOURCES) $(STRESS_LIB_SOURCES)
510ALL_SOURCES += $(TEST_MAIN_SOURCES) $(TOOL_MAIN_SOURCES) $(BENCH_MAIN_SOURCES)
511
512TESTS = $(patsubst %.cc, %, $(notdir $(TEST_MAIN_SOURCES)))
513TESTS += $(patsubst %.c, %, $(notdir $(TEST_MAIN_SOURCES_C)))
514
515ifeq ($(USE_FOLLY_DISTRIBUTED_MUTEX),1)
516	TESTS += folly_synchronization_distributed_mutex_test
517	ALL_SOURCES += third-party/folly/folly/synchronization/test/DistributedMutexTest.cc
518endif
519
520# `make check-headers` to very that each header file includes its own
521# dependencies
522ifneq ($(filter check-headers, $(MAKECMDGOALS)),)
523# TODO: add/support JNI headers
524	DEV_HEADER_DIRS := $(sort include/ hdfs/ $(dir $(ALL_SOURCES)))
525# Some headers like in port/ are platform-specific
526	DEV_HEADERS := $(shell $(FIND) $(DEV_HEADER_DIRS) -type f -name '*.h' | egrep -v 'port/|plugin/|lua/|range_tree/|tools/rdb/db_wrapper.h|include/rocksdb/utilities/env_librados.h')
527else
528	DEV_HEADERS :=
529endif
530HEADER_OK_FILES = $(patsubst %.h, %.h.ok, $(DEV_HEADERS))
531
532AM_V_CCH = $(am__v_CCH_$(V))
533am__v_CCH_ = $(am__v_CCH_$(AM_DEFAULT_VERBOSITY))
534am__v_CCH_0 = @echo "  CC.h    " $<;
535am__v_CCH_1 =
536
537%.h.ok: %.h # .h.ok not actually created, so re-checked on each invocation
538# -DROCKSDB_NAMESPACE=42 ensures the namespace header is included
539	$(AM_V_CCH) echo '#include "$<"' | $(CXX) $(CXXFLAGS) -DROCKSDB_NAMESPACE=42 -x c++ -c - -o /dev/null
540
541check-headers: $(HEADER_OK_FILES)
542
543# options_settable_test doesn't pass with UBSAN as we use hack in the test
544ifdef COMPILE_WITH_UBSAN
545        TESTS := $(shell echo $(TESTS) | sed 's/\boptions_settable_test\b//g')
546endif
547ifdef ASSERT_STATUS_CHECKED
548	# TODO: finish fixing all tests to pass this check
549	TESTS_FAILING_ASC = \
550		c_test \
551		db_test \
552		env_test \
553		range_locking_test \
554		testutil_test \
555
556	# Since we have very few ASC exclusions left, excluding them from
557	# the build is the most convenient way to exclude them from testing
558	TESTS := $(filter-out $(TESTS_FAILING_ASC),$(TESTS))
559endif
560
561ROCKSDBTESTS_SUBSET ?= $(TESTS)
562
563# env_test - suspicious use of test::TmpDir
564# deletefile_test - serial because it generates giant temporary files in
565#   its various tests. Parallel can fill up your /dev/shm
566NON_PARALLEL_TEST = \
567	env_test \
568	deletefile_test \
569
570PARALLEL_TEST = $(filter-out $(NON_PARALLEL_TEST), $(TESTS))
571
572# Not necessarily well thought out or up-to-date, but matches old list
573TESTS_PLATFORM_DEPENDENT := \
574	db_basic_test \
575	db_blob_basic_test \
576	db_encryption_test \
577	db_test2 \
578	external_sst_file_basic_test \
579	auto_roll_logger_test \
580	bloom_test \
581	dynamic_bloom_test \
582	c_test \
583	checkpoint_test \
584	crc32c_test \
585	coding_test \
586	inlineskiplist_test \
587	env_basic_test \
588	env_test \
589	env_logger_test \
590	io_posix_test \
591	hash_test \
592	random_test \
593	ribbon_test \
594	thread_local_test \
595	work_queue_test \
596	rate_limiter_test \
597	perf_context_test \
598	iostats_context_test \
599	db_wal_test \
600
601# Sort ROCKSDBTESTS_SUBSET for filtering, except db_test is special (expensive)
602# so is placed first (out-of-order)
603ROCKSDBTESTS_SUBSET := $(filter db_test, $(ROCKSDBTESTS_SUBSET)) $(sort $(filter-out db_test, $(ROCKSDBTESTS_SUBSET)))
604
605ifdef ROCKSDBTESTS_START
606        ROCKSDBTESTS_SUBSET := $(shell echo $(ROCKSDBTESTS_SUBSET) | sed 's/^.*$(ROCKSDBTESTS_START)/$(ROCKSDBTESTS_START)/')
607endif
608
609ifdef ROCKSDBTESTS_END
610        ROCKSDBTESTS_SUBSET := $(shell echo $(ROCKSDBTESTS_SUBSET) | sed 's/$(ROCKSDBTESTS_END).*//')
611endif
612
613ifeq ($(ROCKSDBTESTS_PLATFORM_DEPENDENT), only)
614        ROCKSDBTESTS_SUBSET := $(filter $(TESTS_PLATFORM_DEPENDENT), $(ROCKSDBTESTS_SUBSET))
615else ifeq ($(ROCKSDBTESTS_PLATFORM_DEPENDENT), exclude)
616        ROCKSDBTESTS_SUBSET := $(filter-out $(TESTS_PLATFORM_DEPENDENT), $(ROCKSDBTESTS_SUBSET))
617endif
618
619# bench_tool_analyer main is in bench_tool_analyzer_tool, or this would be simpler...
620TOOLS = $(patsubst %.cc, %, $(notdir $(patsubst %_tool.cc, %.cc, $(TOOLS_MAIN_SOURCES))))
621
622TEST_LIBS = \
623	librocksdb_env_basic_test.a
624
625# TODO: add back forward_iterator_bench, after making it build in all environemnts.
626BENCHMARKS = $(patsubst %.cc, %, $(notdir $(BENCH_MAIN_SOURCES)))
627
628MICROBENCHS = $(patsubst %.cc, %, $(notdir $(MICROBENCH_SOURCES)))
629
630# if user didn't config LIBNAME, set the default
631ifeq ($(LIBNAME),)
632  LIBNAME=librocksdb
633# we should only run rocksdb in production with DEBUG_LEVEL 0
634ifneq ($(DEBUG_LEVEL),0)
635  LIBDEBUG=_debug
636endif
637endif
638STATIC_LIBRARY = ${LIBNAME}$(LIBDEBUG).a
639STATIC_TEST_LIBRARY =  ${LIBNAME}_test$(LIBDEBUG).a
640STATIC_TOOLS_LIBRARY = ${LIBNAME}_tools$(LIBDEBUG).a
641STATIC_STRESS_LIBRARY = ${LIBNAME}_stress$(LIBDEBUG).a
642
643ALL_STATIC_LIBS = $(STATIC_LIBRARY) $(STATIC_TEST_LIBRARY) $(STATIC_TOOLS_LIBRARY) $(STATIC_STRESS_LIBRARY)
644
645SHARED_TEST_LIBRARY =  ${LIBNAME}_test$(LIBDEBUG).$(PLATFORM_SHARED_EXT)
646SHARED_TOOLS_LIBRARY = ${LIBNAME}_tools$(LIBDEBUG).$(PLATFORM_SHARED_EXT)
647SHARED_STRESS_LIBRARY = ${LIBNAME}_stress$(LIBDEBUG).$(PLATFORM_SHARED_EXT)
648
649ALL_SHARED_LIBS = $(SHARED1) $(SHARED2) $(SHARED3) $(SHARED4) $(SHARED_TEST_LIBRARY) $(SHARED_TOOLS_LIBRARY) $(SHARED_STRESS_LIBRARY)
650
651ifeq ($(LIB_MODE),shared)
652LIBRARY=$(SHARED1)
653TEST_LIBRARY=$(SHARED_TEST_LIBRARY)
654TOOLS_LIBRARY=$(SHARED_TOOLS_LIBRARY)
655STRESS_LIBRARY=$(SHARED_STRESS_LIBRARY)
656CLOUD_LIBRARY=$(SHARED_CLOUD_LIBRARY)
657else
658LIBRARY=$(STATIC_LIBRARY)
659TEST_LIBRARY=$(STATIC_TEST_LIBRARY)
660TOOLS_LIBRARY=$(STATIC_TOOLS_LIBRARY)
661endif
662STRESS_LIBRARY=$(STATIC_STRESS_LIBRARY)
663
664ROCKSDB_MAJOR = $(shell egrep "ROCKSDB_MAJOR.[0-9]" include/rocksdb/version.h | cut -d ' ' -f 3)
665ROCKSDB_MINOR = $(shell egrep "ROCKSDB_MINOR.[0-9]" include/rocksdb/version.h | cut -d ' ' -f 3)
666ROCKSDB_PATCH = $(shell egrep "ROCKSDB_PATCH.[0-9]" include/rocksdb/version.h | cut -d ' ' -f 3)
667
668# If NO_UPDATE_BUILD_VERSION is set we don't update util/build_version.cc, but
669# the file needs to already exist or else the build will fail
670ifndef NO_UPDATE_BUILD_VERSION
671
672# By default, use the current date-time as the date.  If there are no changes,
673# we will use the last commit date instead.
674build_date := $(shell date "+%Y-%m-%d %T")
675
676ifdef FORCE_GIT_SHA
677	git_sha := $(FORCE_GIT_SHA)
678	git_mod := 1
679	git_date := $(build_date)
680else
681	git_sha := $(shell git rev-parse HEAD 2>/dev/null)
682	git_tag  := $(shell git symbolic-ref -q --short HEAD 2> /dev/null || git describe --tags --exact-match 2>/dev/null)
683	git_mod  := $(shell git diff-index HEAD --quiet 2>/dev/null; echo $$?)
684	git_date := $(shell git log -1 --date=format:"%Y-%m-%d %T" --format="%ad" 2>/dev/null)
685endif
686gen_build_version = sed -e s/@GIT_SHA@/$(git_sha)/ -e s:@GIT_TAG@:"$(git_tag)": -e s/@GIT_MOD@/"$(git_mod)"/ -e s/@BUILD_DATE@/"$(build_date)"/ -e s/@GIT_DATE@/"$(git_date)"/ util/build_version.cc.in
687
688# Record the version of the source that we are compiling.
689# We keep a record of the git revision in this file.  It is then built
690# as a regular source file as part of the compilation process.
691# One can run "strings executable_filename | grep _build_" to find
692# the version of the source that we used to build the executable file.
693util/build_version.cc: $(filter-out $(OBJ_DIR)/util/build_version.o, $(LIB_OBJECTS)) util/build_version.cc.in
694	$(AM_V_GEN)rm -f $@-t
695	$(AM_V_at)$(gen_build_version) > $@
696endif
697CLEAN_FILES += util/build_version.cc
698
699default: all
700
701#-----------------------------------------------
702# Create platform independent shared libraries.
703#-----------------------------------------------
704ifneq ($(PLATFORM_SHARED_EXT),)
705
706ifneq ($(PLATFORM_SHARED_VERSIONED),true)
707SHARED1 = ${LIBNAME}$(LIBDEBUG).$(PLATFORM_SHARED_EXT)
708SHARED2 = $(SHARED1)
709SHARED3 = $(SHARED1)
710SHARED4 = $(SHARED1)
711SHARED = $(SHARED1)
712else
713SHARED_MAJOR = $(ROCKSDB_MAJOR)
714SHARED_MINOR = $(ROCKSDB_MINOR)
715SHARED_PATCH = $(ROCKSDB_PATCH)
716SHARED1 = ${LIBNAME}.$(PLATFORM_SHARED_EXT)
717ifeq ($(PLATFORM), OS_MACOSX)
718SHARED_OSX = $(LIBNAME)$(LIBDEBUG).$(SHARED_MAJOR)
719SHARED2 = $(SHARED_OSX).$(PLATFORM_SHARED_EXT)
720SHARED3 = $(SHARED_OSX).$(SHARED_MINOR).$(PLATFORM_SHARED_EXT)
721SHARED4 = $(SHARED_OSX).$(SHARED_MINOR).$(SHARED_PATCH).$(PLATFORM_SHARED_EXT)
722else
723SHARED2 = $(SHARED1).$(SHARED_MAJOR)
724SHARED3 = $(SHARED1).$(SHARED_MAJOR).$(SHARED_MINOR)
725SHARED4 = $(SHARED1).$(SHARED_MAJOR).$(SHARED_MINOR).$(SHARED_PATCH)
726endif # MACOSX
727SHARED = $(SHARED1) $(SHARED2) $(SHARED3) $(SHARED4)
728$(SHARED1): $(SHARED4) $(SHARED2)
729	ln -fs $(SHARED4) $(SHARED1)
730$(SHARED2): $(SHARED4) $(SHARED3)
731	ln -fs $(SHARED4) $(SHARED2)
732$(SHARED3): $(SHARED4)
733	ln -fs $(SHARED4) $(SHARED3)
734
735endif   # PLATFORM_SHARED_VERSIONED
736$(SHARED4): $(LIB_OBJECTS)
737	$(AM_V_CCLD) $(CXX) $(PLATFORM_SHARED_LDFLAGS)$(SHARED3) $(LIB_OBJECTS) $(LDFLAGS) -o $@
738endif  # PLATFORM_SHARED_EXT
739
740.PHONY: blackbox_crash_test check clean coverage crash_test ldb_tests package \
741	release tags tags0 valgrind_check whitebox_crash_test format static_lib shared_lib all \
742	dbg rocksdbjavastatic rocksdbjava gen-pc install install-static install-shared uninstall \
743	analyze tools tools_lib check-headers \
744	blackbox_crash_test_with_atomic_flush whitebox_crash_test_with_atomic_flush  \
745	blackbox_crash_test_with_txn whitebox_crash_test_with_txn \
746	blackbox_crash_test_with_best_efforts_recovery \
747	blackbox_crash_test_with_ts whitebox_crash_test_with_ts
748
749
750all: $(LIBRARY) $(BENCHMARKS) tools tools_lib test_libs # $(TESTS)
751
752all_but_some_tests: $(LIBRARY) $(BENCHMARKS) tools tools_lib test_libs $(ROCKSDBTESTS_SUBSET)
753
754static_lib: $(STATIC_LIBRARY)
755
756shared_lib: $(SHARED)
757
758stress_lib: $(STRESS_LIBRARY)
759
760tools: $(TOOLS)
761
762tools_lib: $(TOOLS_LIBRARY)
763
764test_libs: $(TEST_LIBS)
765
766benchmarks: $(BENCHMARKS)
767
768microbench: $(MICROBENCHS)
769	for t in $(MICROBENCHS); do echo "===== Running benchmark $$t (`date`)"; ./$$t || exit 1; done;
770
771dbg: $(LIBRARY) $(BENCHMARKS) tools $(TESTS)
772
773# creates library and programs
774release: clean
775	LIB_MODE=$(LIB_MODE) DEBUG_LEVEL=0 $(MAKE) $(LIBRARY) tools db_bench
776
777coverage: clean
778	COVERAGEFLAGS="-fprofile-arcs -ftest-coverage" LDFLAGS+="-lgcov" $(MAKE) J=1 all check
779	cd coverage && ./coverage_test.sh
780        # Delete intermediate files
781	$(FIND) . -type f -regex ".*\.\(\(gcda\)\|\(gcno\)\)" -exec rm -f {} \;
782
783ifneq (,$(filter check parallel_check,$(MAKECMDGOALS)),)
784# Use /dev/shm if it has the sticky bit set (otherwise, /tmp),
785# and create a randomly-named rocksdb.XXXX directory therein.
786# We'll use that directory in the "make check" rules.
787ifeq ($(TMPD),)
788TMPDIR := $(shell echo $${TMPDIR:-/tmp})
789TMPD := $(shell f=/dev/shm; test -k $$f || f=$(TMPDIR);     \
790  perl -le 'use File::Temp "tempdir";'					\
791    -e 'print tempdir("'$$f'/rocksdb.XXXX", CLEANUP => 0)')
792endif
793endif
794
795# Run all tests in parallel, accumulating per-test logs in t/log-*.
796#
797# Each t/run-* file is a tiny generated bourne shell script that invokes one of
798# sub-tests. Why use a file for this?  Because that makes the invocation of
799# parallel below simpler, which in turn makes the parsing of parallel's
800# LOG simpler (the latter is for live monitoring as parallel
801# tests run).
802#
803# Test names are extracted by running tests with --gtest_list_tests.
804# This filter removes the "#"-introduced comments, and expands to
805# fully-qualified names by changing input like this:
806#
807#   DBTest.
808#     Empty
809#     WriteEmptyBatch
810#   MultiThreaded/MultiThreadedDBTest.
811#     MultiThreaded/0  # GetParam() = 0
812#     MultiThreaded/1  # GetParam() = 1
813#
814# into this:
815#
816#   DBTest.Empty
817#   DBTest.WriteEmptyBatch
818#   MultiThreaded/MultiThreadedDBTest.MultiThreaded/0
819#   MultiThreaded/MultiThreadedDBTest.MultiThreaded/1
820#
821
822parallel_tests = $(patsubst %,parallel_%,$(PARALLEL_TEST))
823.PHONY: gen_parallel_tests $(parallel_tests)
824$(parallel_tests): $(PARALLEL_TEST)
825	$(AM_V_at)TEST_BINARY=$(patsubst parallel_%,%,$@); \
826  TEST_NAMES=` \
827    ./$$TEST_BINARY --gtest_list_tests \
828    | perl -n \
829      -e 's/ *\#.*//;' \
830      -e '/^(\s*)(\S+)/; !$$1 and do {$$p=$$2; break};'	\
831      -e 'print qq! $$p$$2!'`; \
832	for TEST_NAME in $$TEST_NAMES; do \
833		TEST_SCRIPT=t/run-$$TEST_BINARY-$${TEST_NAME//\//-}; \
834		echo "  GEN     " $$TEST_SCRIPT; \
835    printf '%s\n' \
836      '#!/bin/sh' \
837      "d=\$(TMPD)$$TEST_SCRIPT" \
838      'mkdir -p $$d' \
839      "TEST_TMPDIR=\$$d $(DRIVER) ./$$TEST_BINARY --gtest_filter=$$TEST_NAME" \
840		> $$TEST_SCRIPT; \
841		chmod a=rx $$TEST_SCRIPT; \
842	done
843
844gen_parallel_tests:
845	$(AM_V_at)mkdir -p t
846	$(AM_V_at)$(FIND) t -type f -name 'run-*' -exec rm -f {} \;
847	$(MAKE) $(parallel_tests)
848
849# Reorder input lines (which are one per test) so that the
850# longest-running tests appear first in the output.
851# Do this by prefixing each selected name with its duration,
852# sort the resulting names, and remove the leading numbers.
853# FIXME: the "100" we prepend is a fake time, for now.
854# FIXME: squirrel away timings from each run and use them
855# (when present) on subsequent runs to order these tests.
856#
857# Without this reordering, these two tests would happen to start only
858# after almost all other tests had completed, thus adding 100 seconds
859# to the duration of parallel "make check".  That's the difference
860# between 4 minutes (old) and 2m20s (new).
861#
862# 152.120 PASS t/DBTest.FileCreationRandomFailure
863# 107.816 PASS t/DBTest.EncodeDecompressedBlockSizeTest
864#
865slow_test_regexp = \
866	^.*SnapshotConcurrentAccessTest.*$$|^.*SeqAdvanceConcurrentTest.*$$|^t/run-table_test-HarnessTest.Randomized$$|^t/run-db_test-.*(?:FileCreationRandomFailure|EncodeDecompressedBlockSizeTest)$$|^.*RecoverFromCorruptedWALWithoutFlush$$
867prioritize_long_running_tests =						\
868  perl -pe 's,($(slow_test_regexp)),100 $$1,'				\
869    | sort -k1,1gr							\
870    | sed 's/^[.0-9]* //'
871
872# "make check" uses
873# Run with "make J=1 check" to disable parallelism in "make check".
874# Run with "make J=200% check" to run two parallel jobs per core.
875# The default is to run one job per core (J=100%).
876# See "man parallel" for its "-j ..." option.
877J ?= 100%
878
879# Use this regexp to select the subset of tests whose names match.
880tests-regexp = .
881EXCLUDE_TESTS_REGEX ?= "^$"
882
883ifeq ($(PRINT_PARALLEL_OUTPUTS), 1)
884	parallel_com = '{}'
885else
886	parallel_com = '{} >& t/log-{/}'
887endif
888
889.PHONY: check_0
890check_0:
891	$(AM_V_GEN)export TEST_TMPDIR=$(TMPD); \
892	printf '%s\n' ''						\
893	  'To monitor subtest <duration,pass/fail,name>,'		\
894	  '  run "make watch-log" in a separate window' '';		\
895	test -t 1 && eta=--eta || eta=; \
896	{ \
897		printf './%s\n' $(filter-out $(PARALLEL_TEST),$(TESTS)); \
898		find t -name 'run-*' -print; \
899	} \
900	  | $(prioritize_long_running_tests)				\
901	  | grep -E '$(tests-regexp)'					\
902	  | grep -E -v '$(EXCLUDE_TESTS_REGEX)'					\
903	  | build_tools/gnu_parallel -j$(J) --plain --joblog=LOG $$eta --gnu  $(parallel_com) ; \
904	parallel_retcode=$$? ; \
905	awk '{ if ($$7 != 0 || $$8 != 0) { if ($$7 == "Exitval") { h = $$0; } else { if (!f) print h; print; f = 1 } } } END { if(f) exit 1; }' < LOG ; \
906	awk_retcode=$$?; \
907	if [ $$parallel_retcode -ne 0 ] || [ $$awk_retcode -ne 0 ] ; then exit 1 ; fi
908
909valgrind-exclude-regexp = InlineSkipTest.ConcurrentInsert|TransactionStressTest.DeadlockStress|DBCompactionTest.SuggestCompactRangeNoTwoLevel0Compactions|BackupableDBTest.RateLimiting|DBTest.CloseSpeedup|DBTest.ThreadStatusFlush|DBTest.RateLimitingTest|DBTest.EncodeDecompressedBlockSizeTest|FaultInjectionTest.UninstalledCompaction|HarnessTest.Randomized|ExternalSSTFileTest.CompactDuringAddFileRandom|ExternalSSTFileTest.IngestFileWithGlobalSeqnoRandomized|MySQLStyleTransactionTest.TransactionStressTest
910
911.PHONY: valgrind_check_0
912valgrind_check_0:
913	$(AM_V_GEN)export TEST_TMPDIR=$(TMPD);				\
914	printf '%s\n' ''						\
915	  'To monitor subtest <duration,pass/fail,name>,'		\
916	  '  run "make watch-log" in a separate window' '';		\
917	test -t 1 && eta=--eta || eta=;					\
918	{								\
919	  printf './%s\n' $(filter-out $(PARALLEL_TEST) %skiplist_test options_settable_test, $(TESTS));		\
920	  find t -name 'run-*' -print; \
921	}								\
922	  | $(prioritize_long_running_tests)				\
923	  | grep -E '$(tests-regexp)'					\
924	  | grep -E -v '$(valgrind-exclude-regexp)'					\
925	  | build_tools/gnu_parallel -j$(J) --plain --joblog=LOG $$eta --gnu \
926	  '(if [[ "{}" == "./"* ]] ; then $(DRIVER) {}; else {}; fi) ' \
927	  '>& t/valgrind_log-{/}'
928
929CLEAN_FILES += t LOG $(TMPD)
930
931# When running parallel "make check", you can monitor its progress
932# from another window.
933# Run "make watch_LOG" to show the duration,PASS/FAIL,name of parallel
934# tests as they are being run.  We sort them so that longer-running ones
935# appear at the top of the list and any failing tests remain at the top
936# regardless of their duration. As with any use of "watch", hit ^C to
937# interrupt.
938watch-log:
939	$(WATCH) --interval=0 'sort -k7,7nr -k4,4gr LOG|$(quoted_perl_command)'
940
941dump-log:
942	bash -c '$(quoted_perl_command)' < LOG
943
944# If J != 1 and GNU parallel is installed, run the tests in parallel,
945# via the check_0 rule above.  Otherwise, run them sequentially.
946check: all
947	$(MAKE) gen_parallel_tests
948	$(AM_V_GEN)if test "$(J)" != 1                                  \
949	    && (build_tools/gnu_parallel --gnu --help 2>/dev/null) |                    \
950	        grep -q 'GNU Parallel';                                 \
951	then                                                            \
952	    $(MAKE) T="$$t" TMPD=$(TMPD) check_0;                       \
953	else                                                            \
954	    for t in $(TESTS); do                                       \
955	      echo "===== Running $$t (`date`)"; ./$$t || exit 1; done;          \
956	fi
957	rm -rf $(TMPD)
958ifneq ($(PLATFORM), OS_AIX)
959	$(PYTHON) tools/check_all_python.py
960ifeq ($(filter -DROCKSDB_LITE,$(OPT)),)
961ifndef ASSERT_STATUS_CHECKED # not yet working with these tests
962	$(PYTHON) tools/ldb_test.py
963	sh tools/rocksdb_dump_test.sh
964endif
965endif
966endif
967ifndef SKIP_FORMAT_BUCK_CHECKS
968	$(MAKE) check-format
969	$(MAKE) check-buck-targets
970	$(MAKE) check-sources
971endif
972
973# TODO add ldb_tests
974check_some: $(ROCKSDBTESTS_SUBSET)
975	for t in $(ROCKSDBTESTS_SUBSET); do echo "===== Running $$t (`date`)"; ./$$t || exit 1; done
976
977.PHONY: ldb_tests
978ldb_tests: ldb
979	$(PYTHON) tools/ldb_test.py
980
981crash_test: whitebox_crash_test blackbox_crash_test
982
983crash_test_with_atomic_flush: whitebox_crash_test_with_atomic_flush blackbox_crash_test_with_atomic_flush
984
985crash_test_with_txn: whitebox_crash_test_with_txn blackbox_crash_test_with_txn
986
987crash_test_with_best_efforts_recovery: blackbox_crash_test_with_best_efforts_recovery
988
989crash_test_with_ts: whitebox_crash_test_with_ts blackbox_crash_test_with_ts
990
991blackbox_crash_test: db_stress
992	$(PYTHON) -u tools/db_crashtest.py --simple blackbox $(CRASH_TEST_EXT_ARGS)
993	$(PYTHON) -u tools/db_crashtest.py blackbox $(CRASH_TEST_EXT_ARGS)
994
995blackbox_crash_test_with_atomic_flush: db_stress
996	$(PYTHON) -u tools/db_crashtest.py --cf_consistency blackbox $(CRASH_TEST_EXT_ARGS)
997
998blackbox_crash_test_with_txn: db_stress
999	$(PYTHON) -u tools/db_crashtest.py --txn blackbox $(CRASH_TEST_EXT_ARGS)
1000
1001blackbox_crash_test_with_best_efforts_recovery: db_stress
1002	$(PYTHON) -u tools/db_crashtest.py --test_best_efforts_recovery blackbox $(CRASH_TEST_EXT_ARGS)
1003
1004blackbox_crash_test_with_ts: db_stress
1005	$(PYTHON) -u tools/db_crashtest.py --enable_ts blackbox $(CRASH_TEST_EXT_ARGS)
1006
1007ifeq ($(CRASH_TEST_KILL_ODD),)
1008  CRASH_TEST_KILL_ODD=888887
1009endif
1010
1011whitebox_crash_test: db_stress
1012	$(PYTHON) -u tools/db_crashtest.py --simple whitebox --random_kill_odd \
1013      $(CRASH_TEST_KILL_ODD) $(CRASH_TEST_EXT_ARGS)
1014	$(PYTHON) -u tools/db_crashtest.py whitebox  --random_kill_odd \
1015      $(CRASH_TEST_KILL_ODD) $(CRASH_TEST_EXT_ARGS)
1016
1017whitebox_crash_test_with_atomic_flush: db_stress
1018	$(PYTHON) -u tools/db_crashtest.py --cf_consistency whitebox  --random_kill_odd \
1019      $(CRASH_TEST_KILL_ODD) $(CRASH_TEST_EXT_ARGS)
1020
1021whitebox_crash_test_with_txn: db_stress
1022	$(PYTHON) -u tools/db_crashtest.py --txn whitebox --random_kill_odd \
1023      $(CRASH_TEST_KILL_ODD) $(CRASH_TEST_EXT_ARGS)
1024
1025whitebox_crash_test_with_ts: db_stress
1026	$(PYTHON) -u tools/db_crashtest.py --enable_ts whitebox --random_kill_odd \
1027      $(CRASH_TEST_KILL_ODD) $(CRASH_TEST_EXT_ARGS)
1028
1029asan_check: clean
1030	COMPILE_WITH_ASAN=1 $(MAKE) check -j32
1031	$(MAKE) clean
1032
1033asan_crash_test: clean
1034	COMPILE_WITH_ASAN=1 $(MAKE) crash_test
1035	$(MAKE) clean
1036
1037whitebox_asan_crash_test: clean
1038	COMPILE_WITH_ASAN=1 $(MAKE) whitebox_crash_test
1039	$(MAKE) clean
1040
1041blackbox_asan_crash_test: clean
1042	COMPILE_WITH_ASAN=1 $(MAKE) blackbox_crash_test
1043	$(MAKE) clean
1044
1045asan_crash_test_with_atomic_flush: clean
1046	COMPILE_WITH_ASAN=1 $(MAKE) crash_test_with_atomic_flush
1047	$(MAKE) clean
1048
1049asan_crash_test_with_txn: clean
1050	COMPILE_WITH_ASAN=1 $(MAKE) crash_test_with_txn
1051	$(MAKE) clean
1052
1053asan_crash_test_with_best_efforts_recovery: clean
1054	COMPILE_WITH_ASAN=1 $(MAKE) crash_test_with_best_efforts_recovery
1055	$(MAKE) clean
1056
1057ubsan_check: clean
1058	COMPILE_WITH_UBSAN=1 $(MAKE) check -j32
1059	$(MAKE) clean
1060
1061ubsan_crash_test: clean
1062	COMPILE_WITH_UBSAN=1 $(MAKE) crash_test
1063	$(MAKE) clean
1064
1065whitebox_ubsan_crash_test: clean
1066	COMPILE_WITH_UBSAN=1 $(MAKE) whitebox_crash_test
1067	$(MAKE) clean
1068
1069blackbox_ubsan_crash_test: clean
1070	COMPILE_WITH_UBSAN=1 $(MAKE) blackbox_crash_test
1071	$(MAKE) clean
1072
1073ubsan_crash_test_with_atomic_flush: clean
1074	COMPILE_WITH_UBSAN=1 $(MAKE) crash_test_with_atomic_flush
1075	$(MAKE) clean
1076
1077ubsan_crash_test_with_txn: clean
1078	COMPILE_WITH_UBSAN=1 $(MAKE) crash_test_with_txn
1079	$(MAKE) clean
1080
1081ubsan_crash_test_with_best_efforts_recovery: clean
1082	COMPILE_WITH_UBSAN=1 $(MAKE) crash_test_with_best_efforts_recovery
1083	$(MAKE) clean
1084
1085full_valgrind_test:
1086	ROCKSDB_FULL_VALGRIND_RUN=1 DISABLE_JEMALLOC=1 $(MAKE) valgrind_check
1087
1088full_valgrind_test_some:
1089	ROCKSDB_FULL_VALGRIND_RUN=1 DISABLE_JEMALLOC=1 $(MAKE) valgrind_check_some
1090
1091valgrind_test:
1092	ROCKSDB_VALGRIND_RUN=1 DISABLE_JEMALLOC=1 $(MAKE) valgrind_check
1093
1094valgrind_test_some:
1095	ROCKSDB_VALGRIND_RUN=1 DISABLE_JEMALLOC=1 $(MAKE) valgrind_check_some
1096
1097valgrind_check: $(TESTS)
1098	$(MAKE) DRIVER="$(VALGRIND_VER) $(VALGRIND_OPTS)" gen_parallel_tests
1099	$(AM_V_GEN)if test "$(J)" != 1                                  \
1100	    && (build_tools/gnu_parallel --gnu --help 2>/dev/null) |                    \
1101	        grep -q 'GNU Parallel';                                 \
1102	then                                                            \
1103      $(MAKE) TMPD=$(TMPD)                                        \
1104      DRIVER="$(VALGRIND_VER) $(VALGRIND_OPTS)" valgrind_check_0; \
1105	else                                                            \
1106		for t in $(filter-out %skiplist_test options_settable_test,$(TESTS)); do \
1107			$(VALGRIND_VER) $(VALGRIND_OPTS) ./$$t; \
1108			ret_code=$$?; \
1109			if [ $$ret_code -ne 0 ]; then \
1110				exit $$ret_code; \
1111			fi; \
1112		done; \
1113	fi
1114
1115valgrind_check_some: $(ROCKSDBTESTS_SUBSET)
1116	for t in $(ROCKSDBTESTS_SUBSET); do \
1117		$(VALGRIND_VER) $(VALGRIND_OPTS) ./$$t; \
1118		ret_code=$$?; \
1119		if [ $$ret_code -ne 0 ]; then \
1120			exit $$ret_code; \
1121		fi; \
1122	done
1123
1124ifneq ($(PAR_TEST),)
1125parloop:
1126	ret_bad=0;							\
1127	for t in $(PAR_TEST); do		\
1128		echo "===== Running $$t in parallel $(NUM_PAR) (`date`)";\
1129		if [ $(db_test) -eq 1 ]; then \
1130			seq $(J) | v="$$t" build_tools/gnu_parallel --gnu --plain 's=$(TMPD)/rdb-{};  export TEST_TMPDIR=$$s;' \
1131				'timeout 2m ./db_test --gtest_filter=$$v >> $$s/log-{} 2>1'; \
1132		else\
1133			seq $(J) | v="./$$t" build_tools/gnu_parallel --gnu --plain 's=$(TMPD)/rdb-{};' \
1134			     'export TEST_TMPDIR=$$s; timeout 10m $$v >> $$s/log-{} 2>1'; \
1135		fi; \
1136		ret_code=$$?; \
1137		if [ $$ret_code -ne 0 ]; then \
1138			ret_bad=$$ret_code; \
1139			echo $$t exited with $$ret_code; \
1140		fi; \
1141	done; \
1142	exit $$ret_bad;
1143endif
1144
1145test_names = \
1146  ./db_test --gtest_list_tests						\
1147    | perl -n								\
1148      -e 's/ *\#.*//;'							\
1149      -e '/^(\s*)(\S+)/; !$$1 and do {$$p=$$2; break};'			\
1150      -e 'print qq! $$p$$2!'
1151
1152parallel_check: $(TESTS)
1153	$(AM_V_GEN)if test "$(J)" > 1                                  \
1154	    && (build_tools/gnu_parallel --gnu --help 2>/dev/null) |                    \
1155	        grep -q 'GNU Parallel';                                 \
1156	then                                                            \
1157	    echo Running in parallel $(J);			\
1158	else                                                            \
1159	    echo "Need to have GNU Parallel and J > 1"; exit 1;		\
1160	fi;								\
1161	ret_bad=0;							\
1162	echo $(J);\
1163	echo Test Dir: $(TMPD); \
1164        seq $(J) | build_tools/gnu_parallel --gnu --plain 's=$(TMPD)/rdb-{}; rm -rf $$s; mkdir $$s'; \
1165	$(MAKE)  PAR_TEST="$(shell $(test_names))" TMPD=$(TMPD) \
1166		J=$(J) db_test=1 parloop; \
1167	$(MAKE) PAR_TEST="$(filter-out db_test, $(TESTS))" \
1168		TMPD=$(TMPD) J=$(J) db_test=0 parloop;
1169
1170analyze: clean
1171	USE_CLANG=1 $(MAKE) analyze_incremental
1172
1173analyze_incremental:
1174	$(CLANG_SCAN_BUILD) --use-analyzer=$(CLANG_ANALYZER) \
1175		--use-c++=$(CXX) --use-cc=$(CC) --status-bugs \
1176		-o $(CURDIR)/scan_build_report \
1177		$(MAKE) dbg
1178
1179CLEAN_FILES += unity.cc
1180unity.cc: Makefile util/build_version.cc.in
1181	rm -f $@ $@-t
1182	$(AM_V_at)$(gen_build_version) > util/build_version.cc
1183	for source_file in $(LIB_SOURCES); do \
1184		echo "#include \"$$source_file\"" >> $@-t; \
1185	done
1186	chmod a=r $@-t
1187	mv $@-t $@
1188
1189unity.a: $(OBJ_DIR)/unity.o
1190	$(AM_V_AR)rm -f $@
1191	$(AM_V_at)$(AR) $(ARFLAGS) $@ $(OBJ_DIR)/unity.o
1192
1193
1194# try compiling db_test with unity
1195unity_test: $(OBJ_DIR)/db/db_basic_test.o $(OBJ_DIR)/db/db_test_util.o $(TEST_OBJECTS) $(TOOL_OBJECTS) unity.a
1196	$(AM_LINK)
1197	./unity_test
1198
1199rocksdb.h rocksdb.cc: build_tools/amalgamate.py Makefile $(LIB_SOURCES) unity.cc
1200	build_tools/amalgamate.py -I. -i./include unity.cc -x include/rocksdb/c.h -H rocksdb.h -o rocksdb.cc
1201
1202clean: clean-ext-libraries-all clean-rocks clean-rocksjava
1203
1204clean-not-downloaded: clean-ext-libraries-bin clean-rocks clean-not-downloaded-rocksjava
1205
1206clean-rocks:
1207	echo shared=$(ALL_SHARED_LIBS)
1208	echo static=$(ALL_STATIC_LIBS)
1209	rm -f $(BENCHMARKS) $(TOOLS) $(TESTS) $(PARALLEL_TEST) $(ALL_STATIC_LIBS) $(ALL_SHARED_LIBS) $(MICROBENCHS)
1210	rm -rf $(CLEAN_FILES) ios-x86 ios-arm scan_build_report
1211	$(FIND) . -name "*.[oda]" -exec rm -f {} \;
1212	$(FIND) . -type f -regex ".*\.\(\(gcda\)\|\(gcno\)\)" -exec rm -f {} \;
1213
1214clean-rocksjava:
1215	rm -rf jl jls
1216	cd java && $(MAKE) clean
1217
1218clean-not-downloaded-rocksjava:
1219	cd java && $(MAKE) clean-not-downloaded
1220
1221clean-ext-libraries-all:
1222	rm -rf bzip2* snappy* zlib* lz4* zstd*
1223
1224clean-ext-libraries-bin:
1225	find . -maxdepth 1 -type d \( -name bzip2\* -or -name snappy\* -or -name zlib\* -or -name lz4\* -or -name zstd\* \) -prune -exec rm -rf {} \;
1226
1227tags:
1228	ctags -R .
1229	cscope -b `$(FIND) . -name '*.cc'` `$(FIND) . -name '*.h'` `$(FIND) . -name '*.c'`
1230	ctags -e -R -o etags *
1231
1232tags0:
1233	ctags -R .
1234	cscope -b `$(FIND) . -name '*.cc' -and ! -name '*_test.cc'` \
1235		  `$(FIND) . -name '*.c' -and ! -name '*_test.c'` \
1236		  `$(FIND) . -name '*.h' -and ! -name '*_test.h'`
1237	ctags -e -R -o etags *
1238
1239format:
1240	build_tools/format-diff.sh
1241
1242check-format:
1243	build_tools/format-diff.sh -c
1244
1245check-buck-targets:
1246	buckifier/check_buck_targets.sh
1247
1248check-sources:
1249	build_tools/check-sources.sh
1250
1251package:
1252	bash build_tools/make_package.sh $(SHARED_MAJOR).$(SHARED_MINOR)
1253
1254# ---------------------------------------------------------------------------
1255# 	Unit tests and tools
1256# ---------------------------------------------------------------------------
1257$(STATIC_LIBRARY): $(LIB_OBJECTS)
1258	$(AM_V_AR)rm -f $@ $(SHARED1) $(SHARED2) $(SHARED3) $(SHARED4)
1259	$(AM_V_at)$(AR) $(ARFLAGS) $@ $(LIB_OBJECTS)
1260
1261$(STATIC_TEST_LIBRARY): $(TEST_OBJECTS)
1262	$(AM_V_AR)rm -f $@ $(SHARED_TEST_LIBRARY)
1263	$(AM_V_at)$(AR) $(ARFLAGS) $@ $^
1264
1265$(STATIC_TOOLS_LIBRARY): $(TOOL_OBJECTS)
1266	$(AM_V_AR)rm -f $@ $(SHARED_TOOLS_LIBRARY)
1267	$(AM_V_at)$(AR) $(ARFLAGS) $@ $^
1268
1269$(STATIC_STRESS_LIBRARY): $(ANALYZE_OBJECTS) $(STRESS_OBJECTS) $(TESTUTIL)
1270	$(AM_V_AR)rm -f $@ $(SHARED_STRESS_LIBRARY)
1271	$(AM_V_at)$(AR) $(ARFLAGS) $@ $^
1272
1273$(SHARED_TEST_LIBRARY): $(TEST_OBJECTS) $(SHARED1)
1274	$(AM_V_AR)rm -f $@ $(STATIC_TEST_LIBRARY)
1275	$(AM_SHARE)
1276
1277$(SHARED_TOOLS_LIBRARY): $(TOOL_OBJECTS) $(SHARED1)
1278	$(AM_V_AR)rm -f $@ $(STATIC_TOOLS_LIBRARY)
1279	$(AM_SHARE)
1280
1281$(SHARED_STRESS_LIBRARY): $(ANALYZE_OBJECTS) $(STRESS_OBJECTS) $(TESTUTIL) $(SHARED_TOOLS_LIBRARY) $(SHARED1)
1282	$(AM_V_AR)rm -f $@ $(STATIC_STRESS_LIBRARY)
1283	$(AM_SHARE)
1284
1285librocksdb_env_basic_test.a: $(OBJ_DIR)/env/env_basic_test.o $(LIB_OBJECTS) $(TESTHARNESS)
1286	$(AM_V_AR)rm -f $@
1287	$(AM_V_at)$(AR) $(ARFLAGS) $@ $^
1288
1289db_bench: $(OBJ_DIR)/tools/db_bench.o $(BENCH_OBJECTS) $(TESTUTIL) $(LIBRARY)
1290	$(AM_LINK)
1291
1292trace_analyzer: $(OBJ_DIR)/tools/trace_analyzer.o $(ANALYZE_OBJECTS) $(TOOLS_LIBRARY) $(LIBRARY)
1293	$(AM_LINK)
1294
1295block_cache_trace_analyzer: $(OBJ_DIR)/tools/block_cache_analyzer/block_cache_trace_analyzer_tool.o $(ANALYZE_OBJECTS) $(TOOLS_LIBRARY) $(LIBRARY)
1296	$(AM_LINK)
1297
1298ifeq ($(USE_FOLLY_DISTRIBUTED_MUTEX),1)
1299folly_synchronization_distributed_mutex_test: $(OBJ_DIR)/third-party/folly/folly/synchronization/test/DistributedMutexTest.o $(TEST_LIBRARY) $(LIBRARY)
1300	$(AM_LINK)
1301endif
1302
1303cache_bench: $(OBJ_DIR)/cache/cache_bench.o $(CACHE_BENCH_OBJECTS) $(LIBRARY)
1304	$(AM_LINK)
1305
1306persistent_cache_bench: $(OBJ_DIR)/utilities/persistent_cache/persistent_cache_bench.o $(LIBRARY)
1307	$(AM_LINK)
1308
1309memtablerep_bench: $(OBJ_DIR)/memtable/memtablerep_bench.o $(LIBRARY)
1310	$(AM_LINK)
1311
1312filter_bench: $(OBJ_DIR)/util/filter_bench.o $(LIBRARY)
1313	$(AM_LINK)
1314
1315db_stress: $(OBJ_DIR)/db_stress_tool/db_stress.o $(STRESS_LIBRARY) $(TOOLS_LIBRARY) $(LIBRARY)
1316	$(AM_LINK)
1317
1318write_stress: $(OBJ_DIR)/tools/write_stress.o $(LIBRARY)
1319	$(AM_LINK)
1320
1321db_sanity_test: $(OBJ_DIR)/tools/db_sanity_test.o $(LIBRARY)
1322	$(AM_LINK)
1323
1324db_repl_stress: $(OBJ_DIR)/tools/db_repl_stress.o $(LIBRARY)
1325	$(AM_LINK)
1326
1327arena_test: $(OBJ_DIR)/memory/arena_test.o $(TEST_LIBRARY) $(LIBRARY)
1328	$(AM_LINK)
1329
1330memkind_kmem_allocator_test: memory/memkind_kmem_allocator_test.o $(TEST_LIBRARY) $(LIBRARY)
1331	$(AM_LINK)
1332
1333autovector_test: $(OBJ_DIR)/util/autovector_test.o $(TEST_LIBRARY) $(LIBRARY)
1334	$(AM_LINK)
1335
1336column_family_test: $(OBJ_DIR)/db/column_family_test.o $(TEST_LIBRARY) $(LIBRARY)
1337	$(AM_LINK)
1338
1339table_properties_collector_test: $(OBJ_DIR)/db/table_properties_collector_test.o $(TEST_LIBRARY) $(LIBRARY)
1340	$(AM_LINK)
1341
1342bloom_test: $(OBJ_DIR)/util/bloom_test.o $(TEST_LIBRARY) $(LIBRARY)
1343	$(AM_LINK)
1344
1345dynamic_bloom_test: $(OBJ_DIR)/util/dynamic_bloom_test.o $(TEST_LIBRARY) $(LIBRARY)
1346	$(AM_LINK)
1347
1348c_test: $(OBJ_DIR)/db/c_test.o $(TEST_LIBRARY) $(LIBRARY)
1349	$(AM_LINK)
1350
1351cache_test: $(OBJ_DIR)/cache/cache_test.o $(TEST_LIBRARY) $(LIBRARY)
1352	$(AM_LINK)
1353
1354coding_test: $(OBJ_DIR)/util/coding_test.o $(TEST_LIBRARY) $(LIBRARY)
1355	$(AM_LINK)
1356
1357hash_test: $(OBJ_DIR)/util/hash_test.o $(TEST_LIBRARY) $(LIBRARY)
1358	$(AM_LINK)
1359
1360random_test: $(OBJ_DIR)/util/random_test.o  $(TEST_LIBRARY) $(LIBRARY)
1361	$(AM_LINK)
1362
1363ribbon_test: $(OBJ_DIR)/util/ribbon_test.o $(TEST_LIBRARY) $(LIBRARY)
1364	$(AM_LINK)
1365
1366option_change_migration_test: $(OBJ_DIR)/utilities/option_change_migration/option_change_migration_test.o $(TEST_LIBRARY) $(LIBRARY)
1367	$(AM_LINK)
1368
1369stringappend_test: $(OBJ_DIR)/utilities/merge_operators/string_append/stringappend_test.o $(TEST_LIBRARY) $(LIBRARY)
1370	$(AM_LINK)
1371
1372cassandra_format_test: $(OBJ_DIR)/utilities/cassandra/cassandra_format_test.o $(OBJ_DIR)/utilities/cassandra/test_utils.o $(TEST_LIBRARY) $(LIBRARY)
1373	$(AM_LINK)
1374
1375cassandra_functional_test: $(OBJ_DIR)/utilities/cassandra/cassandra_functional_test.o $(OBJ_DIR)/utilities/cassandra/test_utils.o $(TEST_LIBRARY) $(LIBRARY)
1376	$(AM_LINK)
1377
1378cassandra_row_merge_test: $(OBJ_DIR)/utilities/cassandra/cassandra_row_merge_test.o $(OBJ_DIR)/utilities/cassandra/test_utils.o $(TEST_LIBRARY) $(LIBRARY)
1379	$(AM_LINK)
1380
1381cassandra_serialize_test: $(OBJ_DIR)/utilities/cassandra/cassandra_serialize_test.o $(TEST_LIBRARY) $(LIBRARY)
1382	$(AM_LINK)
1383
1384hash_table_test: $(OBJ_DIR)/utilities/persistent_cache/hash_table_test.o $(TEST_LIBRARY) $(LIBRARY)
1385	$(AM_LINK)
1386
1387histogram_test: $(OBJ_DIR)/monitoring/histogram_test.o $(TEST_LIBRARY) $(LIBRARY)
1388	$(AM_LINK)
1389
1390thread_local_test: $(OBJ_DIR)/util/thread_local_test.o $(TEST_LIBRARY) $(LIBRARY)
1391	$(AM_LINK)
1392
1393work_queue_test: $(OBJ_DIR)/util/work_queue_test.o $(TEST_LIBRARY) $(LIBRARY)
1394	$(AM_LINK)
1395
1396corruption_test: $(OBJ_DIR)/db/corruption_test.o $(TEST_LIBRARY) $(LIBRARY)
1397	$(AM_LINK)
1398
1399crc32c_test: $(OBJ_DIR)/util/crc32c_test.o $(TEST_LIBRARY) $(LIBRARY)
1400	$(AM_LINK)
1401
1402slice_test: $(OBJ_DIR)/util/slice_test.o $(TEST_LIBRARY) $(LIBRARY)
1403	$(AM_LINK)
1404
1405slice_transform_test: $(OBJ_DIR)/util/slice_transform_test.o $(TEST_LIBRARY) $(LIBRARY)
1406	$(AM_LINK)
1407
1408db_basic_test: $(OBJ_DIR)/db/db_basic_test.o $(TEST_LIBRARY) $(LIBRARY)
1409	$(AM_LINK)
1410
1411db_blob_basic_test: $(OBJ_DIR)/db/blob/db_blob_basic_test.o $(TEST_LIBRARY) $(LIBRARY)
1412	$(AM_LINK)
1413
1414db_blob_compaction_test: $(OBJ_DIR)/db/blob/db_blob_compaction_test.o $(TEST_LIBRARY) $(LIBRARY)
1415	$(AM_LINK)
1416
1417db_with_timestamp_basic_test: $(OBJ_DIR)/db/db_with_timestamp_basic_test.o $(TEST_LIBRARY) $(LIBRARY)
1418	$(AM_LINK)
1419
1420db_with_timestamp_compaction_test: db/db_with_timestamp_compaction_test.o $(TEST_LIBRARY) $(LIBRARY)
1421	$(AM_LINK)
1422
1423db_encryption_test: $(OBJ_DIR)/db/db_encryption_test.o $(TEST_LIBRARY) $(LIBRARY)
1424	$(AM_LINK)
1425
1426db_test: $(OBJ_DIR)/db/db_test.o $(TEST_LIBRARY) $(LIBRARY)
1427	$(AM_LINK)
1428
1429db_test2: $(OBJ_DIR)/db/db_test2.o $(TEST_LIBRARY) $(LIBRARY)
1430	$(AM_LINK)
1431
1432db_logical_block_size_cache_test: $(OBJ_DIR)/db/db_logical_block_size_cache_test.o $(TEST_LIBRARY) $(LIBRARY)
1433	$(AM_LINK)
1434
1435db_blob_index_test: $(OBJ_DIR)/db/blob/db_blob_index_test.o $(TEST_LIBRARY) $(LIBRARY)
1436	$(AM_LINK)
1437
1438db_block_cache_test: $(OBJ_DIR)/db/db_block_cache_test.o $(TEST_LIBRARY) $(LIBRARY)
1439	$(AM_LINK)
1440
1441db_bloom_filter_test: $(OBJ_DIR)/db/db_bloom_filter_test.o $(TEST_LIBRARY) $(LIBRARY)
1442	$(AM_LINK)
1443
1444db_log_iter_test: $(OBJ_DIR)/db/db_log_iter_test.o $(TEST_LIBRARY) $(LIBRARY)
1445	$(AM_LINK)
1446
1447db_compaction_filter_test: $(OBJ_DIR)/db/db_compaction_filter_test.o $(TEST_LIBRARY) $(LIBRARY)
1448	$(AM_LINK)
1449
1450db_compaction_test: $(OBJ_DIR)/db/db_compaction_test.o $(TEST_LIBRARY) $(LIBRARY)
1451	$(AM_LINK)
1452
1453db_dynamic_level_test: $(OBJ_DIR)/db/db_dynamic_level_test.o $(TEST_LIBRARY) $(LIBRARY)
1454	$(AM_LINK)
1455
1456db_flush_test: $(OBJ_DIR)/db/db_flush_test.o $(TEST_LIBRARY) $(LIBRARY)
1457	$(AM_LINK)
1458
1459db_inplace_update_test: $(OBJ_DIR)/db/db_inplace_update_test.o $(TEST_LIBRARY) $(LIBRARY)
1460	$(AM_LINK)
1461
1462db_iterator_test: $(OBJ_DIR)/db/db_iterator_test.o $(TEST_LIBRARY) $(LIBRARY)
1463	$(AM_LINK)
1464
1465db_kv_checksum_test: $(OBJ_DIR)/db/db_kv_checksum_test.o $(TEST_LIBRARY) $(LIBRARY)
1466	$(AM_LINK)
1467
1468db_memtable_test: $(OBJ_DIR)/db/db_memtable_test.o $(TEST_LIBRARY) $(LIBRARY)
1469	$(AM_LINK)
1470
1471db_merge_operator_test: $(OBJ_DIR)/db/db_merge_operator_test.o $(TEST_LIBRARY) $(LIBRARY)
1472	$(AM_LINK)
1473
1474db_merge_operand_test: $(OBJ_DIR)/db/db_merge_operand_test.o $(TEST_LIBRARY) $(LIBRARY)
1475	$(AM_LINK)
1476
1477db_options_test: $(OBJ_DIR)/db/db_options_test.o $(TEST_LIBRARY) $(LIBRARY)
1478	$(AM_LINK)
1479
1480db_range_del_test: $(OBJ_DIR)/db/db_range_del_test.o $(TEST_LIBRARY) $(LIBRARY)
1481	$(AM_LINK)
1482
1483db_sst_test: $(OBJ_DIR)/db/db_sst_test.o $(TEST_LIBRARY) $(LIBRARY)
1484	$(AM_LINK)
1485
1486db_statistics_test: $(OBJ_DIR)/db/db_statistics_test.o $(TEST_LIBRARY) $(LIBRARY)
1487	$(AM_LINK)
1488
1489db_write_test: $(OBJ_DIR)/db/db_write_test.o $(TEST_LIBRARY) $(LIBRARY)
1490	$(AM_LINK)
1491
1492error_handler_fs_test: $(OBJ_DIR)/db/error_handler_fs_test.o $(TEST_LIBRARY) $(LIBRARY)
1493	$(AM_LINK)
1494
1495external_sst_file_basic_test: $(OBJ_DIR)/db/external_sst_file_basic_test.o $(TEST_LIBRARY) $(LIBRARY)
1496	$(AM_LINK)
1497
1498external_sst_file_test: $(OBJ_DIR)/db/external_sst_file_test.o $(TEST_LIBRARY) $(LIBRARY)
1499	$(AM_LINK)
1500
1501import_column_family_test: $(OBJ_DIR)/db/import_column_family_test.o $(TEST_LIBRARY) $(LIBRARY)
1502	$(AM_LINK)
1503
1504db_tailing_iter_test: $(OBJ_DIR)/db/db_tailing_iter_test.o $(TEST_LIBRARY) $(LIBRARY)
1505	$(AM_LINK)
1506
1507db_iter_test: $(OBJ_DIR)/db/db_iter_test.o $(TEST_LIBRARY) $(LIBRARY)
1508	$(AM_LINK)
1509
1510db_iter_stress_test: $(OBJ_DIR)/db/db_iter_stress_test.o $(TEST_LIBRARY) $(LIBRARY)
1511	$(AM_LINK)
1512
1513db_universal_compaction_test: $(OBJ_DIR)/db/db_universal_compaction_test.o $(TEST_LIBRARY) $(LIBRARY)
1514	$(AM_LINK)
1515
1516db_wal_test: $(OBJ_DIR)/db/db_wal_test.o $(TEST_LIBRARY) $(LIBRARY)
1517	$(AM_LINK)
1518
1519db_io_failure_test: $(OBJ_DIR)/db/db_io_failure_test.o $(TEST_LIBRARY) $(LIBRARY)
1520	$(AM_LINK)
1521
1522db_properties_test: $(OBJ_DIR)/db/db_properties_test.o $(TEST_LIBRARY) $(LIBRARY)
1523	$(AM_LINK)
1524
1525db_table_properties_test: $(OBJ_DIR)/db/db_table_properties_test.o $(TEST_LIBRARY) $(LIBRARY)
1526	$(AM_LINK)
1527
1528log_write_bench: $(OBJ_DIR)/util/log_write_bench.o $(TEST_LIBRARY) $(LIBRARY)
1529	$(AM_LINK) $(PROFILING_FLAGS)
1530
1531plain_table_db_test: $(OBJ_DIR)/db/plain_table_db_test.o $(TEST_LIBRARY) $(LIBRARY)
1532	$(AM_LINK)
1533
1534comparator_db_test: $(OBJ_DIR)/db/comparator_db_test.o $(TEST_LIBRARY) $(LIBRARY)
1535	$(AM_LINK)
1536
1537table_reader_bench: $(OBJ_DIR)/table/table_reader_bench.o $(TEST_LIBRARY) $(LIBRARY)
1538	$(AM_LINK) $(PROFILING_FLAGS)
1539
1540perf_context_test: $(OBJ_DIR)/db/perf_context_test.o $(TEST_LIBRARY) $(LIBRARY)
1541	$(AM_LINK)
1542
1543prefix_test: $(OBJ_DIR)/db/prefix_test.o $(TEST_LIBRARY) $(LIBRARY)
1544	$(AM_LINK)
1545
1546backupable_db_test: $(OBJ_DIR)/utilities/backupable/backupable_db_test.o $(TEST_LIBRARY) $(LIBRARY)
1547	$(AM_LINK)
1548
1549checkpoint_test: $(OBJ_DIR)/utilities/checkpoint/checkpoint_test.o $(TEST_LIBRARY) $(LIBRARY)
1550	$(AM_LINK)
1551
1552cache_simulator_test: $(OBJ_DIR)/utilities/simulator_cache/cache_simulator_test.o $(TEST_LIBRARY) $(LIBRARY)
1553	$(AM_LINK)
1554
1555sim_cache_test: $(OBJ_DIR)/utilities/simulator_cache/sim_cache_test.o $(TEST_LIBRARY) $(LIBRARY)
1556	$(AM_LINK)
1557
1558env_mirror_test: $(OBJ_DIR)/utilities/env_mirror_test.o $(TEST_LIBRARY) $(LIBRARY)
1559	$(AM_LINK)
1560
1561env_timed_test: $(OBJ_DIR)/utilities/env_timed_test.o $(TEST_LIBRARY) $(LIBRARY)
1562	$(AM_LINK)
1563
1564ifdef ROCKSDB_USE_LIBRADOS
1565env_librados_test: $(OBJ_DIR)/utilities/env_librados_test.o $(TEST_LIBRARY) $(LIBRARY)
1566	$(AM_LINK)
1567endif
1568
1569object_registry_test: $(OBJ_DIR)/utilities/object_registry_test.o $(TEST_LIBRARY) $(LIBRARY)
1570	$(AM_LINK)
1571
1572ttl_test: $(OBJ_DIR)/utilities/ttl/ttl_test.o $(TEST_LIBRARY) $(LIBRARY)
1573	$(AM_LINK)
1574
1575write_batch_with_index_test: $(OBJ_DIR)/utilities/write_batch_with_index/write_batch_with_index_test.o $(TEST_LIBRARY) $(LIBRARY)
1576	$(AM_LINK)
1577
1578flush_job_test: $(OBJ_DIR)/db/flush_job_test.o $(TEST_LIBRARY) $(LIBRARY)
1579	$(AM_LINK)
1580
1581compaction_iterator_test: $(OBJ_DIR)/db/compaction/compaction_iterator_test.o $(TEST_LIBRARY) $(LIBRARY)
1582	$(AM_LINK)
1583
1584compaction_job_test: $(OBJ_DIR)/db/compaction/compaction_job_test.o $(TEST_LIBRARY) $(LIBRARY)
1585	$(AM_LINK)
1586
1587compaction_job_stats_test: $(OBJ_DIR)/db/compaction/compaction_job_stats_test.o $(TEST_LIBRARY) $(LIBRARY)
1588	$(AM_LINK)
1589
1590compaction_service_test: $(OBJ_DIR)/db/compaction/compaction_service_test.o $(TEST_LIBRARY) $(LIBRARY)
1591	$(AM_LINK)
1592
1593compact_on_deletion_collector_test: $(OBJ_DIR)/utilities/table_properties_collectors/compact_on_deletion_collector_test.o $(TEST_LIBRARY) $(LIBRARY)
1594	$(AM_LINK)
1595
1596wal_manager_test: $(OBJ_DIR)/db/wal_manager_test.o $(TEST_LIBRARY) $(LIBRARY)
1597	$(AM_LINK)
1598
1599wal_edit_test: $(OBJ_DIR)/db/wal_edit_test.o $(TEST_LIBRARY) $(LIBRARY)
1600	$(AM_LINK)
1601
1602dbformat_test: $(OBJ_DIR)/db/dbformat_test.o $(TEST_LIBRARY) $(LIBRARY)
1603	$(AM_LINK)
1604
1605env_basic_test: $(OBJ_DIR)/env/env_basic_test.o $(TEST_LIBRARY) $(LIBRARY)
1606	$(AM_LINK)
1607
1608env_test: $(OBJ_DIR)/env/env_test.o $(TEST_LIBRARY) $(LIBRARY)
1609	$(AM_LINK)
1610
1611io_posix_test: $(OBJ_DIR)/env/io_posix_test.o $(TEST_LIBRARY) $(LIBRARY)
1612	$(AM_LINK)
1613
1614fault_injection_test: $(OBJ_DIR)/db/fault_injection_test.o $(TEST_LIBRARY) $(LIBRARY)
1615	$(AM_LINK)
1616
1617rate_limiter_test: $(OBJ_DIR)/util/rate_limiter_test.o $(TEST_LIBRARY) $(LIBRARY)
1618	$(AM_LINK)
1619
1620delete_scheduler_test: $(OBJ_DIR)/file/delete_scheduler_test.o $(TEST_LIBRARY) $(LIBRARY)
1621	$(AM_LINK)
1622
1623filename_test: $(OBJ_DIR)/db/filename_test.o $(TEST_LIBRARY) $(LIBRARY)
1624	$(AM_LINK)
1625
1626random_access_file_reader_test: $(OBJ_DIR)/file/random_access_file_reader_test.o $(TEST_LIBRARY) $(LIBRARY)
1627	$(AM_LINK)
1628
1629file_reader_writer_test: $(OBJ_DIR)/util/file_reader_writer_test.o $(TEST_LIBRARY) $(LIBRARY)
1630	$(AM_LINK)
1631
1632block_based_filter_block_test: $(OBJ_DIR)/table/block_based/block_based_filter_block_test.o $(TEST_LIBRARY) $(LIBRARY)
1633	$(AM_LINK)
1634
1635block_based_table_reader_test: table/block_based/block_based_table_reader_test.o $(TEST_LIBRARY) $(LIBRARY)
1636	$(AM_LINK)
1637
1638full_filter_block_test: $(OBJ_DIR)/table/block_based/full_filter_block_test.o $(TEST_LIBRARY) $(LIBRARY)
1639	$(AM_LINK)
1640
1641partitioned_filter_block_test: $(OBJ_DIR)/table/block_based/partitioned_filter_block_test.o $(TEST_LIBRARY) $(LIBRARY)
1642	$(AM_LINK)
1643
1644log_test: $(OBJ_DIR)/db/log_test.o $(TEST_LIBRARY) $(LIBRARY)
1645	$(AM_LINK)
1646
1647cleanable_test: $(OBJ_DIR)/table/cleanable_test.o $(TEST_LIBRARY) $(LIBRARY)
1648	$(AM_LINK)
1649
1650table_test: $(OBJ_DIR)/table/table_test.o $(TEST_LIBRARY) $(LIBRARY)
1651	$(AM_LINK)
1652
1653block_fetcher_test: table/block_fetcher_test.o $(TEST_LIBRARY) $(LIBRARY)
1654	$(AM_LINK)
1655
1656block_test: $(OBJ_DIR)/table/block_based/block_test.o $(TEST_LIBRARY) $(LIBRARY)
1657	$(AM_LINK)
1658
1659data_block_hash_index_test: $(OBJ_DIR)/table/block_based/data_block_hash_index_test.o $(TEST_LIBRARY) $(LIBRARY)
1660	$(AM_LINK)
1661
1662inlineskiplist_test: $(OBJ_DIR)/memtable/inlineskiplist_test.o $(TEST_LIBRARY) $(LIBRARY)
1663	$(AM_LINK)
1664
1665skiplist_test: $(OBJ_DIR)/memtable/skiplist_test.o $(TEST_LIBRARY) $(LIBRARY)
1666	$(AM_LINK)
1667
1668write_buffer_manager_test: $(OBJ_DIR)/memtable/write_buffer_manager_test.o $(TEST_LIBRARY) $(LIBRARY)
1669	$(AM_LINK)
1670
1671version_edit_test: $(OBJ_DIR)/db/version_edit_test.o $(TEST_LIBRARY) $(LIBRARY)
1672	$(AM_LINK)
1673
1674version_set_test: $(OBJ_DIR)/db/version_set_test.o $(TEST_LIBRARY) $(LIBRARY)
1675	$(AM_LINK)
1676
1677compaction_picker_test: $(OBJ_DIR)/db/compaction/compaction_picker_test.o $(TEST_LIBRARY) $(LIBRARY)
1678	$(AM_LINK)
1679
1680version_builder_test: $(OBJ_DIR)/db/version_builder_test.o $(TEST_LIBRARY) $(LIBRARY)
1681	$(AM_LINK)
1682
1683file_indexer_test: $(OBJ_DIR)/db/file_indexer_test.o $(TEST_LIBRARY) $(LIBRARY)
1684	$(AM_LINK)
1685
1686reduce_levels_test: $(OBJ_DIR)/tools/reduce_levels_test.o $(TOOLS_LIBRARY) $(TEST_LIBRARY) $(LIBRARY)
1687	$(AM_LINK)
1688
1689write_batch_test: $(OBJ_DIR)/db/write_batch_test.o $(TEST_LIBRARY) $(LIBRARY)
1690	$(AM_LINK)
1691
1692write_controller_test: $(OBJ_DIR)/db/write_controller_test.o $(TEST_LIBRARY) $(LIBRARY)
1693	$(AM_LINK)
1694
1695merge_helper_test: $(OBJ_DIR)/db/merge_helper_test.o $(TEST_LIBRARY) $(LIBRARY)
1696	$(AM_LINK)
1697
1698memory_test: $(OBJ_DIR)/utilities/memory/memory_test.o $(TEST_LIBRARY) $(LIBRARY)
1699	$(AM_LINK)
1700
1701merge_test: $(OBJ_DIR)/db/merge_test.o $(TEST_LIBRARY) $(LIBRARY)
1702	$(AM_LINK)
1703
1704merger_test: $(OBJ_DIR)/table/merger_test.o $(TEST_LIBRARY) $(LIBRARY)
1705	$(AM_LINK)
1706
1707util_merge_operators_test: $(OBJ_DIR)/utilities/util_merge_operators_test.o $(TEST_LIBRARY) $(LIBRARY)
1708	$(AM_LINK)
1709
1710options_file_test: $(OBJ_DIR)/db/options_file_test.o $(TEST_LIBRARY) $(LIBRARY)
1711	$(AM_LINK)
1712
1713deletefile_test: $(OBJ_DIR)/db/deletefile_test.o $(TEST_LIBRARY) $(LIBRARY)
1714	$(AM_LINK)
1715
1716obsolete_files_test: $(OBJ_DIR)/db/obsolete_files_test.o $(TEST_LIBRARY) $(LIBRARY)
1717	$(AM_LINK)
1718
1719rocksdb_dump: $(OBJ_DIR)/tools/dump/rocksdb_dump.o $(LIBRARY)
1720	$(AM_LINK)
1721
1722rocksdb_undump: $(OBJ_DIR)/tools/dump/rocksdb_undump.o $(LIBRARY)
1723	$(AM_LINK)
1724
1725cuckoo_table_builder_test: $(OBJ_DIR)/table/cuckoo/cuckoo_table_builder_test.o $(TEST_LIBRARY) $(LIBRARY)
1726	$(AM_LINK)
1727
1728cuckoo_table_reader_test: $(OBJ_DIR)/table/cuckoo/cuckoo_table_reader_test.o $(TEST_LIBRARY) $(LIBRARY)
1729	$(AM_LINK)
1730
1731cuckoo_table_db_test: $(OBJ_DIR)/db/cuckoo_table_db_test.o $(TEST_LIBRARY) $(LIBRARY)
1732	$(AM_LINK)
1733
1734listener_test: $(OBJ_DIR)/db/listener_test.o $(TEST_LIBRARY) $(LIBRARY)
1735	$(AM_LINK)
1736
1737thread_list_test: $(OBJ_DIR)/util/thread_list_test.o $(TEST_LIBRARY) $(LIBRARY)
1738	$(AM_LINK)
1739
1740compact_files_test: $(OBJ_DIR)/db/compact_files_test.o $(TEST_LIBRARY) $(LIBRARY)
1741	$(AM_LINK)
1742
1743configurable_test: options/configurable_test.o $(TEST_LIBRARY) $(LIBRARY)
1744	$(AM_LINK)
1745
1746customizable_test: options/customizable_test.o $(TEST_LIBRARY) $(LIBRARY)
1747	$(AM_LINK)
1748
1749options_test: $(OBJ_DIR)/options/options_test.o $(TEST_LIBRARY) $(LIBRARY)
1750	$(AM_LINK)
1751
1752options_settable_test: $(OBJ_DIR)/options/options_settable_test.o $(TEST_LIBRARY) $(LIBRARY)
1753	$(AM_LINK)
1754
1755options_util_test: $(OBJ_DIR)/utilities/options/options_util_test.o $(TEST_LIBRARY) $(LIBRARY)
1756	$(AM_LINK)
1757
1758db_bench_tool_test: $(OBJ_DIR)/tools/db_bench_tool_test.o $(BENCH_OBJECTS) $(TEST_LIBRARY) $(LIBRARY)
1759	$(AM_LINK)
1760
1761trace_analyzer_test: $(OBJ_DIR)/tools/trace_analyzer_test.o $(ANALYZE_OBJECTS) $(TOOLS_LIBRARY) $(TEST_LIBRARY) $(LIBRARY)
1762	$(AM_LINK)
1763
1764event_logger_test: $(OBJ_DIR)/logging/event_logger_test.o $(TEST_LIBRARY) $(LIBRARY)
1765	$(AM_LINK)
1766
1767timer_queue_test: $(OBJ_DIR)/util/timer_queue_test.o $(TEST_LIBRARY) $(LIBRARY)
1768	$(AM_LINK)
1769
1770sst_dump_test: $(OBJ_DIR)/tools/sst_dump_test.o $(TOOLS_LIBRARY) $(TEST_LIBRARY) $(LIBRARY)
1771	$(AM_LINK)
1772
1773optimistic_transaction_test: $(OBJ_DIR)/utilities/transactions/optimistic_transaction_test.o  $(TEST_LIBRARY) $(LIBRARY)
1774	$(AM_LINK)
1775
1776mock_env_test : $(OBJ_DIR)/env/mock_env_test.o $(TEST_LIBRARY) $(LIBRARY)
1777	$(AM_LINK)
1778
1779manual_compaction_test: $(OBJ_DIR)/db/manual_compaction_test.o $(TEST_LIBRARY) $(LIBRARY)
1780	$(AM_LINK)
1781
1782filelock_test: $(OBJ_DIR)/util/filelock_test.o $(TEST_LIBRARY) $(LIBRARY)
1783	$(AM_LINK)
1784
1785auto_roll_logger_test: $(OBJ_DIR)/logging/auto_roll_logger_test.o $(TEST_LIBRARY) $(LIBRARY)
1786	$(AM_LINK)
1787
1788env_logger_test: $(OBJ_DIR)/logging/env_logger_test.o $(TEST_LIBRARY) $(LIBRARY)
1789	$(AM_LINK)
1790
1791memtable_list_test: $(OBJ_DIR)/db/memtable_list_test.o $(TEST_LIBRARY) $(LIBRARY)
1792	$(AM_LINK)
1793
1794write_callback_test: $(OBJ_DIR)/db/write_callback_test.o $(TEST_LIBRARY) $(LIBRARY)
1795	$(AM_LINK)
1796
1797heap_test: $(OBJ_DIR)/util/heap_test.o $(GTEST)
1798	$(AM_LINK)
1799
1800point_lock_manager_test: utilities/transactions/lock/point/point_lock_manager_test.o $(TEST_LIBRARY) $(LIBRARY)
1801	$(AM_LINK)
1802
1803transaction_test: $(OBJ_DIR)/utilities/transactions/transaction_test.o $(TEST_LIBRARY) $(LIBRARY)
1804	$(AM_LINK)
1805
1806write_prepared_transaction_test: $(OBJ_DIR)/utilities/transactions/write_prepared_transaction_test.o $(TEST_LIBRARY) $(LIBRARY)
1807	$(AM_LINK)
1808
1809write_unprepared_transaction_test: $(OBJ_DIR)/utilities/transactions/write_unprepared_transaction_test.o $(TEST_LIBRARY) $(LIBRARY)
1810	$(AM_LINK)
1811
1812sst_dump: $(OBJ_DIR)/tools/sst_dump.o $(TOOLS_LIBRARY) $(LIBRARY)
1813	$(AM_LINK)
1814
1815blob_dump: $(OBJ_DIR)/tools/blob_dump.o $(TOOLS_LIBRARY) $(LIBRARY)
1816	$(AM_LINK)
1817
1818repair_test: $(OBJ_DIR)/db/repair_test.o $(TEST_LIBRARY) $(LIBRARY)
1819	$(AM_LINK)
1820
1821ldb_cmd_test: $(OBJ_DIR)/tools/ldb_cmd_test.o $(TOOLS_LIBRARY) $(TEST_LIBRARY) $(LIBRARY)
1822	$(AM_LINK)
1823
1824ldb: $(OBJ_DIR)/tools/ldb.o $(TOOLS_LIBRARY) $(LIBRARY)
1825	$(AM_LINK)
1826
1827iostats_context_test: $(OBJ_DIR)/monitoring/iostats_context_test.o $(TEST_LIBRARY) $(LIBRARY)
1828	$(AM_V_CCLD)$(CXX) $^ $(EXEC_LDFLAGS) -o $@ $(LDFLAGS)
1829
1830persistent_cache_test: $(OBJ_DIR)/utilities/persistent_cache/persistent_cache_test.o $(TEST_LIBRARY) $(LIBRARY)
1831	$(AM_LINK)
1832
1833statistics_test: $(OBJ_DIR)/monitoring/statistics_test.o $(TEST_LIBRARY) $(LIBRARY)
1834	$(AM_LINK)
1835
1836stats_history_test: $(OBJ_DIR)/monitoring/stats_history_test.o $(TEST_LIBRARY) $(LIBRARY)
1837	$(AM_LINK)
1838
1839lru_cache_test: $(OBJ_DIR)/cache/lru_cache_test.o $(TEST_LIBRARY) $(LIBRARY)
1840	$(AM_LINK)
1841
1842range_del_aggregator_test: $(OBJ_DIR)/db/range_del_aggregator_test.o $(TEST_LIBRARY) $(LIBRARY)
1843	$(AM_LINK)
1844
1845range_del_aggregator_bench: $(OBJ_DIR)/db/range_del_aggregator_bench.o $(LIBRARY)
1846	$(AM_LINK)
1847
1848blob_db_test: $(OBJ_DIR)/utilities/blob_db/blob_db_test.o $(TEST_LIBRARY) $(LIBRARY)
1849	$(AM_LINK)
1850
1851repeatable_thread_test: $(OBJ_DIR)/util/repeatable_thread_test.o $(TEST_LIBRARY) $(LIBRARY)
1852	$(AM_LINK)
1853
1854range_locking_test: utilities/transactions/lock/range/range_locking_test.o $(TEST_LIBRARY) $(LIBRARY)
1855	$(AM_LINK)
1856
1857range_tombstone_fragmenter_test: $(OBJ_DIR)/db/range_tombstone_fragmenter_test.o $(TEST_LIBRARY) $(LIBRARY)
1858	$(AM_LINK)
1859
1860sst_file_reader_test: $(OBJ_DIR)/table/sst_file_reader_test.o $(TEST_LIBRARY) $(LIBRARY)
1861	$(AM_LINK)
1862
1863db_secondary_test: $(OBJ_DIR)/db/db_secondary_test.o $(TEST_LIBRARY) $(LIBRARY)
1864	$(AM_LINK)
1865
1866block_cache_tracer_test: $(OBJ_DIR)/trace_replay/block_cache_tracer_test.o $(TEST_LIBRARY) $(LIBRARY)
1867	$(AM_LINK)
1868
1869block_cache_trace_analyzer_test: $(OBJ_DIR)/tools/block_cache_analyzer/block_cache_trace_analyzer_test.o $(OBJ_DIR)/tools/block_cache_analyzer/block_cache_trace_analyzer.o $(TEST_LIBRARY) $(LIBRARY)
1870	$(AM_LINK)
1871
1872defer_test: $(OBJ_DIR)/util/defer_test.o $(TEST_LIBRARY) $(LIBRARY)
1873	$(AM_LINK)
1874
1875blob_counting_iterator_test: $(OBJ_DIR)/db/blob/blob_counting_iterator_test.o $(TEST_LIBRARY) $(LIBRARY)
1876	$(AM_LINK)
1877
1878blob_file_addition_test: $(OBJ_DIR)/db/blob/blob_file_addition_test.o $(TEST_LIBRARY) $(LIBRARY)
1879	$(AM_LINK)
1880
1881blob_file_builder_test: $(OBJ_DIR)/db/blob/blob_file_builder_test.o $(TEST_LIBRARY) $(LIBRARY)
1882	$(AM_LINK)
1883
1884blob_file_cache_test: $(OBJ_DIR)/db/blob/blob_file_cache_test.o $(TEST_LIBRARY) $(LIBRARY)
1885	$(AM_LINK)
1886
1887blob_file_garbage_test: $(OBJ_DIR)/db/blob/blob_file_garbage_test.o $(TEST_LIBRARY) $(LIBRARY)
1888	$(AM_LINK)
1889
1890blob_file_reader_test: $(OBJ_DIR)/db/blob/blob_file_reader_test.o $(TEST_LIBRARY) $(LIBRARY)
1891	$(AM_LINK)
1892
1893blob_garbage_meter_test: $(OBJ_DIR)/db/blob/blob_garbage_meter_test.o $(TEST_LIBRARY) $(LIBRARY)
1894	$(AM_LINK)
1895
1896timer_test: $(OBJ_DIR)/util/timer_test.o $(TEST_LIBRARY) $(LIBRARY)
1897	$(AM_LINK)
1898
1899periodic_work_scheduler_test: $(OBJ_DIR)/db/periodic_work_scheduler_test.o $(TEST_LIBRARY) $(LIBRARY)
1900	$(AM_LINK)
1901
1902testutil_test: $(OBJ_DIR)/test_util/testutil_test.o $(TEST_LIBRARY) $(LIBRARY)
1903	$(AM_LINK)
1904
1905io_tracer_test: $(OBJ_DIR)/trace_replay/io_tracer_test.o $(OBJ_DIR)/trace_replay/io_tracer.o $(TEST_LIBRARY) $(LIBRARY)
1906	$(AM_LINK)
1907
1908prefetch_test: $(OBJ_DIR)/file/prefetch_test.o $(TEST_LIBRARY) $(LIBRARY)
1909	$(AM_LINK)
1910
1911io_tracer_parser_test: $(OBJ_DIR)/tools/io_tracer_parser_test.o $(OBJ_DIR)/tools/io_tracer_parser_tool.o $(TEST_LIBRARY) $(LIBRARY)
1912	$(AM_LINK)
1913
1914io_tracer_parser: $(OBJ_DIR)/tools/io_tracer_parser.o $(TOOLS_LIBRARY) $(LIBRARY)
1915	$(AM_LINK)
1916
1917db_blob_corruption_test: $(OBJ_DIR)/db/blob/db_blob_corruption_test.o $(TEST_LIBRARY) $(LIBRARY)
1918	$(AM_LINK)
1919
1920db_write_buffer_manager_test: $(OBJ_DIR)/db/db_write_buffer_manager_test.o $(TEST_LIBRARY) $(LIBRARY)
1921	$(AM_LINK)
1922
1923clipping_iterator_test: $(OBJ_DIR)/db/compaction/clipping_iterator_test.o $(TEST_LIBRARY) $(LIBRARY)
1924	$(AM_LINK)
1925
1926ribbon_bench: $(OBJ_DIR)/microbench/ribbon_bench.o $(LIBRARY)
1927	$(AM_LINK)
1928
1929cache_reservation_manager_test: $(OBJ_DIR)/cache/cache_reservation_manager_test.o $(TEST_LIBRARY) $(LIBRARY)
1930	$(AM_LINK)
1931#-------------------------------------------------
1932# make install related stuff
1933PREFIX ?= /usr/local
1934LIBDIR ?= $(PREFIX)/lib
1935INSTALL_LIBDIR = $(DESTDIR)$(LIBDIR)
1936
1937uninstall:
1938	rm -rf $(DESTDIR)$(PREFIX)/include/rocksdb \
1939	  $(INSTALL_LIBDIR)/$(LIBRARY) \
1940	  $(INSTALL_LIBDIR)/$(SHARED4) \
1941	  $(INSTALL_LIBDIR)/$(SHARED3) \
1942	  $(INSTALL_LIBDIR)/$(SHARED2) \
1943	  $(INSTALL_LIBDIR)/$(SHARED1) \
1944	  $(INSTALL_LIBDIR)/pkgconfig/rocksdb.pc
1945
1946install-headers: gen-pc
1947	install -d $(INSTALL_LIBDIR)
1948	install -d $(INSTALL_LIBDIR)/pkgconfig
1949	for header_dir in `$(FIND) "include/rocksdb" -type d`; do \
1950		install -d $(DESTDIR)/$(PREFIX)/$$header_dir; \
1951	done
1952	for header in `$(FIND) "include/rocksdb" -type f -name *.h`; do \
1953		install -C -m 644 $$header $(DESTDIR)/$(PREFIX)/$$header; \
1954	done
1955	for header in $(ROCKSDB_PLUGIN_HEADERS); do \
1956		install -d $(DESTDIR)/$(PREFIX)/include/rocksdb/`dirname $$header`; \
1957		install -C -m 644 $$header $(DESTDIR)/$(PREFIX)/include/rocksdb/$$header; \
1958	done
1959	install -C -m 644 rocksdb.pc $(INSTALL_LIBDIR)/pkgconfig/rocksdb.pc
1960
1961install-static: install-headers $(LIBRARY)
1962	install -d $(INSTALL_LIBDIR)
1963	install -C -m 755 $(LIBRARY) $(INSTALL_LIBDIR)
1964
1965install-shared: install-headers $(SHARED4)
1966	install -d $(INSTALL_LIBDIR)
1967	install -C -m 755 $(SHARED4) $(INSTALL_LIBDIR)
1968	ln -fs $(SHARED4) $(INSTALL_LIBDIR)/$(SHARED3)
1969	ln -fs $(SHARED4) $(INSTALL_LIBDIR)/$(SHARED2)
1970	ln -fs $(SHARED4) $(INSTALL_LIBDIR)/$(SHARED1)
1971
1972# install static by default + install shared if it exists
1973install: install-static
1974	[ -e $(SHARED4) ] && $(MAKE) install-shared || :
1975
1976# Generate the pkg-config file
1977gen-pc:
1978	-echo 'prefix=$(PREFIX)' > rocksdb.pc
1979	-echo 'exec_prefix=$${prefix}' >> rocksdb.pc
1980	-echo 'includedir=$${prefix}/include' >> rocksdb.pc
1981	-echo 'libdir=$(LIBDIR)' >> rocksdb.pc
1982	-echo '' >> rocksdb.pc
1983	-echo 'Name: rocksdb' >> rocksdb.pc
1984	-echo 'Description: An embeddable persistent key-value store for fast storage' >> rocksdb.pc
1985	-echo Version: $(shell ./build_tools/version.sh full) >> rocksdb.pc
1986	-echo 'Libs: -L$${libdir} $(EXEC_LDFLAGS) -lrocksdb' >> rocksdb.pc
1987	-echo 'Libs.private: $(PLATFORM_LDFLAGS)' >> rocksdb.pc
1988	-echo 'Cflags: -I$${includedir} $(PLATFORM_CXXFLAGS)' >> rocksdb.pc
1989
1990#-------------------------------------------------
1991
1992
1993# ---------------------------------------------------------------------------
1994# Jni stuff
1995# ---------------------------------------------------------------------------
1996
1997JAVA_INCLUDE = -I$(JAVA_HOME)/include/ -I$(JAVA_HOME)/include/linux
1998ifeq ($(PLATFORM), OS_SOLARIS)
1999	ARCH := $(shell isainfo -b)
2000else ifeq ($(PLATFORM), OS_OPENBSD)
2001	ifneq (,$(filter amd64 ppc64 ppc64le arm64 aarch64 sparc64, $(MACHINE)))
2002		ARCH := 64
2003	else
2004		ARCH := 32
2005	endif
2006else
2007	ARCH := $(shell getconf LONG_BIT)
2008endif
2009
2010ifeq ($(shell ldd /usr/bin/env 2>/dev/null | grep -q musl; echo $$?),0)
2011        JNI_LIBC = musl
2012# GNU LibC (or glibc) is so pervasive we can assume it is the default
2013# else
2014#        JNI_LIBC = glibc
2015endif
2016
2017ifneq ($(origin JNI_LIBC), undefined)
2018  JNI_LIBC_POSTFIX = -$(JNI_LIBC)
2019endif
2020
2021ifneq (,$(filter ppc% arm64 aarch64 sparc64, $(MACHINE)))
2022	ROCKSDBJNILIB = librocksdbjni-linux-$(MACHINE)$(JNI_LIBC_POSTFIX).so
2023else
2024	ROCKSDBJNILIB = librocksdbjni-linux$(ARCH)$(JNI_LIBC_POSTFIX).so
2025endif
2026ROCKSDB_JAVA_VERSION ?= $(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)
2027ROCKSDB_JAR = rocksdbjni-$(ROCKSDB_JAVA_VERSION)-linux$(ARCH)$(JNI_LIBC_POSTFIX).jar
2028ROCKSDB_JAR_ALL = rocksdbjni-$(ROCKSDB_JAVA_VERSION).jar
2029ROCKSDB_JAVADOCS_JAR = rocksdbjni-$(ROCKSDB_JAVA_VERSION)-javadoc.jar
2030ROCKSDB_SOURCES_JAR = rocksdbjni-$(ROCKSDB_JAVA_VERSION)-sources.jar
2031SHA256_CMD = sha256sum
2032
2033ZLIB_VER ?= 1.2.11
2034ZLIB_SHA256 ?= c3e5e9fdd5004dcb542feda5ee4f0ff0744628baf8ed2dd5d66f8ca1197cb1a1
2035ZLIB_DOWNLOAD_BASE ?= http://zlib.net
2036BZIP2_VER ?= 1.0.8
2037BZIP2_SHA256 ?= ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269
2038BZIP2_DOWNLOAD_BASE ?= http://sourceware.org/pub/bzip2
2039SNAPPY_VER ?= 1.1.8
2040SNAPPY_SHA256 ?= 16b677f07832a612b0836178db7f374e414f94657c138e6993cbfc5dcc58651f
2041SNAPPY_DOWNLOAD_BASE ?= https://github.com/google/snappy/archive
2042LZ4_VER ?= 1.9.3
2043LZ4_SHA256 ?= 030644df4611007ff7dc962d981f390361e6c97a34e5cbc393ddfbe019ffe2c1
2044LZ4_DOWNLOAD_BASE ?= https://github.com/lz4/lz4/archive
2045ZSTD_VER ?= 1.4.9
2046ZSTD_SHA256 ?= acf714d98e3db7b876e5b540cbf6dee298f60eb3c0723104f6d3f065cd60d6a8
2047ZSTD_DOWNLOAD_BASE ?= https://github.com/facebook/zstd/archive
2048CURL_SSL_OPTS ?= --tlsv1
2049
2050ifeq ($(PLATFORM), OS_MACOSX)
2051	ROCKSDBJNILIB = librocksdbjni-osx.jnilib
2052	ROCKSDB_JAR = rocksdbjni-$(ROCKSDB_JAVA_VERSION)-osx.jar
2053	SHA256_CMD = openssl sha256 -r
2054ifneq ("$(wildcard $(JAVA_HOME)/include/darwin)","")
2055	JAVA_INCLUDE = -I$(JAVA_HOME)/include -I $(JAVA_HOME)/include/darwin
2056else
2057	JAVA_INCLUDE = -I/System/Library/Frameworks/JavaVM.framework/Headers/
2058endif
2059endif
2060ifeq ($(PLATFORM), OS_FREEBSD)
2061	JAVA_INCLUDE = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/freebsd
2062	ROCKSDBJNILIB = librocksdbjni-freebsd$(ARCH).so
2063	ROCKSDB_JAR = rocksdbjni-$(ROCKSDB_JAVA_VERSION)-freebsd$(ARCH).jar
2064endif
2065ifeq ($(PLATFORM), OS_SOLARIS)
2066	ROCKSDBJNILIB = librocksdbjni-solaris$(ARCH).so
2067	ROCKSDB_JAR = rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)-solaris$(ARCH).jar
2068	JAVA_INCLUDE = -I$(JAVA_HOME)/include/ -I$(JAVA_HOME)/include/solaris
2069	SHA256_CMD = digest -a sha256
2070endif
2071ifeq ($(PLATFORM), OS_AIX)
2072	JAVA_INCLUDE = -I$(JAVA_HOME)/include/ -I$(JAVA_HOME)/include/aix
2073	ROCKSDBJNILIB = librocksdbjni-aix.so
2074	EXTRACT_SOURCES = gunzip < TAR_GZ | tar xvf -
2075	SNAPPY_MAKE_TARGET = libsnappy.la
2076endif
2077ifeq ($(PLATFORM), OS_OPENBSD)
2078	JAVA_INCLUDE = -I$(JAVA_HOME)/include -I$(JAVA_HOME)/include/openbsd
2079	ROCKSDBJNILIB = librocksdbjni-openbsd$(ARCH).so
2080	ROCKSDB_JAR = rocksdbjni-$(ROCKSDB_JAVA_VERSION)-openbsd$(ARCH).jar
2081endif
2082
2083zlib-$(ZLIB_VER).tar.gz:
2084	curl --fail --output zlib-$(ZLIB_VER).tar.gz --location ${ZLIB_DOWNLOAD_BASE}/zlib-$(ZLIB_VER).tar.gz
2085	ZLIB_SHA256_ACTUAL=`$(SHA256_CMD) zlib-$(ZLIB_VER).tar.gz | cut -d ' ' -f 1`; \
2086	if [ "$(ZLIB_SHA256)" != "$$ZLIB_SHA256_ACTUAL" ]; then \
2087		echo zlib-$(ZLIB_VER).tar.gz checksum mismatch, expected=\"$(ZLIB_SHA256)\" actual=\"$$ZLIB_SHA256_ACTUAL\"; \
2088		exit 1; \
2089	fi
2090
2091libz.a: zlib-$(ZLIB_VER).tar.gz
2092	-rm -rf zlib-$(ZLIB_VER)
2093	tar xvzf zlib-$(ZLIB_VER).tar.gz
2094	cd zlib-$(ZLIB_VER) && CFLAGS='-fPIC ${JAVA_STATIC_DEPS_CCFLAGS} ${EXTRA_CFLAGS}' LDFLAGS='${JAVA_STATIC_DEPS_LDFLAGS} ${EXTRA_LDFLAGS}' ./configure --static && $(MAKE)
2095	cp zlib-$(ZLIB_VER)/libz.a .
2096
2097bzip2-$(BZIP2_VER).tar.gz:
2098	curl --fail --output bzip2-$(BZIP2_VER).tar.gz --location ${CURL_SSL_OPTS} ${BZIP2_DOWNLOAD_BASE}/bzip2-$(BZIP2_VER).tar.gz
2099	BZIP2_SHA256_ACTUAL=`$(SHA256_CMD) bzip2-$(BZIP2_VER).tar.gz | cut -d ' ' -f 1`; \
2100	if [ "$(BZIP2_SHA256)" != "$$BZIP2_SHA256_ACTUAL" ]; then \
2101		echo bzip2-$(BZIP2_VER).tar.gz checksum mismatch, expected=\"$(BZIP2_SHA256)\" actual=\"$$BZIP2_SHA256_ACTUAL\"; \
2102		exit 1; \
2103	fi
2104
2105libbz2.a: bzip2-$(BZIP2_VER).tar.gz
2106	-rm -rf bzip2-$(BZIP2_VER)
2107	tar xvzf bzip2-$(BZIP2_VER).tar.gz
2108	cd bzip2-$(BZIP2_VER) && $(MAKE) CFLAGS='-fPIC -O2 -g -D_FILE_OFFSET_BITS=64 ${JAVA_STATIC_DEPS_CCFLAGS} ${EXTRA_CFLAGS}' LDFLAGS='${JAVA_STATIC_DEPS_LDFLAGS} ${EXTRA_LDFLAGS}' AR='ar ${EXTRA_ARFLAGS}'
2109	cp bzip2-$(BZIP2_VER)/libbz2.a .
2110
2111snappy-$(SNAPPY_VER).tar.gz:
2112	curl --fail --output snappy-$(SNAPPY_VER).tar.gz --location ${CURL_SSL_OPTS} ${SNAPPY_DOWNLOAD_BASE}/$(SNAPPY_VER).tar.gz
2113	SNAPPY_SHA256_ACTUAL=`$(SHA256_CMD) snappy-$(SNAPPY_VER).tar.gz | cut -d ' ' -f 1`; \
2114	if [ "$(SNAPPY_SHA256)" != "$$SNAPPY_SHA256_ACTUAL" ]; then \
2115		echo snappy-$(SNAPPY_VER).tar.gz checksum mismatch, expected=\"$(SNAPPY_SHA256)\" actual=\"$$SNAPPY_SHA256_ACTUAL\"; \
2116		exit 1; \
2117	fi
2118
2119libsnappy.a: snappy-$(SNAPPY_VER).tar.gz
2120	-rm -rf snappy-$(SNAPPY_VER)
2121	tar xvzf snappy-$(SNAPPY_VER).tar.gz
2122	mkdir snappy-$(SNAPPY_VER)/build
2123	cd snappy-$(SNAPPY_VER)/build && CFLAGS='${JAVA_STATIC_DEPS_CCFLAGS} ${EXTRA_CFLAGS}' CXXFLAGS='${JAVA_STATIC_DEPS_CXXFLAGS} ${EXTRA_CXXFLAGS}' LDFLAGS='${JAVA_STATIC_DEPS_LDFLAGS} ${EXTRA_LDFLAGS}' cmake -DCMAKE_POSITION_INDEPENDENT_CODE=ON ${PLATFORM_CMAKE_FLAGS} .. && $(MAKE) ${SNAPPY_MAKE_TARGET}
2124	cp snappy-$(SNAPPY_VER)/build/libsnappy.a .
2125
2126lz4-$(LZ4_VER).tar.gz:
2127	curl --fail --output lz4-$(LZ4_VER).tar.gz --location ${CURL_SSL_OPTS} ${LZ4_DOWNLOAD_BASE}/v$(LZ4_VER).tar.gz
2128	LZ4_SHA256_ACTUAL=`$(SHA256_CMD) lz4-$(LZ4_VER).tar.gz | cut -d ' ' -f 1`; \
2129	if [ "$(LZ4_SHA256)" != "$$LZ4_SHA256_ACTUAL" ]; then \
2130		echo lz4-$(LZ4_VER).tar.gz checksum mismatch, expected=\"$(LZ4_SHA256)\" actual=\"$$LZ4_SHA256_ACTUAL\"; \
2131		exit 1; \
2132	fi
2133
2134liblz4.a: lz4-$(LZ4_VER).tar.gz
2135	-rm -rf lz4-$(LZ4_VER)
2136	tar xvzf lz4-$(LZ4_VER).tar.gz
2137	cd lz4-$(LZ4_VER)/lib && $(MAKE) CFLAGS='-fPIC -O2 ${JAVA_STATIC_DEPS_CCFLAGS} ${EXTRA_CFLAGS}' LDFLAGS='${JAVA_STATIC_DEPS_LDFLAGS} ${EXTRA_LDFLAGS}' all
2138	cp lz4-$(LZ4_VER)/lib/liblz4.a .
2139
2140zstd-$(ZSTD_VER).tar.gz:
2141	curl --fail --output zstd-$(ZSTD_VER).tar.gz --location ${CURL_SSL_OPTS} ${ZSTD_DOWNLOAD_BASE}/v$(ZSTD_VER).tar.gz
2142	ZSTD_SHA256_ACTUAL=`$(SHA256_CMD) zstd-$(ZSTD_VER).tar.gz | cut -d ' ' -f 1`; \
2143	if [ "$(ZSTD_SHA256)" != "$$ZSTD_SHA256_ACTUAL" ]; then \
2144		echo zstd-$(ZSTD_VER).tar.gz checksum mismatch, expected=\"$(ZSTD_SHA256)\" actual=\"$$ZSTD_SHA256_ACTUAL\"; \
2145		exit 1; \
2146	fi
2147
2148libzstd.a: zstd-$(ZSTD_VER).tar.gz
2149	-rm -rf zstd-$(ZSTD_VER)
2150	tar xvzf zstd-$(ZSTD_VER).tar.gz
2151	cd zstd-$(ZSTD_VER)/lib && DESTDIR=. PREFIX= $(MAKE) CFLAGS='-fPIC -O2 ${JAVA_STATIC_DEPS_CCFLAGS} ${EXTRA_CFLAGS}' LDFLAGS='${JAVA_STATIC_DEPS_LDFLAGS} ${EXTRA_LDFLAGS}' libzstd.a
2152	cp zstd-$(ZSTD_VER)/lib/libzstd.a .
2153
2154# A version of each $(LIB_OBJECTS) compiled with -fPIC and a fixed set of static compression libraries
2155ifneq ($(ROCKSDB_JAVA_NO_COMPRESSION), 1)
2156JAVA_COMPRESSIONS = libz.a libbz2.a libsnappy.a liblz4.a libzstd.a
2157endif
2158
2159JAVA_STATIC_FLAGS = -DZLIB -DBZIP2 -DSNAPPY -DLZ4 -DZSTD
2160JAVA_STATIC_INCLUDES = -I./zlib-$(ZLIB_VER) -I./bzip2-$(BZIP2_VER) -I./snappy-$(SNAPPY_VER) -I./snappy-$(SNAPPY_VER)/build -I./lz4-$(LZ4_VER)/lib -I./zstd-$(ZSTD_VER)/lib -I./zstd-$(ZSTD_VER)/lib/dictBuilder
2161
2162ifneq ($(findstring rocksdbjavastatic, $(filter-out rocksdbjavastatic_deps, $(MAKECMDGOALS))),)
2163CXXFLAGS += $(JAVA_STATIC_FLAGS) $(JAVA_STATIC_INCLUDES)
2164CFLAGS += $(JAVA_STATIC_FLAGS) $(JAVA_STATIC_INCLUDES)
2165endif
2166rocksdbjavastatic:
2167ifeq ($(JAVA_HOME),)
2168	$(error JAVA_HOME is not set)
2169endif
2170	$(MAKE) rocksdbjavastatic_deps
2171	$(MAKE) rocksdbjavastatic_libobjects
2172	$(MAKE) rocksdbjavastatic_javalib
2173
2174rocksdbjavastatic_javalib:
2175	cd java; SHA256_CMD='$(SHA256_CMD)' $(MAKE) javalib
2176	rm -f java/target/$(ROCKSDBJNILIB)
2177	$(CXX) $(CXXFLAGS) -I./java/. $(JAVA_INCLUDE) -shared -fPIC \
2178	  -o ./java/target/$(ROCKSDBJNILIB) $(JNI_NATIVE_SOURCES) \
2179	  $(LIB_OBJECTS) $(COVERAGEFLAGS) \
2180	  $(JAVA_COMPRESSIONS) $(JAVA_STATIC_LDFLAGS)
2181	cd java/target;if [ "$(DEBUG_LEVEL)" == "0" ]; then \
2182		strip $(STRIPFLAGS) $(ROCKSDBJNILIB); \
2183	fi
2184	cd java;jar -cf target/$(ROCKSDB_JAR) HISTORY*.md
2185	cd java/target;jar -uf $(ROCKSDB_JAR) $(ROCKSDBJNILIB)
2186	cd java/target/classes;jar -uf ../$(ROCKSDB_JAR) org/rocksdb/*.class org/rocksdb/util/*.class
2187	cd java/target/apidocs;jar -cf ../$(ROCKSDB_JAVADOCS_JAR) *
2188	cd java/src/main/java;jar -cf ../../../target/$(ROCKSDB_SOURCES_JAR) org
2189	openssl sha1 java/target/$(ROCKSDB_JAR) | sed 's/.*= \([0-9a-f]*\)/\1/' > java/target/$(ROCKSDB_JAR).sha1
2190	openssl sha1 java/target/$(ROCKSDB_JAVADOCS_JAR) | sed 's/.*= \([0-9a-f]*\)/\1/' > java/target/$(ROCKSDB_JAVADOCS_JAR).sha1
2191	openssl sha1 java/target/$(ROCKSDB_SOURCES_JAR) | sed 's/.*= \([0-9a-f]*\)/\1/' > java/target/$(ROCKSDB_SOURCES_JAR).sha1
2192
2193rocksdbjavastatic_deps: $(JAVA_COMPRESSIONS)
2194
2195rocksdbjavastatic_libobjects: $(LIB_OBJECTS)
2196
2197rocksdbjavastaticrelease: rocksdbjavastatic
2198	cd java/crossbuild && (vagrant destroy -f || true) && vagrant up linux32 && vagrant halt linux32 && vagrant up linux64 && vagrant halt linux64 && vagrant up linux64-musl && vagrant halt linux64-musl
2199	cd java;jar -cf target/$(ROCKSDB_JAR_ALL) HISTORY*.md
2200	cd java/target;jar -uf $(ROCKSDB_JAR_ALL) librocksdbjni-*.so librocksdbjni-*.jnilib
2201	cd java/target/classes;jar -uf ../$(ROCKSDB_JAR_ALL) org/rocksdb/*.class org/rocksdb/util/*.class
2202	openssl sha1 java/target/$(ROCKSDB_JAR_ALL) | sed 's/.*= \([0-9a-f]*\)/\1/' > java/target/$(ROCKSDB_JAR_ALL).sha1
2203
2204rocksdbjavastaticreleasedocker: rocksdbjavastatic rocksdbjavastaticdockerx86 rocksdbjavastaticdockerx86_64 rocksdbjavastaticdockerx86musl rocksdbjavastaticdockerx86_64musl
2205	cd java;jar -cf target/$(ROCKSDB_JAR_ALL) HISTORY*.md
2206	cd java/target;jar -uf $(ROCKSDB_JAR_ALL) librocksdbjni-*.so librocksdbjni-*.jnilib
2207	cd java/target/classes;jar -uf ../$(ROCKSDB_JAR_ALL) org/rocksdb/*.class org/rocksdb/util/*.class
2208	openssl sha1 java/target/$(ROCKSDB_JAR_ALL) | sed 's/.*= \([0-9a-f]*\)/\1/' > java/target/$(ROCKSDB_JAR_ALL).sha1
2209
2210rocksdbjavastaticdockerx86:
2211	mkdir -p java/target
2212	docker run --rm --name rocksdb_linux_x86-be --platform linux/386 --attach stdin --attach stdout --attach stderr --volume $(HOME)/.m2:/root/.m2:ro --volume `pwd`:/rocksdb-host:ro --volume /rocksdb-local-build --volume `pwd`/java/target:/rocksdb-java-target --env DEBUG_LEVEL=$(DEBUG_LEVEL) evolvedbinary/rocksjava:centos6_x86-be /rocksdb-host/java/crossbuild/docker-build-linux-centos.sh
2213
2214rocksdbjavastaticdockerx86_64:
2215	mkdir -p java/target
2216	docker run --rm --name rocksdb_linux_x64-be --attach stdin --attach stdout --attach stderr --volume $(HOME)/.m2:/root/.m2:ro --volume `pwd`:/rocksdb-host:ro --volume /rocksdb-local-build --volume `pwd`/java/target:/rocksdb-java-target --env DEBUG_LEVEL=$(DEBUG_LEVEL) evolvedbinary/rocksjava:centos6_x64-be /rocksdb-host/java/crossbuild/docker-build-linux-centos.sh
2217
2218rocksdbjavastaticdockerppc64le:
2219	mkdir -p java/target
2220	docker run --rm --name rocksdb_linux_ppc64le-be --attach stdin --attach stdout --attach stderr --volume $(HOME)/.m2:/root/.m2:ro --volume `pwd`:/rocksdb-host:ro --volume /rocksdb-local-build --volume `pwd`/java/target:/rocksdb-java-target --env DEBUG_LEVEL=$(DEBUG_LEVEL) evolvedbinary/rocksjava:centos7_ppc64le-be /rocksdb-host/java/crossbuild/docker-build-linux-centos.sh
2221
2222rocksdbjavastaticdockerarm64v8:
2223	mkdir -p java/target
2224	docker run --rm --name rocksdb_linux_arm64v8-be --attach stdin --attach stdout --attach stderr --volume $(HOME)/.m2:/root/.m2:ro --volume `pwd`:/rocksdb-host:ro --volume /rocksdb-local-build --volume `pwd`/java/target:/rocksdb-java-target --env DEBUG_LEVEL=$(DEBUG_LEVEL) evolvedbinary/rocksjava:centos7_arm64v8-be /rocksdb-host/java/crossbuild/docker-build-linux-centos.sh
2225
2226rocksdbjavastaticdockerx86musl:
2227	mkdir -p java/target
2228	docker run --rm --name rocksdb_linux_x86-musl-be --platform linux/386 --attach stdin --attach stdout --attach stderr --volume $(HOME)/.m2:/root/.m2:ro --volume `pwd`:/rocksdb-host:ro --volume /rocksdb-local-build --volume `pwd`/java/target:/rocksdb-java-target --env DEBUG_LEVEL=$(DEBUG_LEVEL) evolvedbinary/rocksjava:alpine3_x86-be /rocksdb-host/java/crossbuild/docker-build-linux-centos.sh
2229
2230rocksdbjavastaticdockerx86_64musl:
2231	mkdir -p java/target
2232	docker run --rm --name rocksdb_linux_x64-musl-be --attach stdin --attach stdout --attach stderr --volume $(HOME)/.m2:/root/.m2:ro --volume `pwd`:/rocksdb-host:ro --volume /rocksdb-local-build --volume `pwd`/java/target:/rocksdb-java-target --env DEBUG_LEVEL=$(DEBUG_LEVEL) evolvedbinary/rocksjava:alpine3_x64-be /rocksdb-host/java/crossbuild/docker-build-linux-centos.sh
2233
2234rocksdbjavastaticdockerppc64lemusl:
2235	mkdir -p java/target
2236	docker run --rm --name rocksdb_linux_ppc64le-musl-be --attach stdin --attach stdout --attach stderr --volume $(HOME)/.m2:/root/.m2:ro --volume `pwd`:/rocksdb-host:ro --volume /rocksdb-local-build --volume `pwd`/java/target:/rocksdb-java-target --env DEBUG_LEVEL=$(DEBUG_LEVEL) evolvedbinary/rocksjava:alpine3_ppc64le-be /rocksdb-host/java/crossbuild/docker-build-linux-centos.sh
2237
2238rocksdbjavastaticdockerarm64v8musl:
2239	mkdir -p java/target
2240	docker run --rm --name rocksdb_linux_arm64v8-musl-be --attach stdin --attach stdout --attach stderr --volume $(HOME)/.m2:/root/.m2:ro --volume `pwd`:/rocksdb-host:ro --volume /rocksdb-local-build --volume `pwd`/java/target:/rocksdb-java-target --env DEBUG_LEVEL=$(DEBUG_LEVEL) evolvedbinary/rocksjava:alpine3_arm64v8-be /rocksdb-host/java/crossbuild/docker-build-linux-centos.sh
2241
2242rocksdbjavastaticpublish: rocksdbjavastaticrelease rocksdbjavastaticpublishcentral
2243
2244rocksdbjavastaticpublishdocker: rocksdbjavastaticreleasedocker rocksdbjavastaticpublishcentral
2245
2246rocksdbjavastaticpublishcentral: rocksdbjavageneratepom
2247	mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=java/pom.xml -Dfile=java/target/rocksdbjni-$(ROCKSDB_JAVA_VERSION)-javadoc.jar -Dclassifier=javadoc
2248	mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=java/pom.xml -Dfile=java/target/rocksdbjni-$(ROCKSDB_JAVA_VERSION)-sources.jar -Dclassifier=sources
2249	mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=java/pom.xml -Dfile=java/target/rocksdbjni-$(ROCKSDB_JAVA_VERSION)-linux64.jar -Dclassifier=linux64
2250	mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=java/pom.xml -Dfile=java/target/rocksdbjni-$(ROCKSDB_JAVA_VERSION)-linux32.jar -Dclassifier=linux32
2251	mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=java/pom.xml -Dfile=java/target/rocksdbjni-$(ROCKSDB_JAVA_VERSION)-linux64-musl.jar -Dclassifier=linux64-musl
2252	mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=java/pom.xml -Dfile=java/target/rocksdbjni-$(ROCKSDB_JAVA_VERSION)-linux32-musl.jar -Dclassifier=linux32-musl
2253	mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=java/pom.xml -Dfile=java/target/rocksdbjni-$(ROCKSDB_JAVA_VERSION)-osx.jar -Dclassifier=osx
2254	mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=java/pom.xml -Dfile=java/target/rocksdbjni-$(ROCKSDB_JAVA_VERSION)-win64.jar -Dclassifier=win64
2255	mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=java/pom.xml -Dfile=java/target/rocksdbjni-$(ROCKSDB_JAVA_VERSION).jar
2256
2257rocksdbjavageneratepom:
2258	cd java;cat pom.xml.template | sed 's/\$${ROCKSDB_JAVA_VERSION}/$(ROCKSDB_JAVA_VERSION)/' > pom.xml
2259
2260# A version of each $(LIBOBJECTS) compiled with -fPIC
2261
2262jl/%.o: %.cc
2263	$(AM_V_CC)mkdir -p $(@D) && $(CXX) $(CXXFLAGS) -fPIC -c $< -o $@ $(COVERAGEFLAGS)
2264
2265rocksdbjava: $(LIB_OBJECTS)
2266ifeq ($(JAVA_HOME),)
2267	$(error JAVA_HOME is not set)
2268endif
2269	$(AM_V_GEN)cd java; SHA256_CMD='$(SHA256_CMD)' $(MAKE) javalib;
2270	$(AM_V_at)rm -f ./java/target/$(ROCKSDBJNILIB)
2271	$(AM_V_at)$(CXX) $(CXXFLAGS) -I./java/. $(JAVA_INCLUDE) -shared -fPIC -o ./java/target/$(ROCKSDBJNILIB) $(JNI_NATIVE_SOURCES) $(LIB_OBJECTS) $(JAVA_LDFLAGS) $(COVERAGEFLAGS)
2272	$(AM_V_at)cd java;jar -cf target/$(ROCKSDB_JAR) HISTORY*.md
2273	$(AM_V_at)cd java/target;jar -uf $(ROCKSDB_JAR) $(ROCKSDBJNILIB)
2274	$(AM_V_at)cd java/target/classes;jar -uf ../$(ROCKSDB_JAR) org/rocksdb/*.class org/rocksdb/util/*.class
2275	$(AM_V_at)openssl sha1 java/target/$(ROCKSDB_JAR) | sed 's/.*= \([0-9a-f]*\)/\1/' > java/target/$(ROCKSDB_JAR).sha1
2276
2277jclean:
2278	cd java;$(MAKE) clean;
2279
2280jtest_compile: rocksdbjava
2281	cd java; SHA256_CMD='$(SHA256_CMD)' $(MAKE) java_test
2282
2283jtest_run:
2284	cd java;$(MAKE) run_test
2285
2286jtest: rocksdbjava
2287	cd java;$(MAKE) sample; SHA256_CMD='$(SHA256_CMD)' $(MAKE) test;
2288	$(PYTHON) tools/check_all_python.py # TODO peterd: find a better place for this check in CI targets
2289
2290jdb_bench:
2291	cd java;$(MAKE) db_bench;
2292
2293commit_prereq: build_tools/rocksdb-lego-determinator \
2294               build_tools/precommit_checker.py
2295	J=$(J) build_tools/precommit_checker.py unit unit_481 clang_unit release release_481 clang_release tsan asan ubsan lite unit_non_shm
2296	$(MAKE) clean && $(MAKE) jclean && $(MAKE) rocksdbjava;
2297
2298# ---------------------------------------------------------------------------
2299#  	Platform-specific compilation
2300# ---------------------------------------------------------------------------
2301
2302ifeq ($(PLATFORM), IOS)
2303# For iOS, create universal object files to be used on both the simulator and
2304# a device.
2305XCODEROOT=$(shell xcode-select -print-path)
2306PLATFORMSROOT=$(XCODEROOT)/Platforms
2307SIMULATORROOT=$(PLATFORMSROOT)/iPhoneSimulator.platform/Developer
2308DEVICEROOT=$(PLATFORMSROOT)/iPhoneOS.platform/Developer
2309IOSVERSION=$(shell defaults read $(PLATFORMSROOT)/iPhoneOS.platform/version CFBundleShortVersionString)
2310
2311.cc.o:
2312	mkdir -p ios-x86/$(dir $@)
2313	$(CXX) $(CXXFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 -arch x86_64 -c $< -o ios-x86/$@
2314	mkdir -p ios-arm/$(dir $@)
2315	xcrun -sdk iphoneos $(CXX) $(CXXFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk -arch armv6 -arch armv7 -arch armv7s -arch arm64 -c $< -o ios-arm/$@
2316	lipo ios-x86/$@ ios-arm/$@ -create -output $@
2317
2318.c.o:
2319	mkdir -p ios-x86/$(dir $@)
2320	$(CC) $(CFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 -arch x86_64 -c $< -o ios-x86/$@
2321	mkdir -p ios-arm/$(dir $@)
2322	xcrun -sdk iphoneos $(CC) $(CFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk -arch armv6 -arch armv7 -arch armv7s -arch arm64 -c $< -o ios-arm/$@
2323	lipo ios-x86/$@ ios-arm/$@ -create -output $@
2324
2325else
2326ifeq ($(HAVE_POWER8),1)
2327$(OBJ_DIR)/util/crc32c_ppc.o: util/crc32c_ppc.c
2328	$(AM_V_CC)$(CC) $(CFLAGS) -c $< -o $@
2329
2330$(OBJ_DIR)/util/crc32c_ppc_asm.o: util/crc32c_ppc_asm.S
2331	$(AM_V_CC)$(CC) $(CFLAGS) -c $< -o $@
2332endif
2333$(OBJ_DIR)/%.o: %.cc
2334	$(AM_V_CC)mkdir -p $(@D) && $(CXX) $(CXXFLAGS) -c $< -o $@ $(COVERAGEFLAGS)
2335
2336$(OBJ_DIR)/%.o: %.cpp
2337	$(AM_V_CC)mkdir -p $(@D) && $(CXX) $(CXXFLAGS) -c $< -o $@ $(COVERAGEFLAGS)
2338
2339$(OBJ_DIR)/%.o: %.c
2340	$(AM_V_CC)$(CC) $(CFLAGS) -c $< -o $@
2341endif
2342
2343# ---------------------------------------------------------------------------
2344#  	Source files dependencies detection
2345# ---------------------------------------------------------------------------
2346# If skip dependencies is ON, skip including the dep files
2347ifneq ($(SKIP_DEPENDS), 1)
2348DEPFILES = $(patsubst %.cc, $(OBJ_DIR)/%.cc.d, $(ALL_SOURCES))
2349DEPFILES+ = $(patsubst %.c, $(OBJ_DIR)/%.c.d, $(LIB_SOURCES_C) $(TEST_MAIN_SOURCES_C))
2350ifeq ($(USE_FOLLY_DISTRIBUTED_MUTEX),1)
2351  DEPFILES +=$(patsubst %.cpp, $(OBJ_DIR)/%.cpp.d, $(FOLLY_SOURCES))
2352endif
2353endif
2354
2355# Add proper dependency support so changing a .h file forces a .cc file to
2356# rebuild.
2357
2358# The .d file indicates .cc file's dependencies on .h files. We generate such
2359# dependency by g++'s -MM option, whose output is a make dependency rule.
2360$(OBJ_DIR)/%.cc.d: %.cc
2361	@mkdir -p $(@D) && $(CXX) $(CXXFLAGS) $(PLATFORM_SHARED_CFLAGS) \
2362	  -MM -MT'$@' -MT'$(<:.cc=.o)' -MT'$(<:%.cc=$(OBJ_DIR)/%.o)' \
2363          "$<" -o '$@'
2364
2365$(OBJ_DIR)/%.cpp.d: %.cpp
2366	@mkdir -p $(@D) && $(CXX) $(CXXFLAGS) $(PLATFORM_SHARED_CFLAGS) \
2367	  -MM -MT'$@' -MT'$(<:.cpp=.o)' -MT'$(<:%.cpp=$(OBJ_DIR)/%.o)' \
2368          "$<" -o '$@'
2369
2370ifeq ($(HAVE_POWER8),1)
2371DEPFILES_C = $(patsubst %.c, $(OBJ_DIR)/%.c.d, $(LIB_SOURCES_C))
2372DEPFILES_ASM = $(patsubst %.S, $(OBJ_DIR)/%.S.d, $(LIB_SOURCES_ASM))
2373
2374$(OBJ_DIR)/%.c.d: %.c
2375	@$(CXX) $(CXXFLAGS) $(PLATFORM_SHARED_CFLAGS) \
2376	  -MM -MT'$@' -MT'$(<:.c=.o)' "$<" -o '$@'
2377
2378$(OBJ_DIR)/%.S.d: %.S
2379	@$(CXX) $(CXXFLAGS) $(PLATFORM_SHARED_CFLAGS) \
2380	  -MM -MT'$@' -MT'$(<:.S=.o)' "$<" -o '$@'
2381
2382$(DEPFILES_C): %.c.d
2383
2384$(DEPFILES_ASM): %.S.d
2385depend: $(DEPFILES) $(DEPFILES_C) $(DEPFILES_ASM)
2386else
2387depend: $(DEPFILES)
2388endif
2389
2390build_subset_tests: $(ROCKSDBTESTS_SUBSET)
2391	$(AM_V_GEN)if [ -n "$${ROCKSDBTESTS_SUBSET_TESTS_TO_FILE}" ]; then echo "$(ROCKSDBTESTS_SUBSET)" > "$${ROCKSDBTESTS_SUBSET_TESTS_TO_FILE}"; else echo "$(ROCKSDBTESTS_SUBSET)"; fi
2392
2393# Remove the rules for which dependencies should not be generated and see if any are left.
2394#If so, include the dependencies; if not, do not include the dependency files
2395ROCKS_DEP_RULES=$(filter-out clean format check-format check-buck-targets check-headers check-sources jclean jtest package analyze tags rocksdbjavastatic% unity.% unity_test, $(MAKECMDGOALS))
2396ifneq ("$(ROCKS_DEP_RULES)", "")
2397-include $(DEPFILES)
2398endif
2399