diff options
author | Vadim Mikhailov <vadim.mikhailov@gmail.com> | 2017-04-04 17:36:50 -0700 |
---|---|---|
committer | Vadim Mikhailov <mvp@users.noreply.github.com> | 2017-04-06 11:43:02 -0700 |
commit | 40d446b3943d2b4dcee9b51a9007d54045e6efb8 (patch) | |
tree | 6167df9b805ae661799497e34009e6317694552a | |
parent | 37057c241e3282fca8e6a3ba9fe6c43e91e06fc7 (diff) |
Add support for FreeBSD and MacPorts on Mac
-rw-r--r-- | Makefile | 20 | ||||
-rw-r--r-- | README.md | 9 | ||||
-rw-r--r-- | uhubctl.c | 4 |
3 files changed, 25 insertions, 8 deletions
@@ -13,17 +13,29 @@ RM := rm -rf CC ?= gcc CFLAGS ?= -g -O0 - -CFLAGS += -Wall -Wextra +CFLAGS += -Wall -Wextra ifeq ($(UNAME_S),Linux) - LDFLAGS += -Wl,-z,relro + LDFLAGS += -Wl,-z,relro -lusb-1.0 +endif + +ifeq ($(UNAME_S),Darwin) +ifneq ($(wildcard /opt/local/include),) + # MacPorts + CFLAGS += -I/opt/local/include + LDFLAGS += -L/opt/local/lib +endif + LDFLAGS += -lusb-1.0 +endif + +ifeq ($(UNAME_S),FreeBSD) + LDFLAGS += -lusb endif PROGRAM = uhubctl $(PROGRAM): $(PROGRAM).c - $(CC) $(CFLAGS) $@.c -o $@ -lusb-1.0 $(LDFLAGS) + $(CC) $(CFLAGS) $@.c -o $@ $(LDFLAGS) install: $(INSTALL_DIR) $(DESTDIR)$(sbindir) @@ -49,15 +49,16 @@ Compiling ========= This utility was tested to compile and work on Linux -(Ubuntu, Redhat/Fedora/CentOS) and on Mac OS X. +(Ubuntu, Redhat/Fedora/CentOS), FreeBSD and Mac OS X. It should be possible to compile it for Windows as well - please report if you succeed in doing that. First, you need to install library libusb-1.0 (version 1.0.12 or later): -* Ubuntu: sudo apt-get install libusb-1.0-0-dev -* Redhat: sudo yum install libusb1-devel -* MacOSX: brew install libusb +* Ubuntu: `sudo apt-get install libusb-1.0-0-dev` +* Redhat: `sudo yum install libusb1-devel` +* MacOSX: `brew install libusb`, or `sudo port install libusb-devel` +* FreeBSD: libusb is included by default * Windows: TBD? To compile, simply run `make` - this will generate `uhubctl` binary. @@ -19,7 +19,11 @@ #include <ctype.h> #include <unistd.h> +#ifdef __FreeBSD__ +#include <libusb.h> +#else #include <libusb-1.0/libusb.h> +#endif /* Max number of hub ports supported. * This is somewhat artifically limited by "-p" option parser. |