class Lldpd < Formula desc "Implementation library for LLDP" homepage "https://vincentbernat.github.io/lldpd/" url "http://media.luffy.cx/files/lldpd/lldpd-0.9.2.tar.gz" sha256 "6054f29d41faf32186a22331853a299c87f4419b4332df4a564f76a139305a32" bottle do sha256 "a653e4fab4e04a21c1cf30acce6a6aef8747146239ad3e749958be6989696c11" => :el_capitan sha256 "2c8789cf6590fc9b9d341f92ec44a439d130502a5137f01d46218a8824abe604" => :yosemite sha256 "da4209b5c0a98657602877247777d2b2df55a916745e5fe83e3632e80bdbe03b" => :mavericks end 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 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") args << (build.with?("json") ? "--with-json" : "--without-json") system "./configure", *args system "make" system "make", "install" end def post_install (var/"run").mkpath end plist_options :startup => true def plist additional_args = "" if build.with? "snmp" additional_args += "-x" end <<-EOS.undent Label #{plist_name} ProgramArguments #{opt_sbin}/lldpd #{additional_args} RunAtLoad KeepAlive EOS end end