mirror of
https://github.com/isar/libmdbx.git
synced 2024-12-30 01:24:12 +08:00
mdbx: refine & clarify Makefile.
Change-Id: I4e5b388c65872d4cd413d0ff30f232ed0ad2112d
This commit is contained in:
parent
daba18111b
commit
ba943fcff2
89
Makefile
89
Makefile
@ -1,4 +1,4 @@
|
|||||||
# GNU Makefile for libmdbx (lightning memory-mapped database library for Linux).
|
# GNU Makefile for libmdbx (reliable lightning memory-mapped DB library for Linux).
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
# Configuration. The compiler options must enable threaded compilation.
|
# Configuration. The compiler options must enable threaded compilation.
|
||||||
@ -6,58 +6,69 @@
|
|||||||
# Preprocessor macros (for XCFLAGS) of interest...
|
# Preprocessor macros (for XCFLAGS) of interest...
|
||||||
# Note that the defaults should already be correct for most
|
# Note that the defaults should already be correct for most
|
||||||
# platforms; you should not need to change any of these.
|
# platforms; you should not need to change any of these.
|
||||||
# Read their descriptions in mdb.c if you do:
|
# Read their descriptions in mdb.c if you do. There may be
|
||||||
|
# other macros of interest. You should read mdb.c
|
||||||
|
# before changing any of them.
|
||||||
#
|
#
|
||||||
# - MDB_USE_ROBUST
|
|
||||||
#
|
# install sandbox
|
||||||
# There may be other macros in mdb.c of interest. You should
|
SANDBOX ?=
|
||||||
# read mdb.c before changing any of them.
|
|
||||||
#
|
# install prefixes (inside sandbox)
|
||||||
DESTDIR ?=
|
|
||||||
prefix ?= /usr/local
|
prefix ?= /usr/local
|
||||||
mandir ?= $(prefix)/man
|
mandir ?= $(prefix)/man
|
||||||
|
|
||||||
|
# lib/bin suffix for multiarch/biarch, e.g. '.x86_64'
|
||||||
|
suffix ?=
|
||||||
|
|
||||||
CC ?= gcc
|
CC ?= gcc
|
||||||
XCFLAGS ?= -DNDEBUG=1 -DMDB_DEBUG=0
|
XCFLAGS ?= -DNDEBUG=1 -DMDB_DEBUG=0
|
||||||
CFLAGS ?= -O2 -g3 -Wall -Werror -Wextra
|
CFLAGS ?= -O2 -g3 -Wall -Werror -Wextra
|
||||||
CFLAGS += -pthread $(XCFLAGS)
|
CFLAGS += -pthread $(XCFLAGS)
|
||||||
|
|
||||||
|
# LY: for ability to built with modern glibc,
|
||||||
|
# but then run with the old
|
||||||
|
LDOPS ?= -Wl,--no-as-needed,-lrt
|
||||||
|
|
||||||
|
# LY: just for benchmarking
|
||||||
IOARENA ?= ../ioarena.git/@BUILD/src/ioarena
|
IOARENA ?= ../ioarena.git/@BUILD/src/ioarena
|
||||||
|
|
||||||
########################################################################
|
########################################################################
|
||||||
|
|
||||||
IHDRS := lmdb.h mdbx.h
|
HEADERS := lmdb.h mdbx.h
|
||||||
ILIBS := libmdbx.a libmdbx.so
|
LIBRARIES := libmdbx.a libmdbx.so
|
||||||
IPROGS := mdbx_stat mdbx_copy mdbx_dump mdbx_load mdbx_chk
|
TOOLS := mdbx_stat mdbx_copy mdbx_dump mdbx_load mdbx_chk
|
||||||
IDOCS := mdb_stat.1 mdb_copy.1 mdb_dump.1 mdb_load.1
|
MANPAGES := mdb_stat.1 mdb_copy.1 mdb_dump.1 mdb_load.1
|
||||||
PROGS := $(IPROGS) mtest0 mtest1 mtest2 mtest3 mtest4 mtest5 mtest6 wbench
|
TESTS := mtest0 mtest1 mtest2 mtest3 mtest4 mtest5 mtest6 wbench \
|
||||||
PROGS += yota_test1 yota_test2
|
yota_test1 yota_test2
|
||||||
|
|
||||||
SRC_LMDB := mdb.c midl.c lmdb.h midl.h reopen.h barriers.h
|
SRC_LMDB := mdb.c midl.c lmdb.h midl.h reopen.h barriers.h
|
||||||
SRC_MDBX := $(SRC_LMDB) mdbx.h
|
SRC_MDBX := $(SRC_LMDB) mdbx.h
|
||||||
|
|
||||||
.PHONY: mdbx lmdb all install clean check tests coverage
|
.PHONY: mdbx lmdb all install clean check tests coverage
|
||||||
|
|
||||||
all: $(ILIBS) $(IPROGS)
|
all: $(LIBRARIES) $(TOOLS)
|
||||||
|
|
||||||
mdbx: libmdbx.a libmdbx.so
|
mdbx: libmdbx.a libmdbx.so
|
||||||
|
|
||||||
lmdb: liblmdb.a liblmdb.so
|
lmdb: liblmdb.a liblmdb.so
|
||||||
|
|
||||||
install: $(ILIBS) $(IPROGS) $(IHDRS)
|
tools: $(TOOLS)
|
||||||
mkdir -p $(DESTDIR)$(prefix)/bin \
|
|
||||||
&& cp -t $(DESTDIR)$(prefix)/bin $(IPROGS) && \
|
install: $(LIBRARIES) $(TOOLS) $(HEADERS)
|
||||||
mkdir -p $(DESTDIR)$(prefix)/lib \
|
mkdir -p $(SANDBOX)$(prefix)/bin$(suffix) \
|
||||||
&& cp -t $(DESTDIR)$(prefix)/lib $(ILIBS) && \
|
&& cp -t $(SANDBOX)$(prefix)/bin$(suffix) $(TOOLS) && \
|
||||||
mkdir -p $(DESTDIR)$(prefix)/include \
|
mkdir -p $(SANDBOX)$(prefix)/lib$(suffix) \
|
||||||
&& cp -t $(DESTDIR)$(prefix)/include $(IHDRS) && \
|
&& cp -t $(SANDBOX)$(prefix)/lib$(suffix) $(LIBRARIES) && \
|
||||||
mkdir -p $(DESTDIR)$(mandir)/man1 \
|
mkdir -p $(SANDBOX)$(prefix)/include \
|
||||||
&& cp -t $(DESTDIR)$(mandir)/man1 $(IDOCS)
|
&& cp -t $(SANDBOX)$(prefix)/include $(HEADERS) && \
|
||||||
|
mkdir -p $(SANDBOX)$(mandir)/man1 \
|
||||||
|
&& cp -t $(SANDBOX)$(mandir)/man1 $(MANPAGES)
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -rf $(PROGS) @* *.[ao] *.[ls]o *~ testdb/* *.gcov
|
rm -rf $(TOOLS )$(TESTS) @* *.[ao] *.[ls]o *~ testdb/* *.gcov
|
||||||
|
|
||||||
tests: mdbx $(PROGS)
|
tests: $(TESTS)
|
||||||
|
|
||||||
check: tests
|
check: tests
|
||||||
[ -d testdb ] || mkdir testdb && rm -f testdb/* \
|
[ -d testdb ] || mkdir testdb && rm -f testdb/* \
|
||||||
@ -74,28 +85,28 @@ libmdbx.a: mdbx.o
|
|||||||
$(AR) rs $@ $^
|
$(AR) rs $@ $^
|
||||||
|
|
||||||
libmdbx.so: mdbx.lo
|
libmdbx.so: mdbx.lo
|
||||||
$(CC) $(CFLAGS) $(LDFLAGS) -save-temps -pthread -shared -o $@ $^
|
$(CC) $(CFLAGS) $(LDFLAGS) -save-temps -pthread -shared $(LDOPS) -o $@ $^
|
||||||
|
|
||||||
liblmdb.a: lmdb.o
|
liblmdb.a: lmdb.o
|
||||||
$(AR) rs $@ $^
|
$(AR) rs $@ $^
|
||||||
|
|
||||||
liblmdb.so: lmdb.lo
|
liblmdb.so: lmdb.lo
|
||||||
$(CC) $(CFLAGS) $(LDFLAGS) -pthread -shared -o $@ $^
|
$(CC) $(CFLAGS) $(LDFLAGS) -pthread -shared $(LDOPS) -o $@ $^
|
||||||
|
|
||||||
mdbx_stat: mdb_stat.o mdbx.o
|
mdbx_stat: mdb_stat.o mdbx.o
|
||||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
|
$(CC) $(CFLAGS) $(LDFLAGS) $(LDOPS) -o $@ $^
|
||||||
|
|
||||||
mdbx_copy: mdb_copy.o mdbx.o
|
mdbx_copy: mdb_copy.o mdbx.o
|
||||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
|
$(CC) $(CFLAGS) $(LDFLAGS) $(LDOPS) -o $@ $^
|
||||||
|
|
||||||
mdbx_dump: mdb_dump.o mdbx.o
|
mdbx_dump: mdb_dump.o mdbx.o
|
||||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
|
$(CC) $(CFLAGS) $(LDFLAGS) $(LDOPS) -o $@ $^
|
||||||
|
|
||||||
mdbx_load: mdb_load.o mdbx.o
|
mdbx_load: mdb_load.o mdbx.o
|
||||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
|
$(CC) $(CFLAGS) $(LDFLAGS) $(LDOPS) -o $@ $^
|
||||||
|
|
||||||
mdbx_chk: mdb_chk.o mdbx.o
|
mdbx_chk: mdb_chk.o mdbx.o
|
||||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ -Wl,--no-as-needed,-lrt
|
$(CC) $(CFLAGS) $(LDFLAGS) $(LDOPS) -o $@ $^
|
||||||
|
|
||||||
mtest0: mtest0.o mdbx.o
|
mtest0: mtest0.o mdbx.o
|
||||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
|
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
|
||||||
@ -125,7 +136,7 @@ yota_test2: yota_test2.o mdbx.o
|
|||||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
|
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
|
||||||
|
|
||||||
wbench: wbench.o mdbx.o
|
wbench: wbench.o mdbx.o
|
||||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ -Wl,--no-as-needed,-lrt
|
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^
|
||||||
|
|
||||||
mdbx.o: $(SRC_MDBX)
|
mdbx.o: $(SRC_MDBX)
|
||||||
$(CC) $(CFLAGS) -include mdbx.h -c mdb.c -o $@
|
$(CC) $(CFLAGS) -include mdbx.h -c mdb.c -o $@
|
||||||
@ -145,14 +156,14 @@ lmdb.lo: $(SRC_LMDB)
|
|||||||
%.o: %.c lmdb.h mdbx.h
|
%.o: %.c lmdb.h mdbx.h
|
||||||
$(CC) $(CFLAGS) -c $<
|
$(CC) $(CFLAGS) -c $<
|
||||||
|
|
||||||
COV_FLAGS=-fprofile-arcs -ftest-coverage
|
COFLAGS = -fprofile-arcs -ftest-coverage
|
||||||
|
|
||||||
@gcov-mdb.o: $(SRC_MDBX)
|
@gcov-mdb.o: $(SRC_MDBX)
|
||||||
$(CC) $(CFLAGS) $(COV_FLAGS) -O0 -include mdbx.h -c mdb.c -o $@
|
$(CC) $(CFLAGS) $(COFLAGS) -O0 -include mdbx.h -c mdb.c -o $@
|
||||||
|
|
||||||
coverage: @gcov-mdb.o
|
coverage: @gcov-mdb.o
|
||||||
for t in mtest*.c; do x=`basename \$$t .c`; $(MAKE) $$x.o; \
|
for t in mtest*.c; do x=`basename \$$t .c`; $(MAKE) $$x.o; \
|
||||||
gcc -o @gcov-$$x $$x.o $^ -pthread $(COV_FLAGS); \
|
gcc -o @gcov-$$x $$x.o $^ -pthread $(COFLAGS); \
|
||||||
rm -rf testdb; mkdir testdb; ./@gcov-$$x; done
|
rm -rf testdb; mkdir testdb; ./@gcov-$$x; done
|
||||||
gcov @gcov-mdb
|
gcov @gcov-mdb
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user