This commit is contained in:
Luxferre
2026-10-12 07:43:34 +03:00
commit fc2e01da4d
7 changed files with 1554 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
# Makefile for hygate-c - POSIX-compatible (builds on Linux, FreeBSD, macOS)
# Third-party dependencies: libcurl and json-c (auto-detected via pkg-config).
CC ?= cc
CFLAGS ?= -O3 -flto -pipe -std=c11 -Wall -Wextra -pthread -D_POSIX_C_SOURCE=200809L
SRCS = main.c server.c jsonapi.c util.c
HDRS = hygate.h
BINDIR = bin
BIN = $(BINDIR)/hygate
STATICBIN = $(BINDIR)/hygate.static
# Library flags resolved at recipe time via pkg-config (portable backtick form).
# Falls back to plain -lcurl -ljson-c when pkg-config is unavailable.
LIBS = $$(pkg-config --cflags --libs libcurl json-c 2>/dev/null || echo '-lcurl -ljson-c')
# For static builds we need the full transitive dependency list, which
# pkg-config --static provides (nghttp2, ssl, crypto, z, ...).
STATICLIBS = $$(pkg-config --static --cflags --libs libcurl json-c 2>/dev/null || echo '-lcurl -ljson-c')
.PHONY: all static clean
all: $(BIN)
static: $(STATICBIN)
$(BIN): $(SRCS) $(HDRS)
@test -d $(BINDIR) || mkdir $(BINDIR)
$(CC) $(CFLAGS) $(SRCS) -o $@ $(LIBS)
$(STATICBIN): $(SRCS) $(HDRS)
@test -d $(BINDIR) || mkdir $(BINDIR)
$(CC) $(CFLAGS) -static $(SRCS) -o $@ $(STATICLIBS)
clean:
rm -rf $(BINDIR)