blob: f405d3d25eb9c9cba6de129bd4c148076c76b7cc (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
|
# include config file
CONFIG ?= .config
-include $(CONFIG)
CFLAGSORIG := $(CFLAGS)
-include $(DOVECOT)/dovecot-config
INSTALLDIR ?= $(moduledir)/imap
# Kill CFLAGS from dovecot-config
CFLAGS := $(CFLAGSORIG)
backenddir := /usr/lib/dovecot-antispam
CFLAGS += '-DBACKENDDIR="$(backenddir)"'
# includes/flags we need for building a dovecot plugin
INCS += -DHAVE_CONFIG_H
INCS += -I$(DOVECOT)/
INCS += -I$(DOVECOT)/src/
INCS += -I$(DOVECOT)/src/lib/
INCS += -I$(DOVECOT)/src/lib-storage/
INCS += -I$(DOVECOT)/src/lib-mail/
INCS += -I$(DOVECOT)/src/lib-imap/
INCS += -I$(DOVECOT)/src/lib-dict/
INCS += -I$(DOVECOT)/src/lib-index/
INCS += -I$(DOVECOT)/src/imap/
# output name
LIBRARY_NAME ?= lib90_$(PLUGINNAME)_plugin.so
objs = antispam-storage.o antispam-plugin.o
# debug rules
ifeq ("$(DEBUG)", "stderr")
CFLAGS += -DCONFIG_DEBUG -DDEBUG_STDERR
objs += debug.o
else
ifeq ("$(DEBUG)", "syslog")
CFLAGS += -DCONFIG_DEBUG -DDEBUG_SYSLOG
objs += debug.o
endif
endif
ifeq ("$(DEBUG_VERBOSE)", "1")
CFLAGS += -DCONFIG_DEBUG_VERBOSE
endif
BACKENDS = dspam-exec.so signature-log.so crm114-exec.so mailtrain.so spool2dir.so
# main make rules
CFLAGS += -fPIC -shared -Wall -Wextra -DPLUGINNAME=$(PLUGINNAME)
CC ?= cc
HOSTCC ?= cc
all: verify_config $(LIBRARY_NAME) $(BACKENDS)
antispam-storage.o: antispam-storage.c antispam-storage-*.c $(CONFIG) antispam-plugin.h dovecot-version.h
$(CC) -c $(CFLAGS) $(INCS) -o $@ $<
%.o: %.c $(CONFIG) antispam-plugin.h dovecot-version.h antispam-version.h
$(CC) -c $(CFLAGS) $(INCS) -o $@ $<
$(LIBRARY_NAME): $(objs)
$(CC) $(CFLAGS) $(INCS) $(objs) -o $(LIBRARY_NAME) $(LDFLAGS) -ldl
dovecot-version: dovecot-version.c $(CONFIG)
$(HOSTCC) $(INCS) -o dovecot-version dovecot-version.c
dovecot-version.h: dovecot-version
./dovecot-version > dovecot-version.h
antispam-version.h: version.sh
./version.sh > antispam-version.h
dspam-exec.so: dspam-exec.o signature.o
signature-log.so: signature-log.o signature.o
crm114-exec.so: crm114-exec.o signature.o
mailtrain.so: mailtrain.o
spool2dir.so: spool2dir.o
$(BACKENDS):
$(CC) $(CFLAGS) $(INCS) $(LDFLAGS) -shared -o $@ $^
clean:
rm -f *.so *.o *~ dovecot-version dovecot-version.h antispam-version.h
install: all
install -o $(USER) -g $(GROUP) -m 0755 $(LIBRARY_NAME) $(DESTDIR)$(INSTALLDIR)/
mkdir -p $(DESTDIR)$(backenddir)
install -o $(USER) -g $(GROUP) -m 0755 $(BACKENDS) $(DESTDIR)$(backenddir)/
verify_config:
@if [ ! -r $(CONFIG) ]; then \
echo -e "\nBuilding the plugin requires a configuration file"; \
echo -e $(CONFIG)'. Copy defconfig ("cp defconfig' $(CONFIG)'")' ; \
echo -e "to create an example configuration.\n"; \
exit 1; \
fi
|