homebrew-core/Formula/lldpd.rb

63 lines
1.7 KiB
Ruby
Raw Normal View History

require 'formula'
class Lldpd < Formula
homepage 'http://vincentbernat.github.io/lldpd/'
url 'http://media.luffy.cx/files/lldpd/lldpd-0.7.7.tar.gz'
sha1 '4471e5fcd66d650b6327842a9e2e779e546f2491'
option 'with-snmp', "Build SNMP subagent support"
option 'with-json', "Build JSON support for lldpcli"
depends_on 'pkg-config' => :build
depends_on 'readline'
depends_on 'libevent'
depends_on 'net-snmp' if build.with? "snmp"
depends_on 'jansson' if build.with? "json"
def install
2014-02-27 03:36:54 +00:00
readline = Formula["readline"]
args = ["--prefix=#{prefix}",
"--with-xml",
"--with-readline",
"--with-privsep-chroot=/var/empty",
"--with-privsep-user=nobody",
"--with-privsep-group=nogroup",
"--with-launchddaemonsdir=no",
"CPPFLAGS=-I#{readline.include} -DRONLY=1",
"LDFLAGS=-L#{readline.lib}"]
args << "--with-snmp" if build.with? "snmp"
args << "--with-json" if build.with? "json"
system "./configure", *args
system "make"
system "make install"
end
plist_options :startup => true
def plist
additional_args = ""
if build.with? "snmp"
additional_args += "<string>-x</string>"
end
return <<-EOS.undent
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>#{plist_name}</string>
<key>ProgramArguments</key>
<array>
2014-03-06 05:28:31 +00:00
<string>#{opt_sbin}/lldpd</string>
#{additional_args}
</array>
<key>RunAtLoad</key><true/>
<key>KeepAlive</key><true/>
</dict>
</plist>
EOS
end
end