eedab96ef2d604777055572d409d92d4644ba4e0
[samba.git] / source / lib / ldb / Makefile.in
1 CC = @CC@
2 GCOV = @GCOV@
3 YODL2MAN = @YODL2MAN@
4 prefix = @prefix@
5 exec_prefix = @exec_prefix@
6 includedir = @includedir@
7 libdir = @libdir@
8 bindir = @bindir@
9 WITH_GCOV = @WITH_GCOV@
10
11 ifeq ($(WITH_LDAP),1)
12 OPENLDAP_PREFIX=/usr
13 LDAP_LIBS=-L$(OPENLDAP_PREFIX)/lib -llber -lldap
14 LDAP_FLAGS=-DHAVE_LDAP=1
15 LDB_LDAP_OBJ=ldb_ldap/ldb_ldap.o
16 endif
17
18 TDBDIR=../tdb
19 TALLOCDIR=../talloc
20
21 CFLAGS1=-Wall -Wall -Wshadow -Wstrict-prototypes -Wpointer-arith \
22        -Wcast-qual -Wcast-align -Wwrite-strings -g -Iinclude -I. -I.. \
23        -I$(TDBDIR)/include -I$(TALLOCDIR) -DUSE_MMAP=1 $(LDAP_FLAGS)
24
25 # enable the following two lines to build with gcov code coverage support
26 ifeq ($(WITH_GCOV),1)
27 GCOV_FLAGS = -ftest-coverage -fprofile-arcs 
28 GCOV_LIBS = -lgcov
29 endif
30
31 CFLAGS = $(CFLAGS1) $(GCOV_FLAGS) @CFLAGS@
32
33 LIB_FLAGS=-Llib -lldb $(LDAP_LIBS) $(GCOV_LIBS)
34
35 TDB_OBJ=$(TDBDIR)/common/tdb.o $(TDBDIR)/common/spinlock.o
36 TALLOC_OBJ=$(TALLOCDIR)/talloc.o
37
38 LDB_TDB_OBJ=ldb_tdb/ldb_match.o ldb_tdb/ldb_tdb.o \
39         ldb_tdb/ldb_pack.o ldb_tdb/ldb_search.o ldb_tdb/ldb_index.o \
40         ldb_tdb/ldb_cache.o
41
42
43 COMMON_OBJ=common/ldb.o common/ldb_ldif.o common/util.o \
44            common/ldb_parse.o common/ldb_msg.o common/ldb_utf8.o \
45            common/ldb_debug.o common/ldb_modules.o
46
47 MODULES_OBJ=modules/timestamps.o modules/schema.o
48
49 OBJS =  $(MODULES_OBJ) $(COMMON_OBJ) $(LDB_TDB_OBJ) $(TDB_OBJ) $(TALLOC_OBJ) $(LDB_LDAP_OBJ)
50
51 LDB_LIB = lib/libldb.a
52
53 BINS = bin/ldbadd bin/ldbsearch bin/ldbdel bin/ldbmodify bin/ldbedit bin/ldbrename bin/ldbtest
54
55 LIBS = $(LDB_LIB)($(OBJS))
56
57 DIRS = lib bin
58
59 all: $(DIRS) $(BINS) $(LIBS) manpages
60
61 lib:
62         mkdir -p lib
63
64 bin:
65         mkdir -p bin
66
67 lib/libldb.a: $(OBJS)
68
69 bin/ldbadd: tools/ldbadd.o $(LIBS)
70         $(CC) -o bin/ldbadd tools/ldbadd.o $(LIB_FLAGS)
71
72 bin/ldbsearch: tools/ldbsearch.o $(LIBS)
73         $(CC) -o bin/ldbsearch tools/ldbsearch.o $(LIB_FLAGS)
74
75 bin/ldbdel: tools/ldbdel.o $(LIBS)
76         $(CC) -o bin/ldbdel tools/ldbdel.o $(LIB_FLAGS)
77
78 bin/ldbmodify: tools/ldbmodify.o $(LIBS)
79         $(CC) -o bin/ldbmodify tools/ldbmodify.o $(LIB_FLAGS)
80
81 bin/ldbedit: tools/ldbedit.o $(LIBS)
82         $(CC) -o bin/ldbedit tools/ldbedit.o $(LIB_FLAGS)
83
84 bin/ldbrename: tools/ldbrename.o $(LIBS)
85         $(CC) -o bin/ldbrename tools/ldbrename.o $(LIB_FLAGS)
86
87 bin/ldbtest: tools/ldbtest.o $(LIBS)
88         $(CC) -o bin/ldbtest tools/ldbtest.o $(LIB_FLAGS)
89
90 .SUFFIXES: .1 .2 .3 .yo
91
92 .yo.3: 
93         echo Creating $@ from $<
94         -$(YODL2MAN) -o $@ `dirname $<`/`basename $< .yo` || rm -f $@
95
96 manpages: $(patsubst %.yo,%.3,$(wildcard man/man3/*.yo))
97
98 clean:
99         rm -f */*.o *.gcov */*.gc?? *~ */*~ $(BINS) $(TDB_OBJ) $(TALLOC_OBJ) $(LDB_LIB) man/man?/*.[13]
100
101 etags:
102         etags */*.[ch]
103
104 test-tdb:
105         @echo "STARTING TDB BACKEND TEST"
106         tests/test-tdb.sh
107
108 test-ldap:
109         @echo "STARTING LDAP BACKEND TEST"
110         tests/test-ldap.sh
111
112 test-schema:
113         @echo "STARTING SCHEMA MODULE TEST"
114         tests/test-schema.sh
115
116 test: test-tdb test-ldap test-schema
117
118 install: all
119         cp include/ldb.h $(includedir)
120         cp $(LDB_LIB) $(libdir)
121         cp $(BINS) $(bindir)
122         cp ldb.pc $(libdir)/pkgconfig
123
124 gcov:
125         $(GCOV) -po ldb_ldap ldb_ldap/*.c 2| tee ldb_ldap.report.gcov
126         $(GCOV) -po ldb_tdb ldb_tdb/*.c 2| tee ldb_tdb.report.gcov
127         $(GCOV) -po common common/*.c 2| tee common.report.gcov
128         $(GCOV) -po modules modules/*.c 2| tee modules.report.gcov
129         $(GCOV) -po tools tools/*.c 2| tee tools.report.gcov