File ghc-aeson-pretty.spec of Package ghc-aeson-pretty

# SPDX-License-Identifier: BSD-3-Clause
#
# Minimal spec focused on building the library component and fixing
# the GHC flag issue (-fobject-determinism) by not passing it.

Name:           ghc-aeson-pretty
Version:        0.8.10
Release:        1.1
Summary:        Pretty-printing for aeson Values
License:        BSD-3-Clause
URL:            https://hackage.haskell.org/package/aeson-pretty
Source0:        aeson-pretty-%{version}.tar.gz

# Core toolchain
BuildRequires:  ghc-compiler
BuildRequires:  ghc-Cabal-devel

# Library dependencies (already present in build root, but list for clarity)
BuildRequires:  ghc-aeson-devel
BuildRequires:  ghc-attoparsec-devel
BuildRequires:  ghc-prettyprinter-devel
BuildRequires:  ghc-unordered-containers-devel
BuildRequires:  ghc-vector-devel
BuildRequires:  ghc-scientific-devel
BuildRequires:  ghc-text-devel
BuildRequires:  ghc-bytestring-devel
BuildRequires:  ghc-containers-devel
BuildRequires:  ghc-hashable-devel

%description
aeson-pretty provides pretty-printing of aeson JSON Values.

%prep
%setup -q -n aeson-pretty-%{version}

%build
# Build the Setup helper using the Cabal library
ghc --make -package Cabal -no-user-package-db -dynamic Setup

# Determine GHC version and libdir suffix
GHCV="$(ghc --numeric-version)"
# Default to lib64 on 64-bit, otherwise lib
if [ -d /usr/lib64 ]; then
  GHLIBDIR="/usr/lib64/ghc-${GHCV}/lib"
  LIBDIR="/usr/lib64"
else
  GHLIBDIR="/usr/lib/ghc-${GHCV}/lib"
  LIBDIR="/usr/lib"
fi

# Configure. Important: do NOT pass the unrecognized -fobject-determinism flag.
LANG=C.utf8 \
./Setup configure \
  --prefix=/usr \
  --libdir="${LIBDIR}" \
  --docdir=/usr/share/licenses/%{name} \
  --dynlibdir="${GHLIBDIR}" \
  --global \
  --ghc \
  --enable-library-profiling \
  --enable-shared \
  -f+lib-only \
  --libsubdir='$compiler/lib/$pkgid' \
  --datasubdir='$pkgid' \
  --libexecsubdir='$pkgid' \
  --ghc-options='-fhide-source-paths'

LANG=C.utf8 ./Setup build

%install
rm -rf %{buildroot}

# Use same libdir computation as in %build
GHCV="$(ghc --numeric-version)"
if [ -d /usr/lib64 ]; then
  GHLIBDIR="/usr/lib64/ghc-${GHCV}/lib"
  LIBDIR="/usr/lib64"
else
  GHLIBDIR="/usr/lib/ghc-${GHCV}/lib"
  LIBDIR="/usr/lib"
fi

# Install into buildroot
./Setup copy --destdir=%{buildroot}

# Ensure licensing/doc directory exists if not created by Setup
mkdir -p %{buildroot}/usr/share/licenses/%{name}
# Copy license files if present
for f in LICENSE LICENSE* COPYING COPYING*; do
  if [ -f "$f" ]; then
    install -m0644 "$f" %{buildroot}/usr/share/licenses/%{name}/ || :
  fi
done

%files
%license /usr/share/licenses/%{name}/*
/usr/lib*/ghc-*/lib/*

%changelog
* Mon Sep 22 2025 Build Fixer <noreply@example.com>
- Remove unrecognized GHC flag -fobject-determinism from ghc-options to fix build with GHC 9.10.2
- Minimal spec preserving library-only build
openSUSE Build Service is sponsored by