crywl/Makefile

103 lines
3.8 KiB
Makefile
Raw Normal View History

2022-05-25 16:04:19 -06:00
.POSIX:
.SUFFIXES:
2025-08-26 15:45:07 +10:00
.DEFAULT_GOAL := all
2022-05-25 16:04:19 -06:00
include config.mk
2022-05-25 16:04:19 -06:00
# flags for compiling
2025-08-26 15:53:39 +10:00
DWLCPPFLAGS = -I$(INCLUDE) -DWLR_USE_UNSTABLE -D_POSIX_C_SOURCE=200809L \
-DVERSION=\"$(VERSION)\" $(XWAYLAND)
DWLDEVCFLAGS = -g -Wpedantic -Wall -Wextra -Wdeclaration-after-statement \
-Wno-unused-parameter -Wshadow -Wunused-macros -Werror=strict-prototypes \
-Werror=implicit -Werror=return-type -Werror=incompatible-pointer-types \
-Wfloat-conversion
2022-05-25 16:04:19 -06:00
# CFLAGS / LDFLAGS
PKGS = wayland-server xkbcommon libinput $(XLIBS)
DWLCFLAGS = `$(PKG_CONFIG) --cflags $(PKGS)` $(WLR_INCS) $(DWLCPPFLAGS) $(DWLDEVCFLAGS) $(CFLAGS)
LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` $(WLR_LIBS) -lm $(LIBS)
2025-08-26 15:45:07 +10:00
# macros to relevant path definitions
define mkbin
$(addprefix $(BIN)/,$1)
endef
2025-08-26 15:53:39 +10:00
define mkobj
$(addprefix $(OBJ)/,$1)
endef
define mkinclude
$(addprefix $(INCLUDE)/,$1)
2025-08-26 15:45:07 +10:00
endef
define mksrc
$(addprefix $(SRC)/,$1)
endef
.PHONY: setup
setup:
2025-08-26 15:53:39 +10:00
mkdir -p $(BIN) $(BUILD) $(INCLUDE) $(OBJ)
2025-08-26 15:45:07 +10:00
all: setup $(BIN)/$(BINARY) $(BUILD)/$(BINARY).desktop
$(BIN)/$(BINARY): $(call mkobj,main.o util.o)
2025-08-26 15:45:07 +10:00
$(CC) $^ $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@
$(OBJ)/main.o: $(call mksrc,main.c client.h) config.mk $(call mkinclude,config.h cursor-shape-v1-protocol.h \
pointer-constraints-unstable-v1-protocol.h wlr-layer-shell-unstable-v1-protocol.h \
2025-08-26 15:45:07 +10:00
wlr-output-power-management-unstable-v1-protocol.h xdg-shell-protocol.h)
2025-08-26 15:53:39 +10:00
$(OBJ)/util.o: $(call mksrc,util.c util.h)
2022-05-25 16:04:19 -06:00
# wayland-scanner is a tool which generates C headers and rigging for Wayland
# protocols, which are specified in XML. wlroots requires you to rig these up
# to your build system yourself and provide them in the include path.
WAYLAND_SCANNER = `$(PKG_CONFIG) --variable=wayland_scanner wayland-scanner`
WAYLAND_PROTOCOLS = `$(PKG_CONFIG) --variable=pkgdatadir wayland-protocols`
2025-08-26 15:53:39 +10:00
$(INCLUDE)/cursor-shape-v1-protocol.h:
2024-05-30 15:00:05 -06:00
$(WAYLAND_SCANNER) enum-header \
$(WAYLAND_PROTOCOLS)/staging/cursor-shape/cursor-shape-v1.xml $@
2025-08-26 15:53:39 +10:00
$(INCLUDE)/pointer-constraints-unstable-v1-protocol.h:
2024-05-30 15:00:05 -06:00
$(WAYLAND_SCANNER) enum-header \
$(WAYLAND_PROTOCOLS)/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml $@
2025-08-26 15:53:39 +10:00
$(INCLUDE)/wlr-layer-shell-unstable-v1-protocol.h:
2024-05-30 15:00:05 -06:00
$(WAYLAND_SCANNER) enum-header \
2020-08-24 07:04:34 +02:00
protocols/wlr-layer-shell-unstable-v1.xml $@
2025-08-26 15:53:39 +10:00
$(INCLUDE)/wlr-output-power-management-unstable-v1-protocol.h:
$(WAYLAND_SCANNER) server-header \
protocols/wlr-output-power-management-unstable-v1.xml $@
2025-08-26 15:53:39 +10:00
$(INCLUDE)/xdg-shell-protocol.h:
$(WAYLAND_SCANNER) server-header \
$(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@
2025-08-26 15:53:39 +10:00
$(INCLUDE)/config.h:
2025-08-26 15:45:07 +10:00
cp $(SRC)/config.def.h $@
$(BUILD)/$(BINARY).desktop:
mkdir -p $(BUILD)
echo -e "[Desktop Entry]\nName=$(BINARY)\nComment=$(DESCRIPTION)\nExec=$(BINARY)\nType=Application" > $@
2022-05-25 16:04:19 -06:00
clean:
2025-08-26 15:53:39 +10:00
rm -rf $(INCLUDE) $(OBJ) $(BUILD) $(BIN)
2022-05-25 16:04:19 -06:00
dist: clean $(BUILD)/$(BINARY).desktop
mkdir -p $(BINARY)-$(VERSION)
2025-08-26 15:45:07 +10:00
cp -R LICENSE Makefile CHANGELOG.md README.md src \
config.mk protocols dwl.1 $(BUILD)/$(BINARY).desktop \
$(BINARY)-$(VERSION)
tar -caf $(BINARY)-$(VERSION).tar.gz $(BINARY)-$(VERSION)
rm -rf $(BINARY)-$(VERSION) $(BUILD)
2022-05-25 16:04:19 -06:00
install: $(BIN)/$(BINARY) $(BUILD)/$(BINARY).desktop
2022-05-25 16:04:19 -06:00
mkdir -p $(DESTDIR)$(PREFIX)/bin
rm -f $(DESTDIR)$(PREFIX)/bin/$(BINARY)
cp -f $(BIN)/$(BINARY) $(DESTDIR)$(PREFIX)/bin
chmod 755 $(DESTDIR)$(PREFIX)/bin/$(BINARY)
2022-05-25 16:04:19 -06:00
mkdir -p $(DESTDIR)$(MANDIR)/man1
cp -f dwl.1 $(DESTDIR)$(MANDIR)/man1
2022-05-25 16:04:19 -06:00
chmod 644 $(DESTDIR)$(MANDIR)/man1/dwl.1
mkdir -p $(DESTDIR)$(DATADIR)/wayland-sessions
cp -f $(BUILD)/$(BINARY).desktop $(DESTDIR)$(DATADIR)/wayland-sessions/$(BINARY).desktop
chmod 644 $(DESTDIR)$(DATADIR)/wayland-sessions/$(BINARY).desktop
2022-05-25 16:04:19 -06:00
uninstall:
rm -f $(DESTDIR)$(PREFIX)/bin/$(BINARY) $(DESTDIR)$(MANDIR)/man1/dwl.1 \
$(DESTDIR)$(DATADIR)/wayland-sessions/$(BINARY).desktop
2020-04-11 20:17:20 -05:00
2025-08-26 15:45:07 +10:00
%.c %.o:
2024-06-13 14:23:51 -06:00
$(CC) $(CPPFLAGS) $(DWLCFLAGS) -o $@ -c $<