-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
95 lines (79 loc) · 2.94 KB
/
Makefile
File metadata and controls
95 lines (79 loc) · 2.94 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
CXX = g++
CC = gcc
CXXFLAGS = -std=c++17 -O3 -march=native -Wall -Wextra
LDFLAGS = -lpthread -ltinfo -lncurses -ldl -lm
# dependencies
AICODIX_DSP ?= ../dsp
AICODIX_CODE ?= ../code
MODEM_SRC ?= ../modem
INCLUDES = -I$(AICODIX_DSP) -I$(AICODIX_CODE) -I$(MODEM_SRC)
TARGET = modem73
SRCS = kiss_tnc.cc
HDRS = kiss_tnc.hh miniaudio_audio.hh rigctl_ptt.hh modem.hh phy/mfsk_modem.hh tnc_ui.hh control_port.hh
OBJS = deps/miniaudio.o deps/cJSON.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)
deps/miniaudio.o: deps/miniaudio.c deps/miniaudio.h
$(CC) -c -O2 -o $@ deps/miniaudio.c
deps/cJSON.o: deps/cJSON.c deps/cJSON.h
$(CC) -c -O2 -o $@ deps/cJSON.c
$(TARGET): $(SRCS) $(HDRS) $(OBJS)
$(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/
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
debug: $(TARGET)
# Help
help:
@echo "MODEM73 makefile"
@echo ""
@echo "Targets:"
@echo " all - Build modem"
@echo " clean - Remove build"
@echo " install - Install to /usr/local/bin"
@echo " debug - Build with debug symbols"
@echo ""
@echo "Variables:"
@echo " AICODIX_DSP - Path to aicodix/dsp (default: ../dsp)"
@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 ""
@echo "Runtime options:"
@echo " ./modem73 # Run with UI"
@echo " ./modem73 -h # Run headless"
@echo " ./modem73 --headless"