2
1

postgresql.mk 4.5 KB

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