6 CFLAGS += @CFLAGS@ -Wall -pedantic -fPIC
7 # Uncomment to enable profiling.
9 # Can be "pg" for Postgresql, "file" for flat files or "db2" for pksd db2 style.
12 LIBS = @LIBS@ @NETTLE_LIBS@
14 #MAKEDEPEND = makedepend -f- --
15 MAKEDEPEND = $(CC) -MM
17 exec_prefix ?= @exec_prefix@
19 PROGS = add lookup hashquery gpgwww onak splitkeys onak-mail.pl stripkey
20 CORE_OBJS = armor.o charfuncs.o decodekey.o getcgi.o hash.o marshal.o \
21 keyid.o keyindex.o ll.o mem.o onak-conf.o parsekey.o sigcheck.o \
22 log.o photoid.o wordlist.o cleanup.o merge.o sendsync.o keyarray.o
23 ifeq (x@NETTLE_LIBS@, x)
24 CORE_OBJS += md5.o sha1.o
26 SRCS = armor.c parsekey.c merge.c keyid.c md5.c sha1.c main.c getcgi.c mem.c \
27 keyindex.c stats.c lookup.c add.c keydb_$(DBTYPE).c ll.c hash.c \
28 gpgwww.c onak-conf.c charfuncs.c sendsync.c log.c photoid.c sigcheck.c \
29 wordlist.c cleankey.c cleanup.c keyarray.c hashquery.c marshal.c \
30 $(foreach be,@BACKENDS@,keydb_$(be).c)
35 KEYDB_OBJ = keydb_keyd.o
36 SRCS += keyd.c keydb_keyd.c keydctl.c
38 KEYDB_OBJ = keydb_$(DBTYPE).o
41 ifeq (x@DBTYPE@, xdynamic)
43 BACKENDS = $(foreach be,@BACKENDS@,libkeydb_$(be).so)
45 PROGS_LDFLAGS_EXTRA = -rdynamic
46 SRCS += keyd.c keydctl.c
49 OBJS = stats.o cleankey.o $(CORE_OBJS) $(KEYDB_OBJ)
51 all: .depend $(PROGS) testparse maxpath sixdegrees splitkeys onak.conf \
54 test: onak $(BACKENDS)
57 install: $(PROGS) onak.conf $(BACKENDS)
58 install -d $(DESTDIR)/@bindir@
59 install -d $(DESTDIR)/@libdir@/onak/backends
60 install -d $(DESTDIR)/@localstatedir@/lib/onak
61 install -d $(DESTDIR)/@mandir@/man1
62 install -d $(DESTDIR)/@mandir@/man8
63 install -d $(DESTDIR)/@sysconfdir@
64 install onak-mail.pl $(DESTDIR)/@libdir@/onak
65 install onak splitkeys $(DESTDIR)/@bindir@
66 install onak.1 splitkeys.1 $(DESTDIR)/@mandir@/man1
67 install keyd.8 keydctl.8 onak-mail.pl.8 $(DESTDIR)/@mandir@/man8
68 ifeq (x@DBTYPE@, xdynamic)
69 install $(BACKENDS) $(DESTDIR)/@libdir@/onak/backends
70 install -d $(DESTDIR)/@sbindir@
71 install keyd $(DESTDIR)/@sbindir@
72 install keydctl $(DESTDIR)/@bindir@
75 keyd: keyd.o $(CORE_OBJS) keydb_$(DBTYPE).o
76 $(CC) $(LDFLAGS) $(PROGS_LDFLAGS_EXTRA) \
77 -o keyd keyd.o $(CORE_OBJS) keydb_$(DBTYPE).o $(LIBS)
79 keydctl: keydctl.o onak-conf.o ll.o log.o
80 $(CC) $(LDFLAGS) $(PROGS_LDFLAGS_EXTRA) \
81 -o keydctl keydctl.o onak-conf.o ll.o log.o $(LIBS)
83 libkeydb_db4.so: keydb_db4.o $(CORE_OBJS)
84 $(CC) -shared $(DB4LIBS) -o libkeydb_db4.so keydb_db4.o $(CORE_OBJS)
86 libkeydb_pg.so: keydb_pg.o $(CORE_OBJS)
87 $(CC) -shared $(PQLIBS) -o libkeydb_pg.so keydb_pg.o $(CORE_OBJS)
89 libkeydb_%.so: keydb_%.o $(CORE_OBJS)
90 $(CC) -shared -o $@ $< $(CORE_OBJS)
92 splitkeys: splitkeys.o $(CORE_OBJS) $(KEYDB_OBJ)
93 $(CC) $(LDFLAGS) -o splitkeys splitkeys.o $(CORE_OBJS) $(KEYDB_OBJ) \
94 $(LIBS) $(PROGS_LDFLAGS_EXTRA)
96 testparse: main.o $(OBJS)
97 $(CC) $(LDFLAGS) -o testparse main.o $(OBJS) $(LIBS) \
98 $(PROGS_LDFLAGS_EXTRA)
100 maxpath: maxpath.o $(OBJS)
101 $(CC) $(LDFLAGS) -o maxpath maxpath.o $(OBJS) $(LIBS) \
102 $(PROGS_LDFLAGS_EXTRA)
104 sixdegrees: sixdegrees.o $(OBJS)
105 $(CC) $(LDFLAGS) -o sixdegrees sixdegrees.o $(OBJS) $(LIBS) \
106 $(PROGS_LDFLAGS_EXTRA)
108 stripkey: stripkey.o $(OBJS)
109 $(CC) $(LDFLAGS) -o stripkey stripkey.o $(OBJS) $(LIBS) \
110 $(PROGS_LDFLAGS_EXTRA)
112 gpgwww: gpgwww.o $(OBJS)
113 $(CC) $(LDFLAGS) -o gpgwww gpgwww.o $(OBJS) $(LIBS) \
114 $(PROGS_LDFLAGS_EXTRA)
116 hashquery: hashquery.o $(CORE_OBJS) $(KEYDB_OBJ)
117 $(CC) $(LDFLAGS) -o hashquery hashquery.o $(CORE_OBJS) \
118 $(KEYDB_OBJ) $(LIBS) $(PROGS_LDFLAGS_EXTRA)
120 lookup: lookup.o cleankey.o $(CORE_OBJS) $(KEYDB_OBJ)
121 $(CC) $(LDFLAGS) -o lookup lookup.o cleankey.o $(CORE_OBJS) \
122 $(KEYDB_OBJ) $(LIBS) $(PROGS_LDFLAGS_EXTRA)
124 add: add.o cleankey.o $(CORE_OBJS) $(KEYDB_OBJ)
125 $(CC) $(LDFLAGS) -o add add.o cleankey.o \
126 $(CORE_OBJS) $(KEYDB_OBJ) $(LIBS) $(PROGS_LDFLAGS_EXTRA)
128 onak: onak.o cleankey.o $(CORE_OBJS) $(KEYDB_OBJ)
129 $(CC) $(LDFLAGS) -o onak onak.o cleankey.o \
130 $(CORE_OBJS) $(KEYDB_OBJ) $(LIBS) $(PROGS_LDFLAGS_EXTRA)
132 onak-conf.o: onak-conf.c onak-conf.h
133 $(CC) $(CFLAGS) -DCONFIGFILE=\"@sysconfdir@/onak.conf\" \
134 -DDBFUNCS=keydb_@DBTYPE@_funcs -c onak-conf.c
136 # HACK: onak-conf.o needs to be able to see keydb_@DBTYPE@_funcs, but
137 # keydctl doesn't want to link against the DB stuff. To be fixed more cleanly.
138 keydctl.o: keydctl.c keyd.h
139 $(CC) $(CFLAGS) -DDBFUNCS=keydb_@DBTYPE@_funcs -c keydctl.c
141 onak-mail.pl: onak-mail.pl.in
142 sed 's:@CONFIG@:@sysconfdir@/onak.conf:g' < onak-mail.pl.in > onak-mail.pl
143 chmod +x onak-mail.pl
145 onak.conf: onak.conf.in
146 sed -e 's:@BINDIR@:@bindir@:g' \
147 -e 's:@LIBDIR@:@libdir@:g' \
148 -e 's:@STATEDIR@:@localstatedir@:g' \
149 < onak.conf.in > onak.conf
152 $(RM) $(PROGS) $(OBJS) Makefile.bak testparse maxpath *.core core \
153 gpgwww.o add.o lookup.o main.o maxpath.o onak.o sixdegrees \
154 sixdegrees.o splitkeys.o stripkey.o onak.conf keyd.o \
155 keydctl.o hashquery.o version.h \
156 $(foreach be,@BACKENDS@,keydb_$(be).o) *.so
158 $(RM) keyd.o keydb_$(DBTYPE).o
162 $(RM) -f Makefile .depend config.log config.status config.h
163 $(RM) -r autom4te.cache
166 @echo '#include "config.h"' > version.h
167 @if [ -e .bzr ]; then \
168 echo "#define ONAK_VERSION PACKAGE_VERSION \"+bzr`bzr revno`\"" \
171 echo "#define ONAK_VERSION PACKAGE_VERSION" >> version.h; \
174 .depend: $(SRCS) version.h
176 $(MAKEDEPEND) $(CFLAGS) $(SRCS) > .depend