postgresql: deptest fixes. staging dir is not preserved. Put host-zic into the build...
[openwrt/svn-archive/archive.git] / libs / postgresql / Makefile
index c199856ed67766241343f98c3c2516f2b4775312..a534612795ee7619ae58a98ad3fae5e3e336f75d 100644 (file)
@@ -1,36 +1,39 @@
-# 
-# Copyright (C) 2006 OpenWrt.org
+#
+# Copyright (C) 2006-2010 OpenWrt.org
 #
 # This is free software, licensed under the GNU General Public License v2.
 # See /LICENSE for more information.
 #
-# $Id$
 
 include $(TOPDIR)/rules.mk
 
 PKG_NAME:=postgresql
-PKG_VERSION:=7.4.14
+PKG_VERSION:=9.0.0
 PKG_RELEASE:=1
 
-PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
 PKG_SOURCE_URL:=\
-       ftp://ftp.us.postgresql.org/pub/mirrors/postgresql/source/v$(PKG_VERSION) \
+       http://ftp7.us.postgresql.org/pub/postgresql/source/v$(PKG_VERSION) \
+       http://ftp8.us.postgresql.org/pub/postgresql/source/v$(PKG_VERSION) \
+       http://ftp9.us.postgresql.org/pub/postgresql/source/v$(PKG_VERSION) \
+       http://ftp.be.postgresql.org/postgresql/source/v$(PKG_VERSION) \
        ftp://ftp-archives.postgresql.org/pub/source/v$(PKG_VERSION)
-PKG_MD5SUM:=2e0e82552f8463343df5d89348356481
-PKG_CAT:=bzcat
-
-PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
+PKG_MD5SUM:=14c2122cc322e69ab2ab702ed7714bbe
+PKG_BUILD_PARALLEL:=1
 
 include $(INCLUDE_DIR)/package.mk
 
 define Package/libpq
   SECTION:=libs
   CATEGORY:=Libraries
-  DEPENDS:=+zlib
+  DEPENDS:=+zlib +libreadline +libncurses +coreutils-su
   TITLE:=PostgreSQL client library
-  DESCRIPTION:=PostgreSQL client library.
   URL:=http://www.postgresql.org/
+  SUBMENU:=database
+endef
+
+define Package/libpq/description
+PostgreSQL client library.
 endef
 
 define Package/pgsql-cli
@@ -38,17 +41,81 @@ define Package/pgsql-cli
   CATEGORY:=Utilities
   DEPENDS:=+libpq
   TITLE:=Command Line Interface (CLI) to PostgreSQL databases
-  DESCRIPTION:=Command Line Interface (CLI) to PostgreSQL databases.
   URL:=http://www.postgresql.org/
+  SUBMENU:=database
+endef
+
+define Package/pgsql-cli/description
+Command Line Interface (CLI) to PostgreSQL databases.
+endef
+
+define Package/pgsql-server
+  SECTION:=utils
+  CATEGORY:=Utilities
+  DEPENDS:=+libpq
+  TITLE:=PostgreSQL databases Server
+  URL:=http://www.postgresql.org/
+  SUBMENU:=database
 endef
 
-#      ./configure advertise "--infodir", but does not support it, replaced with "--docdir"
+define Package/pgsql-server/description
+PostgreSQL databases Server.
+endef
+
+# Need a native ecpg ,pg_config, and zic for build
 define Build/Configure
+       (cd $(PKG_BUILD_DIR); rm -f config.cache; \
+               ./configure \
+                       --prefix=/usr \
+                       --exec-prefix=/usr \
+                       --bindir=/usr/bin \
+                       --datadir=/usr/share \
+                       --includedir=/usr/include \
+                       --infodir=/usr/share/info \
+                       --libdir=/usr/lib \
+                       --libexecdir=/usr/lib \
+                       --localstatedir=/var \
+                       --mandir=/usr/share/man \
+                       --sbindir=/usr/sbin \
+                       --sysconfdir=/etc \
+                       $(DISABLE_NLS) \
+                       $(DISABLE_LARGEFILE) \
+                       --enable-shared \
+                       --enable-static \
+                       --disable-integer-datetimes \
+                       --disable-rpath \
+                       --without-java \
+                       --without-krb4 \
+                       --without-krb5 \
+                       --without-openssl \
+                       --without-pam \
+                       --without-perl \
+                       --without-python \
+                       --without-readline \
+                       --without-rendezvous \
+                       --without-tcl \
+                       --without-tk \
+                       --with-zlib="yes" \
+                       --enable-depend \
+                       --with-system-timezone=/tmp \
+       );
+       $(MAKE) -C $(PKG_BUILD_DIR)/src/interfaces/ecpg/preproc CC="$(HOSTCC)" CFLAGS+="-I../../libpq"
+       mv $(PKG_BUILD_DIR)/src/interfaces/ecpg/preproc/ecpg \
+               $(PKG_BUILD_DIR)/src/interfaces/ecpg/preproc/ecpg.host
+       $(MAKE) -C $(PKG_BUILD_DIR)/src/timezone CC="$(HOSTCC)"
+       mv $(PKG_BUILD_DIR)/src/timezone/zic $(PKG_BUILD_DIR)/host-zic
+       $(INSTALL_DIR) $(STAGING_DIR)/host/bin/
+       $(CP) $(PKG_BUILD_DIR)/host-zic $(STAGING_DIR)/host/bin/zic
+       $(MAKE) -C $(PKG_BUILD_DIR)/src/bin/pg_config CC="$(HOSTCC)"
+       mv $(PKG_BUILD_DIR)/src/bin/pg_config/pg_config \
+               $(PKG_BUILD_DIR)/src/bin/pg_config/pg_config.host
+       $(MAKE) -C $(PKG_BUILD_DIR) distclean
+
        (cd $(PKG_BUILD_DIR); rm -f config.cache; \
                $(TARGET_CONFIGURE_OPTS) \
                CFLAGS="$(TARGET_CFLAGS)" \
-               CPPFLAGS="$$$$CPPFLAGS $(EXTRA_CPPFLAGS)" \
-               LDFLAGS="$(EXTRA_LDFLAGS)" \
+               CPPFLAGS="$$$$CPPFLAGS $(TARGET_CPPFLAGS)" \
+               LDFLAGS="$(TARGET_LDFLAGS)" \
                ./configure \
                        --target=$(GNU_TARGET_NAME) \
                        --host=$(GNU_TARGET_NAME) \
@@ -60,7 +127,7 @@ define Build/Configure
                        --bindir=/usr/bin \
                        --datadir=/usr/share \
                        --includedir=/usr/include \
-                       --docdir=/usr/share/info \
+                       --infodir=/usr/share/info \
                        --libdir=/usr/lib \
                        --libexecdir=/usr/lib \
                        --localstatedir=/var \
@@ -80,29 +147,25 @@ define Build/Configure
                        --without-pam \
                        --without-perl \
                        --without-python \
-                       --without-readline \
                        --without-rendezvous \
                        --without-tcl \
                        --without-tk \
                        --with-zlib="yes" \
+                       --enable-depend \
+                       $(if $(CONFIG_TARGET_avr32),--disable-spinlocks) \
        );
+       $(SED) 's@ECPG = ../../preproc/ecpg@ECPG = ../../preproc/ecpg.host@' $(PKG_BUILD_DIR)/src/interfaces/ecpg/test/Makefile.regress
 endef
 
+TARGET_CFLAGS += $(FPIC)
+
 define Build/Compile
-       $(MAKE) -C "$(PKG_BUILD_DIR)/src/include" \
-               DESTDIR="$(PKG_INSTALL_DIR)" \
-               all install
-       $(MAKE) -C "$(PKG_BUILD_DIR)/src/interfaces/libpq" \
+       $(MAKE) $(PKG_JOBS) -C "$(PKG_BUILD_DIR)" \
                DESTDIR="$(PKG_INSTALL_DIR)" \
-               all install
-       $(MAKE) -C "$(PKG_BUILD_DIR)/src/bin/pg_config" \
+               all
+       $(MAKE) $(PKG_JOBS) -C "$(PKG_BUILD_DIR)" \
                DESTDIR="$(PKG_INSTALL_DIR)" \
-               includedir="$(STAGING_DIR)/usr/include" \
-               libdir="$(STAGING_DIR)/usr/lib" \
-               all install
-       $(MAKE) -C "$(PKG_BUILD_DIR)/src/bin/psql" \
-               DESTDIR="$(PKG_INSTALL_DIR)" \
-               all install
+               install
 endef
 
 define Package/libpq/install
@@ -112,32 +175,72 @@ endef
 
 define Package/pgsql-cli/install
        $(INSTALL_DIR) $(1)/usr/bin
-       $(CP) $(PKG_INSTALL_DIR)/usr/bin/psql $(1)/usr/bin/
+       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/psql $(1)/usr/bin/
 endef
 
-define Build/InstallDev
-       mkdir -p $(STAGING_DIR)/usr/bin
-       $(CP) $(PKG_INSTALL_DIR)/usr/bin/pg_config $(STAGING_DIR)/usr/bin/
-       mkdir -p $(STAGING_DIR)/usr/include
-       $(CP) $(PKG_INSTALL_DIR)/usr/include/libpq $(STAGING_DIR)/usr/include/
-       $(CP) $(PKG_INSTALL_DIR)/usr/include/libpq-fe.h $(STAGING_DIR)/usr/include/
-       $(CP) $(PKG_INSTALL_DIR)/usr/include/pg_config.h $(STAGING_DIR)/usr/include/
-       $(CP) $(PKG_INSTALL_DIR)/usr/include/postgres_ext.h $(STAGING_DIR)/usr/include/
-       $(CP) $(PKG_INSTALL_DIR)/usr/include/postgresql $(STAGING_DIR)/usr/include/
-       mkdir -p $(STAGING_DIR)/usr/lib
-       $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpq.{a,so*} $(STAGING_DIR)/usr/lib/
+define Package/pgsql-server/install
+       $(INSTALL_DIR) $(1)/usr/bin
+       $(INSTALL_DIR) $(1)/usr/share/postgresql
+       $(INSTALL_DIR) $(1)/usr/lib
+       $(INSTALL_DIR) $(1)/etc/init.d
+       $(INSTALL_DIR) $(1)/etc/config
+       $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/* $(1)/usr/bin
+       ln -sf postgres $(1)/usr/bin/postmaster
+
+       $(INSTALL_BIN) ./files/postgresql.init $(1)/etc/init.d/postgresql
+
+       $(CP) -r $(PKG_INSTALL_DIR)/usr/share/postgresql/* \
+               $(1)/usr/share/postgresql
+
+       $(INSTALL_DATA) ./files/postgresql.config $(1)/etc/config/postgresql
+
+       $(CP) -r \
+               $(PKG_INSTALL_DIR)/usr/lib/postgresql \
+               $(1)/usr/lib
+endef
+
+define Package/pgsql-server/postinst
+#!/bin/sh
+grep -q '^postgres:' /etc/passwd && exit 0
+group=$$(grep '^postgres:' /etc/group | cut -f3 -d:)
+if [ -z "$${group}" ] ; then
+       group=1000
+       tst=$$(cat /etc/group | grep ":$${group}:")
+       while [ -n "$${tst}" ] ; do
+               group=$$(($${group}+1))
+               tst=$$(cat /etc/group | grep ":$${group}:")
+       done
+       echo "postgres:x:$${group}:" >>/etc/group
+fi
+
+user=$$(cat /etc/passwd | grep "^postgres:")
+if [ -z "$${user}" ] ; then
+       num="$${group}"
+       tst=$$(cat /etc/passwd | grep ":.*:$${num}:")
+       while [ -n "$${tst}" ] ; do
+               num=$$(($${num}+1))
+               tst=$$(cat /etc/passwd | grep ":.*:$${num}:")
+       done
+       echo "postgres:*:$${num}:$${group}:PostgreSQL administrator:/tmp:/bin/ash" >>/etc/passwd
+fi
 endef
 
-define Build/UninstallDev
-       rm -rf \
-               $(STAGING_DIR)/usr/bin/pg_config \
-               $(STAGING_DIR)/usr/include/libpq \
-               $(STAGING_DIR)/usr/include/libpq-fe.h \
-               $(STAGING_DIR)/usr/include/pg_config.h \
-               $(STAGING_DIR)/usr/include/postgres_ext.h \
-               $(STAGING_DIR)/usr/include/postgresql \
-               $(STAGING_DIR)/usr/lib/libpq.{a,so*}
+define Build/InstallDev
+       $(INSTALL_DIR) $(1)/usr/bin
+       $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/bin/pg_config/pg_config.host $(1)/usr/bin/pg_config
+       $(INSTALL_DIR) $(1)/usr/include
+       $(CP) $(PKG_INSTALL_DIR)/usr/include/libpq $(1)/usr/include/
+       $(CP) $(PKG_INSTALL_DIR)/usr/include/libpq-fe.h $(1)/usr/include/
+       $(CP) $(PKG_INSTALL_DIR)/usr/include/pg_config.h $(1)/usr/include/
+       $(CP) $(PKG_INSTALL_DIR)/usr/include/pg_config_manual.h $(1)/usr/include/
+       $(CP) $(PKG_INSTALL_DIR)/usr/include/postgres_ext.h $(1)/usr/include/
+       $(CP) $(PKG_INSTALL_DIR)/usr/include/postgresql $(1)/usr/include/
+       $(INSTALL_DIR) $(1)/usr/lib
+       $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpq.{a,so*} $(1)/usr/lib/
+       $(CP) $(PKG_BUILD_DIR)/src/interfaces/ecpg/preproc/ecpg.host $(1)/usr/bin/ecpg
+       $(CP) $(PKG_BUILD_DIR)/host-zic $(1)/usr/bin/zic
 endef
 
 $(eval $(call BuildPackage,libpq))
 $(eval $(call BuildPackage,pgsql-cli))
+$(eval $(call BuildPackage,pgsql-server))