# Description: A library for a new image format comparable to JPEG.
# URL: https://developers.google.com/speed/webp/
# Maintainer: CRUX compat-32 Team, compat-32-ports at crux dot nu
# Depends on: giflib-32 libpng-32 libtiff-32 zstd-32 libwebp
# Optional: freeglut-32 libsdl-32 ninja

name=libwebp-32
version=1.6.0
release=1
source=(https://storage.googleapis.com/downloads.webmproject.org/releases/webp/${name%-*}-$version.tar.gz)

build() {
  prt-get isinst ninja && PKGMK_LIBWEBP_32+=' -G Ninja'

prt-get isinst freeglut && ! prt-get isinst freeglut-32 && printf "\e[031mfreeglut is detected on your system, please run:
prt-get depinst freeglut-32
before continuing with libwebp-32.\033[0m\n" &&
exit 1

prt-get isinst libsdl && ! prt-get isinst libsdl-32 && printf "\e[031mlibsdl is detected on your system, please run:
prt-get depinst libsdl-32
before continuing with libwebp-32.\033[0m\n" &&
exit 1

  cmake -S ${name%-*}-$version -B build $PKGMK_LIBWEBP_32 \
    -D CMAKE_INSTALL_PREFIX="/usr" \
    -D CMAKE_INSTALL_LIBDIR="/usr/lib32" \
    -D BUILD_SHARED_LIBS=ON \
    -D CMAKE_BUILD_TYPE=Release \
    -D CMAKE_C_FLAGS_RELEASE="${CFLAGS}" \
    -D WEBP_BUILD_VWEBP=OFF \
    -Wno-dev

  cmake --build build
  DESTDIR=$PKG cmake --install build


  rm -r $PKG/usr/{bin,share,include}
}
