aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Formula/hidapi.rb
blob: 3933934d8a28e74dc7ae67ef200a1f640c3c9040 (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
require 'formula'

class Hidapi < Formula
  homepage "https://github.com/signal11/hidapi"
  url "https://github.com/signal11/hidapi/archive/hidapi-0.8.0-rc1.tar.gz"
  sha1 "5e72a4c7add8b85c8abcdd360ab8b1e1421da468"

  # This patch addresses a bug discovered in the HidApi IOHidManager back-end
  # that is being used with Macs.
  # The bug was dramatically changing the behaviour of the function
  # "hid_get_feature_report". As a consequence, many applications working
  # with HidApi were not behaving correctly on OSX.
  # pull request on Hidapi's repo: https://github.com/signal11/hidapi/pull/219
  patch do
    url "https://patch-diff.githubusercontent.com/raw/signal11/hidapi/pull/219.diff"
    sha256 "82631c8a6ec307482c09c133f9da89672c781665704304aa0ef286467b7fe5c2"
  end

  bottle do
    cellar :any
    revision 1
    sha256 "7fb4f99e0d29846541d91834a85c993b4391f78e5635d154da3ef025b0f84be3" => :yosemite
    sha256 "28c0f7b67d8d041f70f2e7278f0e216660c5b4f004d6330f741485e8d75a4955" => :mavericks
    sha256 "b7ced91d5e87d1d47ffc12de47ffbeac3391f1070fb0e2b47b84c929f372e99e" => :mountain_lion
  end

  depends_on 'autoconf' => :build
  depends_on 'automake' => :build
  depends_on 'libtool' => :build
  depends_on 'pkg-config' => :build

  def install
    system './bootstrap'
    system "./configure", "--prefix=#{prefix}"
    system "make install"
  end

  test do
    (testpath/'test.c').write <<-EOS.undent
      #include "hidapi.h"
      int main(void)
      {
        return hid_exit();
      }
    EOS

    flags = ["-I#{include}/hidapi", "-L#{lib}", "-lhidapi"] + ENV.cflags.to_s.split
    system ENV.cc, "-o", "test", "test.c", *flags
    system './test'
  end
end