postgresql.mk 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. ################################################################################
  2. #
  3. # postgresql
  4. #
  5. ################################################################################
  6. POSTGRESQL_VERSION = 13.5
  7. POSTGRESQL_SOURCE = postgresql-$(POSTGRESQL_VERSION).tar.bz2
  8. POSTGRESQL_SITE = https://ftp.postgresql.org/pub/source/v$(POSTGRESQL_VERSION)
  9. POSTGRESQL_LICENSE = PostgreSQL
  10. POSTGRESQL_LICENSE_FILES = COPYRIGHT
  11. POSTGRESQL_CPE_ID_VENDOR = postgresql
  12. POSTGRESQL_SELINUX_MODULES = postgresql
  13. POSTGRESQL_INSTALL_STAGING = YES
  14. POSTGRESQL_CONFIG_SCRIPTS = pg_config
  15. POSTGRESQL_CONF_ENV = \
  16. ac_cv_type_struct_sockaddr_in6=yes \
  17. LIBS=$(TARGET_NLS_LIBS)
  18. POSTGRESQL_CONF_OPTS = --disable-rpath
  19. POSTGRESQL_DEPENDENCIES = $(TARGET_NLS_DEPENDENCIES)
  20. # https://www.postgresql.org/docs/11/static/install-procedure.html:
  21. # "If you want to invoke the build from another makefile rather than
  22. # manually, you must unset MAKELEVEL or set it to zero"
  23. POSTGRESQL_MAKE_OPTS = MAKELEVEL=0
  24. ifeq ($(BR2_PACKAGE_POSTGRESQL_FULL),y)
  25. POSTGRESQL_MAKE_OPTS += world
  26. POSTGRESQL_INSTALL_TARGET_OPTS += DESTDIR=$(TARGET_DIR) install-world
  27. POSTGRESQL_INSTALL_STAGING_OPTS += DESTDIR=$(STAGING_DIR) install-world
  28. endif
  29. ifeq ($(BR2_TOOLCHAIN_USES_UCLIBC),y)
  30. # PostgreSQL does not build against uClibc with locales
  31. # enabled, due to an uClibc bug, see
  32. # http://lists.uclibc.org/pipermail/uclibc/2014-April/048326.html
  33. # so overwrite automatic detection and disable locale support
  34. POSTGRESQL_CONF_ENV += pgac_cv_type_locale_t=no
  35. endif
  36. ifneq ($(BR2_TOOLCHAIN_HAS_THREADS),y)
  37. POSTGRESQL_CONF_OPTS += --disable-thread-safety
  38. endif
  39. ifeq ($(BR2_arcle)$(BR2_arceb)$(BR2_microblazeel)$(BR2_microblazebe)$(BR2_or1k)$(BR2_nios2)$(BR2_riscv)$(BR2_xtensa)$(BR2_nds32),y)
  40. POSTGRESQL_CONF_OPTS += --disable-spinlocks
  41. endif
  42. ifeq ($(BR2_PACKAGE_READLINE),y)
  43. POSTGRESQL_DEPENDENCIES += readline
  44. else
  45. POSTGRESQL_CONF_OPTS += --without-readline
  46. endif
  47. ifeq ($(BR2_PACKAGE_ZLIB),y)
  48. POSTGRESQL_DEPENDENCIES += zlib
  49. else
  50. POSTGRESQL_CONF_OPTS += --without-zlib
  51. endif
  52. ifeq ($(BR2_PACKAGE_TZDATA),y)
  53. POSTGRESQL_DEPENDENCIES += tzdata
  54. POSTGRESQL_CONF_OPTS += --with-system-tzdata=/usr/share/zoneinfo
  55. else
  56. POSTGRESQL_DEPENDENCIES += host-zic
  57. POSTGRESQL_CONF_ENV += ZIC="$(ZIC)"
  58. endif
  59. ifeq ($(BR2_PACKAGE_OPENSSL),y)
  60. POSTGRESQL_DEPENDENCIES += openssl
  61. POSTGRESQL_CONF_OPTS += --with-openssl
  62. else
  63. # PostgreSQL checks for /dev/urandom and fails if it's being cross-compiled and
  64. # an SSL library isn't found. Since /dev/urandom is guaranteed to be provided
  65. # on Linux systems, explicitly tell the configure script it's available.
  66. POSTGRESQL_CONF_ENV += ac_cv_file__dev_urandom=yes
  67. endif
  68. ifeq ($(BR2_PACKAGE_OPENLDAP),y)
  69. POSTGRESQL_DEPENDENCIES += openldap
  70. POSTGRESQL_CONF_OPTS += --with-ldap
  71. else
  72. POSTGRESQL_CONF_OPTS += --without-ldap
  73. endif
  74. ifeq ($(BR2_PACKAGE_LIBXML2),y)
  75. POSTGRESQL_DEPENDENCIES += libxml2
  76. POSTGRESQL_CONF_OPTS += --with-libxml
  77. POSTGRESQL_CONF_ENV += XML2_CONFIG=$(STAGING_DIR)/usr/bin/xml2-config
  78. else
  79. POSTGRESQL_CONF_OPTS += --without-libxml
  80. endif
  81. # required for postgresql.service Type=notify
  82. ifeq ($(BR2_PACKAGE_SYSTEMD),y)
  83. POSTGRESQL_DEPENDENCIES += systemd
  84. POSTGRESQL_CONF_OPTS += --with-systemd
  85. else
  86. POSTGRESQL_CONF_OPTS += --without-systemd
  87. endif
  88. POSTGRESQL_CFLAGS = $(TARGET_CFLAGS)
  89. ifeq ($(BR2_TOOLCHAIN_HAS_GCC_BUG_85180),y)
  90. POSTGRESQL_CFLAGS += -O0
  91. endif
  92. POSTGRESQL_CONF_ENV += CFLAGS="$(POSTGRESQL_CFLAGS)"
  93. define POSTGRESQL_USERS
  94. postgres -1 postgres -1 * /var/lib/pgsql /bin/sh - PostgreSQL Server
  95. endef
  96. define POSTGRESQL_INSTALL_TARGET_FIXUP
  97. $(INSTALL) -dm 0700 $(TARGET_DIR)/var/lib/pgsql
  98. $(RM) -rf $(TARGET_DIR)/usr/lib/postgresql/pgxs
  99. endef
  100. POSTGRESQL_POST_INSTALL_TARGET_HOOKS += POSTGRESQL_INSTALL_TARGET_FIXUP
  101. define POSTGRESQL_INSTALL_CUSTOM_PG_CONFIG
  102. $(INSTALL) -m 0755 -D package/postgresql/pg_config \
  103. $(STAGING_DIR)/usr/bin/pg_config
  104. $(SED) "s|@POSTGRESQL_CONF_OPTIONS@|$(POSTGRESQL_CONF_OPTS)|g" $(STAGING_DIR)/usr/bin/pg_config
  105. $(SED) "s|@POSTGRESQL_VERSION@|$(POSTGRESQL_VERSION)|g" $(STAGING_DIR)/usr/bin/pg_config
  106. $(SED) "s|@TARGET_CFLAGS@|$(TARGET_CFLAGS)|g" $(STAGING_DIR)/usr/bin/pg_config
  107. $(SED) "s|@TARGET_CC@|$(TARGET_CC)|g" $(STAGING_DIR)/usr/bin/pg_config
  108. endef
  109. POSTGRESQL_POST_INSTALL_STAGING_HOOKS += POSTGRESQL_INSTALL_CUSTOM_PG_CONFIG
  110. define POSTGRESQL_INSTALL_INIT_SYSV
  111. $(INSTALL) -m 0755 -D package/postgresql/S50postgresql \
  112. $(TARGET_DIR)/etc/init.d/S50postgresql
  113. endef
  114. define POSTGRESQL_INSTALL_INIT_SYSTEMD
  115. $(INSTALL) -D -m 644 package/postgresql/postgresql.service \
  116. $(TARGET_DIR)/usr/lib/systemd/system/postgresql.service
  117. endef
  118. $(eval $(autotools-package))