CC ?= gcc CXX ?= c++ CFLAGS ?= -Wall -Wextra -Wno-format-truncation -O2 -std=c11 CXXFLAGS ?= -Wall -Wextra -O2 -std=c++17 LDFLAGS ?= PREFIX ?= /usr DESTDIR ?= # json-c via pkg-config JSON_C_CFLAGS := $(shell pkg-config --cflags json-c) JSON_C_LIBS := $(shell pkg-config --libs json-c) # Wayland + EGL + GLESv2 + FreeType WL_CFLAGS := $(shell pkg-config --cflags wayland-client wayland-egl egl glesv2 freetype2) WL_LIBS := $(shell pkg-config --libs wayland-client wayland-egl egl glesv2 freetype2) -lrt -lm # Wayfire plugin helper for compositor cursor control WF_CFLAGS := $(shell pkg-config --cflags wayfire wf-utils) WF_LIBS := $(shell pkg-config --libs wayfire wf-utils) WF_PLUGINDIR := $(shell pkg-config --variable=plugindir wayfire) WF_METADATADIR := $(shell pkg-config --variable=metadatadir wayfire) # Protocol XML sources WLR_LAYER_SHELL_XML ?= wlr-layer-shell-unstable-v1.xml XDG_OUTPUT_XML ?= $(shell pkg-config --variable=pkgdatadir wayland-protocols)/unstable/xdg-output/xdg-output-unstable-v1.xml XDG_SHELL_XML ?= $(shell pkg-config --variable=pkgdatadir wayland-protocols)/stable/xdg-shell/xdg-shell.xml EXT_IDLE_NOTIFY_XML ?= $(shell pkg-config --variable=pkgdatadir wayland-protocols)/staging/ext-idle-notify/ext-idle-notify-v1.xml # Generated protocol files PROTO_HEADERS := wlr-layer-shell-unstable-v1-client-protocol.h \ xdg-output-unstable-v1-client-protocol.h \ xdg-shell-client-protocol.h \ ext-idle-notify-v1-client-protocol.h PROTO_SOURCES := wlr-layer-shell-unstable-v1-protocol.c \ xdg-output-unstable-v1-protocol.c \ xdg-shell-protocol.c \ ext-idle-notify-v1-protocol.c .PHONY: all clean install install-conf IDLE_PLUGIN := $(if $(wildcard oledsaver-idle.cpp),liboledsaver-idle.so) SAMPLER_PLUGIN := $(if $(wildcard oledsaver-sampler.cpp),liboledsaver-sampler.so) all: oledsaver liboledsaver-cursor.so $(IDLE_PLUGIN) $(SAMPLER_PLUGIN) # ── Protocol generation ────────────────────────────────────────────── wlr-layer-shell-unstable-v1-client-protocol.h: $(WLR_LAYER_SHELL_XML) wayland-scanner client-header $< $@ wlr-layer-shell-unstable-v1-protocol.c: $(WLR_LAYER_SHELL_XML) wayland-scanner private-code $< $@ xdg-output-unstable-v1-client-protocol.h: $(XDG_OUTPUT_XML) wayland-scanner client-header $< $@ xdg-output-unstable-v1-protocol.c: $(XDG_OUTPUT_XML) wayland-scanner private-code $< $@ xdg-shell-client-protocol.h: $(XDG_SHELL_XML) wayland-scanner client-header $< $@ xdg-shell-protocol.c: $(XDG_SHELL_XML) wayland-scanner private-code $< $@ ext-idle-notify-v1-client-protocol.h: $(EXT_IDLE_NOTIFY_XML) wayland-scanner client-header $< $@ ext-idle-notify-v1-protocol.c: $(EXT_IDLE_NOTIFY_XML) wayland-scanner private-code $< $@ # ── oledsaver (combined manager + renderer) ────────────────────────── oledsaver: oledsaver.c $(PROTO_SOURCES) $(PROTO_HEADERS) $(CC) $(CFLAGS) $(JSON_C_CFLAGS) $(WL_CFLAGS) -o $@ oledsaver.c $(PROTO_SOURCES) $(LDFLAGS) $(JSON_C_LIBS) $(WL_LIBS) -lpthread liboledsaver-cursor.so: oledsaver-cursor.cpp $(CXX) $(CXXFLAGS) -fPIC -shared -DWAYFIRE_PLUGIN -DWLR_USE_UNSTABLE $(WF_CFLAGS) -o $@ $< $(LDFLAGS) $(WF_LIBS) liboledsaver-idle.so: oledsaver-idle.cpp $(CXX) $(CXXFLAGS) -fPIC -shared -DWAYFIRE_PLUGIN -DWLR_USE_UNSTABLE $(WF_CFLAGS) -o $@ $< $(LDFLAGS) $(WF_LIBS) liboledsaver-sampler.so: oledsaver-sampler.cpp $(CXX) $(CXXFLAGS) -fPIC -shared -DWAYFIRE_PLUGIN -DWLR_USE_UNSTABLE $(WF_CFLAGS) -o $@ $< $(LDFLAGS) $(WF_LIBS) # ── Install / Clean ───────────────────────────────────────────────── install: oledsaver liboledsaver-cursor.so $(IDLE_PLUGIN) $(SAMPLER_PLUGIN) install -Dm755 oledsaver $(DESTDIR)$(PREFIX)/bin/oledsaver install -Dm755 liboledsaver-cursor.so $(DESTDIR)$(WF_PLUGINDIR)/liboledsaver-cursor.so install -Dm644 oledsaver-cursor.xml $(DESTDIR)$(WF_METADATADIR)/oledsaver-cursor.xml ifneq ($(IDLE_PLUGIN),) install -Dm755 liboledsaver-idle.so $(DESTDIR)$(WF_PLUGINDIR)/liboledsaver-idle.so install -Dm644 oledsaver-idle.xml $(DESTDIR)$(WF_METADATADIR)/oledsaver-idle.xml endif ifneq ($(SAMPLER_PLUGIN),) install -Dm755 liboledsaver-sampler.so $(DESTDIR)$(WF_PLUGINDIR)/liboledsaver-sampler.so install -Dm644 oledsaver-sampler.xml $(DESTDIR)$(WF_METADATADIR)/oledsaver-sampler.xml endif install-conf: install -Dm644 oledsaver.conf.default $(DESTDIR)/etc/oledsaver.conf clean: rm -f oledsaver liboledsaver-cursor.so liboledsaver-idle.so liboledsaver-sampler.so $(PROTO_HEADERS) $(PROTO_SOURCES)