homebrew-core/Formula/netpbm.rb

112 lines
3.6 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: "4328"
version "10.86.33"
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_monterey: "4d6847069d5fe7cfa083af5504968be345c51b89654554c0c69af4f851199ba0"
sha256 arm64_big_sur: "13b35ba56a0f7d881b5a3d252736b4916b8e003ae97d49b23e8a97f1d1096558"
sha256 monterey: "2aaa219cee191125fb32b144ef99263f94848fdf1a29f59969d1b051b84183e6"
sha256 big_sur: "18d6a720f0dcdf843f8d636203cea658a73dc4a22ff324169d529c49e94b4d8e"
sha256 catalina: "7c47fda00829312d18b25d50fe5067e4444bdf2a42b7825bbe5f62762912de6d"
sha256 x86_64_linux: "9ab2fffdc4eebc47be06d97c5eb5849d55df9ce27a22d7de445d48a0061ef77c"
end
depends_on "jasper"
depends_on "jpeg"
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 Dir["staticlink/*.a"], Dir["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