+ wordlist.c cleankey.c cleanup.c keyarray.c \
+ $(foreach be,@BACKENDS@,keydb_$(be).c)
+PROGS_LDFLAGS_EXTRA =
+
+ifeq (x@KEYD@, xyes)
+PROGS += keyd
+KEYDB_OBJ = keydb_keyd.o
+SRCS += keyd.c keydb_keyd.c
+else
+KEYDB_OBJ = keydb_$(DBTYPE).o
+endif
+
+ifeq (x@DBTYPE@, xdynamic)
+LIBS += -ldl
+BACKENDS = $(foreach be,@BACKENDS@,libkeydb_$(be).so)
+PROGS += keyd
+PROGS_LDFLAGS_EXTRA = -rdynamic
+SRCS += keyd.c
+endif
+
+OBJS = stats.o cleankey.o $(CORE_OBJS) $(KEYDB_OBJ)
+
+all: .depend $(PROGS) testparse maxpath sixdegrees splitkeys onak.conf \
+ $(BACKENDS)
+
+install: $(PROGS) onak.conf $(BACKENDS)
+ install -d $(DESTDIR)/@bindir@
+ install -d $(DESTDIR)/@libdir@/onak/backends
+ install -d $(DESTDIR)/@localstatedir@/lib/onak
+ install -d $(DESTDIR)/@mandir@/man1
+ install -d $(DESTDIR)/@mandir@/man8
+ install -d $(DESTDIR)/@sysconfdir@
+ install onak-mail.pl $(DESTDIR)/@libdir@/onak
+ install onak splitkeys $(DESTDIR)/@bindir@
+ install onak.1 splitkeys.1 $(DESTDIR)/@mandir@/man1
+ install keyd.8 onak-mail.pl.8 $(DESTDIR)/@mandir@/man8
+ifeq (x@DBTYPE@, xdynamic)
+ install $(BACKENDS) $(DESTDIR)/@libdir@/onak/backends
+ install -d $(DESTDIR)/@sbindir@
+ install keyd $(DESTDIR)/@sbindir@
+endif
+
+keyd: keyd.o $(CORE_OBJS) keydb_$(DBTYPE).o
+ $(CC) $(LDFLAGS) $(PROGS_LDFLAGS_EXTRA) \
+ -o keyd keyd.o $(CORE_OBJS) keydb_$(DBTYPE).o $(LIBS)
+
+libkeydb_db4.so: keydb_db4.o
+ $(CC) -shared $(DB4LIBS) -o libkeydb_db4.so keydb_db4.o $(CORE_OBJS)
+
+libkeydb_pg.so: keydb_pg.o
+ $(CC) -shared $(PQLIBS) -o libkeydb_pg.so keydb_pg.o $(CORE_OBJS)
+
+libkeydb_%.so: keydb_%.o
+ $(CC) -shared -o $@ $< $(CORE_OBJS)
+
+keydb_%.o: keydb_%.c
+ $(CC) -c -fPIC $(LDFLAGS) -o $@ $<
+
+splitkeys: splitkeys.o $(CORE_OBJS) $(KEYDB_OBJ)
+ $(CC) $(LDFLAGS) -o splitkeys splitkeys.o $(CORE_OBJS) $(KEYDB_OBJ) \
+ $(LIBS) $(PROGS_LDFLAGS_EXTRA)