Only seed database for Debian install if we're using default config
[onak.git] / Makefile.in
1 #
2 # Makefile for onak.
3 #
4
5 CC = @CC@
6 CFLAGS += @CFLAGS@ -Wall -pedantic -fPIC
7 # Uncomment to enable profiling.
8 LDFLAGS += @LDFLAGS@
9 # Can be "pg" for Postgresql, "file" for flat files or "db2" for pksd db2 style.
10 DBTYPE = @DBTYPE@
11 #
12 LIBS = @LIBS@
13 DB4LIBS = @DB4LIBS@
14 #MAKEDEPEND = makedepend -f- -- 
15 MAKEDEPEND = $(CC) -MM
16 prefix ?= @prefix@
17 exec_prefix ?= @exec_prefix@
18
19 PROGS = add lookup gpgwww onak splitkeys onak-mail.pl stripkey
20 CORE_OBJS = armor.o charfuncs.o decodekey.o getcgi.o hash.o \
21         keyid.o keyindex.o ll.o mem.o onak-conf.o parsekey.o sha1.o md5.o \
22         log.o photoid.o wordlist.o cleanup.o merge.o sendsync.o keyarray.o
23 SRCS = armor.c parsekey.c merge.c keyid.c md5.c sha1.c main.c getcgi.c mem.c \
24         keyindex.c stats.c lookup.c add.c keydb_$(DBTYPE).c ll.c hash.c \
25         gpgwww.c onak-conf.c charfuncs.c sendsync.c log.c photoid.c \
26         wordlist.c cleankey.c cleanup.c keyarray.c \
27         $(foreach be,@BACKENDS@,keydb_$(be).c)
28 PROGS_LDFLAGS_EXTRA =
29
30 ifeq (x@KEYD@, xyes)
31 PROGS += keyd
32 KEYDB_OBJ = keydb_keyd.o
33 SRCS += keyd.c keydb_keyd.c
34 else
35 KEYDB_OBJ = keydb_$(DBTYPE).o
36 endif
37
38 ifeq (x@DBTYPE@, xdynamic)
39 LIBS += -ldl
40 BACKENDS = $(foreach be,@BACKENDS@,libkeydb_$(be).so)
41 PROGS += keyd
42 PROGS_LDFLAGS_EXTRA = -rdynamic
43 SRCS += keyd.c
44 endif
45
46 OBJS = stats.o cleankey.o $(CORE_OBJS) $(KEYDB_OBJ)
47
48 all: .depend $(PROGS) testparse maxpath sixdegrees splitkeys onak.conf \
49         $(BACKENDS)
50
51 install: $(PROGS) onak.conf $(BACKENDS)
52         install -d $(DESTDIR)/@bindir@
53         install -d $(DESTDIR)/@libdir@/onak/backends
54         install -d $(DESTDIR)/@localstatedir@/lib/onak
55         install -d $(DESTDIR)/@mandir@/man1
56         install -d $(DESTDIR)/@mandir@/man8
57         install -d $(DESTDIR)/@sysconfdir@
58         install onak-mail.pl $(DESTDIR)/@libdir@/onak
59         install onak splitkeys $(DESTDIR)/@bindir@
60         install onak.1 splitkeys.1 $(DESTDIR)/@mandir@/man1
61         install keyd.8 onak-mail.pl.8 $(DESTDIR)/@mandir@/man8
62 ifeq (x@DBTYPE@, xdynamic)
63         install $(BACKENDS) $(DESTDIR)/@libdir@/onak/backends
64         install -d $(DESTDIR)/@sbindir@
65         install keyd $(DESTDIR)/@sbindir@
66 endif
67
68 keyd: keyd.o $(CORE_OBJS) keydb_$(DBTYPE).o
69         $(CC) $(LDFLAGS) $(PROGS_LDFLAGS_EXTRA) \
70                 -o keyd keyd.o $(CORE_OBJS) keydb_$(DBTYPE).o $(LIBS)
71
72 libkeydb_db4.so: keydb_db4.o
73         $(CC) -shared $(DB4LIBS) -o libkeydb_db4.so keydb_db4.o $(CORE_OBJS)
74
75 libkeydb_pg.so: keydb_pg.o
76         $(CC) -shared $(PQLIBS) -o libkeydb_pg.so keydb_pg.o $(CORE_OBJS)
77
78 libkeydb_%.so: keydb_%.o
79         $(CC) -shared -o $@ $< $(CORE_OBJS)
80
81 splitkeys: splitkeys.o $(CORE_OBJS) $(KEYDB_OBJ)
82         $(CC) $(LDFLAGS) -o splitkeys splitkeys.o $(CORE_OBJS) $(KEYDB_OBJ) \
83                 $(LIBS) $(PROGS_LDFLAGS_EXTRA)
84
85 testparse: main.o $(OBJS)
86         $(CC) $(LDFLAGS) -o testparse main.o $(OBJS) $(LIBS) \
87                 $(PROGS_LDFLAGS_EXTRA)
88
89 maxpath: maxpath.o $(OBJS)
90         $(CC) $(LDFLAGS) -o maxpath maxpath.o $(OBJS) $(LIBS) \
91                 $(PROGS_LDFLAGS_EXTRA)
92
93 sixdegrees: sixdegrees.o $(OBJS)
94         $(CC) $(LDFLAGS) -o sixdegrees sixdegrees.o $(OBJS) $(LIBS) \
95                 $(PROGS_LDFLAGS_EXTRA)
96
97 stripkey: stripkey.o $(OBJS)
98         $(CC) $(LDFLAGS) -o stripkey stripkey.o $(OBJS) $(LIBS) \
99                 $(PROGS_LDFLAGS_EXTRA)
100
101 gpgwww: gpgwww.o $(OBJS)
102         $(CC) $(LDFLAGS) -o gpgwww gpgwww.o $(OBJS) $(LIBS) \
103                 $(PROGS_LDFLAGS_EXTRA)
104
105 lookup: lookup.o cleankey.o $(CORE_OBJS) $(KEYDB_OBJ)
106         $(CC) $(LDFLAGS) -o lookup lookup.o cleankey.o $(CORE_OBJS) \
107                 $(KEYDB_OBJ) $(LIBS) $(PROGS_LDFLAGS_EXTRA)
108
109 add: add.o cleankey.o $(CORE_OBJS) $(KEYDB_OBJ)
110         $(CC) $(LDFLAGS) -o add add.o cleankey.o \
111                 $(CORE_OBJS) $(KEYDB_OBJ) $(LIBS) $(PROGS_LDFLAGS_EXTRA)
112
113 onak: onak.o cleankey.o $(CORE_OBJS) $(KEYDB_OBJ)
114         $(CC) $(LDFLAGS) -o onak onak.o cleankey.o \
115                 $(CORE_OBJS) $(KEYDB_OBJ) $(LIBS) $(PROGS_LDFLAGS_EXTRA)
116
117 onak-conf.o: onak-conf.c onak-conf.h
118         $(CC) $(CFLAGS) -DCONFIGFILE=\"@sysconfdir@/onak.conf\" \
119                 -DDBFUNCS=keydb_@DBTYPE@_funcs -c onak-conf.c
120
121 onak-mail.pl: onak-mail.pl.in
122         sed 's:@CONFIG@:@sysconfdir@/onak.conf:g' < onak-mail.pl.in > onak-mail.pl
123         chmod +x onak-mail.pl
124
125 onak.conf: onak.conf.in
126         sed -e 's:@BINDIR@:@bindir@:g' \
127                 -e 's:@LIBDIR@:@libdir@:g' \
128                 -e 's:@STATEDIR@:@localstatedir@:g' \
129                 < onak.conf.in > onak.conf
130
131 clean:
132         $(RM) $(PROGS) $(OBJS) Makefile.bak testparse maxpath *.core core \
133                 gpgwww.o add.o lookup.o main.o maxpath.o onak.o sixdegrees \
134                 sixdegrees.o splitkeys.o stripkey.o onak.conf keyd.o \
135                 $(foreach be,@BACKENDS@,keydb_$(be).o) *.so
136 ifeq (x@KEYD@, xyes)
137         $(RM) keyd.o keydb_$(DBTYPE).o
138 endif
139
140 distclean: clean
141         $(RM) -f Makefile .depend config.log config.status config.h
142         $(RM) -r autom4te.cache
143
144 .depend: $(SRCS)
145         rm -f .depend
146         $(MAKEDEPEND) $(CFLAGS) $(SRCS) > .depend
147
148 include .depend
149
150 .PHONY: all clean