summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormvp <mvp@users.noreply.github.com>2017-02-20 01:59:34 -0800
committerGitHub <noreply@github.com>2017-02-20 01:59:34 -0800
commit5a570c0e9da61f10bfaefaddd4d03c614ac10823 (patch)
tree0bcb44d771f293e765fc4c48d8f986241c58b053
parentf25d3e37866f7edb5b1ae8d7e185aacccd5a7ae1 (diff)
parent5ca2686708399c67809db7dea4c546b6496219d0 (diff)
Merge pull request #10 from rleitner/upstream/make-yp-compatible-v2
Make uhubctl "Yocto-Project Compatible" v2
-rw-r--r--Makefile34
-rw-r--r--uhubctl.c1
2 files changed, 30 insertions, 5 deletions
diff --git a/Makefile b/Makefile
index 7ae9575..936ed35 100644
--- a/Makefile
+++ b/Makefile
@@ -1,9 +1,33 @@
-CFLAGS = -g -O0
-LDFLAGS = -lusb-1.0
+# uhubctl Makefile
+#
+UNAME_S := $(shell uname -s)
+
+DESTDIR ?=
+prefix ?= /usr
+sbindir ?= $(prefix)/sbin
+
+INSTALL := install
+INSTALL_DIR := $(INSTALL) -m 755 -d
+INSTALL_PROGRAM := $(INSTALL) -m 755
+RM := rm -rf
+
+CC ?= gcc
+CFLAGS ?= -g -O0
+
+CFLAGS += -Wall -Wextra
+
+ifeq ($(UNAME_S),Linux)
+ LDFLAGS += -Wl,-z,relro
+endif
+
PROGRAM = uhubctl
-$(PROGRAM): $(PROGRAM).o
- cc $(CFLAGS) $@.c -o $@ $(LDFLAGS)
+$(PROGRAM): $(PROGRAM).c
+ $(CC) $(CFLAGS) $@.c -o $@ -lusb-1.0 $(LDFLAGS)
+
+install:
+ $(INSTALL_DIR) $(DESTDIR)$(sbindir)
+ $(INSTALL_PROGRAM) $(PROGRAM) $(DESTDIR)$(sbindir)
clean:
- rm -rf $(PROGRAM).o $(PROGRAM).dSYM $(PROGRAM)
+ $(RM) $(PROGRAM).o $(PROGRAM).dSYM $(PROGRAM)
diff --git a/uhubctl.c b/uhubctl.c
index 1827b00..5a5dfcc 100644
--- a/uhubctl.c
+++ b/uhubctl.c
@@ -17,6 +17,7 @@
#include <getopt.h>
#include <errno.h>
#include <ctype.h>
+#include <unistd.h>
#include <libusb-1.0/libusb.h>