xref: /OK3568_Linux_fs/buildroot/package/exim/exim.mk (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1################################################################################
2#
3# exim
4#
5################################################################################
6
7EXIM_VERSION = 4.95
8EXIM_SOURCE = exim-$(EXIM_VERSION).tar.xz
9EXIM_SITE = https://ftp.exim.org/pub/exim/exim4
10EXIM_LICENSE = GPL-2.0+
11EXIM_LICENSE_FILES = LICENCE
12EXIM_CPE_ID_VENDOR = exim
13EXIM_SELINUX_MODULES = exim mta
14EXIM_DEPENDENCIES = host-berkeleydb host-pcre pcre berkeleydb host-pkgconf
15
16# Modify a variable value. It must already exist in the file, either
17# commented or not.
18define exim-config-change # variable-name, variable-value
19	$(SED) 's,^[#[:space:]]*$1[[:space:]]*=.*$$,$1=$2,' \
20		$(@D)/Local/Makefile
21endef
22
23# Comment-out a variable. Has no effect if it does not exits.
24define exim-config-unset # variable-name
25	$(SED) 's,^\([[:space:]]*$1[[:space:]]*=.*$$\),# \1,' \
26		$(@D)/Local/Makefile
27endef
28
29# Add a variable definition. It must not already exist in the file,
30# otherwise it would be defined twice with potentially different values.
31define exim-config-add # variable-name, variable-value
32	echo "$1=$2" >>$(@D)/Local/Makefile
33endef
34
35define EXIM_USE_CUSTOM_CONFIG_FILE
36	$(INSTALL) -m 0644 $(BR2_PACKAGE_EXIM_CUSTOM_CONFIG_FILE) \
37		$(@D)/Local/Makefile
38endef
39
40define EXIM_USE_DEFAULT_CONFIG_FILE
41	$(INSTALL) -m 0644 $(@D)/src/EDITME $(@D)/Local/Makefile
42	$(call exim-config-change,BIN_DIRECTORY,/usr/sbin)
43	$(call exim-config-change,CONFIGURE_FILE,/etc/exim/configure)
44	$(call exim-config-change,LOG_FILE_PATH,/var/log/exim/exim_%slog)
45	$(call exim-config-change,PID_FILE_PATH,/var/run/exim/exim.pid)
46	$(call exim-config-change,EXIM_USER,ref:exim)
47	$(call exim-config-change,EXIM_GROUP,mail)
48	$(call exim-config-change,TRANSPORT_LMTP,yes)
49	$(call exim-config-change,PCRE_LIBS,-lpcre)
50	$(call exim-config-change,PCRE_CONFIG,no)
51	$(call exim-config-change,HAVE_ICONV,no)
52	$(call exim-config-unset,EXIM_MONITOR)
53	$(call exim-config-change,AUTH_PLAINTEXT,yes)
54	$(call exim-config-change,AUTH_CRAM_MD5,yes)
55	$(call exim-config-unset,SUPPORT_DANE)
56endef
57
58ifeq ($(BR2_PACKAGE_DOVECOT),y)
59EXIM_DEPENDENCIES += dovecot
60define EXIM_USE_DEFAULT_CONFIG_FILE_DOVECOT
61	$(call exim-config-change,AUTH_DOVECOT,yes)
62endef
63endif
64
65ifeq ($(BR2_PACKAGE_CLAMAV),y)
66EXIM_DEPENDENCIES += clamav
67define EXIM_USE_DEFAULT_CONFIG_FILE_CLAMAV
68	$(call exim-config-change,WITH_CONTENT_SCAN,yes)
69endef
70endif
71
72ifeq ($(BR2_PACKAGE_OPENSSL),y)
73EXIM_DEPENDENCIES += host-openssl openssl
74define EXIM_USE_DEFAULT_CONFIG_FILE_OPENSSL
75	$(call exim-config-change,USE_OPENSSL,yes)
76	$(call exim-config-change,USE_OPENSSL_PC,openssl)
77endef
78else
79define EXIM_USE_DEFAULT_CONFIG_FILE_OPENSSL
80	$(call exim-config-change,DISABLE_TLS,yes)
81endef
82endif
83
84# musl does not provide struct ip_options nor struct ip_opts (but it is
85# available with both glibc and uClibc)
86ifeq ($(BR2_TOOLCHAIN_USES_MUSL),y)
87define EXIM_FIX_IP_OPTIONS_FOR_MUSL
88	$(SED) 's/#define GLIBC_IP_OPTIONS/#define DARWIN_IP_OPTIONS/' \
89		$(@D)/OS/os.h-Linux
90endef
91endif
92
93define EXIM_CONFIGURE_TOOLCHAIN
94	$(call exim-config-add,CC,$(TARGET_CC))
95	$(call exim-config-add,CFLAGS,$(TARGET_CFLAGS))
96	$(call exim-config-add,AR,$(TARGET_AR) cq)
97	$(call exim-config-add,RANLIB,$(TARGET_RANLIB))
98	$(call exim-config-add,HOSTCC,$(HOSTCC))
99	$(call exim-config-add,HOSTCFLAGS,$(HOSTCFLAGS))
100	$(EXIM_FIX_IP_OPTIONS_FOR_MUSL)
101endef
102
103ifneq ($(call qstrip,$(BR2_PACKAGE_EXIM_CUSTOM_CONFIG_FILE)),)
104define EXIM_CONFIGURE_CMDS
105	$(EXIM_USE_CUSTOM_CONFIG_FILE)
106	$(EXIM_CONFIGURE_TOOLCHAIN)
107endef
108else # CUSTOM_CONFIG
109define EXIM_CONFIGURE_CMDS
110	$(EXIM_USE_DEFAULT_CONFIG_FILE)
111	$(EXIM_USE_DEFAULT_CONFIG_FILE_DOVECOT)
112	$(EXIM_USE_DEFAULT_CONFIG_FILE_CLAMAV)
113	$(EXIM_USE_DEFAULT_CONFIG_FILE_OPENSSL)
114	$(EXIM_CONFIGURE_TOOLCHAIN)
115endef
116endif # CUSTOM_CONFIG
117
118# exim needs a bit of love to build statically
119ifeq ($(BR2_STATIC_LIBS),y)
120EXIM_STATIC_FLAGS = LFLAGS="-pthread --static"
121endif
122
123# We need the host version of macro_predef during the build, before
124# building it we need to prepare the makefile.
125define EXIM_BUILD_CMDS
126	$(TARGET_MAKE_ENV) build=br $(MAKE) -C $(@D) makefile
127	$(HOST_MAKE_ENV) $(MAKE) -C $(@D)/build-br macro_predef \
128		CC="$(HOSTCC)" \
129		LNCC="$(HOSTCC)" \
130		CFLAGS="-std=c99 $(HOST_CFLAGS)" \
131		LFLAGS="-fPIC $(HOST_LDFLAGS)"
132	$(TARGET_MAKE_ENV) build=br $(MAKE) -C $(@D) $(EXIM_STATIC_FLAGS) \
133		CFLAGS="-std=c99 $(TARGET_CFLAGS)"
134endef
135
136# Need to replicate the LFLAGS in install, as exim still wants to build
137# something when installing...
138define EXIM_INSTALL_TARGET_CMDS
139	DESTDIR=$(TARGET_DIR) INSTALL_ARG="-no_chown -no_symlink" build=br \
140	  $(MAKE) -C $(@D) $(EXIM_STATIC_FLAGS) \
141		CFLAGS="-std=c99 $(TARGET_CFLAGS)" \
142		install
143	chmod u+s $(TARGET_DIR)/usr/sbin/exim
144endef
145
146define EXIM_USERS
147	exim 88 mail 8 * - - - exim
148endef
149
150define EXIM_INSTALL_INIT_SYSV
151	$(INSTALL) -D -m 755 package/exim/S86exim \
152		$(TARGET_DIR)/etc/init.d/S86exim
153endef
154
155define EXIM_INSTALL_INIT_SYSTEMD
156	$(INSTALL) -D -m 644 package/exim/exim.service \
157		$(TARGET_DIR)/usr/lib/systemd/system/exim.service
158endef
159
160$(eval $(generic-package))
161