require 'formula' class Lldpd < Formula homepage 'http://vincentbernat.github.io/lldpd/' url 'http://media.luffy.cx/files/lldpd/lldpd-0.7.1.tar.gz' sha1 '8eb804ee6b93d12486ee0527828b752dc43158f9' 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.include? 'with-snmp' depends_on 'jansson' if build.include? 'with-json' def install readline = Formula.factory 'readline' args = [ "--prefix=#{prefix}", "--with-xml", "--with-readline", "--with-privsep-chroot=/var/empty", "--with-privsep-user=nobody", "--with-privsep-group=nogroup", "CPPFLAGS=-I#{readline.include} -DRONLY=1", "LDFLAGS=-L#{readline.lib}" ] args << "--with-snmp" if build.include? 'with-snmp' args << "--with-json" if build.include? 'with-json' system "./configure", *args system "make" system "make install" end plist_options :startup => true def plist additional_args = "" if build.include? 'with-snmp' additional_args += "-x" end return <<-EOS.undent Label #{plist_name} ProgramArguments #{opt_prefix}/sbin/lldpd #{additional_args} RunAtLoad KeepAlive EOS end end