2 # Copyright (C) 2006 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
9 include $(TOPDIR)/rules.mk
15 PKG_BUILD_DIR:=$(BUILD_DIR)/$(PKG_NAME)-$(PKG_VERSION)
16 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
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
22 PKG_BUILD_DEPENDS:=libnotimpl
24 PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
26 include $(INCLUDE_DIR)/package.mk
31 DEPENDS:=+zlib +libreadline +libncurses
32 TITLE:=PostgreSQL client library
33 URL:=http://www.postgresql.org/
36 define Package/libpq/description
37 PostgreSQL client library.
40 define Package/pgsql-cli
44 TITLE:=Command Line Interface (CLI) to PostgreSQL databases
45 URL:=http://www.postgresql.org/
48 define Package/pgsql-cli/description
49 Command Line Interface (CLI) to PostgreSQL databases.
52 define Package/pgsql-server
56 TITLE:=PostgreSQL databases Server
57 URL:=http://www.postgresql.org/
60 define Package/pgsql-server/description
61 PostgreSQL databases Server.
64 # Need a native ecpg ,pg_config, and zic for build
65 define Build/Configure
66 (cd $(PKG_BUILD_DIR); rm -f config.cache; \
71 --datadir=/usr/share \
72 --includedir=/usr/include \
73 --infodir=/usr/share/info \
75 --libexecdir=/usr/lib \
76 --localstatedir=/var \
77 --mandir=/usr/share/man \
81 $(DISABLE_LARGEFILE) \
84 --disable-integer-datetimes \
94 --without-rendezvous \
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
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)" \
117 --target=$(GNU_TARGET_NAME) \
118 --host=$(GNU_TARGET_NAME) \
119 --build=$(GNU_HOST_NAME) \
120 --program-prefix="" \
121 --program-suffix="" \
125 --datadir=/usr/share \
126 --includedir=/usr/include \
127 --infodir=/usr/share/info \
129 --libexecdir=/usr/lib \
130 --localstatedir=/var \
131 --mandir=/usr/share/man \
132 --sbindir=/usr/sbin \
135 $(DISABLE_LARGEFILE) \
138 --disable-integer-datetimes \
147 --without-rendezvous \
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
158 $(MAKE) -C "$(PKG_BUILD_DIR)" \
159 DESTDIR="$(PKG_INSTALL_DIR)" \
163 define Package/libpq/install
164 $(INSTALL_DIR) $(1)/usr/lib
165 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpq.so.* $(1)/usr/lib/
168 define Package/pgsql-cli/install
169 $(INSTALL_DIR) $(1)/usr/bin
170 $(CP) $(PKG_INSTALL_DIR)/usr/bin/psql $(1)/usr/bin/
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
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 \
195 $(INSTALL_BIN) ./files/postgresql.init $(1)/etc/init.d/postgresql
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
213 $(INSTALL_DATA) ./files/postgresql.config $(1)/etc/config/postgresql
216 $(PKG_INSTALL_DIR)/usr/share/postgresql/timezone \
217 $(PKG_INSTALL_DIR)/usr/share/postgresql/timezonesets \
218 $(1)/usr/share/postgresql
221 $(PKG_INSTALL_DIR)/usr/lib/postgresql \
225 define Package/pgsql-server/postinst
227 grep -q '^postgres:' /etc/passwd && exit 0
229 if [ -e /bin/addgroup ]; then
230 /bin/addgroup postgres
233 if [ -e /bin/adduser ]; then
234 /bin/adduser -h /tmp -H -g 'PostgreSQL administrator' -s /bin/ash -D -H -G postgres postgres
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"
244 if [ "$${RG}" != "0" -o "$${RU}" != "0" ]; then
245 echo "Failed to created postgres user"
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
265 define Build/UninstallDev
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
278 $(eval $(call BuildPackage,libpq))
279 $(eval $(call BuildPackage,pgsql-cli))
280 $(eval $(call BuildPackage,pgsql-server))