forked from pavel-a/usb-relay-hid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
77 lines (61 loc) · 1.78 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
63
64
65
66
67
68
69
70
71
72
# Makefile for HID USB relay utility, hidusbrelay-cmd and library
# for Linux
# (Quick'n'dirty - no .h dependencies, etc.)
# Assume make is run in this dir
# pa05 21-oct-2015
#
# prototype:
# Author: Christian Starkjohann
# Creation Date: 2008-04-11
# Copyright: (c) 2008 by OBJECTIVE DEVELOPMENT Software GmbH
#
# Update:
# Move Lib & Cmd to src folder
# General cleanup, But not re-written
.DEFAULT_GOAL := all
.PHONY: all clean
SRCDIR := src
OBJDIR := obj
INCDIR := ${SRCDIR}
VPATH := ${SRCDIR}
CMD_UTILITY := hidusb-relay-cmd
SHARED_LIB := usb_relay_device.so
all: $(CMD_UTILITY) $(SHARED_LIB)
# For Linux: Using old simple version 0.1 of libusb
HIDDATA := hiddata_libusb01
USBFLAGS := $(shell libusb-config --cflags)
USBLIBS := $(shell libusb-config --libs)
EXE_SUFFIX=
# Use the following lines to build for Windows and comment out the 3 above:
#HIDDATA=hiddata_mswin
#USBFLAGS=
#USBLIBS= -lhid -lsetupapi
#EXE_SUFFIX= .exe
#+pa GCC on my ubuntu 12 won't pick this dir by default ?!
#USBFLAGS+=-I/usr/include
CC= gcc
DEBUGFLAGS=
CFLAGS= -O -Wall $(EXTRA_CFLAGS) $(USBFLAGS) $(DEBUGFLAGS) -I$(INCDIR)
LIBS= $(USBLIBS)
DEPS=
$(OBJDIR)/%.o: %.c $(DEPS)
@mkdir -p obj
$(CC) -c -o $@ $< $(CFLAGS)
# CMD_UTILITY
SRCS_CMD := usbrelay-cmd $(HIDDATA)
CMD_UTILITY := $(CMD_UTILITY)$(EXE_SUFFIX)
_OBJS_CMD = $(addsuffix .o,$(SRCS_CMD))
OBJS_CMD = $(addprefix $(OBJDIR)/,$(_OBJS_CMD))
$(CMD_UTILITY): $(OBJS_CMD)
$(CC) -o $@ $^ $(LIBS)
# SHARED_LIB
SRCS_LIB := usb_relay_lib $(HIDDATA)
CFLAGS += -fPIC
_OBJS_LIB = $(addsuffix .o,$(SRCS_LIB))
OBJS_LIB = $(addprefix $(OBJDIR)/,$(_OBJS_LIB))
$(SHARED_LIB): $(OBJS_LIB)
$(CC) -shared -o $@ $^ $(LIBS)
strip: $(CMD_UTILITY)
strip $(CMD_UTILITY)
clean:
rm -f $(OBJDIR)/*.o $(CMD_UTILITY) $(SHARED_LIB)