aboutsummaryrefslogtreecommitdiffstats
path: root/Makefile
blob: ba032ab9aca831df84819aacd6d4702b9785045c (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
# include config file
-include .config

# includes/flags we need for building a dovecot plugin
CFLAGS += -DHAVE_CONFIG_H
CFLAGS += -I$(DOVECOT)/
CFLAGS += -I$(DOVECOT)/src/
CFLAGS += -I$(DOVECOT)/src/lib/
CFLAGS += -I$(DOVECOT)/src/lib-storage/
CFLAGS += -I$(DOVECOT)/src/lib-mail/
CFLAGS += -I$(DOVECOT)/src/lib-imap/
CFLAGS += -I$(DOVECOT)/src/imap/

# per-backend configuration
ifeq ("$(BACKEND)", "dspam-exec")
CFLAGS += -DBACKEND_WANTS_SIGNATURE=1
# can take a while, check more often
CFLAGS += -DCOPY_CHECK_INTERVAL=10
endif


# 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


# main make rules
CFLAGS += -fPIC -shared -Wall
CC ?= "gcc"

objs += plugin.o $(BACKEND).o
ALL = antispam

all: verify_config $(ALL)

%.o:	%.c .config
	$(CC) -c $(CFLAGS) -o $@ $<

antispam: $(objs)
	$(CC) $(CFLAGS) $(objs) -o $@.so $(LDFLAGS)

clean:
	rm -f *.so *.o *~

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