# st version
VERSION = 0.9.0.1

# Customize below to fit your system

# paths
PREFIX = /usr/local
MANPREFIX = $(PREFIX)/share/man

PKG_CONFIG = pkg-config
WAYLAND_SCANNER = wayland-scanner

# Wayland protocol XMLs (wayland-protocols).  pkg-config only reports a
# system-wide install, so also look in the usual data dirs (per user and
# under /usr/local).  Override with: make WLPROTO=/path/to/wayland-protocols
WLPROTO_PC = $(shell $(PKG_CONFIG) --variable=pkgdatadir wayland-protocols 2>/dev/null)
WLPROTO_USER = $(or $(XDG_DATA_HOME),$(HOME)/.local/share)/wayland-protocols
WLPROTO_DIRS = $(WLPROTO_PC) $(WLPROTO_USER)
WLPROTO_DIRS += /usr/local/share/wayland-protocols
WLPROTO_DIRS += /usr/share/wayland-protocols
WLPROTO ?= $(firstword $(foreach d,$(WLPROTO_DIRS),$(if $(wildcard $(d)/stable/xdg-shell/xdg-shell.xml),$(d))))
XDG_SHELL_XML = $(WLPROTO)/stable/xdg-shell/xdg-shell.xml
VIEWPORTER_XML = $(WLPROTO)/stable/viewporter/viewporter.xml
FRACTIONAL_XML = $(WLPROTO)/staging/fractional-scale/fractional-scale-v1.xml
CURSOR_SHAPE_XML = $(WLPROTO)/staging/cursor-shape/cursor-shape-v1.xml
SYSTEM_BELL_XML = $(WLPROTO)/staging/xdg-system-bell/xdg-system-bell-v1.xml
PRIMARY_XML = $(WLPROTO)/unstable/primary-selection/primary-selection-unstable-v1.xml
TEXT_INPUT_XML = $(WLPROTO)/unstable/text-input/text-input-unstable-v3.xml
# cursor-shape-v1 references zwp_tablet_tool_v2, so its interface must exist
TABLET_XML = $(WLPROTO)/stable/tablet/tablet-v2.xml

# includes and libs
INCS = `$(PKG_CONFIG) --cflags wayland-client xkbcommon fontconfig freetype2 harfbuzz`
LIBS = -lm -lrt -lutil \
       `$(PKG_CONFIG) --libs wayland-client xkbcommon fontconfig freetype2 harfbuzz`

# flags
CPPFLAGS = -D_DEFAULT_SOURCE -D_BSD_SOURCE -D_POSIX_C_SOURCE=200809L -D_GNU_SOURCE
CFLAGS   = -std=c99 -pedantic -Wall -Wno-deprecated-declarations -O2
STCPPFLAGS = -DVERSION=\"$(VERSION)\" -D_XOPEN_SOURCE=600
STCFLAGS = $(INCS) $(STCPPFLAGS) $(CPPFLAGS) $(CFLAGS)
STLDFLAGS = $(LIBS) $(LDFLAGS)

# compiler and linker
# CC = c99
