113 lines
3.7 KiB
Ruby
113 lines
3.7 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: "4482"
|
|
version "10.86.37"
|
|
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: "56ff56d19bc7d7295f3476d7b175c19cecc0ad1eb66eda08676e2861c60d0367"
|
|
sha256 arm64_monterey: "29d7bdf2039aa7b7e272763ed16b35775d5029ab1eea09960e48d66f0eaeaf72"
|
|
sha256 arm64_big_sur: "264bce0bc44a6ab6284139a74cae82533609bda99c148e92a7056c422d612341"
|
|
sha256 ventura: "214e48fc8d774da41402f33372a5960b7e58aab4d7e3878411582ab0843ca156"
|
|
sha256 monterey: "d9e210cc4ab4238aec0da59b967c9be1dc96fdafa2c82270e14b64814a7e6f7c"
|
|
sha256 big_sur: "de1cabe00a181bcd8fb35408df3ecd89bdf0a698990995768d06acd1fd18b9cb"
|
|
sha256 x86_64_linux: "065a106d58725f57fe502c87f25e0267b53073d2595430163b27f6ceed6a4570"
|
|
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
|