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.
9 # Read their descriptions in mdb.c if you do:
16 # There may be other macros in mdb.c of interest. You should
17 # read mdb.c before changing any of them.
20 W = -W -Wall -Wno-unused-parameter -Wbad-function-cast -Wuninitialized
23 CFLAGS = $(THREADS) $(OPT) $(W) $(XCFLAGS)
28 ########################################################################
31 ILIBS = liblmdb.a liblmdb.so
32 IPROGS = mdb_stat mdb_copy mdb_dump mdb_load
33 IDOCS = mdb_stat.1 mdb_copy.1 mdb_dump.1 mdb_load.1
34 PROGS = $(IPROGS) mtest mtest2 mtest3 mtest4 mtest5
35 all: $(ILIBS) $(PROGS)
37 install: $(ILIBS) $(IPROGS) $(IHDRS)
38 for f in $(IPROGS); do cp $$f $(DESTDIR)$(prefix)/bin; done
39 for f in $(ILIBS); do cp $$f $(DESTDIR)$(prefix)/lib; done
40 for f in $(IHDRS); do cp $$f $(DESTDIR)$(prefix)/include; done
41 for f in $(IDOCS); do cp $$f $(DESTDIR)$(prefix)/man/man1; done
44 rm -rf $(PROGS) *.[ao] *.so *~ testdb
48 ./mtest && ./mdb_stat testdb
50 liblmdb.a: mdb.o midl.o
53 liblmdb.so: mdb.o midl.o
54 # $(CC) $(LDFLAGS) -pthread -shared -Wl,-Bsymbolic -o $@ mdb.o midl.o $(SOLIBS)
55 $(CC) $(LDFLAGS) -pthread -shared -o $@ mdb.o midl.o $(SOLIBS)
57 mdb_stat: mdb_stat.o liblmdb.a
58 mdb_copy: mdb_copy.o liblmdb.a
59 mdb_dump: mdb_dump.o liblmdb.a
60 mdb_load: mdb_load.o liblmdb.a
61 mtest: mtest.o liblmdb.a
62 mtest2: mtest2.o liblmdb.a
63 mtest3: mtest3.o liblmdb.a
64 mtest4: mtest4.o liblmdb.a
65 mtest5: mtest5.o liblmdb.a
66 mtest6: mtest6.o liblmdb.a
68 mdb.o: mdb.c lmdb.h midl.h
69 $(CC) $(CFLAGS) -fPIC $(CPPFLAGS) -c mdb.c
72 $(CC) $(CFLAGS) -fPIC $(CPPFLAGS) -c midl.c
75 $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@
78 $(CC) $(CFLAGS) $(CPPFLAGS) -c $<
80 COV_FLAGS=-fprofile-arcs -ftest-coverage
81 COV_OBJS=xmdb.o xmidl.o
84 for i in mtest*.c [0-9]*.c; do j=`basename \$$i .c`; $(MAKE) $$j.o; \
85 gcc -o x$$j $$j.o $(COV_OBJS) -pthread $(COV_FLAGS); \
86 rm -rf testdb; mkdir testdb; ./x$$j; done
90 xmtest: mtest.o xmdb.o xmidl.o
91 gcc -o xmtest mtest.o xmdb.o xmidl.o -pthread $(COV_FLAGS)
93 xmdb.o: mdb.c lmdb.h midl.h
94 $(CC) $(CFLAGS) -fPIC $(CPPFLAGS) -O0 $(COV_FLAGS) -c mdb.c -o $@
96 xmidl.o: midl.c midl.h
97 $(CC) $(CFLAGS) -fPIC $(CPPFLAGS) -O0 $(COV_FLAGS) -c midl.c -o $@