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:=cb47771004d53505200ffd00ac45bc32
23 PKG_BUILD_DEPENDS:=libnotimpl
25 PKG_INSTALL_DIR:=$(PKG_BUILD_DIR)/ipkg-install
27 include $(INCLUDE_DIR)/package.mk
33 TITLE:=PostgreSQL client library
34 DESCRIPTION:=PostgreSQL client library.
35 URL:=http://www.postgresql.org/
38 define Package/pgsql-cli
42 TITLE:=Command Line Interface (CLI) to PostgreSQL databases
43 DESCRIPTION:=Command Line Interface (CLI) to PostgreSQL databases.
44 URL:=http://www.postgresql.org/
47 define Package/pgsql-server
51 TITLE:=PostgreSQL databases Server
52 DESCRIPTION:=PostgreSQL databases Server.
53 URL:=http://www.postgresql.org/
56 # Need a native ecpg ,pg_config, and zic for build
57 define Build/Configure
58 (cd $(PKG_BUILD_DIR); rm -f config.cache; \
63 --datadir=/usr/share \
64 --includedir=/usr/include \
65 --infodir=/usr/share/info \
67 --libexecdir=/usr/lib \
68 --localstatedir=/var \
69 --mandir=/usr/share/man \
73 $(DISABLE_LARGEFILE) \
76 --disable-integer-datetimes \
86 --without-rendezvous \
92 $(MAKE) -C $(PKG_BUILD_DIR)/src/interfaces/ecpg/preproc CC="$(HOSTCC)" CFLAGS+="-I../../libpq" -j1
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)" -j1
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)" -j1
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 -j1
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)" \
109 --target=$(GNU_TARGET_NAME) \
110 --host=$(GNU_TARGET_NAME) \
111 --build=$(GNU_HOST_NAME) \
112 --program-prefix="" \
113 --program-suffix="" \
117 --datadir=/usr/share \
118 --includedir=/usr/include \
119 --infodir=/usr/share/info \
121 --libexecdir=/usr/lib \
122 --localstatedir=/var \
123 --mandir=/usr/share/man \
124 --sbindir=/usr/sbin \
127 $(DISABLE_LARGEFILE) \
130 --disable-integer-datetimes \
140 --without-rendezvous \
146 $(SED) 's@ECPG = ../../preproc/ecpg@ECPG = ../../preproc/ecpg.host@' $(PKG_BUILD_DIR)/src/interfaces/ecpg/test/Makefile.regress
147 $(SED) 's@\./zic -d@./zic.host -d@' $(PKG_BUILD_DIR)/src/timezone/Makefile
151 $(MAKE) -C "$(PKG_BUILD_DIR)" -j1 \
152 DESTDIR="$(PKG_INSTALL_DIR)" \
156 define Package/libpq/install
157 $(INSTALL_DIR) $(1)/usr/lib
158 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpq.so.* $(1)/usr/lib/
161 define Package/pgsql-cli/install
162 $(INSTALL_DIR) $(1)/usr/bin
163 $(CP) $(PKG_INSTALL_DIR)/usr/bin/psql $(1)/usr/bin/
166 define Package/pgsql-server/install
167 $(INSTALL_DIR) $(1)/usr/bin
168 $(INSTALL_DIR) $(1)/usr/share/postgresql
169 $(INSTALL_DIR) $(1)/usr/lib
170 $(INSTALL_DIR) $(1)/etc/init.d
171 $(INSTALL_DIR) $(1)/etc/config
173 $(PKG_INSTALL_DIR)/usr/bin/postgres \
174 $(PKG_INSTALL_DIR)/usr/bin/dropdb \
175 $(PKG_INSTALL_DIR)/usr/bin/createdb \
176 $(PKG_INSTALL_DIR)/usr/bin/createuser \
177 $(PKG_INSTALL_DIR)/usr/bin/dropuser \
178 $(PKG_INSTALL_DIR)/usr/bin/initdb \
179 $(PKG_INSTALL_DIR)/usr/bin/pg_config \
180 $(PKG_INSTALL_DIR)/usr/bin/pg_controldata \
181 $(PKG_INSTALL_DIR)/usr/bin/pg_ctl \
182 $(PKG_INSTALL_DIR)/usr/bin/pg_dump \
183 $(PKG_INSTALL_DIR)/usr/bin/pg_dumpall \
184 $(PKG_INSTALL_DIR)/usr/bin/pg_restore \
185 $(PKG_INSTALL_DIR)/usr/bin/vacuumdb \
188 $(INSTALL_BIN) ./files/postgresql.init $(1)/etc/init.d/postgresql
191 $(PKG_INSTALL_DIR)/usr/share/postgresql/postgres.bki \
192 $(PKG_INSTALL_DIR)/usr/share/postgresql/postgres.description \
193 $(PKG_INSTALL_DIR)/usr/share/postgresql/conversion_create.sql \
194 $(PKG_INSTALL_DIR)/usr/share/postgresql/information_schema.sql \
195 $(PKG_INSTALL_DIR)/usr/share/postgresql/pg_hba.conf.sample \
196 $(PKG_INSTALL_DIR)/usr/share/postgresql/pg_ident.conf.sample \
197 $(PKG_INSTALL_DIR)/usr/share/postgresql/pg_service.conf.sample \
198 $(PKG_INSTALL_DIR)/usr/share/postgresql/postgresql.conf.sample \
199 $(PKG_INSTALL_DIR)/usr/share/postgresql/sql_features.txt \
200 $(PKG_INSTALL_DIR)/usr/share/postgresql/postgres.shdescription \
201 $(PKG_INSTALL_DIR)/usr/share/postgresql/psqlrc.sample \
202 $(PKG_INSTALL_DIR)/usr/share/postgresql/recovery.conf.sample \
203 $(PKG_INSTALL_DIR)/usr/share/postgresql/system_views.sql \
204 $(1)/usr/share/postgresql
206 $(INSTALL_DATA) ./files/postgresql.config $(1)/etc/config/postgresql
209 $(PKG_INSTALL_DIR)/usr/share/postgresql/timezone \
210 $(PKG_INSTALL_DIR)/usr/share/postgresql/timezonesets \
211 $(1)/usr/share/postgresql
214 $(PKG_INSTALL_DIR)/usr/lib/postgresql \
218 define Package/pgsql-server/postinst
220 grep -q '^postgres:' /etc/passwd && exit 0
222 if [ -e /bin/addgroup ]; then
223 /bin/addgroup postgres
226 if [ -e /bin/adduser ]; then
227 /bin/adduser -h /tmp -H -g 'PostgreSQL administrator' -s /bin/ash -D -H -G postgres postgres
232 if [ -z "$${RG}" -o -z "$${RU}" ]; then
233 echo "Could not find user utils, you will need to create the postgres user by hand"
237 if [ "$${RG}" != "0" -o "$${RU}" != "0" ]; then
238 echo "Failed to created postgres user"
243 define Build/InstallDev
244 mkdir -p $(STAGING_DIR)/usr/bin
245 $(CP) $(PKG_BUILD_DIR)/src/bin/pg_config/pg_config.host $(STAGING_DIR)/usr/bin/pg_config
246 mkdir -p $(STAGING_DIR)/usr/include
247 $(CP) $(PKG_INSTALL_DIR)/usr/include/libpq $(STAGING_DIR)/usr/include/
248 $(CP) $(PKG_INSTALL_DIR)/usr/include/libpq-fe.h $(STAGING_DIR)/usr/include/
249 $(CP) $(PKG_INSTALL_DIR)/usr/include/pg_config.h $(STAGING_DIR)/usr/include/
250 $(CP) $(PKG_INSTALL_DIR)/usr/include/postgres_ext.h $(STAGING_DIR)/usr/include/
251 $(CP) $(PKG_INSTALL_DIR)/usr/include/postgresql $(STAGING_DIR)/usr/include/
252 mkdir -p $(STAGING_DIR)/usr/lib
253 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpq.{a,so*} $(STAGING_DIR)/usr/lib/
254 $(CP) $(PKG_BUILD_DIR)/src/interfaces/ecpg/preproc/ecpg.host $(STAGING_DIR)/usr/bin/ecpg
255 $(CP) $(PKG_BUILD_DIR)/src/timezone/zic.host $(STAGING_DIR)/usr/bin/zic
258 define Build/UninstallDev
260 $(STAGING_DIR)/usr/bin/pg_config \
261 $(STAGING_DIR)/usr/include/libpq \
262 $(STAGING_DIR)/usr/include/libpq-fe.h \
263 $(STAGING_DIR)/usr/include/pg_config.h \
264 $(STAGING_DIR)/usr/include/postgres_ext.h \
265 $(STAGING_DIR)/usr/include/postgresql \
266 $(STAGING_DIR)/usr/lib/libpq.{a,so*} \
267 $(STAGING_DIR)/usr/bin/ecpg \
268 $(STAGING_DIR)/usr/bin/zic
271 $(eval $(call BuildPackage,libpq))
272 $(eval $(call BuildPackage,pgsql-cli))
273 $(eval $(call BuildPackage,pgsql-server))