Expand makefile

This commit is contained in:
Midgard 2022-10-20 15:57:50 +02:00
parent f453bbedab
commit b963cdaa46
Signed by: midgard
GPG Key ID: 511C112F1331BBB4
2 changed files with 35 additions and 14 deletions

View File

@ -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 <http://www.gnu.org/licenses/>.
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)

View File

@ -55,7 +55,7 @@
#include <cairo/cairo.h>
#include <pango/pangocairo.h>
#include "build/wlr-layer-shell-protocol.h"
#include "wlr-layer-shell-protocol.h"
#include "common.h"
#include "wayland.h"
#include "shm.h"