| 1 |
CC ?= gcc |
| 2 |
PKG_CONFIG ?= pkg-config |
| 3 |
|
| 4 |
VERSION = $(shell git describe --tags --abbrev=0) |
| 5 |
GITCOUNT = $(shell git rev-list HEAD --count) |
| 6 |
UNAME = $(shell uname) |
| 7 |
|
| 8 |
OBJS = main.o util.o radio.o dfu-libusb.o uv380.o md380.o rd5r.o \ |
| 9 |
gd77.o hid.o serial.o d868uv.o dm1801.o |
| 10 |
CFLAGS ?= -g -O -Wall -Werror |
| 11 |
CFLAGS += -DVERSION='"$(VERSION).$(GITCOUNT)"' \ |
| 12 |
$(shell $(PKG_CONFIG) --cflags libusb-1.0) |
| 13 |
LDFLAGS ?= -g |
| 14 |
LIBS = $(shell $(PKG_CONFIG) --libs --static libusb-1.0) |
| 15 |
|
| 16 |
# |
| 17 |
# Make sure pkg-config is installed. |
| 18 |
# |
| 19 |
ifeq ($(shell $(PKG_CONFIG) --version),) |
| 20 |
$(error Fatal error: pkg-config is not installed) |
| 21 |
endif |
| 22 |
|
| 23 |
# |
| 24 |
# Linux |
| 25 |
# |
| 26 |
# To install required libraries, use: |
| 27 |
# sudo apt-get install pkg-config libusb-1.0-0-dev libudev-dev |
| 28 |
# |
| 29 |
ifeq ($(UNAME),Linux) |
| 30 |
OBJS += hid-libusb.o |
| 31 |
|
| 32 |
# Link libusb statically, when possible |
| 33 |
LIBUSB = /usr/lib/x86_64-linux-gnu/libusb-1.0.a |
| 34 |
ifeq ($(wildcard $(LIBUSB)),$(LIBUSB)) |
| 35 |
LIBS = $(LIBUSB) -lpthread -ludev |
| 36 |
endif |
| 37 |
endif |
| 38 |
|
| 39 |
# |
| 40 |
# Mac OS X |
| 41 |
# |
| 42 |
# To install required libraries, use: |
| 43 |
# brew install pkg-config libusb |
| 44 |
# |
| 45 |
ifeq ($(UNAME),Darwin) |
| 46 |
OBJS += hid-macos.o |
| 47 |
LIBS += -framework IOKit -framework CoreFoundation |
| 48 |
endif |
| 49 |
|
| 50 |
all: dmrconfig |
| 51 |
|
| 52 |
dmrconfig: $(OBJS) |
| 53 |
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(LIBS) |
| 54 |
|
| 55 |
clean: |
| 56 |
rm -f *~ *.o core dmrconfig dmrconfig.exe |
| 57 |
|
| 58 |
install: dmrconfig |
| 59 |
install -c -s dmrconfig /usr/local/bin/dmrconfig |
| 60 |
|
| 61 |
### |
| 62 |
d868uv.o: d868uv.c radio.h util.h d868uv-map.h |
| 63 |
dfu-libusb.o: dfu-libusb.c util.h |
| 64 |
dfu-windows.o: dfu-windows.c util.h |
| 65 |
gd77.o: gd77.c radio.h util.h |
| 66 |
hid.o: hid.c util.h |
| 67 |
hid-libusb.o: hid-libusb.c util.h |
| 68 |
hid-macos.o: hid-macos.c util.h |
| 69 |
hid-windows.o: hid-windows.c util.h |
| 70 |
main.o: main.c radio.h util.h |
| 71 |
md380.o: md380.c radio.h util.h |
| 72 |
radio.o: radio.c radio.h util.h |
| 73 |
rd5r.o: rd5r.c radio.h util.h |
| 74 |
serial.o: serial.c util.h |
| 75 |
util.o: util.c util.h |
| 76 |
uv380.o: uv380.c radio.h util.h |