DESCRIPTION:= is obselete
[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.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 URL:=http://www.postgresql.org/
35 endef
36
37 define Package/libpq/description
38 PostgreSQL client library.
39 endef
40
41 define Package/pgsql-cli
42 SECTION:=utils
43 CATEGORY:=Utilities
44 DEPENDS:=+libpq
45 TITLE:=Command Line Interface (CLI) to PostgreSQL databases
46 URL:=http://www.postgresql.org/
47 endef
48
49 define Package/pgsql-cli/description
50 Command Line Interface (CLI) to PostgreSQL databases.
51 endef
52
53 define Package/pgsql-server
54 SECTION:=utils
55 CATEGORY:=Utilities
56 DEPENDS:=+libpq
57 TITLE:=PostgreSQL databases Server
58 URL:=http://www.postgresql.org/
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 );
101 $(MAKE) -C $(PKG_BUILD_DIR)/src/interfaces/ecpg/preproc CC="$(HOSTCC)" CFLAGS+="-I../../libpq"
102 mv $(PKG_BUILD_DIR)/src/interfaces/ecpg/preproc/ecpg \
103 $(PKG_BUILD_DIR)/src/interfaces/ecpg/preproc/ecpg.host
104 $(MAKE) -C $(PKG_BUILD_DIR)/src/timezone CC="$(HOSTCC)"
105 mv $(PKG_BUILD_DIR)/src/timezone/zic $(PKG_BUILD_DIR)/src/timezone/zic.host
106 $(MAKE) -C $(PKG_BUILD_DIR)/src/bin/pg_config CC="$(HOSTCC)"
107 mv $(PKG_BUILD_DIR)/src/bin/pg_config/pg_config \
108 $(PKG_BUILD_DIR)/src/bin/pg_config/pg_config.host
109 $(MAKE) -C $(PKG_BUILD_DIR) distclean
110
111 (cd $(PKG_BUILD_DIR); rm -f config.cache; \
112 $(TARGET_CONFIGURE_OPTS) \
113 CFLAGS="$(TARGET_CFLAGS)" \
114 CPPFLAGS="$$$$CPPFLAGS $(TARGET_CPPFLAGS)" \
115 LDFLAGS="$(TARGET_LDFLAGS)" \
116 LIBS="-lnotimpl" \
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 );
154 $(SED) 's@ECPG = ../../preproc/ecpg@ECPG = ../../preproc/ecpg.host@' $(PKG_BUILD_DIR)/src/interfaces/ecpg/test/Makefile.regress
155 $(SED) 's@\./zic -d@./zic.host -d@' $(PKG_BUILD_DIR)/src/timezone/Makefile
156 endef
157
158 define Build/Compile
159 $(MAKE) -C "$(PKG_BUILD_DIR)" \
160 DESTDIR="$(PKG_INSTALL_DIR)" \
161 all install
162 endef
163
164 define Package/libpq/install
165 $(INSTALL_DIR) $(1)/usr/lib
166 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpq.so.* $(1)/usr/lib/
167 endef
168
169 define Package/pgsql-cli/install
170 $(INSTALL_DIR) $(1)/usr/bin
171 $(CP) $(PKG_INSTALL_DIR)/usr/bin/psql $(1)/usr/bin/
172 endef
173
174 define Package/pgsql-server/install
175 $(INSTALL_DIR) $(1)/usr/bin
176 $(INSTALL_DIR) $(1)/usr/share/postgresql
177 $(INSTALL_DIR) $(1)/usr/lib
178 $(INSTALL_DIR) $(1)/etc/init.d
179 $(INSTALL_DIR) $(1)/etc/config
180 $(INSTALL_BIN) \
181 $(PKG_INSTALL_DIR)/usr/bin/postgres \
182 $(PKG_INSTALL_DIR)/usr/bin/dropdb \
183 $(PKG_INSTALL_DIR)/usr/bin/createdb \
184 $(PKG_INSTALL_DIR)/usr/bin/createuser \
185 $(PKG_INSTALL_DIR)/usr/bin/dropuser \
186 $(PKG_INSTALL_DIR)/usr/bin/initdb \
187 $(PKG_INSTALL_DIR)/usr/bin/pg_config \
188 $(PKG_INSTALL_DIR)/usr/bin/pg_controldata \
189 $(PKG_INSTALL_DIR)/usr/bin/pg_ctl \
190 $(PKG_INSTALL_DIR)/usr/bin/pg_dump \
191 $(PKG_INSTALL_DIR)/usr/bin/pg_dumpall \
192 $(PKG_INSTALL_DIR)/usr/bin/pg_restore \
193 $(PKG_INSTALL_DIR)/usr/bin/vacuumdb \
194 $(1)/usr/bin
195
196 $(INSTALL_BIN) ./files/postgresql.init $(1)/etc/init.d/postgresql
197
198 $(INSTALL_DATA) \
199 $(PKG_INSTALL_DIR)/usr/share/postgresql/postgres.bki \
200 $(PKG_INSTALL_DIR)/usr/share/postgresql/postgres.description \
201 $(PKG_INSTALL_DIR)/usr/share/postgresql/conversion_create.sql \
202 $(PKG_INSTALL_DIR)/usr/share/postgresql/information_schema.sql \
203 $(PKG_INSTALL_DIR)/usr/share/postgresql/pg_hba.conf.sample \
204 $(PKG_INSTALL_DIR)/usr/share/postgresql/pg_ident.conf.sample \
205 $(PKG_INSTALL_DIR)/usr/share/postgresql/pg_service.conf.sample \
206 $(PKG_INSTALL_DIR)/usr/share/postgresql/postgresql.conf.sample \
207 $(PKG_INSTALL_DIR)/usr/share/postgresql/sql_features.txt \
208 $(PKG_INSTALL_DIR)/usr/share/postgresql/postgres.shdescription \
209 $(PKG_INSTALL_DIR)/usr/share/postgresql/psqlrc.sample \
210 $(PKG_INSTALL_DIR)/usr/share/postgresql/recovery.conf.sample \
211 $(PKG_INSTALL_DIR)/usr/share/postgresql/system_views.sql \
212 $(1)/usr/share/postgresql
213
214 $(INSTALL_DATA) ./files/postgresql.config $(1)/etc/config/postgresql
215
216 $(CP) -r \
217 $(PKG_INSTALL_DIR)/usr/share/postgresql/timezone \
218 $(PKG_INSTALL_DIR)/usr/share/postgresql/timezonesets \
219 $(1)/usr/share/postgresql
220
221 $(CP) -r \
222 $(PKG_INSTALL_DIR)/usr/lib/postgresql \
223 $(1)/usr/lib
224 endef
225
226 define Package/pgsql-server/postinst
227 #!/bin/sh
228 grep -q '^postgres:' /etc/passwd && exit 0
229
230 if [ -e /bin/addgroup ]; then
231 /bin/addgroup postgres
232 RG=$$?
233
234 if [ -e /bin/adduser ]; then
235 /bin/adduser -h /tmp -H -g 'PostgreSQL administrator' -s /bin/ash -D -H -G postgres postgres
236 RU=$$?
237 fi
238 fi
239
240 if [ -z "$${RG}" -o -z "$${RU}" ]; then
241 echo "Could not find user utils, you will need to create the postgres user by hand"
242 exit
243 fi
244
245 if [ "$${RG}" != "0" -o "$${RU}" != "0" ]; then
246 echo "Failed to created postgres user"
247 exit 1
248 fi
249 endef
250
251 define Build/InstallDev
252 mkdir -p $(1)/usr/bin
253 $(CP) $(PKG_BUILD_DIR)/src/bin/pg_config/pg_config.host $(1)/usr/bin/pg_config
254 mkdir -p $(1)/usr/include
255 $(CP) $(PKG_INSTALL_DIR)/usr/include/libpq $(1)/usr/include/
256 $(CP) $(PKG_INSTALL_DIR)/usr/include/libpq-fe.h $(1)/usr/include/
257 $(CP) $(PKG_INSTALL_DIR)/usr/include/pg_config.h $(1)/usr/include/
258 $(CP) $(PKG_INSTALL_DIR)/usr/include/postgres_ext.h $(1)/usr/include/
259 $(CP) $(PKG_INSTALL_DIR)/usr/include/postgresql $(1)/usr/include/
260 mkdir -p $(1)/usr/lib
261 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpq.{a,so*} $(1)/usr/lib/
262 $(CP) $(PKG_BUILD_DIR)/src/interfaces/ecpg/preproc/ecpg.host $(1)/usr/bin/ecpg
263 $(CP) $(PKG_BUILD_DIR)/src/timezone/zic.host $(1)/usr/bin/zic
264 endef
265
266 define Build/UninstallDev
267 rm -rf \
268 $(STAGING_DIR)/usr/bin/pg_config \
269 $(STAGING_DIR)/usr/include/libpq \
270 $(STAGING_DIR)/usr/include/libpq-fe.h \
271 $(STAGING_DIR)/usr/include/pg_config.h \
272 $(STAGING_DIR)/usr/include/postgres_ext.h \
273 $(STAGING_DIR)/usr/include/postgresql \
274 $(STAGING_DIR)/usr/lib/libpq.{a,so*} \
275 $(STAGING_DIR)/usr/bin/ecpg \
276 $(STAGING_DIR)/usr/bin/zic
277 endef
278
279 $(eval $(call BuildPackage,libpq))
280 $(eval $(call BuildPackage,pgsql-cli))
281 $(eval $(call BuildPackage,pgsql-server))