From 5c056777d606cb96d0cedbb7f358a7f2a692e773 Mon Sep 17 00:00:00 2001 From: Emile Clark-Boman Date: Mon, 25 Aug 2025 14:24:22 +1000 Subject: [PATCH 1/5] opinionated reorganisation --- LICENSE => LICENSE/LICENSE.dwl | 0 LICENSE.dwm => LICENSE/LICENSE.dwm | 0 LICENSE.sway => LICENSE/LICENSE.sway | 0 LICENSE.tinywl => LICENSE/LICENSE.tinywl | 0 client.h => src/client.h | 0 config.def.h => src/config.def.h | 0 dwl.c => src/dwl.c | 0 util.c => src/util.c | 0 util.h => src/util.h | 0 9 files changed, 0 insertions(+), 0 deletions(-) rename LICENSE => LICENSE/LICENSE.dwl (100%) rename LICENSE.dwm => LICENSE/LICENSE.dwm (100%) rename LICENSE.sway => LICENSE/LICENSE.sway (100%) rename LICENSE.tinywl => LICENSE/LICENSE.tinywl (100%) rename client.h => src/client.h (100%) rename config.def.h => src/config.def.h (100%) rename dwl.c => src/dwl.c (100%) rename util.c => src/util.c (100%) rename util.h => src/util.h (100%) diff --git a/LICENSE b/LICENSE/LICENSE.dwl similarity index 100% rename from LICENSE rename to LICENSE/LICENSE.dwl diff --git a/LICENSE.dwm b/LICENSE/LICENSE.dwm similarity index 100% rename from LICENSE.dwm rename to LICENSE/LICENSE.dwm diff --git a/LICENSE.sway b/LICENSE/LICENSE.sway similarity index 100% rename from LICENSE.sway rename to LICENSE/LICENSE.sway diff --git a/LICENSE.tinywl b/LICENSE/LICENSE.tinywl similarity index 100% rename from LICENSE.tinywl rename to LICENSE/LICENSE.tinywl diff --git a/client.h b/src/client.h similarity index 100% rename from client.h rename to src/client.h diff --git a/config.def.h b/src/config.def.h similarity index 100% rename from config.def.h rename to src/config.def.h diff --git a/dwl.c b/src/dwl.c similarity index 100% rename from dwl.c rename to src/dwl.c diff --git a/util.c b/src/util.c similarity index 100% rename from util.c rename to src/util.c diff --git a/util.h b/src/util.h similarity index 100% rename from util.h rename to src/util.h From af68b5e63ccceae5f3cb29d8fec5521f534b02f1 Mon Sep 17 00:00:00 2001 From: Emile Clark-Boman Date: Mon, 25 Aug 2025 15:01:50 +1000 Subject: [PATCH 2/5] add flake.nix --- flake.nix | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 flake.nix diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..e2e0104 --- /dev/null +++ b/flake.nix @@ -0,0 +1,39 @@ +{ + description = "DWL Development Shell"; + + inputs = { + nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05"; + }; + + outputs = {nixpkgs, ...}: let + system = "x86_64-linux"; + in { + devShells."${system}".default = let + pkgs = import nixpkgs { + inherit system; + }; + in + pkgs.mkShell { + packages = with pkgs; [ + # NativeBuildInputs + installShellFiles + pkg-config + wayland-scanner + + # BuildInputs + libinput + libxcb + libxkbcommon + pixman + wayland + wayland-protocols + wlroots + + # XWayland + libX11 + xcbutilwm + xwayland + ]; + }; + }; +} From 9b2fec0df1aa6a4f6db7d6e1918d57fa60cc608f Mon Sep 17 00:00:00 2001 From: Emile Clark-Boman Date: Tue, 26 Aug 2025 15:44:16 +1000 Subject: [PATCH 3/5] complete flake.nix + progress wlroots -> wlroots_0_19 --- flake.lock | 27 ++++++++++++++++++++++++ flake.nix | 60 ++++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 69 insertions(+), 18 deletions(-) create mode 100644 flake.lock diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..5d48cd6 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1755922037, + "narHash": "sha256-wY1+2JPH0ZZC4BQefoZw/k+3+DowFyfOxv17CN/idKs=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "b1b3291469652d5a2edb0becc4ef0246fff97a7c", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixos-25.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix index e2e0104..3ceb42f 100644 --- a/flake.nix +++ b/flake.nix @@ -7,33 +7,57 @@ outputs = {nixpkgs, ...}: let system = "x86_64-linux"; + enableXWayland = false; in { devShells."${system}".default = let pkgs = import nixpkgs { inherit system; }; + lib = nixpkgs.lib; + stdenv = pkgs.stdenv; in pkgs.mkShell { - packages = with pkgs; [ - # NativeBuildInputs - installShellFiles - pkg-config - wayland-scanner + packages = with pkgs; + [ + # NativeBuildInputs + installShellFiles + pkg-config + wayland-scanner - # BuildInputs - libinput - libxcb - libxkbcommon - pixman - wayland - wayland-protocols - wlroots + # BuildInputs + libinput + xorg.libxcb + libxkbcommon + pixman + wayland + wayland-protocols + wlroots_0_19 + ] + ++ lib.optionals enableXWayland + [ + # XWayland + xorg.libX11 + xorg.xcbutilwm + xwayland + ]; - # XWayland - libX11 - xcbutilwm - xwayland - ]; + shellHook = let + makeFlags = + lib.strings.concatStringsSep " " + ([ + "PKG_CONFIG=${stdenv.cc.targetPrefix}pkg-config" + "WAYLAND_SCANNER=wayland-scanner" + # "PREFIX=$(out)" + # "MANDIR=$(man)/share/man" + ] + ++ lib.optionals enableXWayland [ + ''XWAYLAND="-DXWAYLAND"'' + ''XLIBS="xcb xcb-icccm"'' + ]); + in '' + TERM=xterm-256color + alias mk='${makeFlags} make' + ''; }; }; } From 92167bff9e9cb9ab904dc6b24bc79ab87a0cfa5c Mon Sep 17 00:00:00 2001 From: Emile Clark-Boman Date: Tue, 26 Aug 2025 15:45:07 +1000 Subject: [PATCH 4/5] gmake supports restructed directories --- Makefile | 57 +++++++++++++++++++++++++++++++++++-------------------- config.mk | 4 ++++ 2 files changed, 40 insertions(+), 21 deletions(-) diff --git a/Makefile b/Makefile index 578194f..ac37303 100644 --- a/Makefile +++ b/Makefile @@ -1,10 +1,11 @@ .POSIX: .SUFFIXES: +.DEFAULT_GOAL := all include config.mk # flags for compiling -DWLCPPFLAGS = -I. -DWLR_USE_UNSTABLE -D_POSIX_C_SOURCE=200809L \ +DWLCPPFLAGS = -Ibuild -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 \ @@ -16,13 +17,28 @@ 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) -all: dwl -dwl: dwl.o util.o - $(CC) dwl.o util.o $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ -dwl.o: dwl.c client.h config.h config.mk cursor-shape-v1-protocol.h \ +# macros to relevant path definitions +define mkbin +$(addprefix $(BIN)/,$1) +endef +define mkbuild +$(addprefix $(BUILD)/,$1) +endef +define mksrc +$(addprefix $(SRC)/,$1) +endef + +.PHONY: setup +setup: + mkdir -p $(BIN) $(BUILD) + +all: setup $(call mkbin,dwl) +$(BIN)/dwl: $(call mkbuild,dwl.o util.o) + $(CC) $^ $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ +$(BUILD)/dwl.o: $(call mksrc,dwl.c client.h) config.mk $(call mkbuild,config.h cursor-shape-v1-protocol.h \ pointer-constraints-unstable-v1-protocol.h wlr-layer-shell-unstable-v1-protocol.h \ - wlr-output-power-management-unstable-v1-protocol.h xdg-shell-protocol.h -util.o: util.c util.h + wlr-output-power-management-unstable-v1-protocol.h xdg-shell-protocol.h) +$(BUILD)/util.o: $(call mksrc,util.c util.h) # 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 @@ -30,39 +46,39 @@ util.o: util.c util.h WAYLAND_SCANNER = `$(PKG_CONFIG) --variable=wayland_scanner wayland-scanner` WAYLAND_PROTOCOLS = `$(PKG_CONFIG) --variable=pkgdatadir wayland-protocols` -cursor-shape-v1-protocol.h: +$(BUILD)/cursor-shape-v1-protocol.h: $(WAYLAND_SCANNER) enum-header \ $(WAYLAND_PROTOCOLS)/staging/cursor-shape/cursor-shape-v1.xml $@ -pointer-constraints-unstable-v1-protocol.h: +$(BUILD)/pointer-constraints-unstable-v1-protocol.h: $(WAYLAND_SCANNER) enum-header \ $(WAYLAND_PROTOCOLS)/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml $@ -wlr-layer-shell-unstable-v1-protocol.h: +$(BUILD)/wlr-layer-shell-unstable-v1-protocol.h: $(WAYLAND_SCANNER) enum-header \ protocols/wlr-layer-shell-unstable-v1.xml $@ -wlr-output-power-management-unstable-v1-protocol.h: +$(BUILD)/wlr-output-power-management-unstable-v1-protocol.h: $(WAYLAND_SCANNER) server-header \ protocols/wlr-output-power-management-unstable-v1.xml $@ -xdg-shell-protocol.h: +$(BUILD)/xdg-shell-protocol.h: $(WAYLAND_SCANNER) server-header \ $(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@ -config.h: - cp config.def.h $@ +$(BUILD)/config.h: + cp $(SRC)/config.def.h $@ clean: - rm -f dwl *.o *-protocol.h + rm -rf $(BUILD) $(BIN) dist: clean mkdir -p dwl-$(VERSION) - cp -R LICENSE* Makefile CHANGELOG.md README.md client.h config.def.h \ - config.mk protocols dwl.1 dwl.c util.c util.h dwl.desktop \ + cp -R LICENSE Makefile CHANGELOG.md README.md src \ + config.mk protocols dwl.1 dwl.desktop \ dwl-$(VERSION) tar -caf dwl-$(VERSION).tar.gz dwl-$(VERSION) rm -rf dwl-$(VERSION) -install: dwl +install: $(BIN)/dwl mkdir -p $(DESTDIR)$(PREFIX)/bin rm -f $(DESTDIR)$(PREFIX)/bin/dwl - cp -f dwl $(DESTDIR)$(PREFIX)/bin + cp -f $(BIN)/dwl $(DESTDIR)$(PREFIX)/bin chmod 755 $(DESTDIR)$(PREFIX)/bin/dwl mkdir -p $(DESTDIR)$(MANDIR)/man1 cp -f dwl.1 $(DESTDIR)$(MANDIR)/man1 @@ -74,6 +90,5 @@ uninstall: rm -f $(DESTDIR)$(PREFIX)/bin/dwl $(DESTDIR)$(MANDIR)/man1/dwl.1 \ $(DESTDIR)$(DATADIR)/wayland-sessions/dwl.desktop -.SUFFIXES: .c .o -.c.o: +%.c %.o: $(CC) $(CPPFLAGS) $(DWLCFLAGS) -o $@ -c $< diff --git a/config.mk b/config.mk index eb08a05..c58e660 100644 --- a/config.mk +++ b/config.mk @@ -8,6 +8,10 @@ PREFIX = /usr/local MANDIR = $(PREFIX)/share/man DATADIR = $(PREFIX)/share +SRC = src +BUILD = build +BIN = bin + WLR_INCS = `$(PKG_CONFIG) --cflags wlroots-0.19` WLR_LIBS = `$(PKG_CONFIG) --libs wlroots-0.19` From 51e5de1c8bc11c853e7dbf8d0c44e5a783e8a364 Mon Sep 17 00:00:00 2001 From: Emile Clark-Boman Date: Tue, 26 Aug 2025 15:53:39 +1000 Subject: [PATCH 5/5] separate build to obj/ & include/ --- Makefile | 31 +++++++++++++++++-------------- config.mk | 2 ++ 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index ac37303..c3126b6 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ include config.mk # flags for compiling -DWLCPPFLAGS = -Ibuild -DWLR_USE_UNSTABLE -D_POSIX_C_SOURCE=200809L \ +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 \ @@ -21,8 +21,11 @@ LDLIBS = `$(PKG_CONFIG) --libs $(PKGS)` $(WLR_LIBS) -lm $(LIBS) define mkbin $(addprefix $(BIN)/,$1) endef -define mkbuild -$(addprefix $(BUILD)/,$1) +define mkobj +$(addprefix $(OBJ)/,$1) +endef +define mkinclude +$(addprefix $(INCLUDE)/,$1) endef define mksrc $(addprefix $(SRC)/,$1) @@ -30,15 +33,15 @@ endef .PHONY: setup setup: - mkdir -p $(BIN) $(BUILD) + mkdir -p $(BIN) $(BUILD) $(INCLUDE) $(OBJ) all: setup $(call mkbin,dwl) -$(BIN)/dwl: $(call mkbuild,dwl.o util.o) +$(BIN)/dwl: $(call mkobj,dwl.o util.o) $(CC) $^ $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@ -$(BUILD)/dwl.o: $(call mksrc,dwl.c client.h) config.mk $(call mkbuild,config.h cursor-shape-v1-protocol.h \ +$(OBJ)/dwl.o: $(call mksrc,dwl.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 \ wlr-output-power-management-unstable-v1-protocol.h xdg-shell-protocol.h) -$(BUILD)/util.o: $(call mksrc,util.c util.h) +$(OBJ)/util.o: $(call mksrc,util.c util.h) # 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 @@ -46,26 +49,26 @@ $(BUILD)/util.o: $(call mksrc,util.c util.h) WAYLAND_SCANNER = `$(PKG_CONFIG) --variable=wayland_scanner wayland-scanner` WAYLAND_PROTOCOLS = `$(PKG_CONFIG) --variable=pkgdatadir wayland-protocols` -$(BUILD)/cursor-shape-v1-protocol.h: +$(INCLUDE)/cursor-shape-v1-protocol.h: $(WAYLAND_SCANNER) enum-header \ $(WAYLAND_PROTOCOLS)/staging/cursor-shape/cursor-shape-v1.xml $@ -$(BUILD)/pointer-constraints-unstable-v1-protocol.h: +$(INCLUDE)/pointer-constraints-unstable-v1-protocol.h: $(WAYLAND_SCANNER) enum-header \ $(WAYLAND_PROTOCOLS)/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml $@ -$(BUILD)/wlr-layer-shell-unstable-v1-protocol.h: +$(INCLUDE)/wlr-layer-shell-unstable-v1-protocol.h: $(WAYLAND_SCANNER) enum-header \ protocols/wlr-layer-shell-unstable-v1.xml $@ -$(BUILD)/wlr-output-power-management-unstable-v1-protocol.h: +$(INCLUDE)/wlr-output-power-management-unstable-v1-protocol.h: $(WAYLAND_SCANNER) server-header \ protocols/wlr-output-power-management-unstable-v1.xml $@ -$(BUILD)/xdg-shell-protocol.h: +$(INCLUDE)/xdg-shell-protocol.h: $(WAYLAND_SCANNER) server-header \ $(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@ -$(BUILD)/config.h: +$(INCLUDE)/config.h: cp $(SRC)/config.def.h $@ clean: - rm -rf $(BUILD) $(BIN) + rm -rf $(INCLUDE) $(OBJ) $(BUILD) $(BIN) dist: clean mkdir -p dwl-$(VERSION) diff --git a/config.mk b/config.mk index c58e660..7d1dc14 100644 --- a/config.mk +++ b/config.mk @@ -10,6 +10,8 @@ DATADIR = $(PREFIX)/share SRC = src BUILD = build +OBJ = $(BUILD)/obj +INCLUDE = $(BUILD)/include BIN = bin WLR_INCS = `$(PKG_CONFIG) --cflags wlroots-0.19`