class Lldpd < Formula
desc "Implementation of IEEE 802.1ab (LLDP)"
homepage "https://vincentbernat.github.io/lldpd/"
url "https://media.luffy.cx/files/lldpd/lldpd-1.0.0.tar.gz"
sha256 "13b09f43f530c6e9eec8ead0493e1b34f332b8ead89e46623e1fc40bb137b80d"
bottle do
sha256 "76809828122acdc997a3a1d0cb26cbbf1ff824c8749489651e489ea3e7d3de8e" => :high_sierra
sha256 "a4f1f3f4ae1feece3d3c002f2922f9246a9b725d7b21d6a020563958e07b0d61" => :sierra
sha256 "2b27b264d12e097e4ed486c9ea33171c3ef601550e2075b314cb4423721d41df" => :el_capitan
end
option "with-snmp", "Build SNMP subagent support"
depends_on "pkg-config" => :build
depends_on "readline"
depends_on "libevent"
depends_on "net-snmp" if build.with? "snmp"
def install
readline = Formula["readline"]
args = [
"--prefix=#{prefix}",
"--sysconfdir=#{etc}",
"--localstatedir=#{var}",
"--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 << (build.with?("snmp") ? "--with-snmp" : "--without-snmp")
system "./configure", *args
system "make"
system "make", "install"
end
def post_install
(var/"run").mkpath
end
plist_options :startup => true
def plist
additional_args = ""
additional_args += "-x" if build.with? "snmp"
<<~EOS
Label
#{plist_name}
ProgramArguments
#{opt_sbin}/lldpd
#{additional_args}
RunAtLoad
KeepAlive
EOS
end
end