homebrew-core/Formula/hidapi.rb

42 lines
1.2 KiB
Ruby

class Hidapi < Formula
desc "Library for communicating with USB and Bluetooth HID devices"
homepage "https://github.com/libusb/hidapi"
url "https://github.com/libusb/hidapi/archive/hidapi-0.10.0.tar.gz"
sha256 "68febd416cb6e6e6e205c9dd46a6f86f0d5a9808b7cd8c112906cd229889b8e1"
license "GPL-3.0"
head "https://github.com/libusb/hidapi.git"
bottle do
cellar :any
sha256 "72dfa16cd42bbd13962305d59632f144110c647dd575407fedf4596e18bd1ddb" => :catalina
sha256 "71d043045302a15cdb18ec3180f798dda312ee5a0f56ea269c5aabfc67c8119d" => :mojave
sha256 "0b5108af3c48a0d208b74f7f970dd73cda8d5b9dd6e7baed7424efc439bca8bf" => :high_sierra
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"
bin.install "hidtest/.libs/hidtest"
end
test do
(testpath/"test.c").write <<~EOS
#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