2 # Copyright (C) 2006-2010 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
8 include $(TOPDIR
)/rules.mk
14 PKG_SOURCE
:=$(PKG_NAME
)-$(PKG_VERSION
).
tar.bz2
16 http
://ftp9.us.postgresql.org
/pub
/mirrors
/postgresql
/source
/v
$(PKG_VERSION
) \
17 http
://ftp.be.postgresql.org
/postgresql
/source
/v
$(PKG_VERSION
) \
18 ftp
://ftp-archives.postgresql.org
/pub
/source
/v
$(PKG_VERSION
)
19 PKG_MD5SUM
:=57ba57e43cfe29e16dacbf5789be98d1
22 include $(INCLUDE_DIR
)/package.mk
27 DEPENDS
:=+zlib
+libreadline
+libncurses
+coreutils-su
28 TITLE
:=PostgreSQL client library
29 URL
:=http
://www.postgresql.org
/
33 define Package
/libpq
/description
34 PostgreSQL client library.
37 define Package
/pgsql-cli
41 TITLE
:=Command Line Interface
(CLI
) to PostgreSQL databases
42 URL
:=http
://www.postgresql.org
/
46 define Package
/pgsql-cli
/description
47 Command Line Interface
(CLI
) to PostgreSQL databases.
50 define Package
/pgsql-server
54 TITLE
:=PostgreSQL databases Server
55 URL
:=http
://www.postgresql.org
/
59 define Package
/pgsql-server
/description
60 PostgreSQL databases Server.
63 # Need a native ecpg ,pg_config, and zic for build
64 define Build
/Configure
65 (cd
$(PKG_BUILD_DIR
); rm -f config.cache
; \
70 --datadir=/usr
/share \
71 --includedir=/usr
/include \
72 --infodir=/usr
/share
/info \
74 --libexecdir
=/usr
/lib \
75 --localstatedir
=/var \
76 --mandir=/usr
/share
/man \
82 --disable-integer-datetimes \
92 --without-rendezvous \
97 --with-system-timezone
=/tmp \
99 $(MAKE
) -C
$(PKG_BUILD_DIR
)/src
/interfaces
/ecpg
/preproc CC
="$(HOSTCC)" CFLAGS
+="-I../../libpq"
100 mv
$(PKG_BUILD_DIR
)/src
/interfaces
/ecpg
/preproc
/ecpg \
101 $(PKG_BUILD_DIR
)/src
/interfaces
/ecpg
/preproc
/ecpg.host
102 $(MAKE
) -C
$(PKG_BUILD_DIR
)/src
/timezone CC
="$(HOSTCC)"
103 mv
$(PKG_BUILD_DIR
)/src
/timezone
/zic
$(PKG_BUILD_DIR
)/host-zic
104 $(INSTALL_DIR
) $(STAGING_DIR
)/host
/bin
/
105 $(CP
) $(PKG_BUILD_DIR
)/host-zic
$(STAGING_DIR
)/host
/bin
/zic
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
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)" \
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 \
152 $(if
$(CONFIG_TARGET_avr32
),--disable-spinlocks
) \
154 $(SED
) 's@ECPG = ../../preproc/ecpg@ECPG = ../../preproc/ecpg.host@' $(PKG_BUILD_DIR
)/src
/interfaces
/ecpg
/test/Makefile.regress
157 TARGET_CFLAGS
+= $(FPIC
)
160 $(MAKE
) $(PKG_JOBS
) -C
"$(PKG_BUILD_DIR)" \
161 DESTDIR
="$(PKG_INSTALL_DIR)" \
163 $(MAKE
) $(PKG_JOBS
) -C
"$(PKG_BUILD_DIR)" \
164 DESTDIR
="$(PKG_INSTALL_DIR)" \
168 define Package
/libpq
/install
169 $(INSTALL_DIR
) $(1)/usr
/lib
170 $(CP
) $(PKG_INSTALL_DIR
)/usr
/lib
/libpq.so.
* $(1)/usr
/lib
/
173 define Package
/pgsql-cli
/install
174 $(INSTALL_DIR
) $(1)/usr
/bin
175 $(INSTALL_BIN
) $(PKG_INSTALL_DIR
)/usr
/bin
/psql
$(1)/usr
/bin
/
178 define Package
/pgsql-server
/install
179 $(INSTALL_DIR
) $(1)/usr
/bin
180 $(INSTALL_DIR
) $(1)/usr
/share
/postgresql
181 $(INSTALL_DIR
) $(1)/usr
/lib
182 $(INSTALL_DIR
) $(1)/etc
/init.d
183 $(INSTALL_DIR
) $(1)/etc
/config
184 $(INSTALL_BIN
) $(PKG_INSTALL_DIR
)/usr
/bin
/* $(1)/usr
/bin
185 ln
-sf postgres
$(1)/usr
/bin
/postmaster
187 $(INSTALL_BIN
) .
/files
/postgresql.init
$(1)/etc
/init.d
/postgresql
189 $(CP
) -r
$(PKG_INSTALL_DIR
)/usr
/share
/postgresql
/* \
190 $(1)/usr
/share
/postgresql
192 $(INSTALL_DATA
) .
/files
/postgresql.config
$(1)/etc
/config
/postgresql
195 $(PKG_INSTALL_DIR
)/usr
/lib
/postgresql \
199 define Package
/pgsql-server
/postinst
201 grep
-q
'^postgres:' /etc
/passwd
&& exit
0
202 group
=$$(grep
'^postgres:' /etc
/group | cut
-f3
-d
:)
203 if
[ -z
"$${group}" ] ; then
205 tst
=$$(cat
/etc
/group | grep
":$${group}:")
206 while
[ -n
"$${tst}" ] ; do
207 group
=$$(($${group}+1))
208 tst
=$$(cat
/etc
/group | grep
":$${group}:")
210 echo
"postgres:x:$${group}:" >>/etc
/group
213 user
=$$(cat
/etc
/passwd | grep
"^postgres:")
214 if
[ -z
"$${user}" ] ; then
216 tst
=$$(cat
/etc
/passwd | grep
":.*:$${num}:")
217 while
[ -n
"$${tst}" ] ; do
219 tst
=$$(cat
/etc
/passwd | grep
":.*:$${num}:")
221 echo
"postgres:*:$${num}:$${group}:PostgreSQL administrator:/tmp:/bin/ash" >>/etc
/passwd
225 define Build
/InstallDev
226 $(INSTALL_DIR
) $(1)/usr
/bin
227 $(INSTALL_BIN
) $(PKG_BUILD_DIR
)/src
/bin
/pg_config
/pg_config.host
$(1)/usr
/bin
/pg_config
228 $(INSTALL_DIR
) $(1)/usr
/include
229 $(CP
) $(PKG_INSTALL_DIR
)/usr
/include/libpq
$(1)/usr
/include/
230 $(CP
) $(PKG_INSTALL_DIR
)/usr
/include/libpq-fe.h
$(1)/usr
/include/
231 $(CP
) $(PKG_INSTALL_DIR
)/usr
/include/pg_config.h
$(1)/usr
/include/
232 $(CP
) $(PKG_INSTALL_DIR
)/usr
/include/pg_config_manual.h
$(1)/usr
/include/
233 $(CP
) $(PKG_INSTALL_DIR
)/usr
/include/postgres_ext.h
$(1)/usr
/include/
234 $(CP
) $(PKG_INSTALL_DIR
)/usr
/include/postgresql
$(1)/usr
/include/
235 $(INSTALL_DIR
) $(1)/usr
/lib
236 $(CP
) $(PKG_INSTALL_DIR
)/usr
/lib
/libpq.
{a
,so
*} $(1)/usr
/lib
/
237 $(CP
) $(PKG_BUILD_DIR
)/src
/interfaces
/ecpg
/preproc
/ecpg.host
$(1)/usr
/bin
/ecpg
238 $(CP
) $(PKG_BUILD_DIR
)/host-zic
$(1)/usr
/bin
/zic
241 $(eval
$(call BuildPackage
,libpq
))
242 $(eval
$(call BuildPackage
,pgsql-cli
))
243 $(eval
$(call BuildPackage
,pgsql-server
))