# Maintainer: Peter Budai _realname=libgd pkgbase=mingw-w64-${_realname} pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}" pkgver=2.3.2 pkgrel=10 pkgdesc="GD is an open source code library for the dynamic creation of images by programmers (mingw-w64)" arch=('any') mingw_arch=('mingw64' 'ucrt64' 'clang64' 'clangarm64') msys2_references=( 'archlinux: gd' 'cpe: cpe:/a:libgd:libgd' ) url="https://libgd.github.io/" msys2_repository_url='https://github.com/libgd/libgd' license=("custom") depends=("${MINGW_PACKAGE_PREFIX}-libpng" "${MINGW_PACKAGE_PREFIX}-libiconv" "${MINGW_PACKAGE_PREFIX}-libjpeg" "${MINGW_PACKAGE_PREFIX}-libtiff" "${MINGW_PACKAGE_PREFIX}-libavif" "${MINGW_PACKAGE_PREFIX}-libheif" "${MINGW_PACKAGE_PREFIX}-freetype" "${MINGW_PACKAGE_PREFIX}-fontconfig" "${MINGW_PACKAGE_PREFIX}-libimagequant" "${MINGW_PACKAGE_PREFIX}-libwebp" "${MINGW_PACKAGE_PREFIX}-xpm-nox" "${MINGW_PACKAGE_PREFIX}-zlib") replaces=("${MINGW_PACKAGE_PREFIX}-gd") makedepends=("${MINGW_PACKAGE_PREFIX}-cc" "${MINGW_PACKAGE_PREFIX}-cmake" "${MINGW_PACKAGE_PREFIX}-ninja") source=("https://github.com/libgd/libgd/releases/download/gd-${pkgver}/${_realname}-${pkgver}.tar.gz" "libgd-export-pkg-config-build-in-subdirs.patch" "mingw-replace-posix_memalign.patch" "mingw-getline-link.patch") sha256sums=('ee0c74852c102140fc590541950127b63a3c6fa4592305c16738d23ed65f8ac3' 'cd8b1a2dc1515d717c7359d787ff08138af449512ed9280859b5a630886a65e1' 'c3e69c7e59c280e5cc561c984c906b5cfa5ee56aff0b173c0febfdbf90cb048f' 'b52ec6485d43b511b9b399cda41fc85d5f15f5ebccad1dfc76bb89b451aae512') prepare() { cd "${srcdir}/${_realname}-${pkgver}" #This patch actually does more than simply export dirs into a subdir #It also is responsible for creating the pkg_config file and now also #the gdlib-config file that some build scripts seem to still require #in spite of that mechanism being depreciated. patch -Nbp1 -i "${srcdir}/libgd-export-pkg-config-build-in-subdirs.patch" patch -Nbp1 -i "${srcdir}/mingw-replace-posix_memalign.patch" patch -Nbp1 -i "${srcdir}/mingw-getline-link.patch" sed -i "s/libavif 0.8.2 /libavif /" CMakeLists.txt } build() { mkdir -p "${srcdir}"/build-${MSYSTEM} && cd "${srcdir}"/build-${MSYSTEM} MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \ ${MINGW_PREFIX}/bin/cmake.exe \ -GNinja \ -DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \ -DBUILD_{SHARED,STATIC}_LIBS=ON \ -DENABLE_AVIF=ON \ -DENABLE_HEIF=ON \ -DENABLE_FONTCONFIG=ON \ -DENABLE_PNG=ON \ -DENABLE_JPEG=ON \ -DENABLE_TIFF=ON \ -DENABLE_ICONV=ON \ -DENABLE_XPM=ON \ -DENABLE_FREETYPE=ON \ -DENABLE_WEBP=ON \ -DENABLE_GD_FORMATS=ON \ -DENABLE_LIQ=ON \ -DLIQ_INCLUDE_DIR="${MINGW_PREFIX}/include/libimagequant" \ -DXPM_XPM_INCLUDE_DIR="${MINGW_PREFIX}/include/X11" \ -DWEBP_INCLUDE_DIR="${MINGW_PREFIX}/include/webp/" \ -DFREETYPE_INCLUDE_DIR_freetype2="${MINGW_PREFIX}/include/freetype2" \ -DFREETYPE_INCLUDE_DIRS="${MINGW_PREFIX}/include/freetype2" \ ../${_realname}-${pkgver} ${MINGW_PREFIX}/bin/cmake --build ./ } package() { cd "${srcdir}/build-${MSYSTEM}" DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/cmake --install . install -Dm644 "${srcdir}"/${_realname}-${pkgver}/COPYING \ "${pkgdir}"${MINGW_PREFIX}/share/licenses/${_realname}/COPYING local PREFIX_WIN=$(cygpath -wm ${MINGW_PREFIX}) files=("/lib/pkgconfig/gdlib.pc") for f in "${files[@]}" do sed -e "s|${PREFIX_WIN}|${MINGW_PREFIX}|g" -i "${pkgdir}"${MINGW_PREFIX}${f} done }