packages: fix parallel build by adding + for every make command that passes the jobserver
[packages.git] / libs / postgresql / Makefile
1 #
2 # Copyright (C) 2006-2012 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:=9.0.1
12 PKG_RELEASE:=3
13
14 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
15 PKG_SOURCE_URL:=\
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
20 PKG_BUILD_PARALLEL:=1
21
22 include $(INCLUDE_DIR)/package.mk
23
24 define Package/libpq
25   SECTION:=libs
26   CATEGORY:=Libraries
27   DEPENDS:=+zlib +libreadline +libpthread +libncurses +shadow-su
28   TITLE:=PostgreSQL client library
29   URL:=http://www.postgresql.org/
30   SUBMENU:=database
31 endef
32
33 define Package/libpq/description
34 PostgreSQL client library.
35 endef
36
37 define Package/pgsql-cli
38   SECTION:=utils
39   CATEGORY:=Utilities
40   DEPENDS:=+libpq
41   TITLE:=Command Line Interface (CLI) to PostgreSQL databases
42   URL:=http://www.postgresql.org/
43   SUBMENU:=database
44 endef
45
46 define Package/pgsql-cli/description
47 Command Line Interface (CLI) to PostgreSQL databases.
48 endef
49
50 define Package/pgsql-server
51   SECTION:=utils
52   CATEGORY:=Utilities
53   DEPENDS:=+libpq
54   TITLE:=PostgreSQL databases Server
55   URL:=http://www.postgresql.org/
56   SUBMENU:=database
57 endef
58
59 define Package/pgsql-server/description
60 PostgreSQL databases Server.
61 endef
62
63 # Need a native ecpg ,pg_config, and zic for build
64 define Build/Configure
65         (cd $(PKG_BUILD_DIR); rm -f config.cache; \
66                 ./configure \
67                         --prefix=/usr \
68                         --exec-prefix=/usr \
69                         --bindir=/usr/bin \
70                         --datadir=/usr/share \
71                         --includedir=/usr/include \
72                         --infodir=/usr/share/info \
73                         --libdir=/usr/lib \
74                         --libexecdir=/usr/lib \
75                         --localstatedir=/var \
76                         --mandir=/usr/share/man \
77                         --sbindir=/usr/sbin \
78                         --sysconfdir=/etc \
79                         $(DISABLE_NLS) \
80                         --enable-shared \
81                         --enable-static \
82                         --disable-integer-datetimes \
83                         --disable-rpath \
84                         --without-java \
85                         --without-krb4 \
86                         --without-krb5 \
87                         --without-openssl \
88                         --without-pam \
89                         --without-perl \
90                         --without-python \
91                         --without-readline \
92                         --without-rendezvous \
93                         --without-tcl \
94                         --without-tk \
95                         --with-zlib="yes" \
96                         --enable-depend \
97                         --with-system-timezone=/tmp \
98         );
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
110
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)" \
116                 ./configure \
117                         --target=$(GNU_TARGET_NAME) \
118                         --host=$(GNU_TARGET_NAME) \
119                         --build=$(GNU_HOST_NAME) \
120                         --program-prefix="" \
121                         --program-suffix="" \
122                         --prefix=/usr \
123                         --exec-prefix=/usr \
124                         --bindir=/usr/bin \
125                         --datadir=/usr/share \
126                         --includedir=/usr/include \
127                         --infodir=/usr/share/info \
128                         --libdir=/usr/lib \
129                         --libexecdir=/usr/lib \
130                         --localstatedir=/var \
131                         --mandir=/usr/share/man \
132                         --sbindir=/usr/sbin \
133                         --sysconfdir=/etc \
134                         $(DISABLE_NLS) \
135                         $(DISABLE_LARGEFILE) \
136                         --enable-shared \
137                         --enable-static \
138                         --disable-integer-datetimes \
139                         --disable-rpath \
140                         --without-java \
141                         --without-krb4 \
142                         --without-krb5 \
143                         --without-openssl \
144                         --without-pam \
145                         --without-perl \
146                         --without-python \
147                         --without-rendezvous \
148                         --without-tcl \
149                         --without-tk \
150                         --with-zlib="yes" \
151                         --enable-depend \
152                         $(if $(CONFIG_TARGET_avr32),--disable-spinlocks) \
153         );
154         $(SED) 's@ECPG = ../../preproc/ecpg@ECPG = ../../preproc/ecpg.host@' $(PKG_BUILD_DIR)/src/interfaces/ecpg/test/Makefile.regress
155 endef
156
157 TARGET_CFLAGS += $(FPIC)
158
159 # because PROFILE means something else in the project Makefile
160 unexport PROFILE
161
162 define Build/Compile
163         +$(MAKE) $(PKG_JOBS) -C "$(PKG_BUILD_DIR)" \
164                 DESTDIR="$(PKG_INSTALL_DIR)" \
165                 all
166         +$(MAKE) $(PKG_JOBS) -C "$(PKG_BUILD_DIR)" \
167                 DESTDIR="$(PKG_INSTALL_DIR)" \
168                 install
169 endef
170
171 define Package/libpq/install
172         $(INSTALL_DIR) $(1)/usr/lib
173         $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpq.so.* $(1)/usr/lib/
174 endef
175
176 define Package/pgsql-cli/install
177         $(INSTALL_DIR) $(1)/usr/bin
178         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/psql $(1)/usr/bin/
179 endef
180
181 define Package/pgsql-server/install
182         $(INSTALL_DIR) $(1)/usr/bin
183         $(INSTALL_DIR) $(1)/usr/share/postgresql
184         $(INSTALL_DIR) $(1)/usr/lib
185         $(INSTALL_DIR) $(1)/etc/init.d
186         $(INSTALL_DIR) $(1)/etc/config
187         $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/* $(1)/usr/bin
188         ln -sf postgres $(1)/usr/bin/postmaster
189
190         $(INSTALL_BIN) ./files/postgresql.init $(1)/etc/init.d/postgresql
191
192         $(CP) -r $(PKG_INSTALL_DIR)/usr/share/postgresql/* \
193                 $(1)/usr/share/postgresql
194
195         $(INSTALL_DATA) ./files/postgresql.config $(1)/etc/config/postgresql
196
197         $(CP) -r \
198                 $(PKG_INSTALL_DIR)/usr/lib/postgresql \
199                 $(1)/usr/lib
200 endef
201
202 define Package/pgsql-server/conffiles
203 /etc/config/postgresql
204 endef
205
206 define Package/pgsql-server/postinst
207 #!/bin/sh
208 grep -q '^postgres:' /etc/passwd && exit 0
209 group=$$(grep '^postgres:' /etc/group | cut -f3 -d:)
210 if [ -z "$${group}" ] ; then
211         group=1000
212         tst=$$(cat /etc/group | grep ":$${group}:")
213         while [ -n "$${tst}" ] ; do
214                 group=$$(($${group}+1))
215                 tst=$$(cat /etc/group | grep ":$${group}:")
216         done
217         echo "postgres:x:$${group}:" >>/etc/group
218 fi
219
220 user=$$(cat /etc/passwd | grep "^postgres:")
221 if [ -z "$${user}" ] ; then
222         num="$${group}"
223         tst=$$(cat /etc/passwd | grep ":.*:$${num}:")
224         while [ -n "$${tst}" ] ; do
225                 num=$$(($${num}+1))
226                 tst=$$(cat /etc/passwd | grep ":.*:$${num}:")
227         done
228         echo "postgres:*:$${num}:$${group}:PostgreSQL administrator:/tmp:/bin/ash" >>/etc/passwd
229 fi
230 endef
231
232 define Build/InstallDev
233         $(INSTALL_DIR) $(1)/usr/bin
234         $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/bin/pg_config/pg_config.host $(1)/usr/bin/pg_config
235         $(INSTALL_DIR) $(1)/usr/include
236         $(CP) $(PKG_INSTALL_DIR)/usr/include/libpq $(1)/usr/include/
237         $(CP) $(PKG_INSTALL_DIR)/usr/include/libpq-fe.h $(1)/usr/include/
238         $(CP) $(PKG_INSTALL_DIR)/usr/include/pg_config.h $(1)/usr/include/
239         $(CP) $(PKG_INSTALL_DIR)/usr/include/pg_config_manual.h $(1)/usr/include/
240         $(CP) $(PKG_INSTALL_DIR)/usr/include/postgres_ext.h $(1)/usr/include/
241         $(CP) $(PKG_INSTALL_DIR)/usr/include/postgresql $(1)/usr/include/
242         $(INSTALL_DIR) $(1)/usr/lib
243         $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpq.{a,so*} $(1)/usr/lib/
244         $(CP) $(PKG_BUILD_DIR)/src/interfaces/ecpg/preproc/ecpg.host $(1)/usr/bin/ecpg
245         $(CP) $(PKG_BUILD_DIR)/host-zic $(1)/usr/bin/zic
246 endef
247
248 $(eval $(call BuildPackage,libpq))
249 $(eval $(call BuildPackage,pgsql-cli))
250 $(eval $(call BuildPackage,pgsql-server))