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