aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/cppcheck.rb
blob: 461ad27a7e82736443857bd9c99e1b351e224f36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
require 'formula'

class Cppcheck < Formula
  homepage 'http://sourceforge.net/apps/mediawiki/cppcheck/index.php?title=Main_Page'
  url 'http://downloads.sourceforge.net/project/cppcheck/cppcheck/1.52/cppcheck-1.52.tar.bz2'
  md5 'ebb9355890057a5145485dd42c18e05e'

  head 'https://github.com/danmar/cppcheck.git'

  depends_on 'pcre' unless ARGV.include? '--no-rules'
  depends_on 'qt' if ARGV.include? '--with-gui'

  def options
    [
      ['--no-rules', "Build without rules (no pcre dependency)"],
      ['--with-gui', "Build the cppcheck gui."]
    ]
  end

  # Do not strip binaries, or else it fails to run.
  skip_clean :all

  def install
    # Man pages aren't installed as they require docbook schemas.

    # Pass to make variables.
    if ARGV.include? '--no-rules'
      system "make", "HAVE_RULES=no"
    else
      system "make"
    end

    system "make", "DESTDIR=#{prefix}", "BIN=#{bin}", "install"

    if ARGV.include? '--with-gui'
      cd "gui" do
        if ARGV.include? '--no-rules'
          system "qmake", "HAVE_RULES=no"
        else
          system "qmake"
        end

        system "make"
        bin.install "cppcheck-gui.app"
      end
    end
  end

  def caveats; <<-EOS.undent
    --with-gui installs cppcheck-gui.app in:
      #{bin}

    To link the application to a normal Mac OS X location:
        brew linkapps
    or:
        ln -s #{bin}/cppcheck-gui.app /Applications
    EOS
  end
end