102 lines
3.8 KiB
Makefile
102 lines
3.8 KiB
Makefile
.POSIX:
|
|
.SUFFIXES:
|
|
.DEFAULT_GOAL := all
|
|
|
|
include config.mk
|
|
|
|
# flags for compiling
|
|
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
|
|
|
|
# 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)
|
|
|
|
# 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 $(BIN)/$(BINARY) $(BUILD)/$(BINARY).desktop
|
|
$(BIN)/$(BINARY): $(call mkobj,main.o util.o)
|
|
$(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 \
|
|
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
|
|
# 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`
|
|
|
|
$(INCLUDE)/cursor-shape-v1-protocol.h:
|
|
$(WAYLAND_SCANNER) enum-header \
|
|
$(WAYLAND_PROTOCOLS)/staging/cursor-shape/cursor-shape-v1.xml $@
|
|
$(INCLUDE)/pointer-constraints-unstable-v1-protocol.h:
|
|
$(WAYLAND_SCANNER) enum-header \
|
|
$(WAYLAND_PROTOCOLS)/unstable/pointer-constraints/pointer-constraints-unstable-v1.xml $@
|
|
$(INCLUDE)/wlr-layer-shell-unstable-v1-protocol.h:
|
|
$(WAYLAND_SCANNER) enum-header \
|
|
protocols/wlr-layer-shell-unstable-v1.xml $@
|
|
$(INCLUDE)/wlr-output-power-management-unstable-v1-protocol.h:
|
|
$(WAYLAND_SCANNER) server-header \
|
|
protocols/wlr-output-power-management-unstable-v1.xml $@
|
|
$(INCLUDE)/xdg-shell-protocol.h:
|
|
$(WAYLAND_SCANNER) server-header \
|
|
$(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@
|
|
|
|
$(INCLUDE)/config.h:
|
|
cp $(SRC)/config.def.h $@
|
|
|
|
$(BUILD)/$(BINARY).desktop:
|
|
mkdir -p $(BUILD)
|
|
echo -e "[Desktop Entry]\nName=$(BINARY)\nComment=$(DESCRIPTION)\nExec=$(BINARY)\nType=Application" > $@
|
|
|
|
clean:
|
|
rm -rf $(INCLUDE) $(OBJ) $(BUILD) $(BIN)
|
|
|
|
dist: clean $(BUILD)/$(BINARY).desktop
|
|
mkdir -p $(BINARY)-$(VERSION)
|
|
cp -R LICENSE Makefile CHANGELOG.md README.md src \
|
|
config.mk protocols docs/dwl.1 $(BUILD)/$(BINARY).desktop \
|
|
$(BINARY)-$(VERSION)
|
|
tar -caf $(BINARY)-$(VERSION).tar.gz $(BINARY)-$(VERSION)
|
|
rm -rf $(BINARY)-$(VERSION) $(BUILD)
|
|
|
|
install: $(BIN)/$(BINARY) $(BUILD)/$(BINARY).desktop
|
|
mkdir -p $(DESTDIR)$(PREFIX)/bin
|
|
rm -f $(DESTDIR)$(PREFIX)/bin/$(BINARY)
|
|
cp -f $(BIN)/$(BINARY) $(DESTDIR)$(PREFIX)/bin
|
|
chmod 755 $(DESTDIR)$(PREFIX)/bin/$(BINARY)
|
|
mkdir -p $(DESTDIR)$(MANDIR)/man1
|
|
cp -f docs/dwl.1 $(DESTDIR)$(MANDIR)/man1
|
|
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
|
|
uninstall:
|
|
rm -f $(DESTDIR)$(PREFIX)/bin/$(BINARY) $(DESTDIR)$(MANDIR)/man1/dwl.1 \
|
|
$(DESTDIR)$(DATADIR)/wayland-sessions/$(BINARY).desktop
|
|
|
|
%.c %.o:
|
|
$(CC) $(CPPFLAGS) $(DWLCFLAGS) -o $@ -c $<
|