forked from RFnexus/modem73
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
122 lines (97 loc) · 4.63 KB
/
Copy pathMakefile
File metadata and controls
122 lines (97 loc) · 4.63 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
CXX = g++
CC = gcc
CXXFLAGS = -std=c++17 -O3 -march=native -Wall -Wextra
LDFLAGS = -lpthread -ltinfo -lncurses -ldl -lm
# dependencies
AICODIX_DSP ?= deps/aicodix/dsp
AICODIX_CODE ?= deps/aicodix/code
MODEM_SRC ?= deps/aicodix/modem
INCLUDES = -I$(AICODIX_DSP) -I$(AICODIX_CODE) -I$(MODEM_SRC)
TARGET = modem73
SRCS = kiss_tnc.cc
HDRS = kiss_tnc.hh csma.hh miniaudio_audio.hh rigctl_ptt.hh modem.hh phy/mfsk_modem.hh phy/robust_modem.hh phy/common.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) test_suite/test_fade test_suite/test_awgn test_suite/test_mfsk test_suite/test_robust test_suite/test_e2e test_suite/test_csma test_suite/wav_decode
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)
test_fade: test_suite/test_fade.cc modem.hh phy/common.hh
$(CXX) $(CXXFLAGS) $(INCLUDES) -I. -Iphy -o test_suite/$@ test_suite/test_fade.cc -lm
test_micro: test_suite/test_micro.cc modem.hh phy/common.hh phy/polar_tables_micro.hh
$(CXX) $(CXXFLAGS) $(INCLUDES) -I. -Iphy -o test_suite/$@ test_suite/test_micro.cc -lm
test_mfsk_snr: test_suite/test_mfsk_snr.cc phy/mfsk_modem.hh
$(CXX) $(CXXFLAGS) $(INCLUDES) -I. -Iphy -o test_suite/$@ test_suite/test_mfsk_snr.cc -lm
test_awgn: test_suite/test_awgn.cc modem.hh phy/common.hh
$(CXX) $(CXXFLAGS) $(INCLUDES) -I. -Iphy -o test_suite/$@ test_suite/test_awgn.cc -lm
test_mfsk: test_suite/test_mfsk.cc phy/mfsk_modem.hh
$(CXX) $(CXXFLAGS) $(INCLUDES) -I. -Iphy -o test_suite/$@ test_suite/test_mfsk.cc -lm
test_robust: test_suite/test_robust.cc phy/robust_modem.hh phy/common.hh
$(CXX) $(CXXFLAGS) $(INCLUDES) -I. -Iphy -o test_suite/$@ test_suite/test_robust.cc -lm
test_e2e: test_suite/test_e2e.cc modem.hh phy/robust_modem.hh phy/mfsk_modem.hh
$(CXX) $(CXXFLAGS) $(INCLUDES) -I. -Iphy -o test_suite/$@ test_suite/test_e2e.cc -lm
test_csma: test_suite/test_csma.cc csma.hh phy/robust_modem.hh miniaudio_audio.hh deps/miniaudio.o
$(CXX) $(CXXFLAGS) $(INCLUDES) -I. -Iphy -o test_suite/$@ test_suite/test_csma.cc deps/miniaudio.o -lpthread -ldl -lm
wav_decode: test_suite/wav_decode.cc modem.hh phy/robust_modem.hh phy/mfsk_modem.hh
$(CXX) $(CXXFLAGS) $(INCLUDES) -I. -Iphy -o test_suite/$@ test_suite/wav_decode.cc -lm
# 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: deps/aicodix/dsp)"
@echo " AICODIX_CODE - Path to aicodix/code (default: deps/aicodix/code)"
@echo " MODEM_SRC - Path to modem source (default: deps/aicodix/modem)"
@echo ""
@echo "Optional features:"
@echo " CM108 PTT - Requires libhidapi-dev (auto-detected)"
@echo ""
@echo "Example:"
@echo " make AICODIX_DSP=../dsp AICODIX_CODE=../code MODEM_SRC=../modem"
@echo ""
@echo "Runtime options:"
@echo " ./modem73 # Run with UI"
@echo " ./modem73 -h # Run headless"
@echo " ./modem73 --headless"