1 # Makefile for liblmdb (Lightning memory-mapped database library).
3 ########################################################################
4 # Configuration. The compiler options must enable threaded compilation.
6 # Preprocessor macros (for CPPFLAGS) of interest:
8 # To compile successfully if the default does not:
9 # - MDB_USE_POSIX_SEM (enabled by default on BSD, Apple)
10 # Define if shared mutexes are unsupported. Note that Posix
11 # semaphores and shared mutexes have different behaviors and
12 # different problems, see the Caveats section in lmdb.h.
14 # For best performence or to compile successfully:
15 # - MDB_DSYNC = "O_DSYNC" (default) or "O_SYNC" (less efficient)
16 # If O_DSYNC is undefined but exists in /usr/include,
17 # preferably set some compiler flag to get the definition.
18 # - MDB_FDATASYNC = "fdatasync" or "fsync"
19 # Function for flushing the data of a file. Define this to
20 # "fsync" if fdatasync() is not supported. fdatasync is
21 # default except on BSD, Apple, Android which use fsync.
23 # Define if the pwritev() function is supported.
27 # Controls data packing and limits, see mdb.c.
30 # - MDB_DEBUG, MDB_PARANOID.
33 W = -W -Wall -Wno-unused-parameter -Wbad-function-cast
35 CFLAGS = -pthread $(OPT) $(W) $(XCFLAGS)
40 ########################################################################
43 ILIBS = liblmdb.a liblmdb.so
44 IPROGS = mdb_stat mdb_copy
45 IDOCS = mdb_stat.1 mdb_copy.1
46 PROGS = $(IPROGS) mtest mtest2 mtest3 mtest4 mtest5
47 all: $(ILIBS) $(PROGS)
49 install: $(ILIBS) $(IPROGS) $(IHDRS)
50 cp $(IPROGS) $(DESTDIR)$(prefix)/bin
51 cp $(ILIBS) $(DESTDIR)$(prefix)/lib
52 cp $(IHDRS) $(DESTDIR)$(prefix)/include
53 cp $(IDOCS) $(DESTDIR)$(prefix)/man/man1
56 rm -rf $(PROGS) *.[ao] *.so *~ testdb
60 ./mtest && ./mdb_stat testdb
62 liblmdb.a: mdb.o midl.o
65 liblmdb.so: mdb.o midl.o
66 $(CC) $(LDFLAGS) -pthread -shared -o $@ mdb.o midl.o $(SOLIBS)
68 mdb_stat: mdb_stat.o liblmdb.a
69 mdb_copy: mdb_copy.o liblmdb.a
70 mtest: mtest.o liblmdb.a
71 mtest2: mtest2.o liblmdb.a
72 mtest3: mtest3.o liblmdb.a
73 mtest4: mtest4.o liblmdb.a
74 mtest5: mtest5.o liblmdb.a
75 mtest6: mtest6.o liblmdb.a
77 mdb.o: mdb.c lmdb.h midl.h
78 $(CC) $(CFLAGS) -fPIC $(CPPFLAGS) -c mdb.c
81 $(CC) $(CFLAGS) -fPIC $(CPPFLAGS) -c midl.c
84 $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@
87 $(CC) $(CFLAGS) $(CPPFLAGS) -c $<