homebrew-core/Formula/gd.rb

81 lines
3.0 KiB
Ruby

class Gd < Formula
desc "Graphics library to dynamically manipulate images"
homepage "https://libgd.github.io/"
url "https://github.com/libgd/libgd/releases/download/gd-2.3.3/libgd-2.3.3.tar.xz"
sha256 "3fe822ece20796060af63b7c60acb151e5844204d289da0ce08f8fdf131e5a61"
license :cannot_represent
revision 3
bottle do
sha256 cellar: :any, arm64_monterey: "0eda623611efbf26dfedd397bbe5ae313584c162379f5d394e7bb3d39b32f9d5"
sha256 cellar: :any, arm64_big_sur: "dabdab987c6d93166edec28f9cccee0afbcaf71894eb514d665772ff4b9c2840"
sha256 cellar: :any, monterey: "091026601baffccdd8fd0fa401ec03083159ec7cb7aa5fef154190a1d726bc86"
sha256 cellar: :any, big_sur: "3d1452f14af7ba4df550045c145057a9200152feb50f0ada0d8b5d03174663b2"
sha256 cellar: :any, catalina: "acdd2925c5bb3909ab9da38a61854e1e89e2438647d056a6769bc45ae454557a"
sha256 cellar: :any_skip_relocation, x86_64_linux: "5617e4646f9ac9d7c4a768770d2e6a0cbe4feba33050b28921876ee73d9f3fce"
end
head do
url "https://github.com/libgd/libgd.git"
depends_on "autoconf" => :build
depends_on "automake" => :build
depends_on "libtool" => :build
end
depends_on "fontconfig"
depends_on "freetype"
depends_on "jpeg-turbo"
depends_on "libavif"
depends_on "libpng"
depends_on "libtiff"
depends_on "webp"
# revert breaking changes in 2.3.3, remove in next release
patch do
url "https://github.com/libgd/libgd/commit/f4bc1f5c26925548662946ed7cfa473c190a104a.patch?full_index=1"
sha256 "1015f6e125f139a1e922ac4bc2a18abbc498b0142193fa692846bf0f344a3691"
end
def install
system "./bootstrap.sh" if build.head?
system "./configure", *std_configure_args,
"--with-fontconfig=#{Formula["fontconfig"].opt_prefix}",
"--with-freetype=#{Formula["freetype"].opt_prefix}",
"--with-jpeg=#{Formula["jpeg-turbo"].opt_prefix}",
"--with-avif=#{Formula["libavif"].opt_prefix}",
"--with-png=#{Formula["libpng"].opt_prefix}",
"--with-tiff=#{Formula["libtiff"].opt_prefix}",
"--with-webp=#{Formula["webp"].opt_prefix}",
"--without-x",
"--without-xpm"
system "make", "install"
end
test do
(testpath/"test.c").write <<~EOS
#include "gd.h"
#include <stdio.h>
int main() {
gdImagePtr im;
FILE *pngout;
int black;
int white;
im = gdImageCreate(64, 64);
black = gdImageColorAllocate(im, 0, 0, 0);
white = gdImageColorAllocate(im, 255, 255, 255);
gdImageLine(im, 0, 0, 63, 63, white);
pngout = fopen("test.png", "wb");
gdImagePng(im, pngout);
fclose(pngout);
gdImageDestroy(im);
}
EOS
system ENV.cc, "test.c", "-I#{include}", "-L#{lib}", "-lgd", "-o", "test"
system "./test"
assert_path_exists "#{testpath}/test.png"
end
end