<commit_before>require 'formula'

class Wireshark < Formula
  homepage 'http://www.wireshark.org'
  url 'http://wiresharkdownloads.riverbed.com/wireshark/src/wireshark-1.10.5.tar.bz2'
  mirror 'http://www.wireshark.org/download/src/wireshark-1.10.5.tar.bz2'
  sha1 'ebbf4f8382fc8961c1fb7959727b3e6792e597c1'

  head do
    url 'http://anonsvn.wireshark.org/wireshark/trunk/', :using => :svn

    depends_on :autoconf
    depends_on :automake
    depends_on :libtool
  end

  devel do
    url 'http://wiresharkdownloads.riverbed.com/wireshark/src/wireshark-1.11.2.tar.bz2'
    sha1 'af2b03338819b300f621048398b49403675db49c'
  end

  option 'with-x', 'Include X11 support'
  option 'with-qt', 'Use QT for GUI instead of GTK+'
  option 'with-headers', 'Install Wireshark library headers for plug-in developemnt'

  depends_on 'pkg-config' => :build

  depends_on 'glib'
  depends_on 'gnutls'
  depends_on 'libgcrypt'

  depends_on 'geoip' => :recommended

  depends_on 'c-ares' => :optional
  depends_on 'lua' => :optional
  depends_on 'pcre' => :optional
  depends_on 'portaudio' => :optional
  depends_on 'qt' => :optional

  if build.with? 'x'
    depends_on :x11
    depends_on 'gtk+'
  end

  def patches
    {
      # Removes SDK checks that prevent the build from working on CLT-only systems
      # Reported upstream: https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9290
      :p1 => DATA
    }
  end if build.stable?

  def install
    system "./autogen.sh" if build.head?

    args = ["--disable-dependency-tracking",
            "--prefix=#{prefix}",
            "--with-gnutls",
            "--with-ssl"]

    args << "--disable-warnings-as-errors" if build.head?
    args << "--disable-wireshark" unless build.with? "x" or build.with? "qt"
    args << "--disable-gtktest" unless build.with? "x"
    args << "--with-qt" if build.with? "qt"

    system "./configure", *args
    system "make"
    ENV.deparallelize # parallel install fails
    system "make install"

    if build.with? 'headers'
        (include/"wireshark").install Dir["*.h"]
        (include/"wireshark/epan").install Dir["epan/*.h"]
        (include/"wireshark/epan/crypt").install Dir["epan/crypt/*.h"]
        (include/"wireshark/epan/dfilter").install Dir["epan/dfilter/*.h"]
        (include/"wireshark/epan/dissectors").install Dir["epan/dissectors/*.h"]
        (include/"wireshark/epan/ftypes").install Dir["epan/ftypes/*.h"]
        (include/"wireshark/epan/wmem").install Dir["epan/wmem/*.h"]<commit_msg>wireshark: move conditional into method<commit_after>require 'formula'

class Wireshark < Formula
  homepage 'http://www.wireshark.org'
  url 'http://wiresharkdownloads.riverbed.com/wireshark/src/wireshark-1.10.5.tar.bz2'
  mirror 'http://www.wireshark.org/download/src/wireshark-1.10.5.tar.bz2'
  sha1 'ebbf4f8382fc8961c1fb7959727b3e6792e597c1'

  head do
    url 'http://anonsvn.wireshark.org/wireshark/trunk/', :using => :svn

    depends_on :autoconf
    depends_on :automake
    depends_on :libtool
  end

  devel do
    url 'http://wiresharkdownloads.riverbed.com/wireshark/src/wireshark-1.11.2.tar.bz2'
    sha1 'af2b03338819b300f621048398b49403675db49c'
  end

  option 'with-x', 'Include X11 support'
  option 'with-qt', 'Use QT for GUI instead of GTK+'
  option 'with-headers', 'Install Wireshark library headers for plug-in developemnt'

  depends_on 'pkg-config' => :build

  depends_on 'glib'
  depends_on 'gnutls'
  depends_on 'libgcrypt'

  depends_on 'geoip' => :recommended

  depends_on 'c-ares' => :optional
  depends_on 'lua' => :optional
  depends_on 'pcre' => :optional
  depends_on 'portaudio' => :optional
  depends_on 'qt' => :optional

  if build.with? 'x'
    depends_on :x11
    depends_on 'gtk+'
  end

  def patches
    if build.stable?
      # Removes SDK checks that prevent the build from working on CLT-only systems
      # Reported upstream: https://bugs.wireshark.org/bugzilla/show_bug.cgi?id=9290
      { :p1 => DATA }
    end
  end

  def install
    system "./autogen.sh" if build.head?

    args = ["--disable-dependency-tracking",
            "--prefix=#{prefix}",
            "--with-gnutls",
            "--with-ssl"]

    args << "--disable-warnings-as-errors" if build.head?
    args << "--disable-wireshark" unless build.with? "x" or build.with? "qt"
    args << "--disable-gtktest" unless build.with? "x"
    args << "--with-qt" if build.with? "qt"

    system "./configure", *args
    system "make"
    ENV.deparallelize # parallel install fails
    system "make install"

    if build.with? 'headers'
        (include/"wireshark").install Dir["*.h"]
        (include/"wireshark/epan").install Dir["epan/*.h"]
        (include/"wireshark/epan/crypt").install Dir["epan/crypt/*.h"]
        (include/"wireshark/epan/dfilter").install Dir["epan/dfilter/*.h"]
        (include/"wireshark/epan/dissectors").install Dir["epan/dissectors/*.h"]
        (include/"wireshark/epan/ftypes").install Dir["epan/ftypes/*.h"]
        (include/"wireshark/epan/wmem").install Dir["epan/wmem/*.h"]
{'fraction_non_alphanumeric': 0.15113500597371565, 'fraction_numerical': 0.03305455993628036, 'mean_word_length': 3.158112582781457, 'pattern_counts': {'":': 0, '<': 21, '<?xml version=': 0, '>': 21, 'https://': 2, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 6, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3176580', 'n_tokens_mistral': 1934, 'n_tokens_neox': 1877, 'n_words': 354}