]> git.sur5r.net Git - openldap/blob - libraries/liblmdb/Makefile
Makefile/user-macro comments.
[openldap] / libraries / liblmdb / Makefile
1 # Makefile for liblmdb (Lightning memory-mapped database library).
2
3 ########################################################################
4 # Configuration. The compiler options must enable threaded compilation.
5 #
6 # Preprocessor macros (for CPPFLAGS) of interest:
7 #
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.
13 #
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.
22 # - MDB_USE_PWRITEV
23 #       Define if the pwritev() function is supported.
24 #
25 # Data format:
26 # - MDB_MAXKEYSIZE
27 #       Controls data packing and limits, see mdb.c.
28 #
29 # Debugging:
30 # - MDB_DEBUG, MDB_PARANOID.
31 #
32 CC      = gcc
33 W       = -W -Wall -Wno-unused-parameter -Wbad-function-cast
34 OPT = -O2 -g
35 CFLAGS  = -pthread $(OPT) $(W) $(XCFLAGS)
36 LDLIBS  =
37 SOLIBS  =
38 prefix  = /usr/local
39
40 ########################################################################
41
42 IHDRS   = lmdb.h
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)
48
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
54
55 clean:
56         rm -rf $(PROGS) *.[ao] *.so *~ testdb
57
58 test:   all
59         mkdir testdb
60         ./mtest && ./mdb_stat testdb
61
62 liblmdb.a:      mdb.o midl.o
63         ar rs $@ mdb.o midl.o
64
65 liblmdb.so:     mdb.o midl.o
66         $(CC) $(LDFLAGS) -pthread -shared -o $@ mdb.o midl.o $(SOLIBS)
67
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
76
77 mdb.o: mdb.c lmdb.h midl.h
78         $(CC) $(CFLAGS) -fPIC $(CPPFLAGS) -c mdb.c
79
80 midl.o: midl.c midl.h
81         $(CC) $(CFLAGS) -fPIC $(CPPFLAGS) -c midl.c
82
83 %:      %.o
84         $(CC) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@
85
86 %.o:    %.c lmdb.h
87         $(CC) $(CFLAGS) $(CPPFLAGS) -c $<