-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakefile
executable file
·127 lines (98 loc) · 2.74 KB
/
makefile
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
123
124
125
126
127
# This avoids garbled GCC output but prevents running an interactive
# command efficiently :(
ifeq ($(filter run debug,$(MAKECMDGOALS)), )
MAKEFLAGS=-Oline
endif
MAKEFLAGS+=-j
#CXXFLAGS+=-O3 -g
CXXFLAGS+= -g
# Cross-compiler I found is too old for c++20.
CXXFLAGS+=-std=c++2a -Wall -Werror -Wextra
CXXFLAGS+=-fdiagnostics-color=always
# We compile everything with a recent enough GCC hopefully ...
# wxwidgets is the only C++ dependency.
CXXFLAGS+=-Wno-psabi
LFLAGS += -lstdc++fs
#### Cross compilation stuff ####
ifndef X86
CXX=arm-linux-gnueabihf-g++.exe
# This needs to contain includes and binaries for:
# - alsa
# - wxwidgets
# - fmt
# - flac (C APIs only)
# The includes must be in their own folder per project (say fmt/format.h).
# The libraries must all be in the "lib" subfolder.
ROOT=../pi
endif
#### ----------------------- ####
#### LIBRARIES ####
CXXFLAGS+=-I$(ROOT)
LFLAGS+=-L$(ROOT)/lib
# WXWidgets, got from wx-config --cxxflags
CXXFLAGS+= -D_FILE_OFFSET_BITS=64 -DWXUSINGDLL -D__WXGTK__ -pthread
# others
LFLAGS += -lasound -lfmt -lFLAC
# ffmpeg requires dl
LFLAGS += -ldl -lavcodec -lavformat -lavutil
#### --------- ####
BIN = pisample
.PHONY: all
all: $(BIN)
SRC = main.cpp \
Alsa.cpp \
Device.cpp \
ffmpeg.cpp \
Pads.cpp \
PiSample.cpp \
Player.cpp \
Recorder.cpp \
Strings.cpp \
#
OBJ := $(patsubst %.cpp,%.o,$(SRC))
DEPS := $(patsubst %.o,%.d,$(OBJ))
PATHOBJ = $(patsubst %.o,obj/%.o,$(OBJ))
PATHDEPS = $(patsubst %.d,obj/%.d,$(DEPS))
ifneq ($(MAKECMDGOALS), clean)
-include $(PATHDEPS)
endif
.PHONY: obj
obj:
@mkdir -p obj
obj/%.o: %.cpp | obj
$(CXX) $(CXXFLAGS) $(CFLAGS) -MMD -MP -c -o $@ $<
$(OBJ) : $(DEPS)
$(BIN): $(PATHOBJ)
$(BIN):
$(CXX) $(CXXFLAGS) $(CFLAGS) -o $(BIN) $(PATHOBJ) $(LFLAGS)
# ---- run ----
# run on the PI from the host via `make run`
# need SSH keys in the proper places
ifndef PI_IP
ifneq ($(filter sync run debug,$(MAKECMDGOALS)), )
PI_HOST?=raspberrypi.local
PI_IP:=$(shell dig $(PI_HOST) A +noall +answer | sed -r 's/.*A[ \t]*(.*)/\1/')
endif
endif
PI:=pi@$(PI_IP)
.PHONY: sync run debug clean
sync: $(BIN)
@echo "Connecting to ${PI}"
@scp $(BIN) *.cpp *.h *.sh *.ini $(PI):pisample/ 1>/dev/null 2>/dev/null
@echo "Synch’ed files"
### !! The command lines when running debugging
ARGS = --config ~/pisample/config.ini \
# --record \
#
#--audio-in-card pulse \
run: sync
$(info ${ARGS})
@echo ssh -t $(PI) "bash -c '~/pisample/pisample ${ARGS}'"
@ssh -t $(PI) "bash -c '~/pisample/pisample ${ARGS}'"
debug: sync
@echo ssh -t $(PI) bash -c 'cd pisample && gdb --args ~/pisample/pisample ${ARGS}'
@ssh -t $(PI) bash -c 'cd pisample && gdb --args ~/pisample/pisample ${ARGS}'
# ---- /run ---
clean:
rm -rf $(BIN)
rm -rf obj