summaryrefslogtreecommitdiff
path: root/makefile
blob: 1c5b0183f2348ca517f5180eb76cb363477fd7ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
bin:=$(notdir $(shell pwd))
src:=$(wildcard *.c)
obj:=$(src:.c=.o)

obj+=\
	toolbox/buffer.o \
	toolbox/io_muxer.o \
	toolbox/perf.o

libs:=\
	egl \
	gbm \
	glesv2 \
	libdrm \
	libpipewire-0.3 \
	libva \
	libva-drm

protocols_dir:=\
	wlr-protocols/unstable

protocols:=\
	wlr-export-dmabuf-unstable-v1

res:=\
	vertex.glsl \
	luma.glsl \
	chroma.glsl

ifdef USE_WAYLAND
	obj:=$(patsubst %,%.o,$(protocols)) $(obj)
	headers:=$(patsubst %,%.h,$(protocols))
	libs+=wayland-client
	CFLAGS+=-DUSE_WAYLAND
endif

#CFLAGS+=-DUSE_EGL_MESA_PLATFORM_SURFACELESS
CFLAGS+=$(shell pkg-config --cflags $(libs))
LDFLAGS+=$(shell pkg-config --libs $(libs))

comma:=,
LDFLAGS+= \
	-Wl,--format=binary \
	$(patsubst %,-Wl$(comma)%,$(res)) \
	-Wl,--format=default

all: $(bin)

$(bin): $(obj)
	$(CC) $^ $(LDFLAGS) -o $@

%.o: %.c *.h $(res) $(headers)
	$(CC) -c $< $(CFLAGS) -o $@

%.h: $(protocols_dir)/%.xml
	wayland-scanner client-header $< $@

%.c: $(protocols_dir)/%.xml
	wayland-scanner private-code $< $@

clean:
	-rm $(bin) $(obj) $(headers) \
		$(foreach proto,$(protocols),$(proto).h $(proto).o)

.PHONY: all clean

.PRECIOUS: $(headers)