mirror of
https://github.com/RFnexus/modem73.git
synced 2026-04-27 14:30:33 +00:00
Make CM108 support conditional on hidapi availability, cleanup
This commit is contained in:
parent
13c102e7cd
commit
842f9391a4
6 changed files with 167 additions and 71 deletions
34
Makefile
34
Makefile
|
|
@ -1,7 +1,7 @@
|
|||
CXX = g++
|
||||
CC = gcc
|
||||
CXXFLAGS = -std=c++17 -O3 -march=native -Wall -Wextra
|
||||
LDFLAGS = -lpthread -ltinfo -lncurses -ldl -lm -lhidapi-hidraw
|
||||
LDFLAGS = -lpthread -ltinfo -lncurses -ldl -lm
|
||||
|
||||
# dependencies
|
||||
AICODIX_DSP ?= ../dsp
|
||||
|
|
@ -19,6 +19,20 @@ OBJS = miniaudio.o
|
|||
# defualt to build with UI, headless operations through --headless
|
||||
UI_FLAGS = -DWITH_UI
|
||||
|
||||
# Optional CM108 PTT support requires libhidapi-dev
|
||||
HIDAPI_CFLAGS := $(shell pkg-config --cflags hidapi-hidraw 2>/dev/null || pkg-config --cflags hidapi-libusb 2>/dev/null || pkg-config --cflags hidapi 2>/dev/null)
|
||||
HIDAPI_LIBS := $(shell pkg-config --libs hidapi-hidraw 2>/dev/null || pkg-config --libs hidapi-libusb 2>/dev/null || pkg-config --libs hidapi 2>/dev/null)
|
||||
|
||||
ifneq ($(HIDAPI_LIBS),)
|
||||
$(info CM108 PTT support: enabled (found hidapi))
|
||||
CM108_FLAGS = -DWITH_CM108
|
||||
CXXFLAGS += $(HIDAPI_CFLAGS)
|
||||
LDFLAGS += $(HIDAPI_LIBS)
|
||||
else
|
||||
$(info CM108 PTT support: disabled (install libhidapi-dev to enable))
|
||||
CM108_FLAGS =
|
||||
endif
|
||||
|
||||
.PHONY: all clean install debug help
|
||||
|
||||
all: $(TARGET)
|
||||
|
|
@ -27,14 +41,25 @@ miniaudio.o: miniaudio.c miniaudio.h
|
|||
$(CC) -c -O2 -o $@ miniaudio.c
|
||||
|
||||
$(TARGET): $(SRCS) $(HDRS) $(OBJS)
|
||||
$(CXX) $(CXXFLAGS) $(UI_FLAGS) $(INCLUDES) -o $@ $(SRCS) $(OBJS) $(LDFLAGS)
|
||||
$(CXX) $(CXXFLAGS) $(UI_FLAGS) $(CM108_FLAGS) $(INCLUDES) -o $@ $(SRCS) $(OBJS) $(LDFLAGS)
|
||||
ifneq ($(HIDAPI_LIBS),)
|
||||
@echo ""
|
||||
@echo "CM108 PTT support enabled. To allow non-root access, install udev rules:"
|
||||
@echo " sudo cp misc/50-cm108-ptt.rules /etc/udev/rules.d/"
|
||||
@echo " sudo udevadm control --reload-rules"
|
||||
endif
|
||||
|
||||
clean:
|
||||
rm -f $(TARGET) $(OBJS)
|
||||
|
||||
install: $(TARGET)
|
||||
install -m 755 $(TARGET) /usr/local/bin/
|
||||
$(shell cp 50-cm108-ptt.rules /etc/udev/rules.d/)
|
||||
ifneq ($(HIDAPI_LIBS),)
|
||||
@if [ -f misc/50-cm108-ptt.rules ]; then \
|
||||
cp misc/50-cm108-ptt.rules /etc/udev/rules.d/ 2>/dev/null || \
|
||||
echo "Note: Run 'sudo cp misc/50-cm108-ptt.rules /etc/udev/rules.d/' for CM108 udev rules"; \
|
||||
fi
|
||||
endif
|
||||
|
||||
# Debug build
|
||||
debug: CXXFLAGS = -std=c++17 -g -O0 -Wall -Wextra -DDEBUG
|
||||
|
|
@ -55,6 +80,9 @@ help:
|
|||
@echo " AICODIX_CODE - Path to aicodix/code (default: ../code)"
|
||||
@echo " MODEM_SRC - Path to modem source (default: ../modem)"
|
||||
@echo ""
|
||||
@echo "Optional features:"
|
||||
@echo " CM108 PTT - Requires libhidapi-dev (auto-detected)"
|
||||
@echo ""
|
||||
@echo "Example:"
|
||||
@echo " make AICODIX_DSP=~/aicodix/dsp AICODIX_CODE=~/aicodix/code"
|
||||
@echo ""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue