112 lines
3.6 KiB
Ruby
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: "4365"
|
|
version "10.86.34"
|
|
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: "8bf3b9fc4d9ebf4bf94d6eb8d24101ea5b603bc2d637f2c0580e343bf9241ef8"
|
|
sha256 arm64_big_sur: "438ea4c47818e4f842863ef08cdcd6b66aa5760bd4278001697f70e52ce3698a"
|
|
sha256 monterey: "0db6b3939e1d1582f5d1f2d6c773ce59608a0d1f447eddede14c152ae284f0b4"
|
|
sha256 big_sur: "357f2471d61280edaad05bc2dbf455791e6e956c191f0706796d3ecdd261a49d"
|
|
sha256 catalina: "8a1ad15323e118eb77d4c561d8a848ca9dfdc5a60ab467f1dcc6360694defe1f"
|
|
sha256 x86_64_linux: "e5519cec5331aa00d1fe5a3e3ed34d2dffcdcb3a79229eefb2042880ca577302"
|
|
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
|