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