File pgvector.spec of Package failed_pgvector_postgresql17

Name:           pgvector
Version:        0.8.0
Release:        1.1
Summary:        Vector data type for PostgreSQL

License:        MIT
URL:            https://github.com/pgvector/pgvector
Source0:        pgvector-%{version}.tar.gz

%define         pg_name  postgresql17%{nil}

BuildRequires:  make
BuildRequires:  gcc
BuildRequires:  libxml2-devel
BuildRequires:  postgresql%{pg_name}-devel

Provides:       pgvector = %{version}-%{release}
Requires:       postgresql%{pg_name}

%description
pgvector provides a vector data type for PostgreSQL and functions to work with vector embeddings.

%prep
%setup -q

%build
# When cross-compiling (e.g. for riscv64) the global build flags may include
# "-march=native". On cross-build hosts that's invalid for GCC (it expects
# an ISA string starting with rv32 or rv64). Strip any occurrence of
# -march=native from the CFLAGS/OPTFLAGS so the extension builds correctly.
if [ -n "$CFLAGS" ]; then
  CFLAGS="$(echo "$CFLAGS" | sed -e 's/-march=native//g')"
  export CFLAGS
fi
if [ -n "$OPTFLAGS" ]; then
  OPTFLAGS="$(echo "$OPTFLAGS" | sed -e 's/-march=native//g')"
  export OPTFLAGS
fi

# Use the standard PGXS build for postgres extensions.
make USE_PGXS=1 %{?_smp_mflags}

%install
rm -rf %{buildroot}
make USE_PGXS=1 DESTDIR=%{buildroot} install

%files
%doc README.md
%license LICENSE*
%{_libdir}/postgresql/*/extension/*
%{_libdir}/postgresql/*/tsearch/*
%{_libdir}/postgresql/*/pgvector*
%{_datadir}/postgresql/extension/pgvector.control

%changelog
* Mon Aug 11 2025 Packager <packager@example.com> - 0.8.0-1.1
- Strip -march=native in %build to allow cross-building for architectures
  where -march=native is not a valid ISA string (e.g. riscv64).
openSUSE Build Service is sponsored by