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