fix: enhance Makefile by integrating pkg-config for dependency management
Some checks failed
C/C++ CI / build (push) Failing after 17s
C/C++ CI / test (push) Has been skipped
C/C++ CI / code-quality (push) Failing after 32s
C/C++ CI / security-scan (push) Failing after 21s
CI Pipeline / build (push) Failing after 17s
CI Pipeline / test (push) Has been skipped
CI Pipeline / security-scan (push) Failing after 13s
CI Pipeline / code-quality (push) Failing after 35s
CI Pipeline / docker-build (push) Has been cancelled

This commit is contained in:
2025-12-20 23:13:20 +01:00
parent ace79ee1c1
commit 71a397f0d6

View File

@@ -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))