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