diff --git a/makefile b/makefile
index 6598ab3..db71d28 100644
--- a/makefile
+++ b/makefile
@@ -1,3 +1,4 @@
+#!/usr/bin/make -f
# This file is part of wl-overlay: show overlays with images and text in Wayland
# Copyright © 2022 Midgard
#
@@ -15,10 +16,31 @@
# along with this program. If not, see .
+SHELL = /bin/sh
+
# Choose a dedicated build directory as ‘make clean’ will remove it entirely
BUILD = build
$(shell mkdir -p $(BUILD))
+# Convenience targets
+.PHONY: all
+all: $(BUILD)/wl-overlay
+
+.PHONY: clean
+clean:
+ rm -rf $(BUILD) wlr-layer-shell-protocol.h
+
+# Installation
+DESTDIR ?=
+PREFIX ?= /usr/local
+BINDIR ?= $(DESTDIR)$(PREFIX)/bin
+
+
+.PHONY: install
+install: $(BUILD)/wl-overlay
+ install -D -t "$(BINDIR)" "$^"
+
+# Dependencies
CFLAGS += -Wall
CFLAGS += $(shell pkg-config --cflags pangocairo)
@@ -32,24 +54,23 @@ LDLIBS += $(shell pkg-config --libs wayland-client)
LDLIBS += -lrt
-.PHONY: all clean
-
-all: build/wl-overlay
-
-clean:
- rm -rf $(BUILD)
-
-$(BUILD)/wlr-layer-shell-protocol.h: wlr-layer-shell-unstable-v1.xml
+# Generated C files
+wlr-layer-shell-protocol.h: wlr-layer-shell-unstable-v1.xml
wayland-scanner client-header < "$^" > "$@"
$(BUILD)/wlr-layer-shell-protocol.c: wlr-layer-shell-unstable-v1.xml
wayland-scanner private-code < "$^" > "$@"
-$(BUILD)/xdg-shell-client-protocol.h: /usr/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml
- wayland-scanner client-header < "$^" > "$@"
$(BUILD)/xdg-shell-protocol.c: /usr/share/wayland-protocols/stable/xdg-shell/xdg-shell.xml
wayland-scanner private-code < "$^" > "$@"
-C_FILES = $(wildcard *.c) $(BUILD)/wlr-layer-shell-protocol.c $(BUILD)/xdg-shell-protocol.c
-$(BUILD)/wl-overlay: $(C_FILES) $(BUILD)/wlr-layer-shell-protocol.h
- $(CC) $(CFLAGS) $(INC) $(LDFLAGS) $(LDLIBS) -o "$@" $(C_FILES)
+# Objects
+SRCS = $(wildcard *.c)
+GEN_SRCS = $(BUILD)/wlr-layer-shell-protocol.c $(BUILD)/xdg-shell-protocol.c
+OBJS = $(SRCS:%.c=$(BUILD)/%.o) $(GEN_SRCS:%.c=%.o)
+
+$(BUILD)/%.o: %.c
+ $(CC) $(CFLAGS) -c $< $(OUTPUT_OPTION)
+$(BUILD)/wayland.o: wayland.c wlr-layer-shell-protocol.h
+
+$(BUILD)/wl-overlay: $(OBJS)
diff --git a/wayland.c b/wayland.c
index 5f51e90..7b1ab1a 100644
--- a/wayland.c
+++ b/wayland.c
@@ -55,7 +55,7 @@
#include
#include
-#include "build/wlr-layer-shell-protocol.h"
+#include "wlr-layer-shell-protocol.h"
#include "common.h"
#include "wayland.h"
#include "shm.h"