-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
153 lines (115 loc) · 4.2 KB
/
Copy pathMakefile
File metadata and controls
153 lines (115 loc) · 4.2 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# Makefile for fetchmail_wakeup
#### configuration begin ####
## package name and latest version ##
PACKAGE_NAME = dovecot-fetchmail
#PACKAGE_VERSION = $(shell git tag | grep upstream | sort -r | head -n 1 | cut -d / -f 2)
PACKAGE_VERSION = $(lastword $(sort $(subst upstream/,, $(filter upstream/%, $(shell git tag)))))
## paths & directories ##
# Dovecot's header directory
DOVECOT_INCDIR = /usr/include/dovecot
# Dovecot's IMAP plugin path
DOVECOT_MODULEDIR = /usr/lib/dovecot/modules
DOVECOT_SETTINGDIR = ${DOVECOT_MODULEDIR}/settings
# Dovecot's config directory (where dovecot.conf resides)
DOVECOT_ETCDIR = /etc/dovecot
# directory for binaries
BINDIR = /usr/bin
# directories for man pages sections 1 & 7
MAN1DIR = /usr/share/man/man1
MAN7DIR = /usr/share/man/man7
# fetchmail's PID file (used in awaken-fetchmail)
FETCHMAIL_PIDFILE = %{home}/.fetchmail.pid
## compile time flags/defines ##
# uncomment to turn on debugging
#DEBUG = 1
## usually no need to configure anything below this line ##
# set additional flags
CPPFLAGS += -D'FETCHMAIL_PIDFILE="${FETCHMAIL_PIDFILE}"'
ifdef DEBUG
CPPFLAGS += -DFETCHMAIL_WAKEUP_DEBUG
endif
# plugin source & target name #
PLUGIN_SOURCES = fetchmail_wakeupc.c
PLUGIN_OBJECTS = fetchmail_wakeup.o fetchmail_wakeup_settings.o
PLUGIN_NAME = lib_fetchmail_wakeup_plugin.so
SETTINGS_PLUGIN_SOURCES = fetchmail_wakeup_settings.c fetchmail_wakeup_settings.h
SETTINGS_PLUGIN_NAME = libfetchmail_wakeup_settings.so
# helper sources, target name & setuid account #
HELPER_SOURCES = awaken-fetchmail.c
HELPER_NAME = awaken-fetchmail
HELPER_USER = fetchmail
# manual pages in their respective sections #
MAN1PAGES = awaken-fetchmail.1
MAN7PAGES = fetchmail_wakeup.7
#### configuration end ####
.PHONY: all build install install_man clean dist \
install_plugins install_helper install_man \
install_settings_plugin install_plugin \
install_man1 install_man7
all: build
build: ${SETTINGS_PLUGIN_NAME} ${PLUGIN_NAME} ${HELPER_NAME} ${MAN1PAGES} ${MAN7PAGES}
%.o: %.c
$(CC) $(CPPFLAGS) $(CFLAGS) \
-I${DOVECOT_INCDIR} \
-fPIC -Wall \
-DHAVE_CONFIG_H \
$< -c -o $@
${SETTINGS_PLUGIN_NAME}: ${SETTINGS_PLUGIN_SOURCES}
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) \
-fPIC -shared -Wall \
-I${DOVECOT_INCDIR} \
-DHAVE_CONFIG_H \
$< -o $@
${PLUGIN_NAME}: ${PLUGIN_OBJECTS}
$(CC) $(CPPFLAGS) $(LDFLAGS) \
-fPIC -shared -Wall \
-I${DOVECOT_INCDIR} \
-DHAVE_CONFIG_H \
$^ -o $@
${HELPER_NAME}: ${HELPER_SOURCES}
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) \
-Wall \
$< -o $@
%.1 : %.1.in
sed -e 's:DOVECOT_MODULEDIR:${DOVECOT_MODULEDIR}:g' \
-e 's:BINDIR:${BINDIR}:g' \
-e 's:MAN1DIR:${MAN1DIR}:g' \
-e 's:MAN7DIR:${MAN7DIR}:g' \
-e 's:DOVECOT_ETCDIR:${DOVECOT_ETCDIR}:g' \
-e 's:FETCHMAIL_PIDFILE:${FETCHMAIL_PIDFILE}:g' \
-e 's:PLUGIN_NAME:${PLUGIN_NAME}:g' \
$< > $@
%.7 : %.7.in
sed -e 's:DOVECOT_MODULEDIR:${DOVECOT_MODULEDIR}:g' \
-e 's:BINDIR:${BINDIR}:g' \
-e 's:MAN1DIR:${MAN1DIR}:g' \
-e 's:MAN7DIR:${MAN7DIR}:g' \
-e 's:DOVECOT_ETCDIR:${DOVECOT_ETCDIR}:g' \
-e 's:FETCHMAIL_PIDFILE:${FETCHMAIL_PIDFILE}:g' \
-e 's:PLUGIN_NAME:${PLUGIN_NAME}:g' \
$< > $@
install: install_plugins install_helper install_man
install_plugins: install_settings_plugin install_plugin
install_settings_plugin: ${SETTINGS_PLUGIN_NAME}
install -d ${DESTDIR}/${DOVECOT_SETTINGDIR}
install $< ${DESTDIR}/${DOVECOT_SETTINGDIR}
install_plugin: ${PLUGIN_NAME}
install -d ${DESTDIR}/${DOVECOT_MODULEDIR}
install $< ${DESTDIR}/${DOVECOT_MODULEDIR}
install_helper: ${HELPER_NAME}
install -d ${DESTDIR}/${BINDIR}
install -o ${HELPER_USER} -m 4755 $< ${DESTDIR}/${BINDIR}
install_man: install_man1 install_man7
install_man1: ${MAN1PAGES}
install -d ${DESTDIR}/${MAN1DIR}
install $? ${DESTDIR}/${MAN1DIR}
install_man7: ${MAN7PAGES}
install -d ${DESTDIR}/${MAN7DIR}
install $? ${DESTDIR}/${MAN7DIR}
clean:
$(RM) ${SETTINGS_PLUGIN_NAME} ${PLUGIN_NAME} ${HELPER_NAME} ${PLUGIN_OBJECTS} ${MAN1PAGES} ${MAN7PAGES}
dist:
git archive --format=tar --prefix ${PACKAGE_NAME}-${PACKAGE_VERSION}/ \
upstream/${PACKAGE_VERSION} \
| gzip -9f > ${PACKAGE_NAME}-${PACKAGE_VERSION}.tar.gz
# EOF