Fix build env issues with manual build
This commit is contained in:
13
Makefile
13
Makefile
@@ -20,20 +20,29 @@ OBJS_TEST := $(addprefix $(BUILD)/,$(addsuffix .o,config log net proto json ser
|
|||||||
|
|
||||||
PYTHON ?= python3
|
PYTHON ?= python3
|
||||||
|
|
||||||
.PHONY: all test test-c test-web install clean docker-test
|
.PHONY: all test test-c test-web install clean docker-test check-deps
|
||||||
|
|
||||||
all: $(BUILD)/patchbayd
|
all: $(BUILD)/patchbayd
|
||||||
|
|
||||||
$(BUILD):
|
$(BUILD):
|
||||||
mkdir -p $(BUILD)
|
mkdir -p $(BUILD)
|
||||||
|
|
||||||
|
# Fails early with a hint instead of a missing-header compiler error.
|
||||||
|
check-deps:
|
||||||
|
@pkg-config --exists $(PKGS) || { \
|
||||||
|
echo "missing build dependencies (pkg-config cannot find: $(PKGS))" >&2; \
|
||||||
|
echo " APT: sudo apt-get install build-essential pkg-config libssh2-1-dev libsqlite3-dev" >&2; \
|
||||||
|
echo " XBPS: sudo xbps-install base-devel pkg-config libssh2-devel sqlite-devel" >&2; \
|
||||||
|
echo " or: sudo ./install.sh --role client|target (keeps an existing config)" >&2; \
|
||||||
|
exit 1; }
|
||||||
|
|
||||||
# Embed schema.sql as a C string so the daemon has no runtime file dependency.
|
# Embed schema.sql as a C string so the daemon has no runtime file dependency.
|
||||||
$(BUILD)/schema.h: schema.sql | $(BUILD)
|
$(BUILD)/schema.h: schema.sql | $(BUILD)
|
||||||
{ printf 'static const char pb_schema_sql[] =\n'; \
|
{ printf 'static const char pb_schema_sql[] =\n'; \
|
||||||
sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/^/"/' -e 's/$$/\\n"/' $<; \
|
sed -e 's/\\/\\\\/g' -e 's/"/\\"/g' -e 's/^/"/' -e 's/$$/\\n"/' $<; \
|
||||||
printf ';\n'; } > $@
|
printf ';\n'; } > $@
|
||||||
|
|
||||||
$(BUILD)/%.o: $(SRC)/%.c $(wildcard $(SRC)/*.h) $(BUILD)/schema.h | $(BUILD)
|
$(BUILD)/%.o: $(SRC)/%.c $(wildcard $(SRC)/*.h) $(BUILD)/schema.h | $(BUILD) check-deps
|
||||||
$(CC) $(CFLAGS) $(PKG_CFLAGS) -I$(BUILD) -c -o $@ $<
|
$(CC) $(CFLAGS) $(PKG_CFLAGS) -I$(BUILD) -c -o $@ $<
|
||||||
|
|
||||||
$(BUILD)/patchbayd: $(OBJS_ALL)
|
$(BUILD)/patchbayd: $(OBJS_ALL)
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ struct route {
|
|||||||
int sink_id;
|
int sink_id;
|
||||||
int sink_type;
|
int sink_type;
|
||||||
int sink_client;
|
int sink_client;
|
||||||
char bind[64];
|
char bind[256];
|
||||||
char sink_iface[IFNAMSIZ];
|
char sink_iface[IFNAMSIZ];
|
||||||
int port;
|
int port;
|
||||||
int proto;
|
int proto;
|
||||||
@@ -80,7 +80,7 @@ struct tsink {
|
|||||||
struct ev ev;
|
struct ev ev;
|
||||||
struct tsink *next;
|
struct tsink *next;
|
||||||
int sink_id;
|
int sink_id;
|
||||||
char bind[64];
|
char bind[256];
|
||||||
char iface[IFNAMSIZ];
|
char iface[IFNAMSIZ];
|
||||||
unsigned ifindex; // detects a recreated tun interface
|
unsigned ifindex; // detects a recreated tun interface
|
||||||
int port;
|
int port;
|
||||||
@@ -1144,7 +1144,7 @@ static void apply_target_sinks(void)
|
|||||||
int fd = net_listen(r->bind, r->port, r->proto, r->sink_iface);
|
int fd = net_listen(r->bind, r->port, r->proto, r->sink_iface);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
char msg[128];
|
char msg[128];
|
||||||
snprintf(msg, sizeof(msg), "bind %s:%d failed: %s", r->bind, r->port, strerror(errno));
|
snprintf(msg, sizeof(msg), "bind %.64s:%d failed: %s", r->bind, r->port, strerror(errno));
|
||||||
if (strcmp(r->state_err, msg))
|
if (strcmp(r->state_err, msg))
|
||||||
log_warn("sink %d: %s", r->sink_id, msg);
|
log_warn("sink %d: %s", r->sink_id, msg);
|
||||||
snprintf(r->state_err, sizeof(r->state_err), "%s", msg);
|
snprintf(r->state_err, sizeof(r->state_err), "%s", msg);
|
||||||
|
|||||||
Reference in New Issue
Block a user