forked from Homebrew/homebrew-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnetpbm.rb
120 lines (105 loc) · 4.12 KB
/
netpbm.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
class Netpbm < Formula
desc "Image manipulation"
homepage "https://netpbm.sourceforge.net/"
# 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: "4982"
version "11.02.12"
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/log/?path=/stable"
regex(/Release\s+v?(\d+(?:\.\d+)+)/i)
strategy :page_match
end
bottle do
sha256 arm64_sequoia: "564aa426f9e1597c64ebb51b50b5c2776231517b423634764fa06fda93ebff49"
sha256 arm64_sonoma: "e4b174e0c025ec65cfc1cb8567ae2124372a27864f5046af0da8928b8f45b921"
sha256 arm64_ventura: "d4bd64f740a35ca3c49a85d0c27950c67db45a10bd94cfad62fc43cc297e8484"
sha256 sonoma: "31fd82cf18d2bc3cd9af829b1a2fc6cee96886acdf923620b3d046e71800ef80"
sha256 ventura: "6c6baced2256efd2a0032c1282a2ec36d8c63573cfeb459edc34e6cd31ec9e98"
sha256 x86_64_linux: "389525c1edd732598087f85a27752cf394815d6984321285f77941a0086ba366"
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
# Fix compile with newer Clang
ENV.append_to_cflags "-Wno-implicit-function-declaration" if DevelopmentTools.clang_build_version >= 1403
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
# We don't run `make install`, so an unversioned library symlink is never generated.
# FIXME: Check whether we can call `make install` instead of creating this manually.
libnetpbm = lib.glob(shared_library("libnetpbm", "*")).reject(&:symlink?).first.basename
lib.install_symlink libnetpbm => shared_library("libnetpbm")
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