From 71a397f0d631849d6b8fbd61a61c259154564216 Mon Sep 17 00:00:00 2001 From: Azreyo <58790873+Azreyo@users.noreply.github.com> Date: Sat, 20 Dec 2025 23:13:20 +0100 Subject: [PATCH] fix: enhance Makefile by integrating pkg-config for dependency management --- Makefile | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index c3b0311..d54ec9a 100644 --- a/Makefile +++ b/Makefile @@ -15,6 +15,16 @@ CFLAGS += -D_FORTIFY_SOURCE=2 -fvisibility=hidden LDFLAGS = -pthread -Wl,-z,relro,-z,now -pie LIBS = -lssl -lcrypto -lmagic -lnghttp2 -lz +# Use pkg-config for dependencies if available +PKG_CONFIG := $(shell command -v pkg-config 2>/dev/null) +ifdef PKG_CONFIG + PKG_CFLAGS := $(shell pkg-config --cflags-only-I libssl libnghttp2 2>/dev/null) + PKG_LIBS := $(shell pkg-config --libs openssl libnghttp2 2>/dev/null) + ifneq ($(PKG_LIBS),) + LIBS = $(PKG_LIBS) -lmagic -lz + endif +endif + # Source files and object files SRCS = src/server.c src/config_parser.c src/server_config.c src/websocket.c src/http2.c src/performance.c src/logging.c DEST = src/bin/ @@ -24,8 +34,8 @@ TARGET = server # Header files HEADERS = src/server_config.h src/websocket.h src/http2.h src/performance.h src/logging.h -# Include directories -INCLUDES = +# Include directories - add common paths where libmagic headers might be +INCLUDES = $(PKG_CFLAGS) -I/usr/include -I/usr/local/include # Count total number of source files TOTAL_FILES := $(words $(SRCS))