update postgresql to 8.2.6
[openwrt/svn-archive/archive.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.6
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 http://ftp7.us.postgresql.org/pub/postgresql/source/v$(PKG_VERSION) \
19 http://ftp8.us.postgresql.org/pub/postgresql/source/v$(PKG_VERSION) \
20 http://ftp9.us.postgresql.org/pub/postgresql/source/v$(PKG_VERSION) \
21 http://ftp.be.postgresql.org/postgresql/source/v$(PKG_VERSION) \
22 ftp://ftp-archives.postgresql.org/pub/source/v$(PKG_VERSION)
23 PKG_MD5SUM:=17b9049b4fcad42ee95410833c1db228
24
25 PKG_BUILD_DEPENDS:=libnotimpl
26
27 PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
28
29 include $(INCLUDE_DIR)/package.mk
30
31 define Package/libpq
32 SECTION:=libs
33 CATEGORY:=Libraries
34 DEPENDS:=+zlib +libreadline +libncurses
35 TITLE:=PostgreSQL client library
36 URL:=http://www.postgresql.org/
37 SUBMENU:=database
38 endef
39
40 define Package/libpq/description
41 PostgreSQL client library.
42 endef
43
44 define Package/pgsql-cli
45 SECTION:=utils
46 CATEGORY:=Utilities
47 DEPENDS:=+libpq
48 TITLE:=Command Line Interface (CLI) to PostgreSQL databases
49 URL:=http://www.postgresql.org/
50 SUBMENU:=database
51 endef
52
53 define Package/pgsql-cli/description
54 Command Line Interface (CLI) to PostgreSQL databases.
55 endef
56
57 define Package/pgsql-server
58 SECTION:=utils
59 CATEGORY:=Utilities
60 DEPENDS:=+libpq
61 TITLE:=PostgreSQL databases Server
62 URL:=http://www.postgresql.org/
63 SUBMENU:=database
64 endef
65
66 define Package/pgsql-server/description
67 PostgreSQL databases Server.
68 endef
69
70 # Need a native ecpg ,pg_config, and zic for build
71 define Build/Configure
72 (cd $(PKG_BUILD_DIR); rm -f config.cache; \
73 ./configure \
74 --prefix=/usr \
75 --exec-prefix=/usr \
76 --bindir=/usr/bin \
77 --datadir=/usr/share \
78 --includedir=/usr/include \
79 --infodir=/usr/share/info \
80 --libdir=/usr/lib \
81 --libexecdir=/usr/lib \
82 --localstatedir=/var \
83 --mandir=/usr/share/man \
84 --sbindir=/usr/sbin \
85 --sysconfdir=/etc \
86 $(DISABLE_NLS) \
87 $(DISABLE_LARGEFILE) \
88 --enable-shared \
89 --enable-static \
90 --disable-integer-datetimes \
91 --disable-rpath \
92 --without-java \
93 --without-krb4 \
94 --without-krb5 \
95 --without-openssl \
96 --without-pam \
97 --without-perl \
98 --without-python \
99 --without-readline \
100 --without-rendezvous \
101 --without-tcl \
102 --without-tk \
103 --with-zlib="yes" \
104 --enable-depend \
105 );
106 $(MAKE) -C $(PKG_BUILD_DIR)/src/interfaces/ecpg/preproc CC="$(HOSTCC)" CFLAGS+="-I../../libpq"
107 mv $(PKG_BUILD_DIR)/src/interfaces/ecpg/preproc/ecpg \
108 $(PKG_BUILD_DIR)/src/interfaces/ecpg/preproc/ecpg.host
109 $(MAKE) -C $(PKG_BUILD_DIR)/src/timezone CC="$(HOSTCC)"
110 mv $(PKG_BUILD_DIR)/src/timezone/zic $(PKG_BUILD_DIR)/src/timezone/zic.host
111 $(MAKE) -C $(PKG_BUILD_DIR)/src/bin/pg_config CC="$(HOSTCC)"
112 mv $(PKG_BUILD_DIR)/src/bin/pg_config/pg_config \
113 $(PKG_BUILD_DIR)/src/bin/pg_config/pg_config.host
114 $(MAKE) -C $(PKG_BUILD_DIR) distclean
115
116 (cd $(PKG_BUILD_DIR); rm -f config.cache; \
117 $(TARGET_CONFIGURE_OPTS) \
118 CFLAGS="$(TARGET_CFLAGS)" \
119 CPPFLAGS="$$$$CPPFLAGS $(TARGET_CPPFLAGS)" \
120 LDFLAGS="$(TARGET_LDFLAGS)" \
121 LIBS="-lnotimpl" \
122 ./configure \
123 --target=$(GNU_TARGET_NAME) \
124 --host=$(GNU_TARGET_NAME) \
125 --build=$(GNU_HOST_NAME) \
126 --program-prefix="" \
127 --program-suffix="" \
128 --prefix=/usr \
129 --exec-prefix=/usr \
130 --bindir=/usr/bin \
131 --datadir=/usr/share \
132 --includedir=/usr/include \
133 --infodir=/usr/share/info \
134 --libdir=/usr/lib \
135 --libexecdir=/usr/lib \
136 --localstatedir=/var \
137 --mandir=/usr/share/man \
138 --sbindir=/usr/sbin \
139 --sysconfdir=/etc \
140 $(DISABLE_NLS) \
141 $(DISABLE_LARGEFILE) \
142 --enable-shared \
143 --enable-static \
144 --disable-integer-datetimes \
145 --disable-rpath \
146 --without-java \
147 --without-krb4 \
148 --without-krb5 \
149 --without-openssl \
150 --without-pam \
151 --without-perl \
152 --without-python \
153 --without-rendezvous \
154 --without-tcl \
155 --without-tk \
156 --with-zlib="yes" \
157 --enable-depend \
158 );
159 $(SED) 's@ECPG = ../../preproc/ecpg@ECPG = ../../preproc/ecpg.host@' $(PKG_BUILD_DIR)/src/interfaces/ecpg/test/Makefile.regress
160 $(SED) 's@\./zic -d@./zic.host -d@' $(PKG_BUILD_DIR)/src/timezone/Makefile
161 endef
162
163 define Build/Compile
164 $(MAKE) -C "$(PKG_BUILD_DIR)" \
165 DESTDIR="$(PKG_INSTALL_DIR)" \
166 all 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) \
186 $(PKG_INSTALL_DIR)/usr/bin/postgres \
187 $(PKG_INSTALL_DIR)/usr/bin/dropdb \
188 $(PKG_INSTALL_DIR)/usr/bin/createdb \
189 $(PKG_INSTALL_DIR)/usr/bin/createuser \
190 $(PKG_INSTALL_DIR)/usr/bin/dropuser \
191 $(PKG_INSTALL_DIR)/usr/bin/initdb \
192 $(PKG_INSTALL_DIR)/usr/bin/pg_config \
193 $(PKG_INSTALL_DIR)/usr/bin/pg_controldata \
194 $(PKG_INSTALL_DIR)/usr/bin/pg_ctl \
195 $(PKG_INSTALL_DIR)/usr/bin/pg_dump \
196 $(PKG_INSTALL_DIR)/usr/bin/pg_dumpall \
197 $(PKG_INSTALL_DIR)/usr/bin/pg_restore \
198 $(PKG_INSTALL_DIR)/usr/bin/vacuumdb \
199 $(1)/usr/bin
200
201 $(INSTALL_BIN) ./files/postgresql.init $(1)/etc/init.d/postgresql
202
203 $(INSTALL_DATA) \
204 $(PKG_INSTALL_DIR)/usr/share/postgresql/postgres.bki \
205 $(PKG_INSTALL_DIR)/usr/share/postgresql/postgres.description \
206 $(PKG_INSTALL_DIR)/usr/share/postgresql/conversion_create.sql \
207 $(PKG_INSTALL_DIR)/usr/share/postgresql/information_schema.sql \
208 $(PKG_INSTALL_DIR)/usr/share/postgresql/pg_hba.conf.sample \
209 $(PKG_INSTALL_DIR)/usr/share/postgresql/pg_ident.conf.sample \
210 $(PKG_INSTALL_DIR)/usr/share/postgresql/pg_service.conf.sample \
211 $(PKG_INSTALL_DIR)/usr/share/postgresql/postgresql.conf.sample \
212 $(PKG_INSTALL_DIR)/usr/share/postgresql/sql_features.txt \
213 $(PKG_INSTALL_DIR)/usr/share/postgresql/postgres.shdescription \
214 $(PKG_INSTALL_DIR)/usr/share/postgresql/psqlrc.sample \
215 $(PKG_INSTALL_DIR)/usr/share/postgresql/recovery.conf.sample \
216 $(PKG_INSTALL_DIR)/usr/share/postgresql/system_views.sql \
217 $(1)/usr/share/postgresql
218
219 $(INSTALL_DATA) ./files/postgresql.config $(1)/etc/config/postgresql
220
221 $(CP) -r \
222 $(PKG_INSTALL_DIR)/usr/share/postgresql/timezone \
223 $(PKG_INSTALL_DIR)/usr/share/postgresql/timezonesets \
224 $(1)/usr/share/postgresql
225
226 $(CP) -r \
227 $(PKG_INSTALL_DIR)/usr/lib/postgresql \
228 $(1)/usr/lib
229 endef
230
231 define Package/pgsql-server/postinst
232 #!/bin/sh
233 grep -q '^postgres:' /etc/passwd && exit 0
234
235 if [ -e /bin/addgroup ]; then
236 /bin/addgroup postgres
237 RG=$$?
238
239 if [ -e /bin/adduser ]; then
240 /bin/adduser -h /tmp -H -g 'PostgreSQL administrator' -s /bin/ash -D -H -G postgres postgres
241 RU=$$?
242 fi
243 fi
244
245 if [ -z "$${RG}" -o -z "$${RU}" ]; then
246 echo "Could not find user utils, you will need to create the postgres user by hand"
247 exit
248 fi
249
250 if [ "$${RG}" != "0" -o "$${RU}" != "0" ]; then
251 echo "Failed to created postgres user"
252 exit 1
253 fi
254 endef
255
256 define Build/InstallDev
257 mkdir -p $(1)/usr/bin
258 $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/bin/pg_config/pg_config.host $(1)/usr/bin/pg_config
259 mkdir -p $(1)/usr/include
260 $(CP) $(PKG_INSTALL_DIR)/usr/include/libpq $(1)/usr/include/
261 $(CP) $(PKG_INSTALL_DIR)/usr/include/libpq-fe.h $(1)/usr/include/
262 $(CP) $(PKG_INSTALL_DIR)/usr/include/pg_config.h $(1)/usr/include/
263 $(CP) $(PKG_INSTALL_DIR)/usr/include/postgres_ext.h $(1)/usr/include/
264 $(CP) $(PKG_INSTALL_DIR)/usr/include/postgresql $(1)/usr/include/
265 mkdir -p $(1)/usr/lib
266 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpq.{a,so*} $(1)/usr/lib/
267 $(CP) $(PKG_BUILD_DIR)/src/interfaces/ecpg/preproc/ecpg.host $(1)/usr/bin/ecpg
268 $(CP) $(PKG_BUILD_DIR)/src/timezone/zic.host $(1)/usr/bin/zic
269 endef
270
271 $(eval $(call BuildPackage,libpq))
272 $(eval $(call BuildPackage,pgsql-cli))
273 $(eval $(call BuildPackage,pgsql-server))