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