-
Notifications
You must be signed in to change notification settings - Fork 1
/
linux-x64.mk
59 lines (45 loc) · 2.06 KB
/
linux-x64.mk
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
# Copyright 2023 Sam Johnson
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
ERROR_MESSAGE := This Makefile can be run on x86_64 Linux only
CC = gcc
CPP = g++
PROTOC = bin/protoc
PROTOCFLAGS = --cpp_out=.
CFLAGS = -D_POSIX_C_SOURCE=200809L -std=c17 -O3 -fstrict-aliasing -pedantic -pedantic-errors -Wall -Wextra -I./include -I./include/deps -I./include/deps/ck
CPPFLAGS = -std=c++20 -O3 -fstrict-aliasing -Wall -Wextra -I./include -I./include/deps -I./include/deps/ck
ORIGIN=$ORIGIN
O=$$O
LDFLAGS = -Llib/linux-x64 -pthread
LIBS = -lstdc++ -ldl -lm -lssl -lcrypto -lz -lopus -luwebsockets -lraptorq -lck -lr8brain -lprotobuf-lite -lboringtun -ltinyalsa
TARGET = waterslide-linux-x64
PROTOBUFS = init-config.proto monitor.proto
SRCSC = main.c audio-linux.c sender.c receiver.c globals.c utils.c mux.c demux.c endpoint.c pcm.c event-recorder.c
SRCSCPP = syncer/enqueue.cpp syncer/resamp-state.cpp syncer/receiver-sync.cpp config.cpp monitor.cpp $(subst .proto,.pb.cpp,$(addprefix protobufs/,$(PROTOBUFS)))
OBJS = $(subst .c,.o,$(addprefix src/,$(SRCSC))) $(subst .cpp,.o,$(addprefix src/,$(SRCSCPP)))
.PHONY: exit setup
all: exit setup protobufs bin/$(TARGET)
protobufs: $(PROTOBUFS)
exit:
ifneq ($(shell uname), Linux)
$(error $(ERROR_MESSAGE))
endif
setup:
mkdir -p obj/protobufs obj/syncer include/protobufs src/protobufs
%.proto:
$(PROTOC) $(PROTOCFLAGS) protobufs/$@
mv $(subst .proto,.pb.cc,$(addprefix protobufs/,$@)) $(subst .proto,.pb.cpp,$(addprefix src/protobufs/,$@))
mv $(subst .proto,.pb.h,$(addprefix protobufs/,$@)) include/protobufs
bin/$(TARGET): $(OBJS)
$(CC) $(LDFLAGS) -o $@ $(subst src,obj,$(OBJS)) $(LIBS)
.c.o:
$(CC) $(CFLAGS) -c $< -o $(subst src,obj,$@)
.cpp.o:
$(CPP) $(CPPFLAGS) -c $< -o $(subst src,obj,$@)
clean:
rm -f \
$(subst src,obj,$(OBJS)) \
$(subst .proto,.pb.cpp,$(addprefix src/protobufs/,$(PROTOBUFS))) \
$(subst .proto,.pb.h,$(addprefix include/protobufs/,$(PROTOBUFS))) \
bin/$(TARGET) \