You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

254 lines
7.1 KiB

  1. #
  2. # Copyright (C) 2006-2014 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. include $(TOPDIR)/rules.mk
  8. PKG_NAME:=postgresql
  9. PKG_VERSION:=9.0.17
  10. PKG_RELEASE:=1
  11. PKG_MAINTAINER:=Jo-Philipp Wich <jow@openwrt.org>
  12. PKG_LICENSE:=PostgreSQL
  13. PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
  14. PKG_SOURCE_URL:=\
  15. http://ftp9.us.postgresql.org/pub/mirrors/postgresql/source/v$(PKG_VERSION) \
  16. http://ftp.be.postgresql.org/postgresql/source/v$(PKG_VERSION) \
  17. ftp://ftp-archives.postgresql.org/pub/source/v$(PKG_VERSION)
  18. PKG_MD5SUM:=46bf3ef3761c091fb0d2e25012c1709e
  19. PKG_BUILD_PARALLEL:=1
  20. PKG_USE_MIPS16:=0
  21. PKG_FIXUP:=autoreconf
  22. include $(INCLUDE_DIR)/package.mk
  23. define Package/libpq
  24. SECTION:=libs
  25. CATEGORY:=Libraries
  26. DEPENDS:=+zlib +libreadline +libpthread +libncurses +shadow-utils +shadow-su
  27. TITLE:=PostgreSQL client library
  28. URL:=http://www.postgresql.org/
  29. SUBMENU:=database
  30. endef
  31. define Package/libpq/description
  32. PostgreSQL client library.
  33. endef
  34. define Package/pgsql-cli
  35. SECTION:=utils
  36. CATEGORY:=Utilities
  37. DEPENDS:=+libpq
  38. TITLE:=Command Line Interface (CLI) to PostgreSQL databases
  39. URL:=http://www.postgresql.org/
  40. SUBMENU:=database
  41. endef
  42. define Package/pgsql-cli/description
  43. Command Line Interface (CLI) to PostgreSQL databases.
  44. endef
  45. define Package/pgsql-server
  46. SECTION:=utils
  47. CATEGORY:=Utilities
  48. DEPENDS:=+libpq
  49. TITLE:=PostgreSQL databases Server
  50. URL:=http://www.postgresql.org/
  51. SUBMENU:=database
  52. endef
  53. define Package/pgsql-server/description
  54. PostgreSQL databases Server.
  55. endef
  56. # Need a native ecpg ,pg_config, and zic for build
  57. define Build/Configure
  58. (cd $(PKG_BUILD_DIR); rm -f config.cache; \
  59. ./configure \
  60. --prefix=/usr \
  61. --exec-prefix=/usr \
  62. --bindir=/usr/bin \
  63. --datadir=/usr/share \
  64. --includedir=/usr/include \
  65. --infodir=/usr/share/info \
  66. --libdir=/usr/lib \
  67. --libexecdir=/usr/lib \
  68. --localstatedir=/var \
  69. --mandir=/usr/share/man \
  70. --sbindir=/usr/sbin \
  71. --sysconfdir=/etc \
  72. $(DISABLE_NLS) \
  73. --enable-shared \
  74. --enable-static \
  75. --disable-integer-datetimes \
  76. --disable-rpath \
  77. --without-java \
  78. --without-krb4 \
  79. --without-krb5 \
  80. --without-openssl \
  81. --without-pam \
  82. --without-perl \
  83. --without-python \
  84. --without-readline \
  85. --without-rendezvous \
  86. --without-tcl \
  87. --without-tk \
  88. --with-zlib="yes" \
  89. --enable-depend \
  90. --with-system-timezone=/tmp \
  91. );
  92. $(MAKE) -C $(PKG_BUILD_DIR)/src/interfaces/ecpg/preproc CC="$(HOSTCC)" CFLAGS+="-I../../libpq"
  93. mv $(PKG_BUILD_DIR)/src/interfaces/ecpg/preproc/ecpg \
  94. $(PKG_BUILD_DIR)/src/interfaces/ecpg/preproc/ecpg.host
  95. $(MAKE) -C $(PKG_BUILD_DIR)/src/timezone CC="$(HOSTCC)"
  96. mv $(PKG_BUILD_DIR)/src/timezone/zic $(PKG_BUILD_DIR)/host-zic
  97. $(INSTALL_DIR) $(STAGING_DIR)/host/bin/
  98. $(CP) $(PKG_BUILD_DIR)/host-zic $(STAGING_DIR)/host/bin/zic
  99. $(MAKE) -C $(PKG_BUILD_DIR)/src/bin/pg_config CC="$(HOSTCC)"
  100. mv $(PKG_BUILD_DIR)/src/bin/pg_config/pg_config \
  101. $(PKG_BUILD_DIR)/src/bin/pg_config/pg_config.host
  102. $(MAKE) -C $(PKG_BUILD_DIR) distclean
  103. (cd $(PKG_BUILD_DIR); rm -f config.cache; \
  104. $(TARGET_CONFIGURE_OPTS) \
  105. CFLAGS="$(TARGET_CFLAGS)" \
  106. CPPFLAGS="$$$$CPPFLAGS $(TARGET_CPPFLAGS)" \
  107. LDFLAGS="$(TARGET_LDFLAGS)" \
  108. ./configure \
  109. --target=$(GNU_TARGET_NAME) \
  110. --host=$(GNU_TARGET_NAME) \
  111. --build=$(GNU_HOST_NAME) \
  112. --program-prefix="" \
  113. --program-suffix="" \
  114. --prefix=/usr \
  115. --exec-prefix=/usr \
  116. --bindir=/usr/bin \
  117. --datadir=/usr/share \
  118. --includedir=/usr/include \
  119. --infodir=/usr/share/info \
  120. --libdir=/usr/lib \
  121. --libexecdir=/usr/lib \
  122. --localstatedir=/var \
  123. --mandir=/usr/share/man \
  124. --sbindir=/usr/sbin \
  125. --sysconfdir=/etc \
  126. $(DISABLE_NLS) \
  127. $(DISABLE_LARGEFILE) \
  128. --enable-shared \
  129. --enable-static \
  130. --disable-integer-datetimes \
  131. --disable-rpath \
  132. --without-java \
  133. --without-krb4 \
  134. --without-krb5 \
  135. --without-openssl \
  136. --without-pam \
  137. --without-perl \
  138. --without-python \
  139. --without-rendezvous \
  140. --without-tcl \
  141. --without-tk \
  142. --with-zlib="yes" \
  143. --enable-depend \
  144. $(if $(CONFIG_TARGET_avr32),--disable-spinlocks) \
  145. );
  146. $(SED) 's@ECPG = ../../preproc/ecpg@ECPG = ../../preproc/ecpg.host@' $(PKG_BUILD_DIR)/src/interfaces/ecpg/test/Makefile.regress
  147. endef
  148. TARGET_CFLAGS += $(FPIC) -lpthread
  149. # because PROFILE means something else in the project Makefile
  150. unexport PROFILE
  151. define Build/Compile
  152. +$(MAKE) $(PKG_JOBS) -C "$(PKG_BUILD_DIR)" \
  153. DESTDIR="$(PKG_INSTALL_DIR)" \
  154. all
  155. +$(MAKE) $(PKG_JOBS) -C "$(PKG_BUILD_DIR)" \
  156. DESTDIR="$(PKG_INSTALL_DIR)" \
  157. install
  158. endef
  159. define Package/libpq/install
  160. $(INSTALL_DIR) $(1)/usr/lib
  161. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpq.so.* $(1)/usr/lib/
  162. endef
  163. define Package/pgsql-cli/install
  164. $(INSTALL_DIR) $(1)/usr/bin
  165. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/psql $(1)/usr/bin/
  166. endef
  167. define Package/pgsql-server/install
  168. $(INSTALL_DIR) $(1)/usr/bin
  169. $(INSTALL_DIR) $(1)/usr/share/postgresql
  170. $(INSTALL_DIR) $(1)/usr/lib
  171. $(INSTALL_DIR) $(1)/etc/init.d
  172. $(INSTALL_DIR) $(1)/etc/config
  173. $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/* $(1)/usr/bin
  174. ln -sf postgres $(1)/usr/bin/postmaster
  175. $(INSTALL_BIN) ./files/postgresql.init $(1)/etc/init.d/postgresql
  176. $(CP) -r $(PKG_INSTALL_DIR)/usr/share/postgresql/* \
  177. $(1)/usr/share/postgresql
  178. $(INSTALL_DATA) ./files/postgresql.config $(1)/etc/config/postgresql
  179. $(CP) -r \
  180. $(PKG_INSTALL_DIR)/usr/lib/postgresql \
  181. $(1)/usr/lib
  182. endef
  183. define Package/pgsql-server/conffiles
  184. /etc/config/postgresql
  185. endef
  186. define Package/pgsql-server/postinst
  187. #!/bin/sh
  188. grep -q '^postgres:' /etc/passwd && exit 0
  189. group=$$(grep '^postgres:' /etc/group | cut -f3 -d:)
  190. if [ -z "$${group}" ] ; then
  191. group=1000
  192. tst=$$(cat /etc/group | grep ":$${group}:")
  193. while [ -n "$${tst}" ] ; do
  194. group=$$(($${group}+1))
  195. tst=$$(cat /etc/group | grep ":$${group}:")
  196. done
  197. echo "postgres:x:$${group}:" >>/etc/group
  198. fi
  199. user=$$(cat /etc/passwd | grep "^postgres:")
  200. if [ -z "$${user}" ] ; then
  201. num="$${group}"
  202. tst=$$(cat /etc/passwd | grep ":.*:$${num}:")
  203. while [ -n "$${tst}" ] ; do
  204. num=$$(($${num}+1))
  205. tst=$$(cat /etc/passwd | grep ":.*:$${num}:")
  206. done
  207. echo "postgres:*:$${num}:$${group}:PostgreSQL administrator:/tmp:/bin/ash" >>/etc/passwd
  208. fi
  209. endef
  210. define Build/InstallDev
  211. $(INSTALL_DIR) $(1)/usr/bin
  212. $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/bin/pg_config/pg_config.host $(1)/usr/bin/pg_config
  213. $(INSTALL_DIR) $(1)/usr/include
  214. $(CP) $(PKG_INSTALL_DIR)/usr/include/libpq $(1)/usr/include/
  215. $(CP) $(PKG_INSTALL_DIR)/usr/include/libpq-fe.h $(1)/usr/include/
  216. $(CP) $(PKG_INSTALL_DIR)/usr/include/pg_config.h $(1)/usr/include/
  217. $(CP) $(PKG_INSTALL_DIR)/usr/include/pg_config_manual.h $(1)/usr/include/
  218. $(CP) $(PKG_INSTALL_DIR)/usr/include/postgres_ext.h $(1)/usr/include/
  219. $(CP) $(PKG_INSTALL_DIR)/usr/include/postgresql $(1)/usr/include/
  220. $(INSTALL_DIR) $(1)/usr/lib
  221. $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpq.{a,so*} $(1)/usr/lib/
  222. $(CP) $(PKG_BUILD_DIR)/src/interfaces/ecpg/preproc/ecpg.host $(1)/usr/bin/ecpg
  223. $(CP) $(PKG_BUILD_DIR)/host-zic $(1)/usr/bin/zic
  224. endef
  225. $(eval $(call BuildPackage,libpq))
  226. $(eval $(call BuildPackage,pgsql-cli))
  227. $(eval $(call BuildPackage,pgsql-server))