forked from chjj/compton
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
147 lines (117 loc) · 3.75 KB
/
Makefile
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# Use tab to indent recipe lines, spaces to indent other lines, otherwise
# GNU make may get unhappy.
CC ?= gcc
PREFIX ?= /usr
BINDIR ?= $(PREFIX)/bin
MANDIR ?= $(PREFIX)/share/man/man1
APPDIR ?= $(PREFIX)/share/applications
PACKAGES = x11 xcomposite xfixes xdamage xrender xext xrandr
LIBS = -lm -lrt
INCS =
OBJS = compton.o
# === Configuration flags ===
CFG = -std=c99
# ==== libconfig ====
ifeq "$(NO_LIBCONFIG)" ""
CFG += -DCONFIG_LIBCONFIG
PACKAGES += libconfig
# libconfig-1.3* does not define LIBCONFIG_VER* macros, so we use
# pkg-config to determine its version here
CFG += $(shell pkg-config --atleast-version=1.4 libconfig || echo '-DCONFIG_LIBCONFIG_LEGACY')
endif
# ==== PCRE regular expression ====
ifeq "$(NO_REGEX_PCRE)" ""
CFG += -DCONFIG_REGEX_PCRE
LIBS += $(shell pcre-config --libs)
INCS += $(shell pcre-config --cflags)
ifeq "$(NO_REGEX_PCRE_JIT)" ""
CFG += -DCONFIG_REGEX_PCRE_JIT
endif
endif
# ==== DRM VSync ====
ifeq "$(NO_VSYNC_DRM)" ""
INCS += $(shell pkg-config --cflags libdrm)
CFG += -DCONFIG_VSYNC_DRM
endif
# ==== OpenGL VSync ====
ifeq "$(NO_VSYNC_OPENGL)" ""
CFG += -DCONFIG_VSYNC_OPENGL
# -lGL must precede some other libraries, or it segfaults on FreeBSD (#74)
LIBS := -lGL $(LIBS)
OBJS += opengl.o
ifeq "$(NO_VSYNC_OPENGL_GLSL)" ""
CFG += -DCONFIG_VSYNC_OPENGL_GLSL
endif
ifeq "$(NO_VSYNC_OPENGL_FBO)" ""
CFG += -DCONFIG_VSYNC_OPENGL_FBO
endif
ifeq "$(NO_VSYNC_OPENGL_VBO)" ""
CFG += -DCONFIG_VSYNC_OPENGL_VBO
endif
endif
# ==== D-Bus ====
ifeq "$(NO_DBUS)" ""
CFG += -DCONFIG_DBUS
PACKAGES += dbus-1
OBJS += dbus.o
endif
# ==== C2 ====
ifeq "$(NO_C2)" ""
CFG += -DCONFIG_C2
OBJS += c2.o
endif
# === Version string ===
COMPTON_VERSION ?= git-$(shell git describe --always --dirty)-$(shell git log -1 --date=short --pretty=format:%cd)
CFG += -DCOMPTON_VERSION="\"$(COMPTON_VERSION)\""
LDFLAGS ?= -Wl,-O1 -Wl,--as-needed
ifeq "$(CFG_DEV)" ""
CFLAGS ?= -DNDEBUG -O2 -D_FORTIFY_SOURCE=2
else
CC = clang
export LD_ALTEXEC = /usr/bin/ld.gold
OBJS += backtrace-symbols.o
LIBS += -lbfd
CFLAGS += -ggdb -Wshadow
# CFLAGS += -Weverything -Wno-disabled-macro-expansion -Wno-padded -Wno-gnu
endif
LIBS += $(shell pkg-config --libs $(PACKAGES))
INCS += $(shell pkg-config --cflags $(PACKAGES))
CFLAGS += -Wall
BINS = compton bin/compton-trans
MANPAGES = man/compton.1 man/compton-trans.1
MANPAGES_HTML = $(addsuffix .html,$(MANPAGES))
# === Recipes ===
.DEFAULT_GOAL := compton
src/.clang_complete: Makefile
@(for i in $(filter-out -O% -DNDEBUG, $(CFG) $(CFLAGS) $(INCS)); do echo "$$i"; done) > $@
%.o: src/%.c src/%.h src/common.h
$(CC) $(CFG) $(CFLAGS) $(INCS) -c src/$*.c
compton: $(OBJS)
$(CC) $(CFG) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJS) $(LIBS)
man/%.1: man/%.1.asciidoc
a2x --format manpage $<
man/%.1.html: man/%.1.asciidoc
asciidoc $<
docs: $(MANPAGES) $(MANPAGES_HTML)
install: $(BINS) docs
@install -d "$(DESTDIR)$(BINDIR)" "$(DESTDIR)$(MANDIR)" "$(DESTDIR)$(APPDIR)"
@install -m755 $(BINS) "$(DESTDIR)$(BINDIR)"/
@install -m644 $(MANPAGES) "$(DESTDIR)$(MANDIR)"/
@install -m644 compton.desktop "$(DESTDIR)$(APPDIR)"/
ifneq "$(DOCDIR)" ""
@install -d "$(DESTDIR)$(DOCDIR)"
@install -m644 README.md compton.sample.conf "$(DESTDIR)$(DOCDIR)"/
@install -m755 dbus-examples/cdbus-driver.sh "$(DESTDIR)$(DOCDIR)"/
endif
uninstall:
@rm -f "$(DESTDIR)$(BINDIR)/compton" "$(DESTDIR)$(BINDIR)/compton-trans"
@rm -f $(addprefix "$(DESTDIR)$(MANDIR)"/, compton.1 compton-trans.1)
@rm -f "$(DESTDIR)$(APPDIR)/compton.desktop"
ifneq "$(DOCDIR)" ""
@rm -f $(addprefix "$(DESTDIR)$(DOCDIR)"/, README.md compton.sample.conf cdbus-driver.sh)
endif
clean:
@rm -f $(OBJS) compton $(MANPAGES) $(MANPAGES_HTML) .clang_complete
version:
@echo "$(COMPTON_VERSION)"
.PHONY: uninstall clean docs version