homebrew-core/Formula/netpbm.rb

114 lines
3.8 KiB
Ruby

class Netpbm < Formula
desc "Image manipulation"
homepage "https://netpbm.sourceforge.io/"
# Maintainers: Look at https://sourceforge.net/p/netpbm/code/HEAD/tree/
# for stable versions and matching revisions.
url "https://svn.code.sf.net/p/netpbm/code/stable", revision: "4436"
version "10.86.35"
license "GPL-3.0-or-later"
version_scheme 1
head "https://svn.code.sf.net/p/netpbm/code/trunk"
livecheck do
url "https://sourceforge.net/p/netpbm/code/HEAD/tree/stable/"
strategy :page_match
regex(/Release v?(\d+(?:\.\d+)+)/i)
end
bottle do
sha256 arm64_ventura: "3750103cab06a9afd7f646d3e49a5f6cf1c29b0df488ffcf6c61d6bc8e987d59"
sha256 arm64_monterey: "d86a4425340c1f7f616370769fd0a96846bda288cea0c47b1a39bc5f574574ab"
sha256 arm64_big_sur: "66ebd754e252717062e333952615afdc66fdd5b5b1a7862886b9cfd95d1fe524"
sha256 ventura: "1bc78a7636a711b117088e6ff6ce63636468d0e43cd4c5ce3200e6eb31a4f3d9"
sha256 monterey: "8430f4d4b9aba3fbd095874f18ab33b6c855decbc1686dbbd2148194a36843ac"
sha256 big_sur: "76b1ca75707c4dd5d7489e7db6aa6f8954ac650595b3abe273603c99a1a98231"
sha256 catalina: "e7fb4749ec589d7fd853009669c71946af0f79d54f51c6f654c8b3bc6cc30ee2"
sha256 x86_64_linux: "bec920ed95bffa751acf8607ca91a61ccfc6726e311f46fea8f376d17b8fd781"
end
depends_on "jasper"
depends_on "jpeg-turbo"
depends_on "libpng"
depends_on "libtiff"
uses_from_macos "flex" => :build
uses_from_macos "libxml2"
uses_from_macos "zlib"
conflicts_with "jbigkit", because: "both install `pbm.5` and `pgm.5` files"
def install
cp "config.mk.in", "config.mk"
inreplace "config.mk" do |s|
s.remove_make_var! "CC"
s.change_make_var! "TIFFLIB", "-ltiff"
s.change_make_var! "JPEGLIB", "-ljpeg"
s.change_make_var! "PNGLIB", "-lpng"
s.change_make_var! "ZLIB", "-lz"
s.change_make_var! "JASPERLIB", "-ljasper"
s.change_make_var! "JASPERHDR_DIR", Formula["jasper"].opt_include/"jasper"
s.gsub! "/usr/local/netpbm/rgb.txt", prefix/"misc/rgb.txt"
if OS.mac?
s.change_make_var! "CFLAGS_SHLIB", "-fno-common"
s.change_make_var! "NETPBMLIBTYPE", "dylib"
s.change_make_var! "NETPBMLIBSUFFIX", "dylib"
s.change_make_var! "LDSHLIB", "--shared -o $(SONAME)"
else
s.change_make_var! "CFLAGS_SHLIB", "-fPIC"
end
end
ENV.deparallelize
system "make"
system "make", "package", "pkgdir=#{buildpath}/stage"
cd "stage" do
inreplace "pkgconfig_template" do |s|
s.gsub! "@VERSION@", File.read("VERSION").sub("Netpbm ", "").chomp
s.gsub! "@LINKDIR@", lib
s.gsub! "@INCLUDEDIR@", include
end
prefix.install %w[bin include lib misc]
lib.install buildpath.glob("staticlink/*.a"), buildpath.glob("sharedlink/#{shared_library("*")}")
(lib/"pkgconfig").install "pkgconfig_template" => "netpbm.pc"
end
end
test do
fwrite = shell_output("#{bin}/pngtopam #{test_fixtures("test.png")} -alphapam")
(testpath/"test.pam").write fwrite
system bin/"pamdice", "test.pam", "-outstem", testpath/"testing"
assert_predicate testpath/"testing_0_0.pam", :exist?
(testpath/"test.xpm").write <<~EOS
/* XPM */
static char * favicon_xpm[] = {
"16 16 4 1",
" c white",
". c blue",
"X c black",
"o c red",
" ",
" ",
" ",
" ",
" .... .... ",
" . . . . ",
". .. .. .. .",
" . . .. . . ",
" . XXXXXX . ",
" . XXXXXX . ",
"oooooooooooooooo",
"oooooooooooooooo",
"oooooooooooooooo",
"oooooooooooooooo",
"XXXXXXXXXXXXXXXX",
"XXXXXXXXXXXXXXXX"};
EOS
ppmout = shell_output("#{bin}/xpmtoppm test.xpm")
refute_predicate ppmout, :empty?
end
end