Merge pull request #8518 from neheb/i
[feed/packages.git] / mail / postfix / Makefile
1 #
2 # Copyright (C) 2014-2015 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 include $(TOPDIR)/rules.mk
9
10 PKG_NAME:=postfix
11 PKG_RELEASE:=1
12 PKG_VERSION:=3.4.4
13 PKG_SOURCE_URL:= \
14 https://cdn.postfix.johnriley.me/mirrors/postfix-release/official/ \
15 http://ftp.porcupine.org/mirrors/postfix-release/official/
16
17 PKG_HASH:=27f2ab631a966a40e002aedc6db9281e5970295fa5fd96b29066e457a4601e34
18 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
19 PKG_MAINTAINER:=Denis Shulyaka <Shulyaka@gmail.com>
20 PKG_LICENSE:=IPL-1.0
21 PKG_LICENSE_FILES:=LICENSE
22 PKG_BUILD_DEPENDS:=POSTFIX_CDB:tinycdb
23 PKG_CONFIG_DEPENDS:= \
24 CONFIG_POSTFIX_TLS \
25 CONFIG_POSTFIX_SASL \
26 CONFIG_POSTFIX_LDAP \
27 CONFIG_POSTFIX_CDB \
28 CONFIG_POSTFIX_DB \
29 CONFIG_POSTFIX_SQLITE \
30 CONFIG_POSTFIX_MYSQL \
31 CONFIG_POSTFIX_PGSQL \
32 CONFIG_POSTFIX_PCRE \
33 CONFIG_POSTFIX_EAI \
34
35 include $(INCLUDE_DIR)/package.mk
36
37 define Package/postfix
38 SECTION:=mail
39 CATEGORY:=Mail
40 TITLE:=Postfix Mail Transmit Agent
41 USERID:= \
42 postfix=25:postfix=25 \
43 postdrop=26:postdrop=26
44 URL:=http://www.postfix.org/
45 DEPENDS:=+POSTFIX_TLS:libopenssl +POSTFIX_SASL:libsasl2 +POSTFIX_LDAP:libopenldap +POSTFIX_DB:libdb47 +POSTFIX_SQLITE:libsqlite3 +POSTFIX_MYSQL:libmysqlclient +POSTFIX_PGSQL:libpq +POSTFIX_EAI:icu +POSTFIX_PCRE:libpcre
46 endef
47
48 define Package/postfix/description
49 Postfix is Wietse Venema's mailer that started life as an alternative to the widely-used Sendmail program. Postfix attempts to be fast, easy to administer, and secure, while at the same time being sendmail compatible enough to not upset existing users. Thus, the outside has a sendmail-ish flavor, but the inside is completely different.
50 endef
51
52 define Package/postfix/config
53 menu "Select postfix build options"
54 config POSTFIX_TLS
55 bool "TLS support"
56 default y
57 help
58 Implements TLS support in postfix (using OpenSSL).
59 config POSTFIX_SASL
60 bool "SASL support"
61 default y
62 help
63 Implements SASL support in postfix (using Cyrus SASL).
64 config POSTFIX_LDAP
65 bool "LDAP support"
66 default y
67 help
68 Implements LDAP support in postfix (using OpenLDAP).
69 config POSTFIX_DB
70 bool "BerkeleyDB support"
71 default n
72 help
73 Implements support for btree and hash files using Berkeley DB.
74 config POSTFIX_CDB
75 bool "CDB support"
76 default y
77 help
78 Implements support for cdb files using tinycdb
79 config POSTFIX_SQLITE
80 bool "SQLITE support"
81 default y
82 help
83 Implements support for SQLite3 DB
84 config POSTFIX_MYSQL
85 bool "MYSQL support"
86 default n
87 help
88 Implements support for MySQL
89 config POSTFIX_PGSQL
90 bool "PostgreSQL support"
91 default n
92 help
93 Implement support for PostgreSQL
94 config POSTFIX_PCRE
95 bool "PCRE support"
96 default y
97 help
98 Implement support for Perl Compatible Regular Expressions
99 config POSTFIX_EAI
100 bool "SMTPUTF8 support"
101 default n
102 help
103 Enable Postfix support for Email Address Internationalization
104 (EAI) as defined in RFC 6531 (SMTPUTF8 extension), RFC 6532
105 (Internationalized email headers) and RFC 6533
106 (Internationalized delivery status notifications).
107 Since version 3.0, Postfix fully supports UTF-8 email
108 addresses and UTF-8 message header values.
109 endmenu
110 endef
111
112 CCARGS=-DNO_NIS
113 AUXLIBS=-L$(STAGING_DIR)/usr/lib
114
115 ifdef CONFIG_POSTFIX_TLS
116 CCARGS+=-DUSE_TLS
117 AUXLIBS+=-lssl -lcrypto
118 endif
119
120 ifdef CONFIG_POSTFIX_SASL
121 CCARGS+=-DUSE_SASL_AUTH -DUSE_CYRUS_SASL -I$(STAGING_DIR)/usr/include/sasl
122 AUXLIBS+=-lsasl2
123 endif
124
125 ifdef CONFIG_POSTFIX_LDAP
126 CCARGS+=-DHAS_LDAP
127 AUXLIBS+=-lldap -llber
128 endif
129
130 ifdef CONFIG_POSTFIX_CDB
131 CCARGS+=-DHAS_CDB
132 AUXLIBS+=-lcdb
133 ifndef default_database_type
134 default_database_type=cdb
135 endif
136 endif
137
138 ifdef CONFIG_POSTFIX_DB
139 AUXLIBS+=-ldb
140 CCARGS+=-DHAS_DB
141 ifndef default_database_type
142 default_database_type=btree
143 endif
144 else
145 CCARGS+=-DNO_DB
146 endif
147
148 ifdef CONFIG_POSTFIX_SQLITE
149 CCARGS+=-DHAS_SQLITE -I$(STAGING_DIR)/usr/include/
150 AUXLIBS+=-L$(STAGING_DIR)/usr/lib -lsqlite3 -lpthread
151 endif
152
153 ifdef CONFIG_POSTFIX_MYSQL
154 CCARGS+=-DHAS_MYSQL -I$(STAGING_DIR)/usr/include/mysql
155 AUXLIBS+=-L$(STAGING_DIR)/usr/lib -lmysqlclient -lz -lm
156 endif
157
158 ifdef CONFIG_POSTFIX_PGSQL
159 CCARGS+=-DHAS_PGSQL -I$(STAGING_DIR)/usr/include/
160 AUXLIBS+=-L$(STAGING_DIR)/usr/lib -lpq
161 endif
162
163 ifdef CONFIG_POSTFIX_PCRE
164 CCARGS+=-DHAS_PCRE -I$(STAGING_DIR)/usr/include/
165 AUXLIBS+=-L$(STAGING_DIR)/usr/lib -lpcre
166 else
167 CCARGS+=-DNO_PCRE
168 endif
169
170 ifdef CONFIG_POSTFIX_EAI
171 AUXLIBS+=-licuuc
172 CCARGS+=-DHAS_EAI
173 smtputf8_conf = yes
174 else
175 CCARGS+=-DNO_EAI
176 smtputf8_conf = no
177 endif
178
179 CCARGS+=-DDEF_DB_TYPE=\"$(default_database_type)\"
180
181 # prevent postfix-install from executing postconf at build time
182 # by explicitly providing the default values to postfix-install
183 config_directory=/etc/postfix
184 sample_directory=/etc/postfix
185 command_directory=/usr/sbin
186 daemon_directory=/usr/libexec/postfix
187 html_directory=no
188 manpage_directory=no
189 readme_directory=no
190 sendmail_path=/usr/sbin/sendmail
191 newaliases_path=/usr/bin/newaliases
192 mailq_path=/usr/bin/mailq
193 shlib_directory=/usr/lib/postfix
194 meta_directory=/etc/postfix
195 data_directory=/usr/var/lib/postfix
196 queue_directory=/usr/var/spool/postfix
197 mail_spool_directory=/usr/var/mail
198
199 ln_suffix=.postfix
200 ln_suffix_pre_pf=.pre-postfix
201 ln_suffix_legacy=.old
202
203 define Package/postfix/conffiles
204 $(config_directory)
205 endef
206
207 define Build/Configure
208 if [ "$(default_database_type)" = "" ]; then \
209 echo "Build error: CDB or BerkeleyDB support must be enabled."; \
210 exit 1; \
211 fi
212 cd $(PKG_BUILD_DIR); $(MAKE) makefiles CCARGS='$(CCARGS)' $(TARGET_CONFIGURE_OPTS) AUXLIBS="$(AUXLIBS)"
213 endef
214
215 define Build/Compile
216 # Currently postfix has a bug with Makefiles that CCARGS are not passed to the compiler, so we are copying them to CC as a workaround
217 cd $(PKG_BUILD_DIR); $(MAKE) $(TARGET_CONFIGURE_OPTS) CC='$(TARGET_CC) $(CCARGS)'
218 $(foreach p, \
219 default_database_type config_directory command_directory daemon_directory \
220 shlib_directory manpage_directory data_directory queue_directory \
221 mail_spool_directory, \
222 echo "$(p) = $($(p))" >> $(PKG_BUILD_DIR)/conf/main.cf;)
223 endef
224
225 define Package/postfix/install
226 cd $(PKG_BUILD_DIR); $(MAKE) install_root=$(1) command_directory=$(command_directory) daemon_directory=$(daemon_directory) data_directory=$(data_directory) html_directory=$(html_directory) mail_owner=postfix mailq_path=$(mailq_path)$(ln_suffix) manpage_directory=$(manpage_directory) newaliases_path=$(newaliases_path)$(ln_suffix) queue_directory=$(queue_directory) readme_directory=$(readme_directory) sendmail_path=$(sendmail_path)$(ln_suffix) setgid_group=postdrop sample_directory=$(sample_directory) config_directory=$(config_directory) shlib_directory=$(shlib_directory) meta_directory=$(meta_directory) mail_version=$(PKG_VERSION) non-interactive-package
227 $(INSTALL_DIR) $(1)/etc/init.d/
228 $(INSTALL_BIN) ./files/postfix.init $(1)/etc/init.d/postfix
229 endef
230
231 define Package/postfix/postinst
232 #!/bin/sh
233
234 for syml in $(sendmail_path) $(newaliases_path) $(mailq_path); do
235 file=$${IPKG_INSTROOT}$${syml}
236 if [ -f "$${file}$(ln_suffix_legacy)" ]; then
237 # update files saved by legacy versions of Postfix postinst script
238 mv "$${file}$(ln_suffix_legacy)" "$${file}$(ln_suffix_pre_pf)"
239 fi
240 if [ -f "$${file}" ]; then
241 linktarget=$$(basename $$(readlink "$${file}"))
242 postfixf=$$(basename "$${syml}")$(ln_suffix)
243 if [ $${linktarget} != $${postfixf} ]; then
244 mv "$${file}" "$${file}$(ln_suffix_pre_pf)"
245 echo "Info: $${file} saved as $${file}$(ln_suffix_pre_pf)"
246 fi
247 fi
248 if [ ! -f "$${file}" ]; then
249 ln -s "$${syml}$(ln_suffix)" "$${file}"
250 fi
251 done
252 # fix file/dir ownership in data_directory and queue_directory
253 if [ -z "$${IPKG_INSTROOT}" ]; then
254 postfix set-permissions
255 fi
256
257 endef
258
259 define Package/postfix/postrm
260 #!/bin/sh
261 rm -f "$(sendmail_path)" "$(newaliases_path)" "$(mailq_path)"
262
263 for syml in "$(sendmail_path)" "$(newaliases_path)" "$(mailq_path)"; do
264 file=$${IPKG_INSTROOT}$${syml}
265 if [ -f "$${file}$(ln_suffix_legacy)" ]; then
266 # update files saved by legacy versions of Postfix postinst script
267 mv "$${file}$(ln_suffix_legacy)" "$${file}$(ln_suffix_pre_pf)"
268 fi
269 if [ -f "$${syml}$(ln_suffix_pre_pf)" ]; then
270 mv "$${syml}$(ln_suffix_pre_pf)" "$${syml}"
271 echo "Info: $${syml}$(ln_suffix_pre_pf) restored as $${syml}"
272 fi
273 done
274 endef
275
276 $(eval $(call BuildPackage,postfix))