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"
revision 1
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: "381d9545f0bc6430c7db9600c5e7de74d0efd5fdb94fc9effe95bf4818562dc9"
sha256 arm64_monterey: "7575047f5dc8148f30cef28547bd024ed6292e575668b8f99abed5ed5d64122b"
sha256 arm64_big_sur: "7b226e326c02b61f217396fc885fbe91f4eb42913751dc248674ecfd8c3eaf46"
sha256 ventura: "a8dd82da44cc0868b2964aaac1c9d00532c8f7b9bb6b1d1a0831c6c22545c38b"
sha256 monterey: "adc98059ce3b5a2cc8a71e97e203e73424f12df09f0c5934723bbee0c2db1c1c"
sha256 big_sur: "4316824e98dd7fb6cf7fd3cdad449ade4cd03581eaf2ff3c0d91bfdcb4d6d320"
sha256 x86_64_linux: "03f69dcb2a8b57ddcbac77366bf9acdf5c38cc4536a1bbe1f553c1199e3cbc31"
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