Compare commits

...

5 commits

13 changed files with 135 additions and 21 deletions

View file

@ -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 = -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 \
@ -16,13 +17,31 @@ 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 mkobj
$(addprefix $(OBJ)/,$1)
endef
define mkinclude
$(addprefix $(INCLUDE)/,$1)
endef
define mksrc
$(addprefix $(SRC)/,$1)
endef
.PHONY: setup
setup:
mkdir -p $(BIN) $(BUILD) $(INCLUDE) $(OBJ)
all: setup $(call mkbin,dwl)
$(BIN)/dwl: $(call mkobj,dwl.o util.o)
$(CC) $^ $(DWLCFLAGS) $(LDFLAGS) $(LDLIBS) -o $@
$(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
util.o: util.c util.h
wlr-output-power-management-unstable-v1-protocol.h xdg-shell-protocol.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
@ -30,39 +49,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:
$(INCLUDE)/cursor-shape-v1-protocol.h:
$(WAYLAND_SCANNER) enum-header \
$(WAYLAND_PROTOCOLS)/staging/cursor-shape/cursor-shape-v1.xml $@
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 $@
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 $@
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 $@
xdg-shell-protocol.h:
$(INCLUDE)/xdg-shell-protocol.h:
$(WAYLAND_SCANNER) server-header \
$(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@
config.h:
cp config.def.h $@
$(INCLUDE)/config.h:
cp $(SRC)/config.def.h $@
clean:
rm -f dwl *.o *-protocol.h
rm -rf $(INCLUDE) $(OBJ) $(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 +93,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 $<

View file

@ -8,6 +8,12 @@ PREFIX = /usr/local
MANDIR = $(PREFIX)/share/man
DATADIR = $(PREFIX)/share
SRC = src
BUILD = build
OBJ = $(BUILD)/obj
INCLUDE = $(BUILD)/include
BIN = bin
WLR_INCS = `$(PKG_CONFIG) --cflags wlroots-0.19`
WLR_LIBS = `$(PKG_CONFIG) --libs wlroots-0.19`

27
flake.lock generated Normal file
View file

@ -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
}

63
flake.nix Normal file
View file

@ -0,0 +1,63 @@
{
description = "DWL Development Shell";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-25.05";
};
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
# BuildInputs
libinput
xorg.libxcb
libxkbcommon
pixman
wayland
wayland-protocols
wlroots_0_19
]
++ lib.optionals enableXWayland
[
# XWayland
xorg.libX11
xorg.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'
'';
};
};
}

View file

View file

View file