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