Feature flags (FEATURES= make variable):
glfw — GLFW + OpenGL viewer (libglfw3, libglew)
vulkan — future Vulkan renderer
turbojpeg — MJPEG decode/encode (libturbojpeg)
xorg — XRandR geometry + screen grab (libx11, libxrandr)
vaapi — VA-API hardware codec (libva)
Each flag injects -DHAVE_<FEATURE> and the relevant pkg-config flags.
Headless build: make (no FEATURES set).
test_image module (src/modules/test_image/):
Generates test frames in YUV420, YUV422, and BGRA.
Patterns: SMPTE 75% colour bars, greyscale ramp, white/black grid.
BT.601 limited-range RGB→YCbCr in write_pixel().
test_image_cli (dev/cli/):
Generates a frame and writes it as a PPM file for visual verification.
Usage: test_image_cli [--pattern bars|ramp|grid]
[--width N] [--height N]
[--format yuv420|yuv422|bgra]
--out FILE.ppm
xorg module (src/modules/xorg/):
xorg.c — full GLFW+OpenGL implementation (compiled with FEATURES=glfw)
xorg_stub.c — no-op stub (compiled otherwise; xorg_available() returns false)
Renderer: full-screen quad via gl_VertexID, three GL_R8 textures for YUV,
BT.601 matrix in fragment shader, GL_BGRA texture for packed frames.
MJPEG path: tjDecompressToYUVPlanes → planar YUV → upload (requires turbojpeg).
push_yuv420/push_bgra/push_mjpeg all usable independently.
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 ?=
|
|
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)
|