]> git.sur5r.net Git - i3/i3/blob - common.mk
Support for custom bg colors for clients.
[i3/i3] / common.mk
1 UNAME=$(shell uname)
2 DEBUG=1
3 INSTALL=install
4 ifndef PREFIX
5   PREFIX=/usr
6 endif
7 ifndef SYSCONFDIR
8   ifeq ($(PREFIX),/usr)
9     SYSCONFDIR=/etc
10   else
11     SYSCONFDIR=$(PREFIX)/etc
12   endif
13 endif
14 # The escaping is absurd, but we need to escape for shell, sed, make, define
15 GIT_VERSION:="$(shell git describe --tags --always) ($(shell git log --pretty=format:%cd --date=short -n1), branch $(shell [ -f .git/HEAD ] && sed 's/ref: refs\/heads\/\(.*\)/\\\\\\"\1\\\\\\"/g' .git/HEAD || echo 'unknown'))"
16 VERSION:=$(shell git describe --tags --abbrev=0)
17
18 CFLAGS += -std=c99
19 CFLAGS += -pipe
20 CFLAGS += -Wall
21 # unused-function, unused-label, unused-variable are turned on by -Wall
22 # We don’t want unused-parameter because of the use of many callbacks
23 CFLAGS += -Wunused-value
24 CFLAGS += -Iinclude
25 CFLAGS += -I/usr/local/include
26 CFLAGS += -DI3_VERSION=\"${GIT_VERSION}\"
27 CFLAGS += -DSYSCONFDIR=\"${SYSCONFDIR}\"
28
29 # Check if pkg-config is installed, because without pkg-config, the following
30 # check for the version of libxcb cannot be done.
31 ifeq ($(shell which pkg-config 2>/dev/null 1>/dev/null || echo 1),1)
32 $(error "pkg-config was not found")
33 endif
34
35 ifeq ($(shell pkg-config --exists xcb-keysyms || echo 1),1)
36 $(error "pkg-config could not find xcb-keysyms.pc")
37 endif
38
39 ifeq ($(shell pkg-config --exact-version=0.3.3 xcb-keysyms && echo 1),1)
40 # xcb-keysyms fixed API from 0.3.3 to 0.3.4, so for some months, we will
41 # have this here. Distributions should upgrade their libxcb in the meantime.
42 CFLAGS += -DOLD_XCB_KEYSYMS_API
43 endif
44
45 LDFLAGS += -lm
46 LDFLAGS += -lxcb-event
47 LDFLAGS += -lxcb-property
48 LDFLAGS += -lxcb-keysyms
49 LDFLAGS += -lxcb-atom
50 LDFLAGS += -lxcb-aux
51 LDFLAGS += -lxcb-icccm
52 LDFLAGS += -lxcb-xinerama
53 LDFLAGS += -lxcb-randr
54 LDFLAGS += -lxcb
55 LDFLAGS += -lyajl
56 LDFLAGS += -lX11
57 LDFLAGS += -lev
58 LDFLAGS += -L/usr/local/lib -L/usr/pkg/lib
59
60 ifeq ($(UNAME),NetBSD)
61 # We need -idirafter instead of -I to prefer the system’s iconv over GNU libiconv
62 CFLAGS += -idirafter /usr/pkg/include
63 LDFLAGS += -Wl,-rpath,/usr/local/lib -Wl,-rpath,/usr/pkg/lib
64 endif
65
66 ifeq ($(UNAME),OpenBSD)
67 CFLAGS += -I${X11BASE}/include
68 LDFLAGS += -liconv
69 LDFLAGS += -L${X11BASE}/lib
70 endif
71
72 ifeq ($(UNAME),FreeBSD)
73 LDFLAGS += -liconv
74 endif
75
76 ifneq (,$(filter Linux GNU GNU/%, $(UNAME)))
77 CFLAGS += -D_GNU_SOURCE
78 endif
79
80 ifeq ($(DEBUG),1)
81 # Extended debugging flags, macros shall be available in gcc
82 CFLAGS += -gdwarf-2
83 CFLAGS += -g3
84 else
85 CFLAGS += -O2
86 endif
87
88 # Don’t print command lines which are run
89 .SILENT:
90
91 # Always remake the following targets
92 .PHONY: install clean dist distclean
93