master Makefile
ohmu  ·  2026-10-18
 1.POSIX:
 2.SUFFIXES:
 3
 4include config.mk
 5include modules.mk
 6
 7VPATH = src
 8
 9# flags for compiling
10LEELOOCPPFLAGS = -I. -DWLR_USE_UNSTABLE -D_POSIX_C_SOURCE=200809L \
11	-DVERSION=\"$(VERSION)\" $(XWAYLAND)
12LEELOODEVCFLAGS = -g -Wpedantic -Wall -Wextra -Wdeclaration-after-statement \
13	-Wno-unused-parameter -Wshadow -Wunused-macros -Werror=strict-prototypes \
14	-Werror=implicit -Werror=return-type -Werror=incompatible-pointer-types \
15	-Wfloat-conversion
16
17# CFLAGS / LDFLAGS
18PKGS      = wayland-server xkbcommon libinput $(XLIBS)
19LEELOOCFLAGS = `$(PKG_CONFIG) --cflags $(PKGS)` $(WLR_INCS) $(LEELOOMODULES) $(LEELOOCPPFLAGS) $(LEELOODEVCFLAGS) $(CFLAGS)
20LDLIBS    = `$(PKG_CONFIG) --libs $(PKGS)` $(WLR_LIBS) -lm $(LIBS)
21
22all: leeloo
23leeloo: leeloo.o util.o
24	$(CC) leeloo.o util.o $(LEELOOCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@
25leeloo.o: leeloo.c client.h config.h config.mk cursor-shape-v1-protocol.h \
26	pointer-constraints-unstable-v1-protocol.h wlr-layer-shell-unstable-v1-protocol.h \
27	wlr-output-power-management-unstable-v1-protocol.h xdg-shell-protocol.h \
28	tablet-v2-protocol.h
29util.o: util.c util.h
30
31# wayland-scanner is a tool which generates C headers and rigging for Wayland
32# protocols, which are specified in XML. wlroots requires you to rig these up
33# to your build system yourself and provide them in the include path.
34WAYLAND_SCANNER   = `$(PKG_CONFIG) --variable=wayland_scanner wayland-scanner`
35WAYLAND_PROTOCOLS = `$(PKG_CONFIG) --variable=pkgdatadir wayland-protocols`
36
37cursor-shape-v1-protocol.h:
38	$(WAYLAND_SCANNER) enum-header \
39		$(WAYLAND_PROTOCOLS)/staging/cursor-shape/cursor-shape-v1.xml $@
40pointer-constraints-unstable-v1-protocol.h:
41	$(WAYLAND_SCANNER) enum-header \
42		$(WAYLAND_PROTOCOLS)/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml $@
43wlr-layer-shell-unstable-v1-protocol.h:
44	$(WAYLAND_SCANNER) enum-header \
45		protocols/wlr-layer-shell-unstable-v1.xml $@
46wlr-output-power-management-unstable-v1-protocol.h:
47	$(WAYLAND_SCANNER) server-header \
48		protocols/wlr-output-power-management-unstable-v1.xml $@
49xdg-shell-protocol.h:
50	$(WAYLAND_SCANNER) server-header \
51		$(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@
52# tablet-input
53tablet-v2-protocol.h:
54	$(WAYLAND_SCANNER) server-header \
55		$(WAYLAND_PROTOCOLS)/unstable/tablet/tablet-unstable-v2.xml $@
56# tablet-input end
57config.h:
58	cp config.def.h $@
59clean:
60	rm -f leeloo *.o *-protocol.h leeloo-*.tar.gz
61
62dist: clean
63	mkdir -p leeloo-$(VERSION)
64	mkdir -p leeloo-$(VERSION)/src
65	cp -R LICENSE* Makefile config.def.h \
66		config.mk modules.mk protocols leeloo.desktop \
67		leeloo-$(VERSION)
68	cp -R src/leeloo.c src/client.h src/util.c src/util.h leeloo-$(VERSION)/src/
69	tar -caf leeloo-$(VERSION).tar.gz leeloo-$(VERSION)
70
71	rm -rf leeloo-$(VERSION)
72
73install: leeloo
74
75	mkdir -p $(DESTDIR)$(PREFIX)/bin
76	rm -f $(DESTDIR)$(PREFIX)/bin/leeloo
77	cp -f leeloo $(DESTDIR)$(PREFIX)/bin
78	chmod 755 $(DESTDIR)$(PREFIX)/bin/leeloo
79	mkdir -p $(DESTDIR)$(MANDIR)/man1
80	mkdir -p $(DESTDIR)$(DATADIR)/wayland-sessions
81	cp -f leeloo.desktop $(DESTDIR)$(DATADIR)/wayland-sessions/leeloo.desktop
82	chmod 644 $(DESTDIR)$(DATADIR)/wayland-sessions/leeloo.desktop
83uninstall:
84	rm -f $(DESTDIR)$(PREFIX)/bin/leeloo \
85		$(DESTDIR)$(DATADIR)/wayland-sessions/leeloo.desktop
86
87.SUFFIXES: .c .o
88.c.o:
89	$(CC) $(CPPFLAGS) $(LEELOOCFLAGS) -o $@ -c $<