]> git.ipfire.org Git - thirdparty/lldpd.git/blobdiff - osx/lldpd.rb
osx: update Homebrew recipe
[thirdparty/lldpd.git] / osx / lldpd.rb
index d31b8804780f13356f968a5d14ab698ae69e89d3..1e33aeffffd2d8874f6e3b854091d10e03163491 100644 (file)
@@ -1,33 +1,41 @@
-require 'formula'
-
 class Lldpd < Formula
-  homepage 'http://vincentbernat.github.com/lldpd/'
-  url 'http://media.luffy.cx/files/lldpd/lldpd-0.7.1.tar.gz'
-  md5 '1534a5deb9671afb83be9b01edba9908'
+  desc "Implementation of IEEE 802.1ab (LLDP)"
+  homepage "https://vincentbernat.github.io/lldpd/"
+  url "https://media.luffy.cx/files/lldpd/lldpd-0.9.6.tar.gz"
+  sha256 "e74e2dd7e2a233ca1ff385c925ddae2a916d302819d1433741407d2f8fb0ddd8"
 
-  # Included copy of libevent does not like automake 1.13
-  # head 'git://github.com/vincentbernat/lldpd.git'
+  option "with-snmp", "Build SNMP subagent support"
+  option "with-json", "Build JSON support for lldpcli"
 
-  depends_on 'readline'
-  depends_on 'libevent'
-  depends_on 'pkg-config'
-  depends_on 'autoconf' if build.head?
-  depends_on 'automake' if build.head?
-  depends_on 'libtool' if build.head?
+  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.factory 'readline'
-    if build.head?
-      system "env LIBTOOLIZE=glibtoolize ./autogen.sh"
-    end
-    system "./configure", "--prefix=#{prefix}",
-                          "--with-xml",
-                          "--with-readline",
-                          "--with-privsep-chroot=/var/empty",
-                          "CPPFLAGS=-I#{readline.include}",
-                          "LDFLAGS=-L#{readline.lib}"
+    readline = Formula["readline"]
+    args = [
+      "--prefix=#{prefix}",
+      "--sysconfdir=#{etc}",
+      "--localstatedir=#{var}",
+      "--with-xml",
+      "--with-readline",
+      "--with-privsep-chroot=/var/empty",
+      "--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"
+    system "make", "install"
+  end
+
+  def post_install
+    (var/"run").mkpath
   end
 
   def dscl(*args)
@@ -69,7 +77,13 @@ class Lldpd < Formula
   end
 
   plist_options :startup => true
-  def plist; <<-EOS.undent
+
+  def plist
+    additional_args = ""
+    if build.with? "snmp"
+      additional_args += "<string>-x</string>"
+    end
+    <<-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">
@@ -78,7 +92,8 @@ class Lldpd < Formula
       <string>#{plist_name}</string>
       <key>ProgramArguments</key>
       <array>
-        <string>#{opt_prefix}/sbin/lldpd</string>
+        <string>#{opt_sbin}/lldpd</string>
+        #{additional_args}
       </array>
       <key>RunAtLoad</key><true/>
       <key>KeepAlive</key><true/>
@@ -86,5 +101,4 @@ class Lldpd < Formula
     </plist>
     EOS
   end
-
 end