| 1 |
# Use tab to indent recipe lines, spaces to indent other lines, otherwise |
| 2 |
# GNU make may get unhappy. |
| 3 |
|
| 4 |
CC ?= gcc |
| 5 |
|
| 6 |
PREFIX ?= /usr |
| 7 |
BINDIR ?= $(PREFIX)/bin |
| 8 |
MANDIR ?= $(PREFIX)/share/man/man1 |
| 9 |
APPDIR ?= $(PREFIX)/share/applications |
| 10 |
ICODIR ?= $(PREFIX)/share/icons/hicolor/ |
| 11 |
|
| 12 |
PACKAGES = x11 xcomposite xfixes xdamage xrender xext xrandr |
| 13 |
LIBS = -lm -lrt |
| 14 |
INCS = |
| 15 |
|
| 16 |
OBJS = compton.o |
| 17 |
|
| 18 |
# === Configuration flags === |
| 19 |
CFG = -std=c99 |
| 20 |
|
| 21 |
# ==== Xinerama ==== |
| 22 |
# Enables support for --xinerama-shadow-crop |
| 23 |
ifeq "$(NO_XINERAMA)" "" |
| 24 |
CFG += -DCONFIG_XINERAMA |
| 25 |
PACKAGES += xinerama |
| 26 |
endif |
| 27 |
|
| 28 |
# ==== libconfig ==== |
| 29 |
# Enables configuration file parsing support |
| 30 |
ifeq "$(NO_LIBCONFIG)" "" |
| 31 |
CFG += -DCONFIG_LIBCONFIG |
| 32 |
PACKAGES += libconfig |
| 33 |
|
| 34 |
# libconfig-1.3* does not define LIBCONFIG_VER* macros, so we use |
| 35 |
# pkg-config to determine its version here |
| 36 |
CFG += $(shell pkg-config --atleast-version=1.4 libconfig || echo '-DCONFIG_LIBCONFIG_LEGACY') |
| 37 |
endif |
| 38 |
|
| 39 |
# ==== PCRE regular expression ==== |
| 40 |
# Enables support for PCRE regular expression pattern in window conditions |
| 41 |
ifeq "$(NO_REGEX_PCRE)" "" |
| 42 |
CFG += -DCONFIG_REGEX_PCRE |
| 43 |
LIBS += $(shell pcre-config --libs) |
| 44 |
INCS += $(shell pcre-config --cflags) |
| 45 |
# Enables JIT support in libpcre |
| 46 |
ifeq "$(NO_REGEX_PCRE_JIT)" "" |
| 47 |
CFG += -DCONFIG_REGEX_PCRE_JIT |
| 48 |
endif |
| 49 |
endif |
| 50 |
|
| 51 |
# ==== DRM VSync ==== |
| 52 |
# Enables support for "drm" VSync method |
| 53 |
ifeq "$(NO_VSYNC_DRM)" "" |
| 54 |
INCS += $(shell pkg-config --cflags libdrm) |
| 55 |
CFG += -DCONFIG_VSYNC_DRM |
| 56 |
endif |
| 57 |
|
| 58 |
# ==== OpenGL ==== |
| 59 |
# Enables support for GLX backend, OpenGL VSync methods, etc. |
| 60 |
ifeq "$(NO_VSYNC_OPENGL)" "" |
| 61 |
CFG += -DCONFIG_VSYNC_OPENGL |
| 62 |
# -lGL must precede some other libraries, or it segfaults on FreeBSD (#74) |
| 63 |
LIBS := -lGL $(LIBS) |
| 64 |
OBJS += opengl.o |
| 65 |
# Enables support for GLSL (GLX background blur, etc.) |
| 66 |
ifeq "$(NO_VSYNC_OPENGL_GLSL)" "" |
| 67 |
CFG += -DCONFIG_VSYNC_OPENGL_GLSL |
| 68 |
endif |
| 69 |
# Enables support for GL FBO (GLX multi-pass blur, etc.) |
| 70 |
ifeq "$(NO_VSYNC_OPENGL_FBO)" "" |
| 71 |
CFG += -DCONFIG_VSYNC_OPENGL_FBO |
| 72 |
endif |
| 73 |
# Enables support for GL VBO (does nothing right now) |
| 74 |
ifeq "$(NO_VSYNC_OPENGL_VBO)" "" |
| 75 |
CFG += -DCONFIG_VSYNC_OPENGL_VBO |
| 76 |
endif |
| 77 |
endif |
| 78 |
|
| 79 |
# ==== D-Bus ==== |
| 80 |
# Enables support for --dbus (D-Bus remote control) |
| 81 |
ifeq "$(NO_DBUS)" "" |
| 82 |
CFG += -DCONFIG_DBUS |
| 83 |
PACKAGES += dbus-1 |
| 84 |
OBJS += dbus.o |
| 85 |
endif |
| 86 |
|
| 87 |
# ==== X Sync ==== |
| 88 |
# Enables support for --xrender-sync-fence |
| 89 |
ifeq "$(NO_XSYNC)" "" |
| 90 |
CFG += -DCONFIG_XSYNC |
| 91 |
endif |
| 92 |
|
| 93 |
# ==== C2 ==== |
| 94 |
# Enable window condition support |
| 95 |
ifeq "$(NO_C2)" "" |
| 96 |
CFG += -DCONFIG_C2 |
| 97 |
OBJS += c2.o |
| 98 |
endif |
| 99 |
|
| 100 |
# ==== X resource checker ==== |
| 101 |
# Enable X resource leakage checking (Pixmap only, presently) |
| 102 |
ifneq "$(ENABLE_XRESCHECK)" "" |
| 103 |
CFG += -DDEBUG_XRC |
| 104 |
OBJS += xrescheck.o |
| 105 |
endif |
| 106 |
|
| 107 |
# === Version string === |
| 108 |
COMPTON_VERSION ?= git-$(shell git describe --always --dirty)-$(shell git log -1 --date=short --pretty=format:%cd) |
| 109 |
CFG += -DCOMPTON_VERSION="\"$(COMPTON_VERSION)\"" |
| 110 |
|
| 111 |
LDFLAGS ?= -Wl,-O1 -Wl,--as-needed |
| 112 |
|
| 113 |
BUILD_TYPE ?= "Debug" |
| 114 |
|
| 115 |
ifeq "$(BUILD_TYPE)" "Release" |
| 116 |
CFLAGS += -DNDEBUG -O2 -D_FORTIFY_SOURCE=2 |
| 117 |
else ifeq "$(BUILD_TYPE)" "Debug" |
| 118 |
CFLAGS += -ggdb -Wshadow |
| 119 |
endif |
| 120 |
|
| 121 |
ifeq "$(ENABLE_SAN)" "1" |
| 122 |
CFLAGS += -fsanitize=address,undefined |
| 123 |
else ifeq "$(ENABLE_SAN)" "thread" |
| 124 |
CFLAGS += -fsanitize=thread |
| 125 |
else ifeq "$(ENABLE_SAN)" "memory" |
| 126 |
CFLAGS += -fsanitize=memory |
| 127 |
endif |
| 128 |
|
| 129 |
LIBS += $(shell pkg-config --libs $(PACKAGES)) |
| 130 |
INCS += $(shell pkg-config --cflags $(PACKAGES)) |
| 131 |
|
| 132 |
CFLAGS += -Wall -Wimplicit-fallthrough |
| 133 |
|
| 134 |
BINS = compton bin/compton-trans |
| 135 |
MANPAGES = man/compton.1 man/compton-trans.1 |
| 136 |
MANPAGES_HTML = $(addsuffix .html,$(MANPAGES)) |
| 137 |
|
| 138 |
# === Recipes === |
| 139 |
.DEFAULT_GOAL := compton |
| 140 |
|
| 141 |
src/.clang_complete: Makefile |
| 142 |
@(for i in $(filter-out -O% -DNDEBUG, $(CFG) $(CPPFLAGS) $(CFLAGS) $(INCS)); do echo "$$i"; done) > $@ |
| 143 |
|
| 144 |
%.o: src/%.c src/%.h src/common.h |
| 145 |
$(CC) $(CFG) $(CPPFLAGS) $(CFLAGS) $(INCS) -c src/$*.c |
| 146 |
|
| 147 |
compton: $(OBJS) |
| 148 |
$(CC) $(CFG) $(CPPFLAGS) $(LDFLAGS) $(CFLAGS) -o $@ $(OBJS) $(LIBS) |
| 149 |
|
| 150 |
man/%.1: man/%.1.asciidoc |
| 151 |
a2x --format manpage $< |
| 152 |
|
| 153 |
man/%.1.html: man/%.1.asciidoc |
| 154 |
asciidoc $< |
| 155 |
|
| 156 |
docs: $(MANPAGES) $(MANPAGES_HTML) |
| 157 |
|
| 158 |
install: $(BINS) docs |
| 159 |
@install -d "$(DESTDIR)$(BINDIR)" "$(DESTDIR)$(MANDIR)" "$(DESTDIR)$(APPDIR)" |
| 160 |
@install -m755 $(BINS) "$(DESTDIR)$(BINDIR)"/ |
| 161 |
ifneq "$(MANPAGES)" "" |
| 162 |
@install -m644 $(MANPAGES) "$(DESTDIR)$(MANDIR)"/ |
| 163 |
endif |
| 164 |
@install -d \ |
| 165 |
"$(DESTDIR)$(ICODIR)/scalable/apps" \ |
| 166 |
"$(DESTDIR)$(ICODIR)/48x48/apps" |
| 167 |
@install -m644 media/compton.svg "$(DESTDIR)$(ICODIR)/scalable/apps"/ |
| 168 |
@install -m644 media/icons/48x48/compton.png "$(DESTDIR)$(ICODIR)/48x48/apps"/ |
| 169 |
@install -m644 compton.desktop "$(DESTDIR)$(APPDIR)"/ |
| 170 |
ifneq "$(DOCDIR)" "" |
| 171 |
@install -d "$(DESTDIR)$(DOCDIR)" |
| 172 |
@install -m644 README.md compton.sample.conf "$(DESTDIR)$(DOCDIR)"/ |
| 173 |
@install -m755 dbus-examples/cdbus-driver.sh "$(DESTDIR)$(DOCDIR)"/ |
| 174 |
endif |
| 175 |
|
| 176 |
uninstall: |
| 177 |
@rm -f "$(DESTDIR)$(BINDIR)/compton" "$(DESTDIR)$(BINDIR)/compton-trans" |
| 178 |
@rm -f $(addprefix "$(DESTDIR)$(MANDIR)"/, compton.1 compton-trans.1) |
| 179 |
@rm -f "$(DESTDIR)$(APPDIR)/compton.desktop" |
| 180 |
ifneq "$(DOCDIR)" "" |
| 181 |
@rm -f $(addprefix "$(DESTDIR)$(DOCDIR)"/, README.md compton.sample.conf cdbus-driver.sh) |
| 182 |
endif |
| 183 |
|
| 184 |
clean: |
| 185 |
@rm -f $(OBJS) compton $(MANPAGES) $(MANPAGES_HTML) .clang_complete |
| 186 |
|
| 187 |
version: |
| 188 |
@echo "$(COMPTON_VERSION)" |
| 189 |
|
| 190 |
.PHONY: uninstall clean docs version |