make — builds with glfw, vulkan, turbojpeg, xorg, vaapi make FEATURES= — headless build with no optional dependencies Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
61 lines
2.5 KiB
Makefile
61 lines
2.5 KiB
Makefile
# Included by all module and cli Makefiles.
|
|
# Each including Makefile must set ROOT before including this file:
|
|
# ROOT := $(abspath <relative path to repo root>)
|
|
|
|
CC = gcc
|
|
CFLAGS = -std=c11 -Wall -Wextra -D_GNU_SOURCE -flto -I$(ROOT)/include
|
|
BUILD = $(ROOT)/build
|
|
|
|
# Automatic dependency generation.
|
|
# -MMD emit a .d file listing header prerequisites alongside each .o
|
|
# -MP add phony targets for headers so removed headers don't break make
|
|
DEPFLAGS = -MMD -MP
|
|
|
|
# -----------------------------------------------------------------------
|
|
# Feature flags
|
|
# Set FEATURES to a space-separated list of optional deps to enable.
|
|
# Example: make FEATURES="glfw turbojpeg"
|
|
# Headless (no optional deps): make FEATURES=
|
|
#
|
|
# Available features:
|
|
# glfw — GLFW window management + OpenGL renderer (libglfw3, libglew)
|
|
# vulkan — GLFW window management + Vulkan renderer (vulkan-loader, libglfw3)
|
|
# turbojpeg — MJPEG encode/decode (libturbojpeg)
|
|
# xorg — XRandR geometry queries + XShmGetImage screen grab (libx11, libxrandr)
|
|
# vaapi — VA-API hardware encode/decode (libva)
|
|
# -----------------------------------------------------------------------
|
|
FEATURES ?= glfw vulkan turbojpeg xorg vaapi
|
|
export FEATURES
|
|
|
|
# Inject HAVE_ defines into CFLAGS
|
|
CFLAGS += $(if $(filter glfw, $(FEATURES)),-DHAVE_GLFW)
|
|
CFLAGS += $(if $(filter vulkan, $(FEATURES)),-DHAVE_VULKAN)
|
|
CFLAGS += $(if $(filter turbojpeg, $(FEATURES)),-DHAVE_TURBOJPEG)
|
|
CFLAGS += $(if $(filter xorg, $(FEATURES)),-DHAVE_XORG)
|
|
CFLAGS += $(if $(filter vaapi, $(FEATURES)),-DHAVE_VAAPI)
|
|
|
|
# Per-feature pkg-config flags — accumulated into PKG_CFLAGS / PKG_LDFLAGS.
|
|
# Modules that need them add $(PKG_CFLAGS) to their compile rules.
|
|
# The node and cli link rules append $(PKG_LDFLAGS).
|
|
PKG_CFLAGS :=
|
|
PKG_LDFLAGS :=
|
|
|
|
ifneq (,$(filter glfw,$(FEATURES)))
|
|
PKG_CFLAGS += $(shell pkg-config --cflags glfw3 glew 2>/dev/null)
|
|
PKG_LDFLAGS += $(shell pkg-config --libs glfw3 glew 2>/dev/null) -lGL
|
|
endif
|
|
ifneq (,$(filter turbojpeg,$(FEATURES)))
|
|
PKG_CFLAGS += $(shell pkg-config --cflags libturbojpeg 2>/dev/null)
|
|
PKG_LDFLAGS += $(shell pkg-config --libs libturbojpeg 2>/dev/null)
|
|
endif
|
|
ifneq (,$(filter xorg,$(FEATURES)))
|
|
PKG_CFLAGS += $(shell pkg-config --cflags x11 xrandr 2>/dev/null)
|
|
PKG_LDFLAGS += $(shell pkg-config --libs x11 xrandr 2>/dev/null)
|
|
endif
|
|
ifneq (,$(filter vaapi,$(FEATURES)))
|
|
PKG_CFLAGS += $(shell pkg-config --cflags libva 2>/dev/null)
|
|
PKG_LDFLAGS += $(shell pkg-config --libs libva 2>/dev/null)
|
|
endif
|
|
|
|
CFLAGS += $(PKG_CFLAGS)
|