update to postgresql 8.2.5 and refresh patches
[packages.git] / libs / postgresql / Makefile
1
2 # Copyright (C) 2006 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7 # $Id$
8
9 include $(TOPDIR)/rules.mk
10
11 PKG_NAME:=postgresql
12 PKG_VERSION:=8.2.5
13 PKG_RELEASE:=1
14
15 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
16 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
17 PKG_SOURCE_URL:=\
18         ftp://ftp.us.postgresql.org/pub/mirrors/postgresql/source/v$(PKG_VERSION) \
19         ftp://ftp-archives.postgresql.org/pub/source/v$(PKG_VERSION)
20 PKG_MD5SUM:=bb1cd309ea72f070cb964736f5755847
21 PKG_CAT:=bzcat
22
23 PKG_BUILD_DEPENDS:=libnotimpl
24
25 PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
26
27 include $(INCLUDE_DIR)/package.mk
28
29 define Package/libpq
30   SECTION:=libs
31   CATEGORY:=Libraries
32   DEPENDS:=+zlib +libreadline +libncurses
33   TITLE:=PostgreSQL client library
34   DESCRIPTION:=PostgreSQL client library.
35   URL:=http://www.postgresql.org/
36 endef
37
38 define Package/pgsql-cli
39   SECTION:=utils
40   CATEGORY:=Utilities
41   DEPENDS:=+libpq
42   TITLE:=Command Line Interface (CLI) to PostgreSQL databases
43   DESCRIPTION:=Command Line Interface (CLI) to PostgreSQL databases.
44   URL:=http://www.postgresql.org/
45 endef
46
47 define Package/pgsql-server
48   SECTION:=utils
49   CATEGORY:=Utilities
50   DEPENDS:=+libpq
51   TITLE:=PostgreSQL databases Server
52   DESCRIPTION:=PostgreSQL databases Server.
53   URL:=http://www.postgresql.org/
54 endef
55
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                         $(DISABLE_LARGEFILE) \
74                         --enable-shared \
75                         --enable-static \
76                         --disable-integer-datetimes \
77                         --disable-rpath \
78                         --without-java \
79                         --without-krb4 \
80                         --without-krb5 \
81                         --without-openssl \
82                         --without-pam \
83                         --without-perl \
84                         --without-python \
85                         --without-readline \
86                         --without-rendezvous \
87                         --without-tcl \
88                         --without-tk \
89                         --with-zlib="yes" \
90                         --enable-depend \
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)/src/timezone/zic.host
97         $(MAKE) -C $(PKG_BUILD_DIR)/src/bin/pg_config CC="$(HOSTCC)"
98         mv $(PKG_BUILD_DIR)/src/bin/pg_config/pg_config \
99                 $(PKG_BUILD_DIR)/src/bin/pg_config/pg_config.host
100         $(MAKE) -C $(PKG_BUILD_DIR) distclean
101
102         (cd $(PKG_BUILD_DIR); rm -f config.cache; \
103                 $(TARGET_CONFIGURE_OPTS) \
104                 CFLAGS="$(TARGET_CFLAGS)" \
105                 CPPFLAGS="$$$$CPPFLAGS $(TARGET_CPPFLAGS)" \
106                 LDFLAGS="$(TARGET_LDFLAGS)" \
107                 LIBS="-lnotimpl" \
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         );
145         $(SED) 's@ECPG = ../../preproc/ecpg@ECPG = ../../preproc/ecpg.host@' $(PKG_BUILD_DIR)/src/interfaces/ecpg/test/Makefile.regress
146         $(SED) 's@\./zic -d@./zic.host -d@' $(PKG_BUILD_DIR)/src/timezone/Makefile
147 endef
148
149 define Build/Compile
150         $(MAKE) -C "$(PKG_BUILD_DIR)" \
151                 DESTDIR="$(PKG_INSTALL_DIR)" \
152                 all install
153 endef
154
155 define Package/libpq/install
156         $(INSTALL_DIR) $(1)/usr/lib
157         $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpq.so.* $(1)/usr/lib/
158 endef
159
160 define Package/pgsql-cli/install
161         $(INSTALL_DIR) $(1)/usr/bin
162         $(CP) $(PKG_INSTALL_DIR)/usr/bin/psql $(1)/usr/bin/
163 endef
164
165 define Package/pgsql-server/install
166         $(INSTALL_DIR) $(1)/usr/bin
167         $(INSTALL_DIR) $(1)/usr/share/postgresql
168         $(INSTALL_DIR) $(1)/usr/lib
169         $(INSTALL_DIR) $(1)/etc/init.d
170         $(INSTALL_DIR) $(1)/etc/config
171         $(INSTALL_BIN) \
172                 $(PKG_INSTALL_DIR)/usr/bin/postgres \
173                 $(PKG_INSTALL_DIR)/usr/bin/dropdb \
174                 $(PKG_INSTALL_DIR)/usr/bin/createdb \
175                 $(PKG_INSTALL_DIR)/usr/bin/createuser \
176                 $(PKG_INSTALL_DIR)/usr/bin/dropuser \
177                 $(PKG_INSTALL_DIR)/usr/bin/initdb \
178                 $(PKG_INSTALL_DIR)/usr/bin/pg_config \
179                 $(PKG_INSTALL_DIR)/usr/bin/pg_controldata \
180                 $(PKG_INSTALL_DIR)/usr/bin/pg_ctl \
181                 $(PKG_INSTALL_DIR)/usr/bin/pg_dump \
182                 $(PKG_INSTALL_DIR)/usr/bin/pg_dumpall \
183                 $(PKG_INSTALL_DIR)/usr/bin/pg_restore \
184                 $(PKG_INSTALL_DIR)/usr/bin/vacuumdb \
185                 $(1)/usr/bin
186
187         $(INSTALL_BIN) ./files/postgresql.init $(1)/etc/init.d/postgresql
188
189         $(INSTALL_DATA) \
190                 $(PKG_INSTALL_DIR)/usr/share/postgresql/postgres.bki \
191                 $(PKG_INSTALL_DIR)/usr/share/postgresql/postgres.description \
192                 $(PKG_INSTALL_DIR)/usr/share/postgresql/conversion_create.sql \
193                 $(PKG_INSTALL_DIR)/usr/share/postgresql/information_schema.sql \
194                 $(PKG_INSTALL_DIR)/usr/share/postgresql/pg_hba.conf.sample \
195                 $(PKG_INSTALL_DIR)/usr/share/postgresql/pg_ident.conf.sample \
196                 $(PKG_INSTALL_DIR)/usr/share/postgresql/pg_service.conf.sample \
197                 $(PKG_INSTALL_DIR)/usr/share/postgresql/postgresql.conf.sample \
198                 $(PKG_INSTALL_DIR)/usr/share/postgresql/sql_features.txt \
199                 $(PKG_INSTALL_DIR)/usr/share/postgresql/postgres.shdescription \
200                 $(PKG_INSTALL_DIR)/usr/share/postgresql/psqlrc.sample \
201                 $(PKG_INSTALL_DIR)/usr/share/postgresql/recovery.conf.sample \
202                 $(PKG_INSTALL_DIR)/usr/share/postgresql/system_views.sql \
203                 $(1)/usr/share/postgresql
204
205                 $(INSTALL_DATA) ./files/postgresql.config $(1)/etc/config/postgresql
206
207                 $(CP) -r \
208                         $(PKG_INSTALL_DIR)/usr/share/postgresql/timezone \
209                         $(PKG_INSTALL_DIR)/usr/share/postgresql/timezonesets \
210                         $(1)/usr/share/postgresql
211
212                 $(CP) -r \
213                         $(PKG_INSTALL_DIR)/usr/lib/postgresql \
214                         $(1)/usr/lib
215 endef
216
217 define Package/pgsql-server/postinst
218 #!/bin/sh
219 grep -q '^postgres:' /etc/passwd && exit 0
220
221 if [ -e /bin/addgroup ]; then
222   /bin/addgroup postgres
223   RG=$$?
224
225   if [ -e /bin/adduser ]; then
226     /bin/adduser -h /tmp -H -g 'PostgreSQL administrator' -s /bin/ash -D -H -G postgres postgres
227         RU=$$?
228   fi
229 fi
230
231 if [ -z "$${RG}" -o -z "$${RU}" ]; then
232   echo "Could not find user utils, you will need to create the postgres user by hand"
233   exit 
234 fi
235
236 if [ "$${RG}" != "0" -o "$${RU}" != "0" ]; then
237   echo "Failed to created postgres user"
238   exit 1
239 fi
240 endef
241
242 define Build/InstallDev
243         mkdir -p $(STAGING_DIR)/usr/bin
244         $(CP) $(PKG_BUILD_DIR)/src/bin/pg_config/pg_config.host $(STAGING_DIR)/usr/bin/pg_config
245         mkdir -p $(STAGING_DIR)/usr/include
246         $(CP) $(PKG_INSTALL_DIR)/usr/include/libpq $(STAGING_DIR)/usr/include/
247         $(CP) $(PKG_INSTALL_DIR)/usr/include/libpq-fe.h $(STAGING_DIR)/usr/include/
248         $(CP) $(PKG_INSTALL_DIR)/usr/include/pg_config.h $(STAGING_DIR)/usr/include/
249         $(CP) $(PKG_INSTALL_DIR)/usr/include/postgres_ext.h $(STAGING_DIR)/usr/include/
250         $(CP) $(PKG_INSTALL_DIR)/usr/include/postgresql $(STAGING_DIR)/usr/include/
251         mkdir -p $(STAGING_DIR)/usr/lib
252         $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpq.{a,so*} $(STAGING_DIR)/usr/lib/
253         $(CP) $(PKG_BUILD_DIR)/src/interfaces/ecpg/preproc/ecpg.host $(STAGING_DIR)/usr/bin/ecpg
254         $(CP) $(PKG_BUILD_DIR)/src/timezone/zic.host $(STAGING_DIR)/usr/bin/zic
255 endef
256
257 define Build/UninstallDev
258         rm -rf \
259                 $(STAGING_DIR)/usr/bin/pg_config \
260                 $(STAGING_DIR)/usr/include/libpq \
261                 $(STAGING_DIR)/usr/include/libpq-fe.h \
262                 $(STAGING_DIR)/usr/include/pg_config.h \
263                 $(STAGING_DIR)/usr/include/postgres_ext.h \
264                 $(STAGING_DIR)/usr/include/postgresql \
265                 $(STAGING_DIR)/usr/lib/libpq.{a,so*} \
266                 $(STAGING_DIR)/usr/bin/ecpg \
267                 $(STAGING_DIR)/usr/bin/zic
268 endef
269
270 $(eval $(call BuildPackage,libpq))
271 $(eval $(call BuildPackage,pgsql-cli))
272 $(eval $(call BuildPackage,pgsql-server))