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