nostrdb

an unfairly fast embedded nostr database backed by lmdb
git clone git://jb55.com/nostrdb
Log | Files | Refs | Submodules | README | LICENSE

Makefile (3330B)


      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_FDATASYNC_WORKS
     15 # - MDB_USE_PWRITEV
     16 # - MDB_USE_ROBUST
     17 #
     18 # There may be other macros in mdb.c of interest. You should
     19 # read mdb.c before changing any of them.
     20 #
     21 CC	= gcc
     22 AR	= ar
     23 W	= -W -Wall -Wno-unused-parameter -Wbad-function-cast -Wuninitialized
     24 THREADS = -pthread
     25 OPT = -O2 -g
     26 CFLAGS	= $(THREADS) $(OPT) $(W) $(XCFLAGS)
     27 LDLIBS	=
     28 SOLIBS	=
     29 SOEXT	= .so
     30 prefix	= /usr/local
     31 exec_prefix = $(prefix)
     32 bindir = $(exec_prefix)/bin
     33 libdir = $(exec_prefix)/lib
     34 includedir = $(prefix)/include
     35 datarootdir = $(prefix)/share
     36 mandir = $(datarootdir)/man
     37 
     38 ########################################################################
     39 
     40 IHDRS	= lmdb.h
     41 ILIBS	= liblmdb.a liblmdb$(SOEXT)
     42 IPROGS	= mdb_stat mdb_copy mdb_dump mdb_load
     43 IDOCS	= mdb_stat.1 mdb_copy.1 mdb_dump.1 mdb_load.1
     44 PROGS	= $(IPROGS) mtest mtest2 mtest3 mtest4 mtest5
     45 all:	$(ILIBS) $(PROGS)
     46 
     47 install: $(ILIBS) $(IPROGS) $(IHDRS)
     48 	mkdir -p $(DESTDIR)$(bindir)
     49 	mkdir -p $(DESTDIR)$(libdir)
     50 	mkdir -p $(DESTDIR)$(includedir)
     51 	mkdir -p $(DESTDIR)$(mandir)/man1
     52 	for f in $(IPROGS); do cp $$f $(DESTDIR)$(bindir); done
     53 	for f in $(ILIBS); do cp $$f $(DESTDIR)$(libdir); done
     54 	for f in $(IHDRS); do cp $$f $(DESTDIR)$(includedir); done
     55 	for f in $(IDOCS); do cp $$f $(DESTDIR)$(mandir)/man1; done
     56 
     57 clean:
     58 	rm -rf $(PROGS) *.[ao] *.[ls]o *~ testdb
     59 
     60 test:	all
     61 	rm -rf testdb && mkdir testdb
     62 	./mtest && ./mdb_stat testdb
     63 
     64 liblmdb.a:	mdb.o midl.o
     65 	$(AR) rs $@ mdb.o midl.o
     66 
     67 liblmdb$(SOEXT):	mdb.lo midl.lo
     68 #	$(CC) $(LDFLAGS) -pthread -shared -Wl,-Bsymbolic -o $@ mdb.o midl.o $(SOLIBS)
     69 	$(CC) $(LDFLAGS) -pthread -shared -o $@ mdb.lo midl.lo $(SOLIBS)
     70 
     71 mdb_stat: mdb_stat.o liblmdb.a
     72 mdb_copy: mdb_copy.o liblmdb.a
     73 mdb_dump: mdb_dump.o liblmdb.a
     74 mdb_load: mdb_load.o liblmdb.a
     75 mtest:    mtest.o    liblmdb.a
     76 mtest2:	mtest2.o liblmdb.a
     77 mtest3:	mtest3.o liblmdb.a
     78 mtest4:	mtest4.o liblmdb.a
     79 mtest5:	mtest5.o liblmdb.a
     80 mtest6:	mtest6.o liblmdb.a
     81 
     82 mdb.o: mdb.c lmdb.h midl.h
     83 	$(CC) $(CFLAGS) $(CPPFLAGS) -c mdb.c
     84 
     85 midl.o: midl.c midl.h
     86 	$(CC) $(CFLAGS) $(CPPFLAGS) -c midl.c
     87 
     88 mdb.lo: mdb.c lmdb.h midl.h
     89 	$(CC) $(CFLAGS) -fPIC $(CPPFLAGS) -c mdb.c -o $@
     90 
     91 midl.lo: midl.c midl.h
     92 	$(CC) $(CFLAGS) -fPIC $(CPPFLAGS) -c midl.c -o $@
     93 
     94 %:	%.o
     95 	$(CC) $(CFLAGS) $(LDFLAGS) $^ $(LDLIBS) -o $@
     96 
     97 %.o:	%.c lmdb.h
     98 	$(CC) $(CFLAGS) $(CPPFLAGS) -c $<
     99 
    100 COV_FLAGS=-fprofile-arcs -ftest-coverage
    101 COV_OBJS=xmdb.o xmidl.o
    102 
    103 coverage: xmtest
    104 	for i in mtest*.c [0-9]*.c; do j=`basename \$$i .c`; $(MAKE) $$j.o; \
    105 		gcc -o x$$j $$j.o $(COV_OBJS) -pthread $(COV_FLAGS); \
    106 		rm -rf testdb; mkdir testdb; ./x$$j; done
    107 	gcov xmdb.c
    108 	gcov xmidl.c
    109 
    110 xmtest:	mtest.o xmdb.o xmidl.o
    111 	gcc -o xmtest mtest.o xmdb.o xmidl.o -pthread $(COV_FLAGS)
    112 
    113 xmdb.o: mdb.c lmdb.h midl.h
    114 	$(CC) $(CFLAGS) -fPIC $(CPPFLAGS) -O0 $(COV_FLAGS) -c mdb.c -o $@
    115 
    116 xmidl.o: midl.c midl.h
    117 	$(CC) $(CFLAGS) -fPIC $(CPPFLAGS) -O0 $(COV_FLAGS) -c midl.c -o $@