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