dmrconfig/Makefile

81 lines
2.1 KiB
Makefile
Raw Normal View History

2019-09-18 22:12:09 -07:00
CC ?= gcc
2018-08-20 22:47:13 -07:00
2018-09-15 15:43:23 -07:00
VERSION = $(shell git describe --tags --abbrev=0)
2018-08-27 13:34:21 -07:00
GITCOUNT = $(shell git rev-list HEAD --count)
UNAME = $(shell uname)
2021-02-28 00:00:31 -08:00
VERSION_STR = '$(VERSION).$(GITCOUNT)'
2021-03-03 01:19:14 -08:00
OBJS = main.o util.o dfu-libusb.o uv380.o md380.o rd5r.o \
gd77.o hid.o serial.o d868uv.o dm1801.o
2019-09-18 22:12:09 -07:00
CFLAGS ?= -g -O -Wall -Werror
CFLAGS += -DVERSION='"$(VERSION).$(GITCOUNT)"' \
2019-07-25 12:13:20 -07:00
$(shell pkg-config --cflags libusb-1.0)
2019-09-18 22:12:09 -07:00
LDFLAGS ?= -g
LIBS = $(shell pkg-config --libs --static libusb-1.0)
2018-08-20 22:47:13 -07:00
2021-02-27 21:01:44 -08:00
RUST_RELEASE := target/release/libdmrconfig.a
#
# Make sure pkg-config is installed.
#
ifeq ($(shell pkg-config --version),)
$(error Fatal error: pkg-config is not installed)
endif
2018-08-20 22:47:13 -07:00
#
# Linux
#
# To install required libraries, use:
2019-07-25 12:13:20 -07:00
# sudo apt-get install pkg-config libusb-1.0-0-dev libudev-dev
#
ifeq ($(UNAME),Linux)
OBJS += hid-libusb.o
2019-07-25 12:13:20 -07:00
# Link libusb statically, when possible
LIBUSB = /usr/lib/x86_64-linux-gnu/libusb-1.0.a
ifeq ($(wildcard $(LIBUSB)),$(LIBUSB))
LIBS = $(LIBUSB) -lpthread -ludev
endif
endif
2018-08-20 22:47:13 -07:00
#
2018-09-17 14:20:02 -07:00
# Mac OS X
#
2019-07-25 12:13:20 -07:00
# To install required libraries, use:
# brew install pkg-config libusb
#
2018-09-17 14:20:02 -07:00
ifeq ($(UNAME),Darwin)
OBJS += hid-macos.o
LIBS += -framework IOKit -framework CoreFoundation
endif
2018-08-20 22:47:13 -07:00
all: dmrconfig
2021-02-27 21:01:44 -08:00
dmrconfig: $(OBJS) $(RUST_RELEASE)
$(CC) $(LDFLAGS) -o $@ $(OBJS) $(RUST_RELEASE) -ldl $(LIBS)
2018-08-20 22:47:13 -07:00
clean:
2018-09-05 23:47:57 -07:00
rm -f *~ *.o core dmrconfig dmrconfig.exe
2018-08-20 22:47:13 -07:00
install: dmrconfig
install -c -s dmrconfig /usr/local/bin/dmrconfig
2021-02-27 21:01:44 -08:00
.PHONY: $(RUST_RELEASE)
target/release/libdmrconfig.a:
2021-02-28 00:00:31 -08:00
VERSION=$(VERSION_STR) cargo build --verbose --release
2021-02-27 21:01:44 -08:00
2018-08-20 22:47:13 -07:00
###
d868uv.o: d868uv.c radio.h util.h d868uv-map.h
2018-09-06 12:10:01 -07:00
dfu-libusb.o: dfu-libusb.c util.h
2018-09-15 15:43:23 -07:00
dfu-windows.o: dfu-windows.c util.h
2018-10-04 19:51:10 -07:00
gd77.o: gd77.c radio.h util.h
hid.o: hid.c util.h
2018-09-15 15:43:23 -07:00
hid-libusb.o: hid-libusb.c util.h
hid-macos.o: hid-macos.c util.h
hid-windows.o: hid-windows.c util.h
2018-08-20 22:47:13 -07:00
main.o: main.c radio.h util.h
2018-08-24 20:13:27 -07:00
md380.o: md380.c radio.h util.h
2018-09-15 15:43:23 -07:00
rd5r.o: rd5r.c radio.h util.h
2018-10-13 21:16:03 -07:00
serial.o: serial.c util.h
2018-08-20 22:47:13 -07:00
util.o: util.c util.h
uv380.o: uv380.c radio.h util.h