postgresql: properly handle pg_config host build
[feed/packages.git] / libs / postgresql / Makefile
1 # This is free software, licensed under the GNU General Public License v2.
2 # See /LICENSE for more information.
3 #
4
5 include $(TOPDIR)/rules.mk
6
7 PKG_NAME:=postgresql
8 PKG_VERSION:=9.4.12
9 PKG_RELEASE:=3
10 PKG_MAINTAINER:=Daniel Golle <daniel@makrotopia.org>
11 PKG_LICENSE:=PostgreSQL
12
13 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
14 PKG_SOURCE_URL:=\
15 https://ftp.postgresql.org/pub/source/v$(PKG_VERSION) \
16 http://ftp.postgresql.org/pub/source/v$(PKG_VERSION) \
17 ftp://ftp.postgresql.org/pub/source/v$(PKG_VERSION)
18 PKG_MD5SUM:=fca055481875d1c49e31c28443f56472a1474b3fbe25b7ae64440c6118f82e64
19
20 PKG_USE_MIPS16:=0
21 PKG_FIXUP:=autoreconf
22 PKG_MACRO_PATHS:=config
23 PKG_BUILD_DEPENDS += postgresql/host
24 PKG_INSTALL:=1
25
26 include $(INCLUDE_DIR)/host-build.mk
27 include $(INCLUDE_DIR)/package.mk
28
29 define Package/libpq
30 SECTION:=libs
31 CATEGORY:=Libraries
32 DEPENDS:=+zlib +libreadline +libpthread +libncursesw
33 TITLE:=PostgreSQL client library
34 URL:=http://www.postgresql.org/
35 SUBMENU:=database
36 endef
37
38 define Package/libpq/description
39 PostgreSQL client library.
40 endef
41
42 define Package/pgsql-cli
43 SECTION:=utils
44 CATEGORY:=Utilities
45 DEPENDS:=+libpq +librt
46 TITLE:=Command Line Interface (CLI) to PostgreSQL databases
47 URL:=http://www.postgresql.org/
48 SUBMENU:=database
49 endef
50
51 define Package/pgsql-cli/description
52 Command Line Interface (CLI) to PostgreSQL databases.
53 endef
54
55 define Package/pgsql-cli-extra
56 SECTION:=utils
57 CATEGORY:=Utilities
58 DEPENDS:=+libpq +librt
59 TITLE:=Command Line extras for PostgreSQL databases
60 URL:=http://www.postgresql.org/
61 SUBMENU:=database
62 endef
63
64 define Package/pgsql-cli-extra/description
65 Command Line extras for PostgreSQL databases.
66 endef
67
68 define Package/pgsql-server
69 SECTION:=utils
70 CATEGORY:=Utilities
71 DEPENDS:=+libpq +librt +pgsql-cli
72 TITLE:=PostgreSQL databases Server
73 URL:=http://www.postgresql.org/
74 SUBMENU:=database
75 USERID:=postgres=5432:postgres=5432
76 endef
77
78 define Package/pgsql-server/description
79 PostgreSQL databases Server.
80 endef
81
82 PGSQL_SERVER_BIN := \
83 pg_archivecleanup \
84 pg_basebackup \
85 pg_controldata \
86 pg_ctl \
87 pg_dump \
88 pg_dumpall \
89 pg_isready \
90 pg_receivexlog \
91 pg_recvlogical \
92 pg_resetxlog \
93 pg_restore \
94 pg_standby \
95 pg_upgrade \
96 pg_xlogdump \
97 postgres \
98 initdb
99
100 PGSQL_CLI_EXTRA_BIN := \
101 clusterdb \
102 createdb \
103 createlang \
104 createuser \
105 dropdb \
106 droplang \
107 dropuser \
108 pgbench \
109 reindexdb \
110 vacuumdb
111
112 PGSQL_CONFIG_VARS:= \
113 pgac_cv_snprintf_long_long_int_format="%lld" \
114 pgac_cv_snprintf_size_t_support=yes
115
116 ifeq ($(CONFIG_USE_UCLIBC),y)
117 # PostgreSQL does not build against uClibc with locales
118 # enabled, due to an uClibc bug, see
119 # http://lists.uclibc.org/pipermail/uclibc/2014-April/048326.html
120 # so overwrite automatic detection and disable locale support
121 PGSQL_CONFIG_VARS+= \
122 pgac_cv_type_locale_t=no
123 endif
124
125 TARGET_CONFIGURE_OPTS+=$(PGSQL_CONFIG_VARS)
126
127 HOST_CONFIGURE_ARGS += \
128 $(DISABLE_NLS) \
129 --disable-rpath \
130 --without-bonjour \
131 --without-gssapi \
132 --without-ldap \
133 --without-openssl \
134 --without-pam \
135 --without-perl \
136 --without-python \
137 --without-readline \
138 --without-tcl \
139 --with-zlib="yes" \
140 --enable-depend
141
142 CONFIGURE_ARGS += \
143 --disable-rpath \
144 --without-bonjour \
145 --without-gssapi \
146 --without-ldap \
147 --without-openssl \
148 --without-pam \
149 --without-perl \
150 --without-python \
151 --without-tcl \
152 --with-zlib="yes" \
153 --enable-depend \
154 $(if $(CONFIG_TARGET_avr32),--disable-spinlocks)
155
156 EXTRA_CFLAGS:= -I$(PKG_BUILD_DIR)/src/include/
157
158 # Need a native ecpg and zic for build
159 define Host/Compile
160 $(MAKE) -C $(HOST_BUILD_DIR)/src/interfaces/ecpg/preproc CC="$(HOSTCC)"
161 $(MAKE) -C $(HOST_BUILD_DIR)/src/timezone CC="$(HOSTCC)"
162 endef
163
164 define Host/Install
165 $(INSTALL_DIR) $(STAGING_DIR_HOSTPKG)/bin/
166 $(INSTALL_BIN) $(HOST_BUILD_DIR)/src/interfaces/ecpg/preproc/ecpg $(STAGING_DIR_HOSTPKG)/bin/
167 $(INSTALL_BIN) $(HOST_BUILD_DIR)/src/timezone/zic $(STAGING_DIR_HOSTPKG)/bin/
168 endef
169
170 define Build/Configure
171 $(Build/Configure/Default)
172 $(SED) 's@ECPG = ../../preproc/ecpg@ECPG = $(STAGING_DIR_HOSTPKG)/bin/ecpg@' $(PKG_BUILD_DIR)/src/interfaces/ecpg/test/Makefile.regress
173 endef
174
175 define Build/Compile
176 $(call Build/Compile/Default, )
177 $(MAKE) -C $(PKG_BUILD_DIR)/src/bin/pg_config clean
178 $(MAKE) -C $(PKG_BUILD_DIR)/src/bin/pg_config CC="$(HOSTCC)" TARGET_CC="$(TARGET_CC)" CFLAGS="$(HOST_CFLAGS)" TARGET_CFLAGS="$(TARGET_CFLAGS)" LDFLAGS="$(HOST_LDFLAGS)" STD_LDFLAGS="$(TARGET_LDFLAGS)"
179 endef
180
181 TARGET_CFLAGS += $(FPIC) -lpthread
182
183 # because PROFILE means something else in the project Makefile
184 unexport PROFILE
185
186 define Package/libpq/install
187 $(INSTALL_DIR) $(1)/usr/lib
188 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpq.so.* $(1)/usr/lib/
189 endef
190
191 define Package/pgsql-cli/install
192 $(INSTALL_DIR) $(1)/usr/bin
193 $(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/psql $(1)/usr/bin/
194 endef
195
196 define Package/pgsql-cli-extra/install
197 $(INSTALL_DIR) $(1)/usr/bin
198 $(INSTALL_BIN) $(foreach bin,$(PGSQL_CLI_EXTRA_BIN),$(PKG_INSTALL_DIR)/usr/bin/$(bin)) $(1)/usr/bin/
199 endef
200
201 define Package/pgsql-server/install
202 $(INSTALL_DIR) $(1)/usr/bin
203 $(INSTALL_BIN) $(foreach bin,$(PGSQL_SERVER_BIN),$(PKG_INSTALL_DIR)/usr/bin/$(bin)) $(1)/usr/bin/
204
205 ln -sf postgres $(1)/usr/bin/postmaster
206
207 $(INSTALL_DIR) $(1)/usr/share/postgresql
208 $(CP) $(PKG_INSTALL_DIR)/usr/share/postgresql/* \
209 $(1)/usr/share/postgresql
210
211 $(INSTALL_DIR) $(1)/usr/lib
212 $(CP) $(PKG_INSTALL_DIR)/usr/lib/postgresql \
213 $(1)/usr/lib/
214
215 $(INSTALL_DIR) $(1)/lib/functions
216 $(INSTALL_BIN) ./files/postgresql.sh $(1)/lib/functions/
217
218 $(INSTALL_DIR) $(1)/etc/config
219 $(INSTALL_DATA) ./files/postgresql.config $(1)/etc/config/postgresql
220
221 $(INSTALL_DIR) $(1)/etc/init.d
222 $(INSTALL_BIN) ./files/postgresql.init $(1)/etc/init.d/postgresql
223 endef
224
225 define Build/InstallDev
226 $(INSTALL_DIR) $(1)/usr/bin
227 $(INSTALL_BIN) $(PKG_BUILD_DIR)/src/bin/pg_config/pg_config $(1)/usr/bin/
228 $(INSTALL_DIR) $(1)/host/bin/
229 $(LN) $(STAGING_DIR)/usr/bin/pg_config $(1)/host/bin
230 $(INSTALL_DIR) $(1)/usr/include
231 $(CP) $(PKG_INSTALL_DIR)/usr/include/libpq $(1)/usr/include/
232 $(CP) $(PKG_INSTALL_DIR)/usr/include/libpq-fe.h $(1)/usr/include/
233 $(CP) $(PKG_INSTALL_DIR)/usr/include/pg_config.h $(1)/usr/include/
234 $(CP) $(PKG_INSTALL_DIR)/usr/include/pg_config_manual.h $(1)/usr/include/
235 $(CP) $(PKG_INSTALL_DIR)/usr/include/postgres_ext.h $(1)/usr/include/
236 $(CP) $(PKG_INSTALL_DIR)/usr/include/pg_config_ext.h $(1)/usr/include/
237 $(CP) $(PKG_INSTALL_DIR)/usr/include/postgresql $(1)/usr/include/
238 $(INSTALL_DIR) $(1)/usr/lib
239 $(CP) $(PKG_INSTALL_DIR)/usr/lib/libpq.{a,so*} $(1)/usr/lib/
240 endef
241
242 $(eval $(call HostBuild))
243 $(eval $(call BuildPackage,libpq))
244 $(eval $(call BuildPackage,pgsql-cli))
245 $(eval $(call BuildPackage,pgsql-cli-extra))
246 $(eval $(call BuildPackage,pgsql-server))