diff options
author | Richard Leitner <richard.leitner@skidata.com> | 2017-02-20 09:39:23 +0100 |
---|---|---|
committer | Richard Leitner <richard.leitner@skidata.com> | 2017-02-20 10:49:30 +0100 |
commit | a45cb2a59add6e15efa4d2dc11920dabdde34125 (patch) | |
tree | d59e093ac501d7a050382b315abc4e9a85185ca2 /Makefile | |
parent | f25d3e37866f7edb5b1ae8d7e185aacccd5a7ae1 (diff) |
Makefile: add cross-compile functionality
Add cross-compile functionality to the Makefile and add an "install"
target. This makes uhubctl "Yocto Project Compatible".
Signed-off-by: Richard Leitner <richard.leitner@skidata.com>
Diffstat (limited to 'Makefile')
-rw-r--r-- | Makefile | 34 |
1 files changed, 29 insertions, 5 deletions
@@ -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) |