Browse Source

postgresql: properly handle pg_config host build

pg_config needs to be build for each target which creates some
extra complications...

Signed-off-by: Daniel Golle <daniel@makrotopia.org>
lilik-openwrt-22.03
Daniel Golle 8 years ago
parent
commit
d0c3f8b967
2 changed files with 45 additions and 8 deletions
  1. +31
    -8
      libs/postgresql/Makefile
  2. +14
    -0
      libs/postgresql/patches/020-pg_config-target-cflags.patch

+ 31
- 8
libs/postgresql/Makefile View File

@ -6,7 +6,7 @@ include $(TOPDIR)/rules.mk
PKG_NAME:=postgresql
PKG_VERSION:=9.4.12
PKG_RELEASE:=2
PKG_RELEASE:=3
PKG_MAINTAINER:=Daniel Golle <daniel@makrotopia.org>
PKG_LICENSE:=PostgreSQL
@ -79,6 +79,24 @@ define Package/pgsql-server/description
PostgreSQL databases Server.
endef
PGSQL_SERVER_BIN := \
pg_archivecleanup \
pg_basebackup \
pg_controldata \
pg_ctl \
pg_dump \
pg_dumpall \
pg_isready \
pg_receivexlog \
pg_recvlogical \
pg_resetxlog \
pg_restore \
pg_standby \
pg_upgrade \
pg_xlogdump \
postgres \
initdb
PGSQL_CLI_EXTRA_BIN := \
clusterdb \
createdb \
@ -137,16 +155,13 @@ CONFIGURE_ARGS += \
EXTRA_CFLAGS:= -I$(PKG_BUILD_DIR)/src/include/
# Need a native ecpg ,pg_config, and zic for build
# Need a native ecpg and zic for build
define Host/Compile
$(MAKE) -C $(HOST_BUILD_DIR)/src/interfaces/ecpg/preproc CC="$(HOSTCC)"
$(MAKE) -C $(HOST_BUILD_DIR)/src/timezone CC="$(HOSTCC)"
$(MAKE) -C $(HOST_BUILD_DIR)/src/bin/pg_config CC="$(HOSTCC)"
endef
define Host/Install
$(INSTALL_DIR) $(STAGING_DIR)/host/bin/
$(INSTALL_BIN) $(HOST_BUILD_DIR)/src/bin/pg_config/pg_config $(STAGING_DIR)/host/bin/
$(INSTALL_DIR) $(STAGING_DIR_HOSTPKG)/bin/
$(INSTALL_BIN) $(HOST_BUILD_DIR)/src/interfaces/ecpg/preproc/ecpg $(STAGING_DIR_HOSTPKG)/bin/
$(INSTALL_BIN) $(HOST_BUILD_DIR)/src/timezone/zic $(STAGING_DIR_HOSTPKG)/bin/
@ -157,6 +172,12 @@ define Build/Configure
$(SED) 's@ECPG = ../../preproc/ecpg@ECPG = $(STAGING_DIR_HOSTPKG)/bin/ecpg@' $(PKG_BUILD_DIR)/src/interfaces/ecpg/test/Makefile.regress
endef
define Build/Compile
$(call Build/Compile/Default, )
$(MAKE) -C $(PKG_BUILD_DIR)/src/bin/pg_config clean
$(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)"
endef
TARGET_CFLAGS += $(FPIC) -lpthread
# because PROFILE means something else in the project Makefile
@ -179,8 +200,8 @@ endef
define Package/pgsql-server/install
$(INSTALL_DIR) $(1)/usr/bin
$(INSTALL_BIN) $(PKG_INSTALL_DIR)/usr/bin/pg_* $(PKG_INSTALL_DIR)/usr/bin/postgres \
$(PKG_INSTALL_DIR)/usr/bin/initdb $(1)/usr/bin/
$(INSTALL_BIN) $(foreach bin,$(PGSQL_SERVER_BIN),$(PKG_INSTALL_DIR)/usr/bin/$(bin)) $(1)/usr/bin/
ln -sf postgres $(1)/usr/bin/postmaster
$(INSTALL_DIR) $(1)/usr/share/postgresql
@ -203,7 +224,9 @@ endef
define Build/InstallDev
$(INSTALL_DIR) $(1)/usr/bin
$(LN) $(STAGING_DIR)/host/bin/pg_config $(1)/usr/bin
$(INSTALL_BIN) $(PKG_BUILD_DIR)/src/bin/pg_config/pg_config $(1)/usr/bin/
$(INSTALL_DIR) $(1)/host/bin/
$(LN) $(STAGING_DIR)/usr/bin/pg_config $(1)/host/bin
$(INSTALL_DIR) $(1)/usr/include
$(CP) $(PKG_INSTALL_DIR)/usr/include/libpq $(1)/usr/include/
$(CP) $(PKG_INSTALL_DIR)/usr/include/libpq-fe.h $(1)/usr/include/


+ 14
- 0
libs/postgresql/patches/020-pg_config-target-cflags.patch View File

@ -0,0 +1,14 @@
--- a/src/bin/pg_config/Makefile
+++ b/src/bin/pg_config/Makefile
@@ -22,9 +22,9 @@ STD_CPPFLAGS := $(filter-out -I$(top_src
STD_LDFLAGS := $(filter-out -L$(top_builddir)/src/port,$(LDFLAGS))
override CPPFLAGS += -DVAL_CONFIGURE="\"$(configure_args)\""
-override CPPFLAGS += -DVAL_CC="\"$(CC)\""
+override CPPFLAGS += -DVAL_CC="\"$(TARGET_CC)\""
override CPPFLAGS += -DVAL_CPPFLAGS="\"$(STD_CPPFLAGS)\""
-override CPPFLAGS += -DVAL_CFLAGS="\"$(CFLAGS)\""
+override CPPFLAGS += -DVAL_CFLAGS="\"$(TARGET_CFLAGS)\""
override CPPFLAGS += -DVAL_CFLAGS_SL="\"$(CFLAGS_SL)\""
override CPPFLAGS += -DVAL_LDFLAGS="\"$(STD_LDFLAGS)\""
override CPPFLAGS += -DVAL_LDFLAGS_EX="\"$(LDFLAGS_EX)\""

Loading…
Cancel
Save