diff --git a/.github/workflows/makefile.yml b/.github/workflows/makefile.yml index 59202bc..e7f6e72 100644 --- a/.github/workflows/makefile.yml +++ b/.github/workflows/makefile.yml @@ -33,16 +33,5 @@ jobs: libxcb \ xcb-util-wm - - name: Test 'make debug' (Clang + Sanitizers) - run: | - make debug - make clean - - - name: Test Default 'make' (Auto-detecting TCC) - run: | - make - make clean - - - name: Test 'make release' (Clang + Strict Warnings) - run: | - make release + - name: Test all targets and packaging modes + run: make test diff --git a/Makefile b/Makefile index da77a8e..17f7a27 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,7 @@ .POSIX: .SUFFIXES: +.ONESHELL: +.SHELLFLAGS = -ec VERSION = `git describe --tags --dirty 2>/dev/null || echo 0.2` PREFIX = /usr/local @@ -24,6 +26,7 @@ endif XWAYLAND = -DXWAYLAND XLIBS = xcb xcb-icccm +DISTRO = LUA_PKG = lua5.4 PKGS = wayland-server xkbcommon libinput $(LUA_PKG) $(XLIBS) @@ -47,6 +50,7 @@ all: peachwm smsg/smsg release: CC = clang release: CFLAGS += -Werror -Wpedantic -Wmissing-prototypes -Wstrict-prototypes \ -Wold-style-definition -Wmissing-declarations -Wimplicit-fallthrough \ + -Wno-gnu-zero-variadic-macro-arguments \ -march=native release: peachwm smsg/smsg @@ -157,6 +161,8 @@ clean: rm -f peachwm smsg/smsg src/*.o parser/*.o smsg/*.o \ protocols/*.o protocols/*-protocol.h protocols/*-protocol.c \ smsg/*-protocol.h smsg/*-protocol.c + rm -f peachwm-*.tar.gz peachwm-*.pkg.tar.* peachwm_*.deb peachwm-*.rpm + rm -rf _pkg packaging install: peachwm smsg/smsg mkdir -p $(DESTDIR)$(PREFIX)/bin @@ -171,3 +177,326 @@ uninstall: rm -f $(DESTDIR)$(PREFIX)/bin/peachwm rm -f $(DESTDIR)$(PREFIX)/bin/smsg rm -rf $(DESTDIR)/etc/peachwm + +# Packaging +# make package - source tarball +# DISTRO=arch make package - Arch Linux PKGBUILD (build with makepkg if available) +# DISTRO=debian make package - Debian/Ubuntu .deb (build with dpkg-deb) +# DISTRO=fedora make package - Fedora .rpm (build with rpmbuild) +# DISTRO=opensuse make package - OpenSUSE .rpm (build with rpmbuild) +# DISTRO=gentoo make package - Gentoo ebuild +# DISTRO=void make package - Void Linux template + +_pkg-tarball: peachwm smsg/smsg + rm -rf peachwm-$(VERSION) + mkdir -p peachwm-$(VERSION) + cp -r .gitignore Makefile LICENSE README.md include src parser protocols smsg example peachwm-$(VERSION)/ + cp peachwm peachwm-$(VERSION)/ + tar -czf peachwm-$(VERSION).tar.gz peachwm-$(VERSION) + rm -rf peachwm-$(VERSION) + +_pkg-arch: _pkg-tarball + rm -rf _pkg/arch + mkdir -p _pkg/arch + ver="$(VERSION)"; cat > _pkg/arch/PKGBUILD <<- HEREDOC + # Maintainer: PeachWM Maintainers + pkgname=peachwm + pkgver=$$ver + pkgrel=1 + pkgdesc="PeachWM - A lightweight Wayland compositor" + arch=('x86_64') + url="https://github.com/HuntedByTheIRS/peachwm" + license=('GPL3') + depends=( + 'libinput' + 'wayland' + 'wlroots0.20' + 'libxkbcommon' + 'lua' + 'libxcb' + 'xcb-util-wm' + ) + makedepends=( + 'clang' + 'pkg-config' + 'wayland-protocols' + 'git' + ) + source=("peachwm-$${ver}.tar.gz") + sha256sums=('SKIP') + build() { + cd "$${srcdir}/peachwm-$${ver}" + make + } + package() { + cd "$${srcdir}/peachwm-$${ver}" + make DESTDIR="$${pkgdir}" PREFIX=/usr install + } + HEREDOC + cp peachwm-$(VERSION).tar.gz _pkg/arch/ + if command -v makepkg >/dev/null 2>&1; then \ + cd _pkg/arch && makepkg -f && cp *.pkg.tar.* ../.. || \ + echo "makepkg failed (try building manually with the PKGBUILD at _pkg/arch/)"; \ + else \ + echo "PKGBUILD generated at _pkg/arch/PKGBUILD"; \ + fi + +_pkg-debian: _pkg-tarball + rm -rf _pkg/debian + mkdir -p _pkg/debian/DEBIAN + mkdir -p _pkg/debian/usr/bin + mkdir -p _pkg/debian/usr/share/doc/peachwm + mkdir -p _pkg/debian/etc/peachwm + cp peachwm _pkg/debian/usr/bin/ + cp smsg/smsg _pkg/debian/usr/bin/ + cp README.md _pkg/debian/usr/share/doc/peachwm/ + cp -r example/* _pkg/debian/etc/peachwm/ + ver="$(VERSION)"; date="$(shell date -R)"; cat > _pkg/debian/DEBIAN/control <<- HEREDOC + Source: peachwm + Section: x11 + Priority: optional + Maintainer: PeachWM Maintainers + Build-Depends: debhelper-compat (= 13), libwayland-dev, libwlroots-dev (>= 0.20), libxkbcommon-dev, libinput-dev, liblua5.4-dev, pkgconf, libxcb-dev, libxcb-icccm4-dev, wayland-protocols, clang + Standards-Version: 4.6.2 + Homepage: https://github.com/HuntedByTheIRS/peachwm + Package: peachwm + Architecture: linux-any + Depends: $${shlibs:Depends}, $${misc:Depends} + Description: A lightweight Wayland compositor + PeachWM is a Wayland compositor focused on simplicity and + lightweight design. It features Lua configuration, multiple + layouts (Dwindle, Master, Monocle, Floating), and XWayland + support. + HEREDOC + cat > _pkg/debian/DEBIAN/copyright <<- HEREDOC + Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ + Upstream-Name: peachwm + Source: https://github.com/HuntedByTheIRS/peachwm + Files: * + Copyright: 2026 HuntedByTheIRS + License: GPL-3+ + HEREDOC + if command -v dpkg-deb >/dev/null 2>&1; then \ + dpkg-deb --build _pkg/debian peachwm_$(VERSION)_amd64.deb; \ + else \ + echo "Debian package structure at _pkg/debian/"; \ + fi + +_pkg-fedora: _pkg-tarball + rm -rf _pkg/fedora + mkdir -p _pkg/fedora/SOURCES _pkg/fedora/SPECS + cp peachwm-$(VERSION).tar.gz _pkg/fedora/SOURCES/ + ver="$(VERSION)"; date="$(shell date +'%a %b %d %Y')"; cat > _pkg/fedora/SPECS/peachwm.spec <<- HEREDOC + Name: peachwm + Version: $$ver + Release: 1%{?dist} + Summary: A lightweight Wayland compositor + License: GPLv3 + URL: https://github.com/HuntedByTheIRS/peachwm + Source0: peachwm-$${ver}.tar.gz + BuildRequires: clang + BuildRequires: pkgconfig + BuildRequires: wayland-devel + BuildRequires: wayland-protocols-devel + BuildRequires: wlroots0.20-devel + BuildRequires: libxkbcommon-devel + BuildRequires: libinput-devel + BuildRequires: lua-devel + BuildRequires: libxcb-devel + BuildRequires: xcb-util-wm-devel + BuildRequires: git + Requires: libinput + Requires: wayland + Requires: wlroots0.20 + Requires: libxkbcommon + Requires: lua + Requires: libxcb + Requires: xcb-util-wm + %description + PeachWM is a Wayland compositor focused on simplicity and lightweight + design. It features Lua configuration, multiple layouts (Dwindle, + Master, Monocle, Floating), and XWayland support. + %prep + %setup -q + %build + make + %install + make DESTDIR=%{buildroot} PREFIX=/usr install + %files + %license LICENSE + %doc README.md + %{_bindir}/peachwm + %{_bindir}/smsg + %config(noreplace) /etc/peachwm/* + %changelog + * $$date PeachWM Maintainers - $$ver-1 + - Package peachwm $$ver. + HEREDOC + if command -v rpmbuild >/dev/null 2>&1; then \ + rpmbuild --define "_topdir $(PWD)/_pkg/fedora" \ + -ba _pkg/fedora/SPECS/peachwm.spec && \ + find _pkg/fedora -name "*.rpm" -exec cp {} . \;; \ + else \ + echo "RPM spec at _pkg/fedora/SPECS/peachwm.spec"; \ + fi + +_pkg-opensuse: _pkg-tarball + rm -rf _pkg/opensuse + mkdir -p _pkg/opensuse/SOURCES _pkg/opensuse/SPECS + cp peachwm-$(VERSION).tar.gz _pkg/opensuse/SOURCES/ + ver="$(VERSION)"; date="$(shell date +'%a %b %d %Y')"; cat > _pkg/opensuse/SPECS/peachwm.spec <<- HEREDOC + Name: peachwm + Version: $$ver + Release: 1 + Summary: A lightweight Wayland compositor + License: GPL-3.0-or-later + URL: https://github.com/HuntedByTheIRS/peachwm + Source0: peachwm-$${ver}.tar.gz + BuildRequires: clang + BuildRequires: pkgconfig + BuildRequires: wayland-devel + BuildRequires: wayland-protocols-devel + BuildRequires: wlroots0.20-devel + BuildRequires: libxkbcommon-devel + BuildRequires: libinput-devel + BuildRequires: lua54-devel + BuildRequires: libxcb-devel + BuildRequires: xcb-util-wm-devel + BuildRequires: git + Requires: libinput + Requires: wayland + Requires: wlroots0.20 + Requires: libxkbcommon + Requires: lua54 + Requires: libxcb + Requires: xcb-util-wm + %description + PeachWM is a Wayland compositor focused on simplicity and lightweight + design. It features Lua configuration, multiple layouts (Dwindle, + Master, Monocle, Floating), and XWayland support. + %prep + %setup -q + %build + make + %install + make DESTDIR=%{buildroot} PREFIX=/usr install + %files + %license LICENSE + %doc README.md + %{_bindir}/peachwm + %{_bindir}/smsg + %config(noreplace) /etc/peachwm/* + %changelog + * $$date PeachWM Maintainers - $$ver-1 + - Package peachwm $$ver. + HEREDOC + if command -v rpmbuild >/dev/null 2>&1; then \ + rpmbuild --define "_topdir $(PWD)/_pkg/opensuse" \ + -ba _pkg/opensuse/SPECS/peachwm.spec && \ + find _pkg/opensuse -name "*.rpm" -exec cp {} . \;; \ + else \ + echo "RPM spec at _pkg/opensuse/SPECS/peachwm.spec"; \ + fi + +_pkg-gentoo: _pkg-tarball + rm -rf _pkg/gentoo + mkdir -p _pkg/gentoo + ver="$(VERSION)"; cat > _pkg/gentoo/peachwm-$${ver}.ebuild <<- HEREDOC + # Copyright 2026-2026 Gentoo Authors + # Distributed under the terms of the GNU General Public License v2 + EAPI=8 + DESCRIPTION="A lightweight Wayland compositor" + HOMEPAGE="https://github.com/HuntedByTheIRS/peachwm" + SRC_URI="" + if [[ $${PV} == 9999 ]]; then + inherit git-r3 + EGIT_REPO_URI="https://github.com/HuntedByTheIRS/peachwm.git" + else + SRC_URI="https://github.com/HuntedByTheIRS/peachwm/archive/v$${PV}.tar.gz -> $${P}.tar.gz" + KEYWORDS="~amd64" + fi + LICENSE="GPL-3" + SLOT="0" + IUSE="+X" + RDEPEND=" + dev-libs/libinput:= + dev-libs/wayland + dev-libs/wayland-protocols + gui-libs/wlroots:0.20 + x11-libs/libxkbcommon + dev-lang/lua:5.4 + X? ( x11-libs/libxcb + x11-libs/xcb-util-wm ) + " + DEPEND="$${RDEPEND} + >=dev-libs/wayland-protocols-1.24 + " + BDEPEND=" + virtual/pkgconfig + sys-devel/clang + " + src_compile() { + make + } + src_install() { + make DESTDIR="$${D}" PREFIX=/usr install + } + HEREDOC + echo "Ebuild generated at _pkg/gentoo/peachwm-$(VERSION).ebuild" + +_pkg-void: _pkg-tarball + rm -rf _pkg/void + mkdir -p _pkg/void + ver="$(VERSION)"; cat > _pkg/void/template <<- HEREDOC + # Template file for 'peachwm' + pkgname=peachwm + version=$$ver + revision=1 + build_style=gnu-makefile + make_build_args="" + make_install_args="DESTDIR=$${DESTDIR} PREFIX=/usr" + hostmakedepends="clang pkg-config wayland-protocols git" + makedepends="wayland-devel wlroots0.20-devel libxkbcommon-devel libinput-devel lua54-devel libxcb-devel xcb-util-wm-devel" + depends="libinput wayland wlroots0.20 libxkbcommon lua54 libxcb xcb-util-wm" + short_desc="PeachWM - A lightweight Wayland compositor" + maintainer="PeachWM Maintainers" + license="GPL-3.0-or-later" + homepage="https://github.com/HuntedByTheIRS/peachwm" + distfiles="https://github.com/HuntedByTheIRS/peachwm/archive/v$${version}.tar.gz" + checksum=SKIP + HEREDOC + echo "Void template generated at _pkg/void/template" + +package: _pkg-tarball + @case "$(DISTRO)" in \ + "") \ + ;; \ + arch) \ + $(MAKE) _pkg-arch ;; \ + debian) \ + $(MAKE) _pkg-debian ;; \ + fedora) \ + $(MAKE) _pkg-fedora ;; \ + opensuse) \ + $(MAKE) _pkg-opensuse ;; \ + gentoo) \ + $(MAKE) _pkg-gentoo ;; \ + void) \ + $(MAKE) _pkg-void ;; \ + *) \ + echo "Unknown DISTRO '$(DISTRO)'. Supported: arch, debian, fedora, opensuse, gentoo, void"; \ + exit 1 ;; \ + esac + +test: + @for target in all debug release; do \ + echo "=== Testing 'make $$target' ==="; \ + $(MAKE) $$target && $(MAKE) clean || { echo "FAIL: make $$target"; exit 1; }; \ + done + @echo "=== Testing 'make package' ===" + $(MAKE) package && $(MAKE) clean || { echo "FAIL: make package"; exit 1; } + @for distro in arch debian fedora opensuse gentoo void; do \ + echo "=== Testing 'DISTRO=$$distro make package' ==="; \ + $(MAKE) package DISTRO=$$distro && $(MAKE) clean || { echo "FAIL: DISTRO=$$distro"; exit 1; }; \ + done + @echo "=== All tests passed ==="