xref: /netbsd-src/external/bsd/openldap/dist/libraries/liblmdb/Makefile (revision 212397c69a103ae7e5eafa8731ddfae671d2dee7)
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# 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:
10#
11# - MDB_USE_POSIX_SEM
12# - MDB_DSYNC
13# - MDB_FDATASYNC
14# - MDB_USE_PWRITEV
15#
16# There may be other macros in mdb.c of interest. You should
17# read mdb.c before changing any of them.
18#
19CC	= gcc
20W	= -W -Wall -Wno-unused-parameter -Wbad-function-cast
21THREADS = -pthread
22OPT = -O2 -g
23CFLAGS	= $(THREADS) $(OPT) $(W) $(XCFLAGS)
24LDLIBS	=
25SOLIBS	=
26prefix	= /usr/local
27
28########################################################################
29
30IHDRS	= lmdb.h
31ILIBS	= liblmdb.a liblmdb.so
32IPROGS	= mdb_stat mdb_copy
33IDOCS	= mdb_stat.1 mdb_copy.1
34PROGS	= $(IPROGS) mtest mtest2 mtest3 mtest4 mtest5
35all:	$(ILIBS) $(PROGS)
36
37install: $(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
42
43clean:
44	rm -rf $(PROGS) *.[ao] *.so *~ testdb
45
46test:	all
47	mkdir testdb
48	./mtest && ./mdb_stat testdb
49
50liblmdb.a:	mdb.o midl.o
51	ar rs $@ mdb.o midl.o
52
53liblmdb.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)
56
57mdb_stat: mdb_stat.o liblmdb.a
58mdb_copy: mdb_copy.o liblmdb.a
59mtest:    mtest.o    liblmdb.a
60mtest2:	mtest2.o liblmdb.a
61mtest3:	mtest3.o liblmdb.a
62mtest4:	mtest4.o liblmdb.a
63mtest5:	mtest5.o liblmdb.a
64mtest6:	mtest6.o liblmdb.a
65
66mdb.o: mdb.c lmdb.h midl.h
67	$(CC) $(CFLAGS) -fPIC $(CPPFLAGS) -c mdb.c
68
69midl.o: midl.c midl.h
70	$(CC) $(CFLAGS) -fPIC $(CPPFLAGS) -c midl.c
71
72%:	%.o
73	$(CC) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@
74
75%.o:	%.c lmdb.h
76	$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
77