Initial Awawawa
This commit is contained in:
69
Makefile
Normal file
69
Makefile
Normal file
@@ -0,0 +1,69 @@
|
||||
# PatchBay top-level Makefile
|
||||
|
||||
PREFIX ?= /usr/local
|
||||
SBINDIR ?= $(PREFIX)/sbin
|
||||
LIBDIR ?= $(PREFIX)/lib/patchbay
|
||||
DESTDIR ?=
|
||||
|
||||
CC ?= cc
|
||||
CFLAGS ?= -O2 -g
|
||||
CFLAGS += -std=c99 -D_GNU_SOURCE -Wall -Wextra -Wno-unused-parameter
|
||||
PKGS := libssh2 sqlite3
|
||||
PKG_CFLAGS := $(shell pkg-config --cflags $(PKGS))
|
||||
PKG_LIBS := $(shell pkg-config --libs $(PKGS))
|
||||
|
||||
BUILD := build
|
||||
SRC := backend/src
|
||||
COMMON := config log net proto json services db stats
|
||||
OBJS_ALL := $(addprefix $(BUILD)/,$(addsuffix .o,$(COMMON) hub client relay main))
|
||||
OBJS_TEST := $(addprefix $(BUILD)/,$(addsuffix .o,config log net proto json services))
|
||||
|
||||
PYTHON ?= python3
|
||||
|
||||
.PHONY: all test test-c test-web install clean docker-test
|
||||
|
||||
all: $(BUILD)/patchbayd
|
||||
|
||||
$(BUILD):
|
||||
mkdir -p $(BUILD)
|
||||
|
||||
# Embed schema.sql as a C string so the daemon has no runtime file dependency.
|
||||
$(BUILD)/schema.h: schema.sql | $(BUILD)
|
||||
{ printf 'static const char pb_schema_sql[] =\n'; \
|
||||
sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/^/"/' -e 's/$$/\\n"/' $<; \
|
||||
printf ';\n'; } > $@
|
||||
|
||||
$(BUILD)/%.o: $(SRC)/%.c $(wildcard $(SRC)/*.h) $(BUILD)/schema.h | $(BUILD)
|
||||
$(CC) $(CFLAGS) $(PKG_CFLAGS) -I$(BUILD) -c -o $@ $<
|
||||
|
||||
$(BUILD)/patchbayd: $(OBJS_ALL)
|
||||
$(CC) $(CFLAGS) -o $@ $^ $(PKG_LIBS)
|
||||
|
||||
$(BUILD)/test_runner: backend/tests/test_main.c $(OBJS_TEST)
|
||||
$(CC) $(CFLAGS) $(PKG_CFLAGS) -I$(BUILD) -o $@ $^ $(PKG_LIBS)
|
||||
|
||||
test: test-c test-web
|
||||
|
||||
# Single C test: make test-c T=services_parse
|
||||
test-c: $(BUILD)/test_runner
|
||||
$(BUILD)/test_runner $(T)
|
||||
|
||||
# Single web test: make test-web T=tests.test_auth.AuthTest.test_login_2fa
|
||||
test-web:
|
||||
cd web && $(PYTHON) -m unittest $(if $(T),$(T),discover -s tests -t .) -v
|
||||
|
||||
install: all
|
||||
install -Dm755 $(BUILD)/patchbayd $(DESTDIR)$(SBINDIR)/patchbayd
|
||||
install -Dm755 sshd/patchbay-sshd $(DESTDIR)$(LIBDIR)/patchbay-sshd
|
||||
install -Dm644 sshd/sshd_config.in $(DESTDIR)$(LIBDIR)/sshd_config.in
|
||||
mkdir -p $(DESTDIR)$(LIBDIR)/web
|
||||
cp -r web/patchbay_web $(DESTDIR)$(LIBDIR)/web/
|
||||
install -Dm644 schema.sql $(DESTDIR)$(LIBDIR)/web/patchbay_web/schema.sql
|
||||
rm -rf $(DESTDIR)$(LIBDIR)/web/patchbay_web/__pycache__
|
||||
|
||||
# Builds the images and runs the target + clients integration test.
|
||||
docker-test:
|
||||
docker/run-tests.sh
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILD)
|
||||
Reference in New Issue
Block a user