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