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