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...
7 # Note that the defaults should already be correct for most
8 # platforms; you should not need to change any of these:
10 # To compile successfully if the default does not:
11 # - MDB_USE_POSIX_SEM (enabled by default on BSD, Apple)
12 # Define if shared mutexes are unsupported. Note that Posix
13 # semaphores and shared mutexes have different behaviors and
14 # different problems, see the Caveats section in lmdb.h.
16 # For best performance or to compile successfully:
17 # - MDB_DSYNC = "O_DSYNC" (default) or "O_SYNC" (less efficient)
18 # If O_DSYNC is undefined but exists in /usr/include,
19 # preferably set some compiler flag to get the definition.
20 # - MDB_FDATASYNC = "fdatasync" or "fsync"
21 # Function for flushing the data of a file. Define this to
22 # "fsync" if fdatasync() is not supported. fdatasync is
23 # default except on BSD, Apple, Android which use fsync.
25 # Define if the pwritev() function is supported.
29 # Controls data packing and limits, see mdb.c.
30 # You might need to change this if the default size is too small.
33 W = -W -Wall -Wno-unused-parameter -Wbad-function-cast
36 CFLAGS = $(THREADS) $(OPT) $(W) $(XCFLAGS)
41 ########################################################################
44 ILIBS = liblmdb.a liblmdb.so
45 IPROGS = mdb_stat mdb_copy
46 IDOCS = mdb_stat.1 mdb_copy.1
47 PROGS = $(IPROGS) mtest mtest2 mtest3 mtest4 mtest5
48 all: $(ILIBS) $(PROGS)
50 install: $(ILIBS) $(IPROGS) $(IHDRS)
51 cp $(IPROGS) $(DESTDIR)$(prefix)/bin
52 cp $(ILIBS) $(DESTDIR)$(prefix)/lib
53 cp $(IHDRS) $(DESTDIR)$(prefix)/include
54 cp $(IDOCS) $(DESTDIR)$(prefix)/man/man1
57 rm -rf $(PROGS) *.[ao] *.so *~ testdb
61 ./mtest && ./mdb_stat testdb
63 liblmdb.a: mdb.o midl.o
66 liblmdb.so: mdb.o midl.o
67 $(CC) $(LDFLAGS) -pthread -shared -o $@ mdb.o midl.o $(SOLIBS)
69 mdb_stat: mdb_stat.o liblmdb.a
70 mdb_copy: mdb_copy.o liblmdb.a
71 mtest: mtest.o liblmdb.a
72 mtest2: mtest2.o liblmdb.a
73 mtest3: mtest3.o liblmdb.a
74 mtest4: mtest4.o liblmdb.a
75 mtest5: mtest5.o liblmdb.a
76 mtest6: mtest6.o liblmdb.a
78 mdb.o: mdb.c lmdb.h midl.h
79 $(CC) $(CFLAGS) -fPIC $(CPPFLAGS) -c mdb.c
82 $(CC) $(CFLAGS) -fPIC $(CPPFLAGS) -c midl.c
85 $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@
88 $(CC) $(CFLAGS) $(CPPFLAGS) -c $<