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.
7 #-----------------------------------------------
8 # Uncomment exactly one of the lines labelled (A), (B), and (C) below
9 # to switch between compilation modes.
11 OPT ?= -O2 -DNDEBUG # (A) Production use (optimized mode)
12 # OPT ?= -g2 # (B) Debug mode, w/ full line-level debugging symbols
13 # OPT ?= -O2 -g2 -DNDEBUG # (C) Profiling mode: opt, but w/debugging symbols
14 #-----------------------------------------------
16 # detect what platform we're building on
17 $(shell sh ./build_detect_platform)
18 # this file is generated by build_detect_platform to set build flags
19 include build_config.mk
21 # If Snappy is installed, add compilation and linker flags
22 # (see http://code.google.com/p/snappy/)
24 SNAPPY_CFLAGS=-DSNAPPY
25 SNAPPY_LDFLAGS=-lsnappy
31 # If Google Perf Tools are installed, add compilation and linker flags
32 # (see http://code.google.com/p/google-perftools/)
33 ifeq ($(GOOGLE_PERFTOOLS), 1)
34 GOOGLE_PERFTOOLS_LDFLAGS=-ltcmalloc
36 GOOGLE_PERFTOOLS_LDFLAGS=
40 includedir=/usr/include
41 pkgconfigdir=$(libdir)/pkgconfig
42 leveldbincludedir=$(includedir)/leveldb
43 memenvincludedir=$(includedir)/helpers/memenv
45 MKDIR_P = /bin/mkdir -p
46 INSTALL = /usr/bin/install -c
47 INSTALL_DATA = ${INSTALL} -m 644
48 LIBTOOL = /usr/bin/libtool
50 DESTDIR=$(CURDIR)/debian/tmp
51 am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
53 CFLAGS = -c -fPIC -I. -I./include $(PORT_CFLAGS) $(PLATFORM_CFLAGS) $(OPT) $(SNAPPY_CFLAGS)
55 LDFLAGS += $(PLATFORM_LDFLAGS) $(SNAPPY_LDFLAGS) $(GOOGLE_PERFTOOLS_LDFLAGS)
74 ./table/block_builder.o \
79 ./table/table_builder.o \
80 ./table/two_level_iterator.o \
94 LEVELDBHEADERFILES = \
95 ./include/leveldb/slice.h \
96 ./include/leveldb/write_batch.h \
97 ./include/leveldb/comparator.h \
98 ./include/leveldb/table.h \
99 ./include/leveldb/c.h \
100 ./include/leveldb/cache.h \
101 ./include/leveldb/table_builder.h \
102 ./include/leveldb/status.h \
103 ./include/leveldb/env.h \
104 ./include/leveldb/db.h \
105 ./include/leveldb/options.h \
106 ./include/leveldb/iterator.h
108 MEMENVHEADERFILES = \
109 ./helpers/memenv/memenv.h
115 TESTUTIL = ./util/testutil.o
116 TESTHARNESS = ./util/testharness.o $(TESTUTIL)
137 PROGRAMS = db_bench $(TESTS)
138 BENCHMARKS = db_bench_sqlite3 db_bench_tree_db
140 #LIBRARY = libleveldb.a
141 #MEMENVLIBRARY = libmemenv.a
142 #LIBRARIES = $(LIBRARY) $(MEMENVLIBRARY) libleveldb.so libleveldb.so.0 libleveldb.so.1.1.0 libmemenv.so libmemenv.so.0 libmemenv.so.1.1.0
144 MEMENVLIBRARY = libmemenv
145 #LIBRARIES = $(LIBRARY) $(MEMENVLIBRARY) libleveldb.so.0 libleveldb.so.1.1.0 libmemenv.so.0 libmemenv.so.1.1.0
146 LIBRARIES = libleveldb.so.1.1.0 libmemenv.so.1.1.0
148 all: $(LIBRARY) $(MEMENVLIBRARY)
150 install: all install-pkgconfigDATA install-libLEVELDB install-leveldbHeaderFiles install-memenvHeaderFiles
152 install-libLEVELDB: $(LIBRARIES)
153 test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
154 @list='$(LIBRARIES)'; test -n "$(libdir)" || list=; \
155 for p in $$list; do \
156 if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
159 while read files; do \
160 echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(libdir)'"; \
161 $(INSTALL_DATA) $$files "$(DESTDIR)$(libdir)" || exit $$?; \
164 cd "$(DESTDIR)$(libdir)" && $(LN_S) libleveldb.so.1.1.0 libleveldb.so
165 cd "$(DESTDIR)$(libdir)" && $(LN_S) libleveldb.so.1.1.0 libleveldb.so.0
166 cd "$(DESTDIR)$(libdir)" && $(LN_S) libmemenv.so.1.1.0 libmemenv.so
167 cd "$(DESTDIR)$(libdir)" && $(LN_S) libmemenv.so.1.1.0 libmemenv.so.0
169 uninstall-libLEVELDB:
170 test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
171 @list='$(LIBRARIES)'; test -n "$(libdir)" || list=; \
172 for p in $$list; do \
174 echo " $(LIBTOOL) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
175 $(LIBTOOL) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
178 install-pkgconfigDATA: $(pkgconfig_DATA)
179 test -z "$(pkgconfigdir)" || $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)"
180 @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \
181 for p in $$list; do \
182 if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
185 while read files; do \
186 echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(pkgconfigdir)'"; \
187 $(INSTALL_DATA) $$files "$(DESTDIR)$(pkgconfigdir)" || exit $$?; \
190 uninstall-pkgconfigDATA:
191 test -z "$(pkgconfigdir)" || $(MKDIR_P) "$(DESTDIR)$(pkgconfigdir)"
192 @list='$(pkgconfig_DATA)'; test -n "$(pkgconfigdir)" || list=; \
193 files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
194 test -n "$$files" || exit 0; \
195 echo " ( cd '$(DESTDIR)$(pkgconfigdir)' && rm -f" $$files ")"; \
196 cd "$(DESTDIR)$(pkgconfigdir)" && rm -f $$files
198 install-leveldbHeaderFiles: $(LEVELDBHEADERFILES)
199 test -z "$(leveldbincludedir)" || $(MKDIR_P) "$(DESTDIR)$(leveldbincludedir)"
200 @list='$(LEVELDBHEADERFILES)'; test -n "$(leveldbincludedir)" || list=; \
201 for p in $$list; do \
202 if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
205 while read files; do \
206 echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(leveldbincludedir)'"; \
207 $(INSTALL_DATA) $$files "$(DESTDIR)$(leveldbincludedir)" || exit $$?; \
210 uninstall-leveldbHeaderFiles:
211 test -z "$(leveldbincludedir)" || $(MKDIR_P) "$(DESTDIR)$(leveldbincludedir)"
212 @list='$(LEVELDBHEADERFILES)'; test -n "$(leveldbincludedir)" || list=; \
213 files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
214 test -n "$$files" || exit 0; \
215 echo " ( cd '$(DESTDIR)$(leveldbincludedir)' && rm -f" $$files ")"; \
216 cd "$(DESTDIR)$(leveldbincludedir)" && rm -f $$files
218 install-memenvHeaderFiles: $(MEMENVHEADERFILES)
219 test -z "$(memenvincludedir)" || $(MKDIR_P) "$(DESTDIR)$(memenvincludedir)"
220 @list='$(MEMENVHEADERFILES)'; test -n "$(memenvincludedir)" || list=; \
221 for p in $$list; do \
222 if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
225 while read files; do \
226 echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(memenvincludedir)'"; \
227 $(INSTALL_DATA) $$files "$(DESTDIR)$(memenvincludedir)" || exit $$?; \
230 uninstall-memenvHeaderFiles:
231 test -z "$(memenvincludedir)" || $(MKDIR_P) "$(DESTDIR)$(memenvincludedir)"
232 @list='$(MEMENVHEADERFILES)'; test -n "$(memenvincludedir)" || list=; \
233 files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
234 test -n "$$files" || exit 0; \
235 echo " ( cd '$(DESTDIR)$(memenvincludedir)' && rm -f" $$files ")"; \
236 cd "$(DESTDIR)$(memenvincludedir)" && rm -f $$files
239 check: $(PROGRAMS) $(TESTS)
240 for t in $(TESTS); do echo "***** Running $$t"; ./$$t || exit 1; done
242 clean: uninstall-pkgconfigDATA uninstall-libLEVELDB uninstall-leveldbHeaderFiles uninstall-memenvHeaderFiles
243 -rm -f $(PROGRAMS) $(BENCHMARKS) $(LIBRARY) $(MEMENVLIBRARY) $(LIBRARIES) */*.o */*/*.o ios-x86/*/*.o ios-arm/*/*.o
245 -rm -rf ios-x86/* ios-arm/*
251 $(LIBRARY): $(LIBOBJECTS)
253 #$(AR) -rs $@ $(LIBOBJECTS)
254 $(CC) -shared -Wl,-soname,libleveldb.so -o libleveldb.so.1.1.0 $(LIBOBJECTS)
256 db_bench: db/db_bench.o $(LIBOBJECTS) $(TESTUTIL)
257 $(CC) $(LDFLAGS) db/db_bench.o $(LIBOBJECTS) $(TESTUTIL) -o $@
259 db_bench_sqlite3: doc/bench/db_bench_sqlite3.o $(LIBOBJECTS) $(TESTUTIL)
260 $(CC) $(LDFLAGS) -lsqlite3 doc/bench/db_bench_sqlite3.o $(LIBOBJECTS) $(TESTUTIL) -o $@
262 db_bench_tree_db: doc/bench/db_bench_tree_db.o $(LIBOBJECTS) $(TESTUTIL)
263 $(CC) $(LDFLAGS) -lkyotocabinet doc/bench/db_bench_tree_db.o $(LIBOBJECTS) $(TESTUTIL) -o $@
265 arena_test: util/arena_test.o $(LIBOBJECTS) $(TESTHARNESS)
266 $(CC) $(LDFLAGS) util/arena_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
268 c_test: db/c_test.o $(LIBOBJECTS) $(TESTHARNESS)
269 $(CC) $(LDFLAGS) db/c_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
271 cache_test: util/cache_test.o $(LIBOBJECTS) $(TESTHARNESS)
272 $(CC) $(LDFLAGS) util/cache_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
274 coding_test: util/coding_test.o $(LIBOBJECTS) $(TESTHARNESS)
275 $(CC) $(LDFLAGS) util/coding_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
277 corruption_test: db/corruption_test.o $(LIBOBJECTS) $(TESTHARNESS)
278 $(CC) $(LDFLAGS) db/corruption_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
280 crc32c_test: util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS)
281 $(CC) $(LDFLAGS) util/crc32c_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
283 db_test: db/db_test.o $(LIBOBJECTS) $(TESTHARNESS)
284 $(CC) $(LDFLAGS) db/db_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
286 dbformat_test: db/dbformat_test.o $(LIBOBJECTS) $(TESTHARNESS)
287 $(CC) $(LDFLAGS) db/dbformat_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
289 env_test: util/env_test.o $(LIBOBJECTS) $(TESTHARNESS)
290 $(CC) $(LDFLAGS) util/env_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
292 filename_test: db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS)
293 $(CC) $(LDFLAGS) db/filename_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
295 log_test: db/log_test.o $(LIBOBJECTS) $(TESTHARNESS)
296 $(CC) $(LDFLAGS) db/log_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
298 table_test: table/table_test.o $(LIBOBJECTS) $(TESTHARNESS)
299 $(CC) $(LDFLAGS) table/table_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
301 skiplist_test: db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS)
302 $(CC) $(LDFLAGS) db/skiplist_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
304 version_edit_test: db/version_edit_test.o $(LIBOBJECTS) $(TESTHARNESS)
305 $(CC) $(LDFLAGS) db/version_edit_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
307 version_set_test: db/version_set_test.o $(LIBOBJECTS) $(TESTHARNESS)
308 $(CC) $(LDFLAGS) db/version_set_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
310 write_batch_test: db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS)
311 $(CC) $(LDFLAGS) db/write_batch_test.o $(LIBOBJECTS) $(TESTHARNESS) -o $@
313 $(MEMENVLIBRARY) : helpers/memenv/memenv.o
315 #$(AR) -rs $@ helpers/memenv/memenv.o
316 $(CC) -shared -Wl,-soname,libmemenv.so -o libmemenv.so.1.1.0 helpers/memenv/memenv.o
318 memenv_test : helpers/memenv/memenv_test.o $(MEMENVLIBRARY) $(LIBRARY) $(TESTHARNESS)
319 $(CC) $(LDFLAGS) helpers/memenv/memenv_test.o $(MEMENVLIBRARY) $(LIBRARY) $(TESTHARNESS) -o $@
321 ifeq ($(PLATFORM), IOS)
322 # For iOS, create universal object files to be used on both the simulator and
324 SIMULATORROOT=/Developer/Platforms/iPhoneSimulator.platform/Developer
325 DEVICEROOT=/Developer/Platforms/iPhoneOS.platform/Developer
326 IOSVERSION=$(shell defaults read /Developer/Platforms/iPhoneOS.platform/version CFBundleShortVersionString)
329 mkdir -p ios-x86/$(dir $@)
330 $(SIMULATORROOT)/usr/bin/$(CC) $(CFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 $< -o ios-x86/$@
331 mkdir -p ios-arm/$(dir $@)
332 $(DEVICEROOT)/usr/bin/$(CC) $(CFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk -arch armv6 -arch armv7 $< -o ios-arm/$@
333 lipo ios-x86/$@ ios-arm/$@ -create -output $@
336 mkdir -p ios-x86/$(dir $@)
337 $(SIMULATORROOT)/usr/bin/$(CC) $(CFLAGS) -isysroot $(SIMULATORROOT)/SDKs/iPhoneSimulator$(IOSVERSION).sdk -arch i686 $< -o ios-x86/$@
338 mkdir -p ios-arm/$(dir $@)
339 $(DEVICEROOT)/usr/bin/$(CC) $(CFLAGS) -isysroot $(DEVICEROOT)/SDKs/iPhoneOS$(IOSVERSION).sdk -arch armv6 -arch armv7 $< -o ios-arm/$@
340 lipo ios-x86/$@ ios-arm/$@ -create -output $@
344 $(CC) $(CFLAGS) $< -o $@
347 $(CC) $(CFLAGS) $< -o $@
350 .PHONY: install-pkgconfigDATA uninstall-pkgconfigDATA install-libLEVELDB uninstall-libLEVELDB install-leveldbHeaderFiles uninstall-leveldbHeaderFiles install-memenvHeaderFiles uninstall-memenvHeaderFiles