Skip to content

Commit 5db2487

Browse files
committed
Add support for NetBSD
This adds support to be able to build and use uhubctl on NetBSD by using pkg-config to get proper CFLAGS and LDFLAGS. Perhaps we should use pkg-config universally across all platforms, but I don't want to potentially break support for existing plaftorms because pkg-config does not seem to be unconditionally available everywhere.
1 parent 9cae5e2 commit 5db2487

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

Makefile

+5
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,11 @@ ifeq ($(UNAME_S),FreeBSD)
3737
LDFLAGS += -lusb
3838
endif
3939

40+
ifeq ($(UNAME_S),NetBSD)
41+
CFLAGS += $(shell pkg-config --cflags libusb-1.0)
42+
LDFLAGS += $(shell pkg-config --libs libusb-1.0)
43+
endif
44+
4045
PROGRAM = uhubctl
4146

4247
$(PROGRAM): $(PROGRAM).c

README.md

+3-2
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ Compiling
9191
=========
9292

9393
This utility was tested to compile and work on Linux
94-
(Ubuntu/Debian, Redhat/Fedora/CentOS, Arch Linux, Gentoo, openSUSE, Buildroot), FreeBSD and Mac OS X.
94+
(Ubuntu/Debian, Redhat/Fedora/CentOS, Arch Linux, Gentoo, openSUSE, Buildroot), FreeBSD, NetBSD and Mac OS X.
9595

9696
While `uhubctl` compiles on Windows, USB power switching does not work on Windows because `libusb`
9797
is using `winusb.sys` driver, which according to Microsoft does not support
@@ -104,10 +104,11 @@ First, you need to install library libusb-1.0 (version 1.0.12 or later):
104104
* Redhat: `sudo yum install libusb1-devel`
105105
* MacOSX: `brew install libusb`, or `sudo port install libusb-devel`
106106
* FreeBSD: libusb is included by default
107+
* NetBSD: `sudo pkgin install libusb1 gmake pkg-config`
107108
* Windows: TBD?
108109

109110
To compile, simply run `make` - this will generate `uhubctl` binary.
110-
Note that on some OS (e.g. FreeBSD) you may need to use `gmake` to build.
111+
Note that on some OS (e.g. FreeBSD/NetBSD) you need to use `gmake` instead to build.
111112

112113
Also, for Mac OS X you can install `uhubctl` with Homebrew custom tap:
113114

uhubctl.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
#include <unistd.h>
3030
#endif
3131

32-
#if defined(__FreeBSD__) || defined(_WIN32)
32+
#if defined(__FreeBSD__) || defined(__NetBSD__) || defined(_WIN32)
3333
#include <libusb.h>
3434
#else
3535
#include <libusb-1.0/libusb.h>

0 commit comments

Comments
 (0)