Makefile 41.0 KB
Newer Older
J
jorlow@chromium.org 已提交
1 2 3 4
# Copyright (c) 2011 The LevelDB Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. See the AUTHORS file for names of contributors.

5
# Inherit some settings from environment variables, if available
J
jorlow@chromium.org 已提交
6

7
#-----------------------------------------------
8

9
CLEAN_FILES = # deliberately empty, so we can append below.
10 11 12 13
CFLAGS += ${EXTRA_CFLAGS}
CXXFLAGS += ${EXTRA_CXXFLAGS}
LDFLAGS += $(EXTRA_LDFLAGS)
MACHINE ?= $(shell uname -m)
I
Igor Canadi 已提交
14
ARFLAGS = rs
15

16 17
# Transform parallel LOG output into something more readable.
perl_command = perl -n \
Y
Yueh-Hsuan Chiang 已提交
18 19 20 21
  -e '@a=split("\t",$$_,-1); $$t=$$a[8]; $$t =~ s,^\./,,;'		\
  -e '$$t =~ s, >.*,,; chomp $$t;'					\
  -e '$$t =~ /.*--gtest_filter=(.*?\.[\w\/]+)/ and $$t=$$1;'		\
  -e 'printf "%7.3f %s %s\n", $$a[3], $$a[6] == 0 ? "PASS" : "FAIL", $$t'
22 23
quoted_perl_command = $(subst ','\'',$(perl_command))

24 25 26 27 28 29 30 31 32
# DEBUG_LEVEL can have three values:
# * DEBUG_LEVEL=2; this is the ultimate debug mode. It will compile rocksdb
# without any optimizations. To compile with level 2, issue `make dbg`
# * DEBUG_LEVEL=1; debug level 1 enables all assertions and debug code, but
# compiles rocksdb with -O2 optimizations. this is the default debug level.
# `make all` or `make <binary_target>` compile RocksDB with debug level 1.
# We use this debug level when developing RocksDB.
# * DEBUG_LEVEL=0; this is the debug level we use for release. If you're
# running rocksdb in production you most definitely want to compile RocksDB
A
agiardullo 已提交
33
# with debug level 0. To compile with level 0, run `make shared_lib`,
34 35
# `make install-shared`, `make static_lib`, `make install-static` or
# `make install`
36 37 38

# Set the default DEBUG_LEVEL to 1
DEBUG_LEVEL?=1
39 40

ifeq ($(MAKECMDGOALS),dbg)
Y
Yueh-Hsuan Chiang 已提交
41
	DEBUG_LEVEL=2
42
endif
43

44 45 46 47 48 49 50 51
ifeq ($(MAKECMDGOALS),clean)
	DEBUG_LEVEL=0
endif

ifeq ($(MAKECMDGOALS),release)
	DEBUG_LEVEL=0
endif

52
ifeq ($(MAKECMDGOALS),shared_lib)
Y
Yueh-Hsuan Chiang 已提交
53
	DEBUG_LEVEL=0
I
Igor Canadi 已提交
54
endif
I
Igor Canadi 已提交
55

I
Igor Canadi 已提交
56
ifeq ($(MAKECMDGOALS),install-shared)
Y
Yueh-Hsuan Chiang 已提交
57
	DEBUG_LEVEL=0
I
Igor Canadi 已提交
58 59
endif

I
Igor Canadi 已提交
60
ifeq ($(MAKECMDGOALS),static_lib)
Y
Yueh-Hsuan Chiang 已提交
61
	DEBUG_LEVEL=0
62
endif
I
Igor Canadi 已提交
63

I
Igor Canadi 已提交
64
ifeq ($(MAKECMDGOALS),install-static)
Y
Yueh-Hsuan Chiang 已提交
65
	DEBUG_LEVEL=0
I
Igor Canadi 已提交
66 67 68
endif

ifeq ($(MAKECMDGOALS),install)
Y
Yueh-Hsuan Chiang 已提交
69
	DEBUG_LEVEL=0
70 71
endif

72
ifeq ($(MAKECMDGOALS),rocksdbjavastatic)
Y
Yueh-Hsuan Chiang 已提交
73
	DEBUG_LEVEL=0
74 75
endif

Y
Yueh-Hsuan Chiang 已提交
76 77 78 79 80 81 82 83
ifeq ($(MAKECMDGOALS),rocksdbjavastaticrelease)
	DEBUG_LEVEL=0
endif

ifeq ($(MAKECMDGOALS),rocksdbjavastaticpublish)
	DEBUG_LEVEL=0
endif

84 85 86
# compile with -O2 if debug level is not 2
ifneq ($(DEBUG_LEVEL), 2)
OPT += -O2 -fno-omit-frame-pointer
87
ifeq (,$(findstring ppc64,$(MACHINE))) # ppc64[le] doesn't support -momit-leaf-frame-pointer
B
benoitc 已提交
88
ifneq ($(MACHINE),armv7l)
89 90 91
OPT += -momit-leaf-frame-pointer
endif
endif
B
benoitc 已提交
92
endif
93 94 95 96

# if we're compiling for release, compile without debug code (-DNDEBUG) and
# don't treat warnings as errors
ifeq ($(DEBUG_LEVEL),0)
I
Igor Canadi 已提交
97
OPT += -DNDEBUG
98
DISABLE_WARNING_AS_ERROR=1
99 100
else
$(warning Warning: Compiling in debug mode. Don't use the resulting binary in production)
I
Igor Canadi 已提交
101 102
endif

103
#-----------------------------------------------
104
include src.mk
105

106 107 108 109 110 111
AM_DEFAULT_VERBOSITY = 0

AM_V_GEN = $(am__v_GEN_$(V))
am__v_GEN_ = $(am__v_GEN_$(AM_DEFAULT_VERBOSITY))
am__v_GEN_0 = @echo "  GEN     " $@;
am__v_GEN_1 =
J
Jim Meyering 已提交
112 113 114 115
AM_V_at = $(am__v_at_$(V))
am__v_at_ = $(am__v_at_$(AM_DEFAULT_VERBOSITY))
am__v_at_0 = @
am__v_at_1 =
116 117 118 119 120 121 122 123 124 125 126

AM_V_CC = $(am__v_CC_$(V))
am__v_CC_ = $(am__v_CC_$(AM_DEFAULT_VERBOSITY))
am__v_CC_0 = @echo "  CC      " $@;
am__v_CC_1 =
CCLD = $(CC)
LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
AM_V_CCLD = $(am__v_CCLD_$(V))
am__v_CCLD_ = $(am__v_CCLD_$(AM_DEFAULT_VERBOSITY))
am__v_CCLD_0 = @echo "  CCLD    " $@;
am__v_CCLD_1 =
J
Jim Meyering 已提交
127 128 129 130
AM_V_AR = $(am__v_AR_$(V))
am__v_AR_ = $(am__v_AR_$(AM_DEFAULT_VERBOSITY))
am__v_AR_0 = @echo "  AR      " $@;
am__v_AR_1 =
131

132 133
AM_LINK = $(AM_V_CCLD)$(CXX) $^ $(EXEC_LDFLAGS) -o $@ $(LDFLAGS) $(COVERAGEFLAGS)

134
# detect what platform we're building on
135
dummy := $(shell (export ROCKSDB_ROOT="$(CURDIR)"; "$(CURDIR)/build_tools/build_detect_platform" "$(CURDIR)/make_config.mk"))
S
Sanjay Ghemawat 已提交
136
# this file is generated by the previous line to set build flags and sources
I
Igor Canadi 已提交
137
include make_config.mk
138
CLEAN_FILES += make_config.mk
J
jorlow@chromium.org 已提交
139

I
Igor Canadi 已提交
140 141 142 143 144 145 146 147
ifneq ($(PLATFORM), IOS)
CFLAGS += -g
CXXFLAGS += -g
else
# no debug info for IOS, that will make our library big
OPT += -DNDEBUG
endif

D
David Bernard 已提交
148 149 150
ifeq ($(PLATFORM), OS_SOLARIS)
	PLATFORM_CXXFLAGS += -D _GLIBCXX_USE_C99
endif
151
ifneq ($(filter -DROCKSDB_LITE,$(OPT)),)
Y
Yueh-Hsuan Chiang 已提交
152 153 154
	# found
	CFLAGS += -fno-exceptions
	CXXFLAGS += -fno-exceptions
155 156
endif

I
Igor Canadi 已提交
157 158
# ASAN doesn't work well with jemalloc. If we're compiling with ASAN, we should use regular malloc.
ifdef COMPILE_WITH_ASAN
Y
Yueh-Hsuan Chiang 已提交
159 160 161 162
	DISABLE_JEMALLOC=1
	EXEC_LDFLAGS += -fsanitize=address
	PLATFORM_CCFLAGS += -fsanitize=address
	PLATFORM_CXXFLAGS += -fsanitize=address
I
Igor Canadi 已提交
163 164 165 166
endif

# TSAN doesn't work well with jemalloc. If we're compiling with TSAN, we should use regular malloc.
ifdef COMPILE_WITH_TSAN
Y
Yueh-Hsuan Chiang 已提交
167 168 169 170
	DISABLE_JEMALLOC=1
	EXEC_LDFLAGS += -fsanitize=thread -pie
	PLATFORM_CCFLAGS += -fsanitize=thread -fPIC -DROCKSDB_TSAN_RUN
	PLATFORM_CXXFLAGS += -fsanitize=thread -fPIC -DROCKSDB_TSAN_RUN
171 172
        # Turn off -pg when enabling TSAN testing, because that induces
        # a link failure.  TODO: find the root cause
Y
Yueh-Hsuan Chiang 已提交
173
	pg =
174
else
Y
Yueh-Hsuan Chiang 已提交
175
	pg = -pg
I
Igor Canadi 已提交
176 177 178
endif

ifndef DISABLE_JEMALLOC
Y
Yueh-Hsuan Chiang 已提交
179 180 181
	EXEC_LDFLAGS := $(JEMALLOC_LIB) $(EXEC_LDFLAGS)
	PLATFORM_CXXFLAGS += $(JEMALLOC_INCLUDE)
	PLATFORM_CCFLAGS += $(JEMALLOC_INCLUDE)
I
Igor Canadi 已提交
182 183
endif

I
Igor Sugak 已提交
184 185 186 187 188
export GTEST_THROW_ON_FAILURE=1 GTEST_HAS_EXCEPTIONS=1
GTEST_DIR = ./third-party/gtest-1.7.0/fused-src
PLATFORM_CCFLAGS += -isystem $(GTEST_DIR)
PLATFORM_CXXFLAGS += -isystem $(GTEST_DIR)

189 190 191
# This (the first rule) must depend on "all".
default: all

192
WARNING_FLAGS = -W -Wextra -Wall -Wsign-compare -Wshadow \
Y
Yueh-Hsuan Chiang 已提交
193
  -Wno-unused-parameter
194

195
ifndef DISABLE_WARNING_AS_ERROR
Y
Yueh-Hsuan Chiang 已提交
196
	WARNING_FLAGS += -Werror
197 198
endif

I
Igor Canadi 已提交
199
CFLAGS += $(WARNING_FLAGS) -I. -I./include $(PLATFORM_CCFLAGS) $(OPT)
I
Islam AbdelRahman 已提交
200
CXXFLAGS += $(WARNING_FLAGS) -I. -I./include $(PLATFORM_CXXFLAGS) $(OPT) -Woverloaded-virtual -Wnon-virtual-dtor -Wno-missing-field-initializers
201

S
Sanjay Ghemawat 已提交
202
LDFLAGS += $(PLATFORM_LDFLAGS)
J
jorlow@chromium.org 已提交
203

204
date := $(shell date +%F)
I
Igor Canadi 已提交
205
ifdef FORCE_GIT_SHA
Y
Yueh-Hsuan Chiang 已提交
206
	git_sha := $(FORCE_GIT_SHA)
I
Igor Canadi 已提交
207
else
Y
Yueh-Hsuan Chiang 已提交
208
	git_sha := $(shell git rev-parse HEAD 2>/dev/null)
I
Igor Canadi 已提交
209
endif
210
gen_build_version =							\
Y
Yueh-Hsuan Chiang 已提交
211 212 213 214 215 216 217
  printf '%s\n'								\
    '\#include "build_version.h"'					\
    'const char* rocksdb_build_git_sha =				\
      "rocksdb_build_git_sha:$(git_sha)";'			\
    'const char* rocksdb_build_git_date =				\
      "rocksdb_build_git_date:$(date)";'				\
    'const char* rocksdb_build_compile_date = __DATE__;'
218 219 220 221 222 223

# Record the version of the source that we are compiling.
# We keep a record of the git revision in this file.  It is then built
# as a regular source file as part of the compilation process.
# One can run "strings executable_filename | grep _build_" to find
# the version of the source that we used to build the executable file.
224
CLEAN_FILES += util/build_version.cc:
225 226
FORCE:
util/build_version.cc: FORCE
Y
Yueh-Hsuan Chiang 已提交
227 228 229 230 231
	$(AM_V_GEN)rm -f $@-t
	$(AM_V_at)$(gen_build_version) > $@-t
	$(AM_V_at)if test -f $@; then					\
	  cmp -s $@-t $@ && rm -f $@-t || mv -f $@-t $@;		\
	else mv -f $@-t $@; fi
232

233
LIBOBJECTS = $(LIB_SOURCES:.cc=.o)
E
Evan Shaw 已提交
234
LIBOBJECTS += $(TOOL_SOURCES:.cc=.o)
235
MOCKOBJECTS = $(MOCK_SOURCES:.cc=.o)
J
jorlow@chromium.org 已提交
236

I
Igor Sugak 已提交
237
GTEST = $(GTEST_DIR)/gtest/gtest-all.o
J
jorlow@chromium.org 已提交
238
TESTUTIL = ./util/testutil.o
I
Igor Sugak 已提交
239
TESTHARNESS = ./util/testharness.o $(TESTUTIL) $(MOCKOBJECTS) $(GTEST)
240
VALGRIND_ERROR = 2
241
VALGRIND_VER := $(join $(VALGRIND_VER),valgrind)
242

243
VALGRIND_OPTS = --error-exitcode=$(VALGRIND_ERROR) --leak-check=full
244

J
jorlow@chromium.org 已提交
245
TESTS = \
246 247 248 249
	db_test \
	db_iter_test \
	db_log_iter_test \
	db_compaction_filter_test \
250
	db_compaction_test \
251
	db_dynamic_level_test \
252
	db_inplace_update_test \
253 254
	db_tailing_iter_test \
	db_universal_compaction_test \
S
sdong 已提交
255
	db_wal_test \
256
	db_properties_test \
257
	db_table_properties_test \
258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278
	block_hash_index_test \
	autovector_test \
	column_family_test \
	table_properties_collector_test \
	arena_test \
	auto_roll_logger_test \
	block_test \
	bloom_test \
	dynamic_bloom_test \
	c_test \
	cache_test \
	checkpoint_test \
	coding_test \
	corruption_test \
	crc32c_test \
	slice_transform_test \
	dbformat_test \
	env_test \
	fault_injection_test \
	filelock_test \
	filename_test \
279
	file_reader_writer_test \
280 281 282
	block_based_filter_block_test \
	full_filter_block_test \
	histogram_test \
N
Nathan Bronson 已提交
283
	inlineskiplist_test \
284 285 286 287 288 289
	log_test \
	manual_compaction_test \
	memenv_test \
	mock_env_test \
	memtable_list_test \
	merge_helper_test \
290
	memory_test \
291 292
	merge_test \
	merger_test \
293
	options_file_test \
294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318
	redis_test \
	reduce_levels_test \
	plain_table_db_test \
	comparator_db_test \
	prefix_test \
	skiplist_test \
	stringappend_test \
	ttl_test \
	backupable_db_test \
	document_db_test \
	json_document_test \
	spatial_db_test \
	version_edit_test \
	version_set_test \
	compaction_picker_test \
	version_builder_test \
	file_indexer_test \
	write_batch_test \
	write_batch_with_index_test \
	write_controller_test\
	deletefile_test \
	table_test \
	thread_local_test \
	geodb_test \
	rate_limiter_test \
I
Islam AbdelRahman 已提交
319
	delete_scheduler_test \
320
	options_test \
321
	options_util_test \
322 323 324 325 326 327 328
	event_logger_test \
	cuckoo_table_builder_test \
	cuckoo_table_reader_test \
	cuckoo_table_db_test \
	flush_job_test \
	wal_manager_test \
	listener_test \
A
Andres Noetzli 已提交
329
	compaction_iterator_test \
330 331 332 333 334 335 336
	compaction_job_test \
	thread_list_test \
	sst_dump_test \
	compact_files_test \
	perf_context_test \
	optimistic_transaction_test \
	write_callback_test \
337 338
	heap_test \
	compact_on_deletion_collector_test \
A
agiardullo 已提交
339
	compaction_job_stats_test \
340 341
	transaction_test \
	ldb_cmd_test
342

343 344
SUBSET :=  $(shell echo $(TESTS) |sed s/^.*$(ROCKSDBTESTS_START)/$(ROCKSDBTESTS_START)/)

345
TOOLS = \
Y
Yueh-Hsuan Chiang 已提交
346 347 348
	sst_dump \
	db_sanity_test \
	db_stress \
I
Igor Canadi 已提交
349
	write_stress \
Y
Yueh-Hsuan Chiang 已提交
350 351 352 353
	ldb \
	db_repl_stress \
	rocksdb_dump \
	rocksdb_undump
J
jorlow@chromium.org 已提交
354

S
sdong 已提交
355 356
# TODO: add back forward_iterator_bench, after making it build in all environemnts.
BENCHMARKS = db_bench table_reader_bench cache_bench memtablerep_bench
J
jorlow@chromium.org 已提交
357

358
# if user didn't config LIBNAME, set the default
359
ifeq ($(LIBNAME),)
360 361
# we should only run rocksdb in production with DEBUG_LEVEL 0
ifeq ($(DEBUG_LEVEL),0)
Y
Yueh-Hsuan Chiang 已提交
362
        LIBNAME=librocksdb
363 364 365
else
        LIBNAME=librocksdb_debug
endif
366
endif
367
LIBRARY = ${LIBNAME}.a
368

369 370 371
ROCKSDB_MAJOR = $(shell egrep "ROCKSDB_MAJOR.[0-9]" include/rocksdb/version.h | cut -d ' ' -f 3)
ROCKSDB_MINOR = $(shell egrep "ROCKSDB_MINOR.[0-9]" include/rocksdb/version.h | cut -d ' ' -f 3)
ROCKSDB_PATCH = $(shell egrep "ROCKSDB_PATCH.[0-9]" include/rocksdb/version.h | cut -d ' ' -f 3)
372

373 374
default: all

375 376 377
#-----------------------------------------------
# Create platform independent shared libraries.
#-----------------------------------------------
378
ifneq ($(PLATFORM_SHARED_EXT),)
H
heyongqiang 已提交
379 380

ifneq ($(PLATFORM_SHARED_VERSIONED),true)
381
SHARED1 = ${LIBNAME}.$(PLATFORM_SHARED_EXT)
H
heyongqiang 已提交
382 383
SHARED2 = $(SHARED1)
SHARED3 = $(SHARED1)
384
SHARED4 = $(SHARED1)
H
heyongqiang 已提交
385 386
SHARED = $(SHARED1)
else
387 388
SHARED_MAJOR = $(ROCKSDB_MAJOR)
SHARED_MINOR = $(ROCKSDB_MINOR)
389
SHARED_PATCH = $(ROCKSDB_PATCH)
390
SHARED1 = ${LIBNAME}.$(PLATFORM_SHARED_EXT)
391 392 393 394 395 396
ifeq ($(PLATFORM), OS_MACOSX)
SHARED_OSX = $(LIBNAME).$(SHARED_MAJOR)
SHARED2 = $(SHARED_OSX).$(PLATFORM_SHARED_EXT)
SHARED3 = $(SHARED_OSX).$(SHARED_MINOR).$(PLATFORM_SHARED_EXT)
SHARED4 = $(SHARED_OSX).$(SHARED_MINOR).$(SHARED_PATCH).$(PLATFORM_SHARED_EXT)
else
397 398
SHARED2 = $(SHARED1).$(SHARED_MAJOR)
SHARED3 = $(SHARED1).$(SHARED_MAJOR).$(SHARED_MINOR)
399
SHARED4 = $(SHARED1).$(SHARED_MAJOR).$(SHARED_MINOR).$(SHARED_PATCH)
400
endif
401 402
SHARED = $(SHARED1) $(SHARED2) $(SHARED3) $(SHARED4)
$(SHARED1): $(SHARED4)
Y
Yueh-Hsuan Chiang 已提交
403
	ln -fs $(SHARED4) $(SHARED1)
404
$(SHARED2): $(SHARED4)
Y
Yueh-Hsuan Chiang 已提交
405
	ln -fs $(SHARED4) $(SHARED2)
406
$(SHARED3): $(SHARED4)
Y
Yueh-Hsuan Chiang 已提交
407
	ln -fs $(SHARED4) $(SHARED3)
408 409
endif

410
$(SHARED4):
411
	$(CXX) $(PLATFORM_SHARED_LDFLAGS)$(SHARED3) $(CXXFLAGS) $(PLATFORM_SHARED_CFLAGS) $(LIB_SOURCES) $(TOOL_SOURCES) \
Y
Yueh-Hsuan Chiang 已提交
412
		$(LDFLAGS) -o $@
H
heyongqiang 已提交
413 414 415

endif  # PLATFORM_SHARED_EXT

416
.PHONY: blackbox_crash_test check clean coverage crash_test ldb_tests package \
Y
Yueh-Hsuan Chiang 已提交
417 418
	release tags valgrind_check whitebox_crash_test format static_lib shared_lib all \
	dbg rocksdbjavastatic rocksdbjava install install-static install-shared uninstall \
M
maurice barnum 已提交
419
	analyze tools
420

M
maurice barnum 已提交
421 422

all: $(LIBRARY) $(BENCHMARKS) tools $(TESTS)
423

I
Igor Canadi 已提交
424 425 426 427
static_lib: $(LIBRARY)

shared_lib: $(SHARED)

M
maurice barnum 已提交
428 429 430
tools: $(TOOLS)

dbg: $(LIBRARY) $(BENCHMARKS) tools $(TESTS)
K
Kai Liu 已提交
431

432
# creates static library and programs
433
release:
Y
Yueh-Hsuan Chiang 已提交
434
	$(MAKE) clean
435
	DEBUG_LEVEL=0 $(MAKE) static_lib tools db_bench
K
Kai Liu 已提交
436 437

coverage:
Y
Yueh-Hsuan Chiang 已提交
438 439 440 441 442
	$(MAKE) clean
	COVERAGEFLAGS="-fprofile-arcs -ftest-coverage" LDFLAGS+="-lgcov" $(MAKE) J=1 all check
	cd coverage && ./coverage_test.sh
        # Delete intermediate files
	find . -type f -regex ".*\.\(\(gcda\)\|\(gcno\)\)" -exec rm {} \;
J
jorlow@chromium.org 已提交
443

444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462
# Extract the names of its tests by running db_test with --gtest_list_tests.
# This filter removes the "#"-introduced comments, and expands to
# fully-qualified names by changing input like this:
#
#   DBTest.
#     Empty
#     WriteEmptyBatch
#   MultiThreaded/MultiThreadedDBTest.
#     MultiThreaded/0  # GetParam() = 0
#     MultiThreaded/1  # GetParam() = 1
#
# into this:
#
#   DBTest.Empty
#   DBTest.WriteEmptyBatch
#   MultiThreaded/MultiThreadedDBTest.MultiThreaded/0
#   MultiThreaded/MultiThreadedDBTest.MultiThreaded/1
#
test_names = \
Y
Yueh-Hsuan Chiang 已提交
463 464 465 466 467
  ./db_test --gtest_list_tests						\
    | perl -n								\
      -e 's/ *\#.*//;'							\
      -e '/^(\s*)(\S+)/; !$$1 and do {$$p=$$2; break};'			\
      -e 'print qq! $$p$$2!'
468

469
ifneq (,$(filter check parallel_check,$(MAKECMDGOALS)),)
470 471 472 473 474
# Use /dev/shm if it has the sticky bit set (otherwise, /tmp),
# and create a randomly-named rocksdb.XXXX directory therein.
# We'll use that directory in the "make check" rules.
ifeq ($(TMPD),)
TMPD := $(shell f=/dev/shm; test -k $$f || f=/tmp;			\
Y
Yueh-Hsuan Chiang 已提交
475 476
  perl -le 'use File::Temp "tempdir";'					\
    -e 'print tempdir("'$$f'/rocksdb.XXXX", CLEANUP => 0)')
477 478
endif
endif
J
jorlow@chromium.org 已提交
479

480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497
ifneq ($(T),)

# Run all tests in parallel, accumulating per-test logs in t/log-*.

# t_sanitized is each $(T) with "-" in place of each "/".
t_sanitized = $(subst /,-,$(T))

# t_run is each sanitized name with a leading "t/".
t_run = $(patsubst %,t/%,$(t_sanitized))

# Each t_run file is a tiny generated bourne shell script
# that invokes one of db_tests's sub-tests. Why use a file
# for this?  Because that makes the invocation of parallel
# below simpler, which in turn makes the parsing of parallel's
# LOG simpler (the latter is for live monitoring as parallel
# tests run).
filter = --gtest_filter=$(subst -,/,$(@F))
$(t_run): Makefile db_test
Y
Yueh-Hsuan Chiang 已提交
498 499 500 501 502 503 504 505 506 507
	$(AM_V_GEN)mkdir -p t
	$(AM_V_at)rm -f $@ $@-t
	$(AM_V_at)printf '%s\n'						\
	    '#!/bin/sh'							\
	    'd=$(TMPD)/$(@F)'						\
	    'mkdir -p $$d'						\
	    'TEST_TMPDIR=$$d ./db_test $(filter)'			\
	  > $@-t
	$(AM_V_at)chmod a=rx $@-t
	$(AM_V_at)mv $@-t $@
508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525

# Reorder input lines (which are one per test) so that the
# longest-running tests appear first in the output.
# Do this by prefixing each selected name with its duration,
# sort the resulting names, and remove the leading numbers.
# FIXME: the "100" we prepend is a fake time, for now.
# FIXME: squirrel away timings from each run and use them
# (when present) on subsequent runs to order these tests.
#
# Without this reordering, these two tests would happen to start only
# after almost all other tests had completed, thus adding 100 seconds
# to the duration of parallel "make check".  That's the difference
# between 4 minutes (old) and 2m20s (new).
#
# 152.120 PASS t/DBTest.FileCreationRandomFailure
# 107.816 PASS t/DBTest.EncodeDecompressedBlockSizeTest
#
slow_test_regexp = \
Y
Yueh-Hsuan Chiang 已提交
526
  ^t/DBTest\.(?:FileCreationRandomFailure|EncodeDecompressedBlockSizeTest)$$
527
prioritize_long_running_tests =						\
Y
Yueh-Hsuan Chiang 已提交
528 529 530
  perl -pe 's,($(slow_test_regexp)),100 $$1,'				\
    | sort -k1,1gr							\
    | sed 's/^[.0-9]* //'
531 532 533 534 535 536 537 538

# "make check" uses
# Run with "make J=1 check" to disable parallelism in "make check".
# Run with "make J=200% check" to run two parallel jobs per core.
# The default is to run one job per core (J=100%).
# See "man parallel" for its "-j ..." option.
J = 100%

V
Venkatesh Radhakrishnan 已提交
539 540 541
# Use this regexp to select the subset of tests whose names match.
tests-regexp = .

542 543
.PHONY: check_0
check_0: $(t_run)
Y
Yueh-Hsuan Chiang 已提交
544 545 546 547 548 549 550 551 552 553 554 555
	$(AM_V_GEN)export TEST_TMPDIR=$(TMPD);				\
	printf '%s\n' ''						\
	  'To monitor subtest <duration,pass/fail,name>,'		\
	  '  run "make watch-log" in a separate window' '';		\
	test -t 1 && eta=--eta || eta=;					\
	{								\
	  printf './%s\n' $(filter-out db_test, $(TESTS));		\
	  printf '%s\n' $(t_run);					\
	}								\
	  | $(prioritize_long_running_tests)				\
	  | grep -E '$(tests-regexp)'					\
	  | parallel -j$(J) --joblog=LOG $$eta --gnu '{} >& t/log-{/}'
556 557 558
endif

CLEAN_FILES += t LOG $(TMPD)
559

560 561 562 563 564 565 566 567
# When running parallel "make check", you can monitor its progress
# from another window.
# Run "make watch_LOG" to show the duration,PASS/FAIL,name of parallel
# tests as they are being run.  We sort them so that longer-running ones
# appear at the top of the list and any failing tests remain at the top
# regardless of their duration. As with any use of "watch", hit ^C to
# interrupt.
watch-log:
Y
Yueh-Hsuan Chiang 已提交
568
	watch --interval=0 'sort -k7,7nr -k4,4gr LOG|$(quoted_perl_command)'
569

I
Igor Canadi 已提交
570
# If J != 1 and GNU parallel is installed, run the tests in parallel,
571 572
# via the check_0 rule above.  Otherwise, run them sequentially.
check: all
Y
Yueh-Hsuan Chiang 已提交
573 574 575 576 577 578 579 580 581 582 583
	$(AM_V_GEN)if test "$(J)" != 1                                  \
	    && (parallel --gnu --help 2>/dev/null) |                    \
	        grep -q 'GNU Parallel';                                 \
	then                                                            \
	    t=$$($(test_names));                                        \
	    $(MAKE) T="$$t" TMPD=$(TMPD) check_0;                       \
	else                                                            \
	    for t in $(TESTS); do                                       \
	      echo "===== Running $$t"; ./$$t || exit 1; done;          \
	fi
	rm -rf $(TMPD)
I
Islam AbdelRahman 已提交
584
ifeq ($(filter -DROCKSDB_LITE,$(OPT)),)
Y
Yueh-Hsuan Chiang 已提交
585 586
	python tools/ldb_test.py
	sh tools/rocksdb_dump_test.sh
I
Islam AbdelRahman 已提交
587
endif
588 589

check_some: $(SUBSET) ldb_tests
Y
Yueh-Hsuan Chiang 已提交
590
	for t in $(SUBSET); do echo "===== Running $$t"; ./$$t || exit 1; done
591 592

.PHONY: ldb_tests
593
ldb_tests: ldb
Y
Yueh-Hsuan Chiang 已提交
594
	python tools/ldb_test.py
595

I
Igor Canadi 已提交
596
crash_test: whitebox_crash_test blackbox_crash_test
597 598

blackbox_crash_test: db_stress
599 600
	python -u tools/db_crashtest.py --simple blackbox 
	python -u tools/db_crashtest.py blackbox
601 602

whitebox_crash_test: db_stress
603 604
	python -u tools/db_crashtest.py --simple whitebox
	python -u tools/db_crashtest.py whitebox
605

I
Igor Canadi 已提交
606
asan_check:
Y
Yueh-Hsuan Chiang 已提交
607 608 609
	$(MAKE) clean
	COMPILE_WITH_ASAN=1 $(MAKE) check -j32
	$(MAKE) clean
610 611

asan_crash_test:
Y
Yueh-Hsuan Chiang 已提交
612 613 614
	$(MAKE) clean
	COMPILE_WITH_ASAN=1 $(MAKE) crash_test
	$(MAKE) clean
I
Igor Canadi 已提交
615

I
Igor Canadi 已提交
616
valgrind_check: $(TESTS)
N
Nathan Bronson 已提交
617
	for t in $(filter-out %skiplist_test,$(TESTS)); do \
Y
Yueh-Hsuan Chiang 已提交
618
		$(VALGRIND_VER) $(VALGRIND_OPTS) ./$$t; \
S
sdong 已提交
619
		ret_code=$$?; \
K
krad 已提交
620
		if [ $$ret_code -ne 0 ]; then \
S
sdong 已提交
621
			exit $$ret_code; \
Y
Yueh-Hsuan Chiang 已提交
622 623
		fi; \
	done
624

625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666

ifneq ($(PAR_TEST),)
parloop:
	ret_bad=0;							\
	for t in $(PAR_TEST); do		\
		echo "===== Running $$t in parallel $(NUM_PAR)";\
		if [ $(db_test) -eq 1 ]; then \
			seq $(J) | v="$$t" parallel --gnu 's=$(TMPD)/rdb-{};  export TEST_TMPDIR=$$s;' \
				'timeout 2m ./db_test --gtest_filter=$$v >> $$s/log-{} 2>1'; \
		else\
			seq $(J) | v="./$$t" parallel --gnu 's=$(TMPD)/rdb-{};' \
			     'export TEST_TMPDIR=$$s; timeout 10m $$v >> $$s/log-{} 2>1'; \
		fi; \
		ret_code=$$?; \
		if [ $$ret_code -ne 0 ]; then \
			ret_bad=$$ret_code; \
			echo $$t exited with $$ret_code; \
		fi; \
	done; \
	exit $$ret_bad;
endif

all_tests:=$(shell $(test_names))

parallel_check: $(TESTS)
	$(AM_V_GEN)if test "$(J)" > 1                                  \
	    && (parallel --gnu --help 2>/dev/null) |                    \
	        grep -q 'GNU Parallel';                                 \
	then                                                            \
	    echo Running in parallel $(J);			\
	else                                                            \
	    echo "Need to have GNU Parallel and J > 1"; exit 1;		\
	fi;								\
	ret_bad=0;							\
	echo $(J);\
	echo Test Dir: $(TMPD); \
        seq $(J) | parallel --gnu 's=$(TMPD)/rdb-{}; rm -rf $$s; mkdir $$s'; \
	$(MAKE)  PAR_TEST="$(all_tests)" TMPD=$(TMPD) \
		J=$(J) db_test=1 parloop; \
	$(MAKE) PAR_TEST="$(filter-out db_test, $(TESTS))" \
		TMPD=$(TMPD) J=$(J) db_test=0 parloop;

667
analyze: clean
Y
Yueh-Hsuan Chiang 已提交
668 669 670 671
	$(CLANG_SCAN_BUILD) --use-analyzer=$(CLANG_ANALYZER) \
		--use-c++=$(CXX) --use-cc=$(CC) --status-bugs \
		-o $(CURDIR)/scan_build_report \
		$(MAKE) dbg
672

673 674
CLEAN_FILES += unity.cc
unity.cc: Makefile
Y
Yueh-Hsuan Chiang 已提交
675 676
	rm -f $@ $@-t
	for source_file in $(LIB_SOURCES); do \
E
Evan Shaw 已提交
677
		echo "#include \"$$source_file\"" >> $@-t; \
Y
Yueh-Hsuan Chiang 已提交
678 679 680
	done
	chmod a=r $@-t
	mv $@-t $@
M
miguelportilla 已提交
681

E
Evan Shaw 已提交
682 683 684 685
unity.a: unity.o
	$(AM_V_AR)rm -f $@
	$(AM_V_at)$(AR) $(ARFLAGS) $@ unity.o

I
Igor Canadi 已提交
686
# try compiling db_test with unity
687
unity_test: db/db_test.o db/db_test_util.o $(TESTHARNESS) unity.a
I
Igor Canadi 已提交
688 689 690
	$(AM_LINK)
	./unity_test

E
Evan Shaw 已提交
691 692
rocksdb.h rocksdb.cc: build_tools/amalgamate.py Makefile $(LIB_SOURCES) unity.cc
	build_tools/amalgamate.py -I. -i./include unity.cc -x include/rocksdb/c.h -H rocksdb.h -o rocksdb.cc
M
miguelportilla 已提交
693

J
jorlow@chromium.org 已提交
694
clean:
Y
Yueh-Hsuan Chiang 已提交
695 696 697 698 699
	rm -f $(BENCHMARKS) $(TOOLS) $(TESTS) $(LIBRARY) $(SHARED)
	rm -rf $(CLEAN_FILES) ios-x86 ios-arm scan_build_report
	find . -name "*.[oda]" -exec rm -f {} \;
	find . -type f -regex ".*\.\(\(gcda\)\|\(gcno\)\)" -exec rm {} \;
	rm -rf bzip2* snappy* zlib* lz4*
700

701
tags:
Y
Yueh-Hsuan Chiang 已提交
702 703
	ctags * -R
	cscope -b `find . -name '*.cc'` `find . -name '*.h'`
704

705
format:
Y
Yueh-Hsuan Chiang 已提交
706
	build_tools/format-diff.sh
707

708
package:
Y
Yueh-Hsuan Chiang 已提交
709
	bash build_tools/make_package.sh $(SHARED_MAJOR).$(SHARED_MINOR)
710

711 712 713
# ---------------------------------------------------------------------------
# 	Unit tests and tools
# ---------------------------------------------------------------------------
714
$(LIBRARY): $(LIBOBJECTS)
Y
Yueh-Hsuan Chiang 已提交
715 716
	$(AM_V_AR)rm -f $@
	$(AM_V_at)$(AR) $(ARFLAGS) $@ $(LIBOBJECTS)
J
jorlow@chromium.org 已提交
717

718
db_bench: db/db_bench.o $(LIBOBJECTS) $(TESTUTIL)
Y
Yueh-Hsuan Chiang 已提交
719
	$(AM_LINK)
J
jorlow@chromium.org 已提交
720

F
Feng Zhu 已提交
721
cache_bench: util/cache_bench.o $(LIBOBJECTS) $(TESTUTIL)
Y
Yueh-Hsuan Chiang 已提交
722
	$(AM_LINK)
J
jorlow@chromium.org 已提交
723

A
Ameya Gupte 已提交
724
memtablerep_bench: db/memtablerep_bench.o $(LIBOBJECTS) $(TESTUTIL)
Y
Yueh-Hsuan Chiang 已提交
725
	$(AM_LINK)
A
Ameya Gupte 已提交
726

K
kailiu 已提交
727
block_hash_index_test: table/block_hash_index_test.o $(LIBOBJECTS) $(TESTHARNESS)
Y
Yueh-Hsuan Chiang 已提交
728
	$(AM_LINK)
K
kailiu 已提交
729

730
db_stress: tools/db_stress.o $(LIBOBJECTS) $(TESTUTIL)
Y
Yueh-Hsuan Chiang 已提交
731
	$(AM_LINK)
732

I
Igor Canadi 已提交
733 734 735
write_stress: tools/write_stress.o $(LIBOBJECTS) $(TESTUTIL)
	$(AM_LINK)

I
Igor Canadi 已提交
736
db_sanity_test: tools/db_sanity_test.o $(LIBOBJECTS) $(TESTUTIL)
Y
Yueh-Hsuan Chiang 已提交
737
	$(AM_LINK)
738

739
db_repl_stress: tools/db_repl_stress.o $(LIBOBJECTS) $(TESTUTIL)
Y
Yueh-Hsuan Chiang 已提交
740
	$(AM_LINK)
741

J
jorlow@chromium.org 已提交
742
arena_test: util/arena_test.o $(LIBOBJECTS) $(TESTHARNESS)
Y
Yueh-Hsuan Chiang 已提交
743
	$(AM_LINK)
J
jorlow@chromium.org 已提交
744

K
kailiu 已提交
745
autovector_test: util/autovector_test.o $(LIBOBJECTS) $(TESTHARNESS)
Y
Yueh-Hsuan Chiang 已提交
746
	$(AM_LINK)
K
kailiu 已提交
747

748
column_family_test: db/column_family_test.o $(LIBOBJECTS) $(TESTHARNESS)
Y
Yueh-Hsuan Chiang 已提交
749
	$(AM_LINK)
750

K
kailiu 已提交
751
table_properties_collector_test: db/table_properties_collector_test.o $(LIBOBJECTS) $(TESTHARNESS)
Y
Yueh-Hsuan Chiang 已提交
752
	$(AM_LINK)
753

S
Sanjay Ghemawat 已提交
754
bloom_test: util/bloom_test.o $(LIBOBJECTS) $(TESTHARNESS)
Y
Yueh-Hsuan Chiang 已提交
755
	$(AM_LINK)
S
Sanjay Ghemawat 已提交
756

757
dynamic_bloom_test: util/dynamic_bloom_test.o $(LIBOBJECTS) $(TESTHARNESS)
Y
Yueh-Hsuan Chiang 已提交
758
	$(AM_LINK)
759

760
c_test: db/c_test.o $(LIBOBJECTS) $(TESTHARNESS)
Y
Yueh-Hsuan Chiang 已提交
761
	$(AM_LINK)
762

J
jorlow@chromium.org 已提交
763
cache_test: util/cache_test.o $(LIBOBJECTS) $(TESTHARNESS)
Y
Yueh-Hsuan Chiang 已提交
764
	$(AM_LINK)
J
jorlow@chromium.org 已提交
765 766

coding_test: util/coding_test.o $(LIBOBJECTS) $(TESTHARNESS)
Y
Yueh-Hsuan Chiang 已提交
767
	$(AM_LINK)
J
jorlow@chromium.org 已提交
768

769
stringappend_test: utilities/merge_operators/string_append/stringappend_test.o $(LIBOBJECTS) $(TESTHARNESS)
Y
Yueh-Hsuan Chiang 已提交
770
	$(AM_LINK)
771

772
redis_test: utilities/redis/redis_lists_test.o $(LIBOBJECTS) $(TESTHARNESS)
Y
Yueh-Hsuan Chiang 已提交
773
	$(AM_LINK)
774

A
Abhishek Kona 已提交
775
histogram_test: util/histogram_test.o $(LIBOBJECTS) $(TESTHARNESS)
Y
Yueh-Hsuan Chiang 已提交
776
	$(AM_LINK)
A
Abhishek Kona 已提交
777

L
Lei Jin 已提交
778
thread_local_test: util/thread_local_test.o $(LIBOBJECTS) $(TESTHARNESS)
Y
Yueh-Hsuan Chiang 已提交
779
	$(AM_LINK)
L
Lei Jin 已提交
780

J
jorlow@chromium.org 已提交
781
corruption_test: db/corruption_test.o $(LIBOBJECTS) $(TESTHARNESS)
Y
Yueh-Hsuan Chiang 已提交
782
	$(AM_LINK)
J
jorlow@chromium.org 已提交
783 784

crc32c_test: util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS)
Y
Yueh-Hsuan Chiang 已提交
785
	$(AM_LINK)
J
jorlow@chromium.org 已提交
786

787
slice_transform_test: util/slice_transform_test.o $(LIBOBJECTS) $(TESTHARNESS)
Y
Yueh-Hsuan Chiang 已提交
788
	$(AM_LINK)
789

790
db_test: db/db_test.o db/db_test_util.o $(LIBOBJECTS) $(TESTHARNESS)
Y
Yueh-Hsuan Chiang 已提交
791
	$(AM_LINK)
J
jorlow@chromium.org 已提交
792

793
db_log_iter_test: db/db_log_iter_test.o db/db_test_util.o $(LIBOBJECTS) $(TESTHARNESS)
794
	$(AM_LINK)
795

796
db_compaction_filter_test: db/db_compaction_filter_test.o db/db_test_util.o $(LIBOBJECTS) $(TESTHARNESS)
797 798
	$(AM_LINK)

799
db_compaction_test: db/db_compaction_test.o db/db_test_util.o $(LIBOBJECTS) $(TESTHARNESS)
800 801
	$(AM_LINK)

802
db_dynamic_level_test: db/db_dynamic_level_test.o db/db_test_util.o $(LIBOBJECTS) $(TESTHARNESS)
803 804
	$(AM_LINK)

805
db_inplace_update_test: db/db_inplace_update_test.o db/db_test_util.o $(LIBOBJECTS) $(TESTHARNESS)
806 807
	$(AM_LINK)

808
db_tailing_iter_test: db/db_tailing_iter_test.o db/db_test_util.o $(LIBOBJECTS) $(TESTHARNESS)
809 810
	$(AM_LINK)

S
Stanislau Hlebik 已提交
811
db_iter_test: db/db_iter_test.o $(LIBOBJECTS) $(TESTHARNESS)
812
	$(AM_LINK)
S
Stanislau Hlebik 已提交
813

814
db_universal_compaction_test: db/db_universal_compaction_test.o db/db_test_util.o $(LIBOBJECTS) $(TESTHARNESS)
815 816
	$(AM_LINK)

817
db_wal_test: db/db_wal_test.o db/db_test_util.o $(LIBOBJECTS) $(TESTHARNESS)
S
sdong 已提交
818 819
	$(AM_LINK)

820 821 822
db_properties_test: db/db_properties_test.o db/db_test_util.o $(LIBOBJECTS) $(TESTHARNESS)
	$(AM_LINK)

823 824 825
db_table_properties_test: db/db_table_properties_test.o db/db_test_util.o $(LIBOBJECTS) $(TESTHARNESS)
	$(AM_LINK)

826
log_write_bench: util/log_write_bench.o $(LIBOBJECTS) $(TESTHARNESS)
827
	$(AM_LINK) $(pg)
828

S
Siying Dong 已提交
829
plain_table_db_test: db/plain_table_db_test.o $(LIBOBJECTS) $(TESTHARNESS)
830
	$(AM_LINK)
S
Siying Dong 已提交
831

832
comparator_db_test: db/comparator_db_test.o $(LIBOBJECTS) $(TESTHARNESS)
833
	$(AM_LINK)
834

835
table_reader_bench: table/table_reader_bench.o $(LIBOBJECTS) $(TESTHARNESS)
836
	$(AM_LINK) $(pg)
837

838
perf_context_test: db/perf_context_test.o $(LIBOBJECTS) $(TESTHARNESS)
839
	$(AM_V_CCLD)$(CXX) $^ $(EXEC_LDFLAGS) -o $@ $(LDFLAGS)
840

H
Haobo Xu 已提交
841
prefix_test: db/prefix_test.o $(LIBOBJECTS) $(TESTHARNESS)
842
	$(AM_V_CCLD)$(CXX) $^ $(EXEC_LDFLAGS) -o $@ $(LDFLAGS)
H
Haobo Xu 已提交
843

I
Igor Canadi 已提交
844
backupable_db_test: utilities/backupable/backupable_db_test.o $(LIBOBJECTS) $(TESTHARNESS)
845
	$(AM_LINK)
I
Igor Canadi 已提交
846

847 848 849
checkpoint_test: utilities/checkpoint/checkpoint_test.o $(LIBOBJECTS) $(TESTHARNESS)
	$(AM_LINK)

I
Igor Canadi 已提交
850
document_db_test: utilities/document/document_db_test.o $(LIBOBJECTS) $(TESTHARNESS)
851
	$(AM_LINK)
I
Igor Canadi 已提交
852

I
Igor Canadi 已提交
853
json_document_test: utilities/document/json_document_test.o $(LIBOBJECTS) $(TESTHARNESS)
854
	$(AM_LINK)
I
Igor Canadi 已提交
855

I
Igor Canadi 已提交
856
spatial_db_test: utilities/spatialdb/spatial_db_test.o $(LIBOBJECTS) $(TESTHARNESS)
857
	$(AM_LINK)
I
Igor Canadi 已提交
858

S
Sage Weil 已提交
859 860 861
env_mirror_test: utilities/env_mirror_test.o $(LIBOBJECTS) $(TESTHARNESS)
	$(AM_LINK)

862
ttl_test: utilities/ttl/ttl_test.o $(LIBOBJECTS) $(TESTHARNESS)
863
	$(AM_LINK)
864

865
write_batch_with_index_test: utilities/write_batch_with_index/write_batch_with_index_test.o $(LIBOBJECTS) $(TESTHARNESS)
866
	$(AM_LINK)
867

I
Igor Canadi 已提交
868
flush_job_test: db/flush_job_test.o $(LIBOBJECTS) $(TESTHARNESS)
869
	$(AM_LINK)
A
Andres Noetzli 已提交
870 871 872

compaction_iterator_test: db/compaction_iterator_test.o $(LIBOBJECTS) $(TESTHARNESS)
	$(AM_LINK)
I
Igor Canadi 已提交
873

I
Igor Canadi 已提交
874
compaction_job_test: db/compaction_job_test.o $(LIBOBJECTS) $(TESTHARNESS)
875
	$(AM_LINK)
I
Igor Canadi 已提交
876

877 878 879
compaction_job_stats_test: db/compaction_job_stats_test.o $(LIBOBJECTS) $(TESTHARNESS)
	$(AM_LINK)

880 881 882
compact_on_deletion_collector_test: utilities/table_properties_collectors/compact_on_deletion_collector_test.o $(LIBOBJECTS) $(TESTHARNESS)
	$(AM_LINK)

I
Igor Canadi 已提交
883
wal_manager_test: db/wal_manager_test.o $(LIBOBJECTS) $(TESTHARNESS)
884
	$(AM_LINK)
I
Igor Canadi 已提交
885

J
jorlow@chromium.org 已提交
886
dbformat_test: db/dbformat_test.o $(LIBOBJECTS) $(TESTHARNESS)
887
	$(AM_LINK)
J
jorlow@chromium.org 已提交
888 889

env_test: util/env_test.o $(LIBOBJECTS) $(TESTHARNESS)
890
	$(AM_LINK)
J
jorlow@chromium.org 已提交
891

892
fault_injection_test: db/fault_injection_test.o $(LIBOBJECTS) $(TESTHARNESS)
893
	$(AM_LINK)
894

L
Lei Jin 已提交
895
rate_limiter_test: util/rate_limiter_test.o $(LIBOBJECTS) $(TESTHARNESS)
896
	$(AM_LINK)
L
Lei Jin 已提交
897

I
Islam AbdelRahman 已提交
898 899 900
delete_scheduler_test: util/delete_scheduler_test.o $(LIBOBJECTS) $(TESTHARNESS)
	$(AM_LINK)

J
jorlow@chromium.org 已提交
901
filename_test: db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS)
902
	$(AM_LINK)
J
jorlow@chromium.org 已提交
903

904 905 906
file_reader_writer_test: util/file_reader_writer_test.o $(LIBOBJECTS) $(TESTHARNESS)
	$(AM_LINK)

907
block_based_filter_block_test: table/block_based_filter_block_test.o $(LIBOBJECTS) $(TESTHARNESS)
908
	$(AM_LINK)
909 910

full_filter_block_test: table/full_filter_block_test.o $(LIBOBJECTS) $(TESTHARNESS)
911
	$(AM_LINK)
S
Sanjay Ghemawat 已提交
912

J
jorlow@chromium.org 已提交
913
log_test: db/log_test.o $(LIBOBJECTS) $(TESTHARNESS)
914
	$(AM_LINK)
J
jorlow@chromium.org 已提交
915 916

table_test: table/table_test.o $(LIBOBJECTS) $(TESTHARNESS)
917
	$(AM_LINK)
J
jorlow@chromium.org 已提交
918

D
Dhruba Borthakur 已提交
919
block_test: table/block_test.o $(LIBOBJECTS) $(TESTHARNESS)
920
	$(AM_LINK)
D
Dhruba Borthakur 已提交
921

N
Nathan Bronson 已提交
922 923 924
inlineskiplist_test: db/inlineskiplist_test.o $(LIBOBJECTS) $(TESTHARNESS)
	$(AM_LINK)

J
jorlow@chromium.org 已提交
925
skiplist_test: db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS)
926
	$(AM_LINK)
J
jorlow@chromium.org 已提交
927 928

version_edit_test: db/version_edit_test.o $(LIBOBJECTS) $(TESTHARNESS)
929
	$(AM_LINK)
J
jorlow@chromium.org 已提交
930

931
version_set_test: db/version_set_test.o $(LIBOBJECTS) $(TESTHARNESS)
932
	$(AM_LINK)
933

S
sdong 已提交
934
compaction_picker_test: db/compaction_picker_test.o $(LIBOBJECTS) $(TESTHARNESS)
935
	$(AM_LINK)
S
sdong 已提交
936

S
sdong 已提交
937
version_builder_test: db/version_builder_test.o $(LIBOBJECTS) $(TESTHARNESS)
938
	$(AM_LINK)
S
sdong 已提交
939

940
file_indexer_test: db/file_indexer_test.o $(LIBOBJECTS) $(TESTHARNESS)
941
	$(AM_LINK)
942

943
reduce_levels_test: tools/reduce_levels_test.o $(LIBOBJECTS) $(TESTHARNESS)
944
	$(AM_LINK)
945

J
jorlow@chromium.org 已提交
946
write_batch_test: db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS)
947
	$(AM_LINK)
948

949
write_controller_test: db/write_controller_test.o $(LIBOBJECTS) $(TESTHARNESS)
950
	$(AM_LINK)
951

952 953 954
merge_helper_test: db/merge_helper_test.o $(LIBOBJECTS) $(TESTHARNESS)
	$(AM_LINK)

955 956 957
memory_test: utilities/memory/memory_test.o $(LIBOBJECTS) $(TESTHARNESS)
	$(AM_LINK)

J
Jim Paton 已提交
958
merge_test: db/merge_test.o $(LIBOBJECTS) $(TESTHARNESS)
959
	$(AM_LINK)
J
jorlow@chromium.org 已提交
960

I
Igor Canadi 已提交
961
merger_test: table/merger_test.o $(LIBOBJECTS) $(TESTHARNESS)
962
	$(AM_LINK)
I
Igor Canadi 已提交
963

964 965 966
options_file_test: db/options_file_test.o $(LIBOBJECTS) $(TESTHARNESS)
	$(AM_LINK)

967
deletefile_test: db/deletefile_test.o $(LIBOBJECTS) $(TESTHARNESS)
968
	$(AM_LINK)
969

970
geodb_test: utilities/geodb/geodb_test.o $(LIBOBJECTS) $(TESTHARNESS)
971
	$(AM_LINK)
972

973 974 975 976 977 978
rocksdb_dump: tools/dump/rocksdb_dump.o $(LIBOBJECTS)
	$(AM_LINK)

rocksdb_undump: tools/dump/rocksdb_undump.o $(LIBOBJECTS)
	$(AM_LINK)

979
cuckoo_table_builder_test: table/cuckoo_table_builder_test.o $(LIBOBJECTS) $(TESTHARNESS)
980
	$(AM_LINK)
981

I
Igor Canadi 已提交
982
cuckoo_table_reader_test: table/cuckoo_table_reader_test.o $(LIBOBJECTS) $(TESTHARNESS)
983
	$(AM_LINK)
984

985
cuckoo_table_db_test: db/cuckoo_table_db_test.o $(LIBOBJECTS) $(TESTHARNESS)
986
	$(AM_LINK)
987

988
listener_test: db/listener_test.o db/db_test_util.o $(LIBOBJECTS) $(TESTHARNESS)
989
	$(AM_LINK)
990

Y
Yueh-Hsuan Chiang 已提交
991
thread_list_test: util/thread_list_test.o $(LIBOBJECTS) $(TESTHARNESS)
992
	$(AM_LINK)
Y
Yueh-Hsuan Chiang 已提交
993

994 995 996
compact_files_test: db/compact_files_test.o $(LIBOBJECTS) $(TESTHARNESS)
	$(AM_LINK)

997
options_test: util/options_test.o $(LIBOBJECTS) $(TESTHARNESS)
998
	$(AM_LINK)
999

1000 1001 1002
options_util_test: utilities/options/options_util_test.o $(LIBOBJECTS) $(TESTHARNESS)
	$(AM_LINK)

I
Igor Canadi 已提交
1003 1004 1005
event_logger_test: util/event_logger_test.o $(LIBOBJECTS) $(TESTHARNESS)
	$(AM_LINK)

1006
sst_dump_test: tools/sst_dump_test.o $(LIBOBJECTS) $(TESTHARNESS)
1007
	$(AM_LINK)
1008

1009
memenv_test : util/memenv_test.o $(LIBOBJECTS) $(TESTHARNESS)
1010
	$(AM_LINK)
H
Hans Wennborg 已提交
1011

A
agiardullo 已提交
1012 1013 1014
optimistic_transaction_test: utilities/transactions/optimistic_transaction_test.o $(LIBOBJECTS) $(TESTHARNESS)
	$(AM_LINK)

1015
mock_env_test : util/mock_env_test.o $(LIBOBJECTS) $(TESTHARNESS)
1016
	$(AM_LINK)
1017

1018
manual_compaction_test: db/manual_compaction_test.o $(LIBOBJECTS) $(TESTHARNESS)
1019
	$(AM_LINK)
1020

1021
filelock_test: util/filelock_test.o $(LIBOBJECTS) $(TESTHARNESS)
1022
	$(AM_LINK)
K
Kai Liu 已提交
1023

1024
auto_roll_logger_test: db/auto_roll_logger_test.o $(LIBOBJECTS) $(TESTHARNESS)
1025
	$(AM_LINK)
1026

A
agiardullo 已提交
1027 1028 1029
memtable_list_test: db/memtable_list_test.o $(LIBOBJECTS) $(TESTHARNESS)
	$(AM_LINK)

A
agiardullo 已提交
1030 1031 1032
write_callback_test: db/write_callback_test.o $(LIBOBJECTS) $(TESTHARNESS)
	$(AM_LINK)

1033 1034 1035
heap_test: util/heap_test.o $(GTEST)
	$(AM_LINK)

A
agiardullo 已提交
1036 1037 1038
transaction_test: utilities/transactions/transaction_test.o $(LIBOBJECTS) $(TESTHARNESS)
	$(AM_LINK)

1039
sst_dump: tools/sst_dump.o $(LIBOBJECTS)
1040
	$(AM_LINK)
1041

1042
ldb_cmd_test: tools/ldb_cmd_test.o $(LIBOBJECTS) $(TESTHARNESS)
1043 1044
	$(AM_LINK)

1045
ldb: tools/ldb.o $(LIBOBJECTS)
1046
	$(AM_LINK)
1047

I
Igor Canadi 已提交
1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079
#-------------------------------------------------
# make install related stuff
INSTALL_PATH ?= /usr/local

uninstall:
	rm -rf $(INSTALL_PATH)/include/rocksdb \
	  $(INSTALL_PATH)/lib/$(LIBRARY) \
	  $(INSTALL_PATH)/lib/$(SHARED4) \
	  $(INSTALL_PATH)/lib/$(SHARED3) \
	  $(INSTALL_PATH)/lib/$(SHARED2) \
	  $(INSTALL_PATH)/lib/$(SHARED1)

install-headers:
	install -d $(INSTALL_PATH)/lib
	for header_dir in `find "include/rocksdb" -type d`; do \
		install -d $(INSTALL_PATH)/$$header_dir; \
	done
	for header in `find "include/rocksdb" -type f -name *.h`; do \
		install -C -m 644 $$header $(INSTALL_PATH)/$$header; \
	done

install-static: install-headers $(LIBRARY)
	install -C -m 755 $(LIBRARY) $(INSTALL_PATH)/lib

install-shared: install-headers $(SHARED4)
	install -C -m 755 $(SHARED4) $(INSTALL_PATH)/lib && \
		ln -fs $(SHARED4) $(INSTALL_PATH)/lib/$(SHARED3) && \
		ln -fs $(SHARED4) $(INSTALL_PATH)/lib/$(SHARED2) && \
		ln -fs $(SHARED4) $(INSTALL_PATH)/lib/$(SHARED1)

# install static by default + install shared if it exists
install: install-static
I
Igor Canadi 已提交
1080
	[ -e $(SHARED4) ] && $(MAKE) install-shared || :
I
Igor Canadi 已提交
1081 1082 1083 1084

#-------------------------------------------------


1085 1086 1087 1088
# ---------------------------------------------------------------------------
# Jni stuff
# ---------------------------------------------------------------------------

1089
JAVA_INCLUDE = -I$(JAVA_HOME)/include/ -I$(JAVA_HOME)/include/linux
D
David Bernard 已提交
1090 1091 1092 1093 1094
ifeq ($(PLATFORM), OS_SOLARIS)
	ARCH := $(shell isainfo -b)
else
	ARCH := $(shell getconf LONG_BIT)
endif
1095
ROCKSDBJNILIB = librocksdbjni-linux$(ARCH).so
1096
ROCKSDB_JAR = rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)-linux$(ARCH).jar
1097
ROCKSDB_JAR_ALL = rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH).jar
C
Chris Riccomini 已提交
1098
ROCKSDB_JAVADOCS_JAR = rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)-javadoc.jar
1099
ROCKSDB_SOURCES_JAR = rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)-sources.jar
1100 1101

ifeq ($(PLATFORM), OS_MACOSX)
D
David Bernard 已提交
1102 1103
	ROCKSDBJNILIB = librocksdbjni-osx.jnilib
	ROCKSDB_JAR = rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)-osx.jar
1104 1105 1106 1107 1108
ifneq ("$(wildcard $(JAVA_HOME)/include/darwin)","")
	JAVA_INCLUDE = -I$(JAVA_HOME)/include -I $(JAVA_HOME)/include/darwin
else
	JAVA_INCLUDE = -I/System/Library/Frameworks/JavaVM.framework/Headers/
endif
1109
endif
D
David Bernard 已提交
1110 1111 1112 1113 1114
ifeq ($(PLATFORM), OS_SOLARIS)
	ROCKSDBJNILIB = librocksdbjni-solaris$(ARCH).so
	ROCKSDB_JAR = rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)-solaris$(ARCH).jar
	JAVA_INCLUDE = -I$(JAVA_HOME)/include/ -I$(JAVA_HOME)/include/solaris
endif
1115

N
Naveen 已提交
1116 1117
libz.a:
	-rm -rf zlib-1.2.8
N
Naveen 已提交
1118 1119 1120
	curl -O http://zlib.net/zlib-1.2.8.tar.gz
	tar xvzf zlib-1.2.8.tar.gz
	cd zlib-1.2.8 && CFLAGS='-fPIC' ./configure --static && make
1121
	cp zlib-1.2.8/libz.a .
N
Naveen 已提交
1122 1123 1124

libbz2.a:
	-rm -rf bzip2-1.0.6
1125
	curl -O  http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz
N
Naveen 已提交
1126
	tar xvzf bzip2-1.0.6.tar.gz
1127
	cd bzip2-1.0.6 && make CFLAGS='-fPIC -O2 -g -D_FILE_OFFSET_BITS=64'
N
Naveen 已提交
1128 1129
	cp bzip2-1.0.6/libbz2.a .

N
Naveen 已提交
1130 1131
libsnappy.a:
	-rm -rf snappy-1.1.1
N
Naveen 已提交
1132 1133
	curl -O https://snappy.googlecode.com/files/snappy-1.1.1.tar.gz
	tar xvzf snappy-1.1.1.tar.gz
N
Naveen 已提交
1134
	cd snappy-1.1.1 && ./configure --with-pic --enable-static
N
Naveen 已提交
1135 1136
	cd snappy-1.1.1 && make
	cp snappy-1.1.1/.libs/libsnappy.a .
1137

1138 1139 1140 1141 1142 1143 1144
liblz4.a:
	   -rm -rf lz4-r127
	   curl -O https://codeload.github.com/Cyan4973/lz4/tar.gz/r127
	   mv r127 lz4-r127.tar.gz
	   tar xvzf lz4-r127.tar.gz
	   cd lz4-r127/lib && make CFLAGS='-fPIC' all
	   cp lz4-r127/lib/liblz4.a .
N
Naveen 已提交
1145

1146 1147 1148
# A version of each $(LIBOBJECTS) compiled with -fPIC and a fixed set of static compression libraries
java_static_libobjects = $(patsubst %,jls/%,$(LIBOBJECTS))
CLEAN_FILES += jls
1149

1150 1151 1152 1153 1154
JAVA_STATIC_FLAGS = -DZLIB -DBZIP2 -DSNAPPY -DLZ4
JAVA_STATIC_INCLUDES = -I./zlib-1.2.8 -I./bzip2-1.0.6 -I./snappy-1.1.1 -I./lz4-r127/lib

$(java_static_libobjects): jls/%.o: %.cc libz.a libbz2.a libsnappy.a liblz4.a
	$(AM_V_CC)mkdir -p $(@D) && $(CXX) $(CXXFLAGS) $(JAVA_STATIC_FLAGS) $(JAVA_STATIC_INCLUDES) -fPIC -c $< -o $@ $(COVERAGEFLAGS)
1155

1156
rocksdbjavastatic: $(java_static_libobjects)
F
fyrz 已提交
1157
	cd java;$(MAKE) javalib;
1158
	rm -f ./java/target/$(ROCKSDBJNILIB)
1159 1160
	$(CXX) $(CXXFLAGS) -I./java/. $(JAVA_INCLUDE) -shared -fPIC \
	  -o ./java/target/$(ROCKSDBJNILIB) $(JNI_NATIVE_SOURCES) \
1161
	  $(java_static_libobjects) $(COVERAGEFLAGS) \
1162
	  libz.a libbz2.a libsnappy.a liblz4.a $(JAVA_STATIC_LDFLAGS)
1163 1164 1165 1166 1167 1168
	cd java/target;strip -S -x $(ROCKSDBJNILIB)
	cd java;jar -cf target/$(ROCKSDB_JAR) HISTORY*.md
	cd java/target;jar -uf $(ROCKSDB_JAR) $(ROCKSDBJNILIB)
	cd java/target/classes;jar -uf ../$(ROCKSDB_JAR) org/rocksdb/*.class org/rocksdb/util/*.class
	cd java/target/apidocs;jar -cf ../$(ROCKSDB_JAVADOCS_JAR) *
	cd java/src/main/java;jar -cf ../../../target/$(ROCKSDB_SOURCES_JAR) org
N
Naveen 已提交
1169

1170
rocksdbjavastaticrelease: rocksdbjavastatic
1171
	cd java/crossbuild && vagrant destroy -f && vagrant up linux32 && vagrant halt linux32 && vagrant up linux64 && vagrant halt linux64
1172
	cd java;jar -cf target/$(ROCKSDB_JAR_ALL) HISTORY*.md
1173
	cd java/target;jar -uf $(ROCKSDB_JAR_ALL) librocksdbjni-*.so librocksdbjni-*.jnilib
1174
	cd java/target/classes;jar -uf ../$(ROCKSDB_JAR_ALL) org/rocksdb/*.class org/rocksdb/util/*.class
1175

1176
rocksdbjavastaticpublish: rocksdbjavastaticrelease
1177 1178 1179 1180 1181 1182
	mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=java/rocksjni.pom -Dfile=java/target/rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)-javadoc.jar -Dclassifier=javadoc
	mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=java/rocksjni.pom -Dfile=java/target/rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)-sources.jar -Dclassifier=sources
	mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=java/rocksjni.pom -Dfile=java/target/rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)-linux64.jar -Dclassifier=linux64
	mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=java/rocksjni.pom -Dfile=java/target/rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)-linux32.jar -Dclassifier=linux32
	mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=java/rocksjni.pom -Dfile=java/target/rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH)-osx.jar -Dclassifier=osx
	mvn gpg:sign-and-deploy-file -Durl=https://oss.sonatype.org/service/local/staging/deploy/maven2/ -DrepositoryId=sonatype-nexus-staging -DpomFile=java/rocksjni.pom -Dfile=java/target/rocksdbjni-$(ROCKSDB_MAJOR).$(ROCKSDB_MINOR).$(ROCKSDB_PATCH).jar
1183

1184 1185 1186 1187 1188 1189 1190
# A version of each $(LIBOBJECTS) compiled with -fPIC
java_libobjects = $(patsubst %,jl/%,$(LIBOBJECTS))
CLEAN_FILES += jl

$(java_libobjects): jl/%.o: %.cc
	$(AM_V_CC)mkdir -p $(@D) && $(CXX) $(CXXFLAGS) -fPIC -c $< -o $@ $(COVERAGEFLAGS)

1191
rocksdbjava: $(java_libobjects)
1192 1193 1194 1195 1196 1197
	$(AM_V_GEN)cd java;$(MAKE) javalib;
	$(AM_V_at)rm -f ./java/target/$(ROCKSDBJNILIB)
	$(AM_V_at)$(CXX) $(CXXFLAGS) -I./java/. $(JAVA_INCLUDE) -shared -fPIC -o ./java/target/$(ROCKSDBJNILIB) $(JNI_NATIVE_SOURCES) $(java_libobjects) $(JAVA_LDFLAGS) $(COVERAGEFLAGS)
	$(AM_V_at)cd java;jar -cf target/$(ROCKSDB_JAR) HISTORY*.md
	$(AM_V_at)cd java/target;jar -uf $(ROCKSDB_JAR) $(ROCKSDBJNILIB)
	$(AM_V_at)cd java/target/classes;jar -uf ../$(ROCKSDB_JAR) org/rocksdb/*.class org/rocksdb/util/*.class
1198 1199 1200 1201

jclean:
	cd java;$(MAKE) clean;

1202
jtest: rocksdbjava
1203
	cd java;$(MAKE) sample;$(MAKE) test;
1204

1205 1206 1207
jdb_bench:
	cd java;$(MAKE) db_bench;

1208 1209
commit_prereq: build_tools/rocksdb-lego-determinator \
               build_tools/precommit_checker.py
1210
	$(MAKE) clean && $(MAKE) jclean && $(MAKE) rocksdbjava;
1211
	build_tools/precommit_checker.py unit uint_481 clang_unit tsan asan lite
1212

V
Venkatesh Radhakrishnan 已提交
1213 1214 1215 1216 1217 1218 1219
xfunc:
	for xftest in $(XFUNC_TESTS); do \
		echo "===== Running xftest $$xftest"; \
		make check ROCKSDB_XFUNC_TEST="$$xftest" tests-regexp="DBTest" ;\
	done


1220 1221 1222
# ---------------------------------------------------------------------------
#  	Platform-specific compilation
# ---------------------------------------------------------------------------
J
Jim Paton 已提交
1223

1224 1225 1226
ifeq ($(PLATFORM), IOS)
# For iOS, create universal object files to be used on both the simulator and
# a device.
H
heyongqiang 已提交
1227 1228 1229
PLATFORMSROOT=/Applications/Xcode.app/Contents/Developer/Platforms
SIMULATORROOT=$(PLATFORMSROOT)/iPhoneSimulator.platform/Developer
DEVICEROOT=$(PLATFORMSROOT)/iPhoneOS.platform/Developer
I
Igor Canadi 已提交
1230
IOSVERSION=$(shell defaults read $(PLATFORMSROOT)/iPhoneOS.platform/version CFBundleShortVersionString)
1231

1232 1233
.cc.o:
	mkdir -p ios-x86/$(dir $@)
I
Igor Canadi 已提交
1234
	$(CXX) $(CXXFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 -arch x86_64 -c $< -o ios-x86/$@
1235
	mkdir -p ios-arm/$(dir $@)
I
Igor Canadi 已提交
1236
	xcrun -sdk iphoneos $(CXX) $(CXXFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk -arch armv6 -arch armv7 -arch armv7s -arch arm64 -c $< -o ios-arm/$@
1237
	lipo ios-x86/$@ ios-arm/$@ -create -output $@
1238 1239 1240

.c.o:
	mkdir -p ios-x86/$(dir $@)
I
Igor Canadi 已提交
1241
	$(CC) $(CFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 -arch x86_64 -c $< -o ios-x86/$@
1242
	mkdir -p ios-arm/$(dir $@)
I
Igor Canadi 已提交
1243
	xcrun -sdk iphoneos $(CC) $(CFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk -arch armv6 -arch armv7 -arch armv7s -arch arm64 -c $< -o ios-arm/$@
1244 1245
	lipo ios-x86/$@ ios-arm/$@ -create -output $@

1246
else
J
jorlow@chromium.org 已提交
1247
.cc.o:
1248
	$(AM_V_CC)$(CXX) $(CXXFLAGS) -c $< -o $@ $(COVERAGEFLAGS)
1249 1250

.c.o:
1251
	$(AM_V_CC)$(CC) $(CFLAGS) -c $< -o $@
1252
endif
1253

1254 1255 1256 1257
# ---------------------------------------------------------------------------
#  	Source files dependencies detection
# ---------------------------------------------------------------------------

1258 1259 1260
all_sources = $(LIB_SOURCES) $(TEST_BENCH_SOURCES) $(MOCK_SOURCES)
DEPFILES = $(all_sources:.cc=.d)

1261 1262 1263 1264 1265
# Add proper dependency support so changing a .h file forces a .cc file to
# rebuild.

# The .d file indicates .cc file's dependencies on .h files. We generate such
# dependency by g++'s -MM option, whose output is a make dependency rule.
1266
$(DEPFILES): %.d: %.cc
1267
	@$(CXX) $(CXXFLAGS) $(PLATFORM_SHARED_CFLAGS) \
1268
	  -MM -MT'$@' -MT'$(<:.cc=.o)' "$<" -o '$@'
1269 1270 1271

depend: $(DEPFILES)

1272 1273 1274 1275
# if the make goal is either "clean" or "format", we shouldn't
# try to import the *.d files.
# TODO(kailiu) The unfamiliarity of Make's conditions leads to the ugly
# working solution.
1276
ifneq ($(MAKECMDGOALS),clean)
1277
ifneq ($(MAKECMDGOALS),format)
1278 1279
ifneq ($(MAKECMDGOALS),jclean)
ifneq ($(MAKECMDGOALS),jtest)
1280
ifneq ($(MAKECMDGOALS),package)
1281
ifneq ($(MAKECMDGOALS),analyze)
1282 1283
-include $(DEPFILES)
endif
1284
endif
1285 1286
endif
endif
1287
endif
1288
endif