-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathMakefile
63 lines (50 loc) · 1.28 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
PREFIX := /usr/local
UDEVPREFIX := /etc/udev
TARGETS := \
footswitch \
scythe \
scythe2
INCDIR := include
SRCDIR := src
OBJDIR := obj
COMMONSRC := \
common.c \
debug.c
INSTALL := /usr/bin/install -c
INSTALLDATA := /usr/bin/install -c -m 644
CFLAGS := -Wall -I$(INCDIR)
UNAME := $(shell uname)
ifeq ($(UNAME), Darwin)
CFLAGS += -DOSX $(shell pkg-config --cflags hidapi)
LDLIBS := $(shell pkg-config --libs hidapi)
else
ifeq ($(UNAME), Linux)
CFLAGS += $(shell pkg-config --cflags hidapi-libusb)
LDLIBS := $(shell pkg-config --libs hidapi-libusb)
else
LDLIBS := -lhidapi
endif
endif
all: $(OBJDIR) $(TARGETS)
$(OBJDIR):
mkdir $@
$(OBJDIR)/%.o: $(SRCDIR)/%.c
$(CC) $(CFLAGS) -c -o $@ $<
$(TARGETS): %: $(patsubst %.c, $(OBJDIR)/%.o, $(COMMONSRC)) $(OBJDIR)/%.o
$(CC) $(CFLAGS) -o $@ $^ $(LDLIBS)
install: all
$(INSTALL) -d $(DESTDIR)$(PREFIX)/bin
for target in $(TARGETS); do \
$(INSTALL) "$$target" $(DESTDIR)$(PREFIX)/bin; \
done
ifeq ($(UNAME), Linux)
$(INSTALL) -d $(DESTDIR)$(UDEVPREFIX)/rules.d
$(INSTALLDATA) 19-footswitch.rules $(DESTDIR)$(UDEVPREFIX)/rules.d
endif
uninstall:
rm -f $(addprefix $(DESTDIR)$(PREFIX)/bin/, $(TARGETS))
ifeq ($(UNAME), Linux)
rm -f $(DESTDIR)$(UDEVPREFIX)/rules.d/19-footswitch.rules
endif
clean:
rm -rf $(TARGETS) $(OBJDIR)