Clean up protocol building

Move protocols to a subdirectory, /protocols, and DRY the Makefile.
ext-image-capture
itycodes 2 months ago
parent 6d53770d65
commit e75d715714

@ -4,22 +4,21 @@ CC = gcc
CLIBS = -lwayland-client
CFLAGS = $(CLIBS)
EXT_SOURCE_PROTOCOL_IMPL = ext-image-capture-source-v1-protocol.c
EXT_SOURCE_PROTOCOL_HEADER = ext-image-capture-source-v1-protocol.h
EXT_CAPTURE_PROTOCOL_IMPL = ext-image-copy-capture-v1-protocol.c
EXT_CAPTURE_PROTOCOL_HEADER = ext-image-copy-capture-v1-protocol.h
EXT_TOPLEVEL_PROTOCOL_IMPL = ext-foreign-toplevel-list-v1-protocol.c
EXT_TOPLEVEL_PROTOCOL_HEADER = ext-foreign-toplevel-list-v1-protocol.h
SRC = main.c
OUT = screencap
PROTOCOL_IMPLS = $(EXT_TOPLEVEL_PROTOCOL_IMPL) $(EXT_SOURCE_PROTOCOL_IMPL) $(EXT_CAPTURE_PROTOCOL_IMPL)
PROTOCOL_HEADERS = $(EXT_TOPLEVEL_PROTOCOL_HEADER) $(EXT_SOURCE_PROTOCOL_HEADER) $(EXT_CAPTURE_PROTOCOL_HEADER)
PROTOCOL_NAMES = $(foreach proto, $(wildcard protocols/*), $(notdir $(basename $(proto))))
PROTOCOL_IMPLS = $(foreach proto, $(PROTOCOL_NAMES), $(addsuffix .prot.c,$(proto)))
PROTOCOL_HEADERS = $(foreach proto, $(PROTOCOL_NAMES), $(addsuffix .prot.h,$(proto)))
PROTOCOLS = $(PROTOCOL_IMPLS) $(PROTOCOL_HEADERS)
%.prot.c: protocols/%.xml
wayland-scanner private-code $< $@
%.prot.h: protocols/%.xml
wayland-scanner client-header $< $@
all: $(OUT)
clean:
@ -29,21 +28,3 @@ clean:
$(OUT): $(PROTOCOLS) $(SRC)
$(CC) $(PROTOCOL_IMPLS) $(SRC) $(CFLAGS) -o $(OUT)
$(EXT_SOURCE_PROTOCOL_IMPL):
wayland-scanner private-code ./ext-image-capture-source-v1.xml $(EXT_SOURCE_PROTOCOL_IMPL)
$(EXT_SOURCE_PROTOCOL_HEADER):
wayland-scanner client-header ./ext-image-capture-source-v1.xml $(EXT_SOURCE_PROTOCOL_HEADER)
$(EXT_CAPTURE_PROTOCOL_IMPL):
wayland-scanner private-code ./ext-image-copy-capture-v1.xml $(EXT_CAPTURE_PROTOCOL_IMPL)
$(EXT_CAPTURE_PROTOCOL_HEADER):
wayland-scanner client-header ./ext-image-copy-capture-v1.xml $(EXT_CAPTURE_PROTOCOL_HEADER)
$(EXT_TOPLEVEL_PROTOCOL_IMPL):
wayland-scanner private-code ./ext-foreign-toplevel-list-v1.xml $(EXT_TOPLEVEL_PROTOCOL_IMPL)
$(EXT_TOPLEVEL_PROTOCOL_HEADER):
wayland-scanner client-header ./ext-foreign-toplevel-list-v1.xml $(EXT_TOPLEVEL_PROTOCOL_HEADER)

@ -7,8 +7,8 @@
#include <wayland-client.h>
#include "ext-image-capture-source-v1-protocol.h"
#include "ext-image-copy-capture-v1-protocol.h"
#include "ext-image-capture-source-v1.prot.h"
#include "ext-image-copy-capture-v1.prot.h"
#include "rif.h"

Loading…
Cancel
Save