@@ -14,42 +14,47 @@ LICENSE = GPLv2
1414
1515GNU_CONFIGURE = 1
1616
17- # Path to cross-compiled PostgreSQL
18- CROSS_PG_CONFIG = $(STAGING_INSTALL_PREFIX ) /bin/pg_config
17+ # Cross-compilation requires a pg_config wrapper that returns cross-compiled
18+ # paths for libraries but uses native PGXS for building
19+ PG_VERSION = 17.4
20+ PG_CONFIG_WRAPPER = $(WORK_DIR ) /pg_config_wrapper
21+ NATIVE_PG_DIR = $(realpath $(WORK_DIR ) /../../../native/postgresql/work-native/install/usr/local)
1922
20- CONFIGURE_ARGS = --with-pgconfig=$(CROSS_PG_CONFIG )
23+ CONFIGURE_ARGS = --with-pgconfig=$(PG_CONFIG_WRAPPER )
2124CONFIGURE_ARGS += --with-geosconfig=$(STAGING_INSTALL_PREFIX ) /bin/geos-config
2225CONFIGURE_ARGS += --with-projdir=$(STAGING_INSTALL_PREFIX )
23-
24- # Provide PROJ version to avoid cross-compilation test failure
2526CONFIGURE_ARGS += PROJ_VERSION=8.2.1
26-
2727CONFIGURE_ARGS += --without-raster
2828CONFIGURE_ARGS += --without-protobuf
2929CONFIGURE_ARGS += --without-gui
3030CONFIGURE_ARGS += --without-topology
31+ # SSL libraries needed for libpq link check
32+ CONFIGURE_ARGS += LIBS="-lssl -lcrypto -lpthread -lm"
3133
32- # Disable parallel build to avoid race conditions in SQL file generation
33- COMPILE_MAKE_OPTIONS = -j1
34+ # Disable parallel build (SQL file generation race conditions)
35+ # Override CC since PGXS hardcodes gcc
36+ COMPILE_MAKE_OPTIONS = -j1 CC="$(TC_PATH )$(TC_PREFIX ) gcc"
3437
35- # Override install to use a custom target that handles PGXS path issues
36- # PostGIS uses PGXS which gets paths from pg_config. The cross-compiled
37- # pg_config returns paths with INSTALL_DIR baked in (e.g., /workspace/.../install/var/packages/...)
38- # Since these paths already contain the install directory, we use DESTDIR=""
39- # and PostGIS will install directly to the correct staging location.
38+ PRE_CONFIGURE_TARGET = postgis_pre_configure
4039INSTALL_TARGET = postgis_install
4140
4241include ../../mk/spksrc.cross-cc.mk
4342
43+ .PHONY : postgis_pre_configure
44+ postgis_pre_configure :
45+ @# Fix PostGIS configure to preserve LIBS during libpq check
46+ sed -i ' s/LIBS="$$PGSQL_FE_LDFLAGS"/LIBS="$$PGSQL_FE_LDFLAGS $$LIBS"/g' $(WORK_DIR ) /$(PKG_DIR ) /configure
47+ @# Create pg_config wrapper from template
48+ sed -e ' s|@NATIVE_PG_DIR@|$(NATIVE_PG_DIR)|g' \
49+ -e ' s|@PG_VERSION@|$(PG_VERSION)|g' \
50+ -e ' s|@CROSS_PG_INCLUDEDIR@|$(STAGING_INSTALL_PREFIX)/include|g' \
51+ -e ' s|@CROSS_PG_LIBDIR@|$(STAGING_INSTALL_PREFIX)/lib|g' \
52+ -e ' s|@CROSS_PG_SHAREDIR@|$(STAGING_INSTALL_PREFIX)/share|g' \
53+ -e ' s|@CROSS_PG_BINDIR@|$(STAGING_INSTALL_PREFIX)/bin|g' \
54+ -e ' s|@CROSS_CC@|$(TC_PATH)$(TC_PREFIX)gcc|g' \
55+ $(CURDIR ) /src/pg_config_wrapper.sh.in > $(PG_CONFIG_WRAPPER )
56+ chmod +x $(PG_CONFIG_WRAPPER )
57+
4458.PHONY : postgis_install
4559postgis_install :
46- @echo " Installing PostGIS with custom target..."
4760 $(RUN ) $(MAKE ) install DESTDIR=" "
48- @# Verify PostGIS files were installed
49- @PKGLIBDIR=$$($(CROSS_PG_CONFIG ) --pkglibdir) ; \
50- if [ -f " $$ PKGLIBDIR/postgis-3.so" ]; then \
51- echo " PostGIS installation verified: $$ PKGLIBDIR/postgis-3.so" ; \
52- else \
53- echo " ERROR: PostGIS shared library not found at $$ PKGLIBDIR" ; \
54- exit 1; \
55- fi
0 commit comments