exim.mk 4.9 KB

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