]> git.sur5r.net Git - i3/i3/blob - common.mk
makefiles: support PREFIX and SYSCONFDIR
[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-event
41 LDFLAGS += -lxcb-property
42 LDFLAGS += -lxcb-keysyms
43 LDFLAGS += -lxcb-atom
44 LDFLAGS += -lxcb-aux
45 LDFLAGS += -lxcb-icccm
46 LDFLAGS += -lxcb-xinerama
47 LDFLAGS += -lxcb-randr
48 LDFLAGS += -lxcb
49 LDFLAGS += -lyajl
50 LDFLAGS += -lX11
51 LDFLAGS += -lev
52 LDFLAGS += -L/usr/local/lib -L/usr/pkg/lib
53
54 ifeq ($(UNAME),NetBSD)
55 # We need -idirafter instead of -I to prefer the system’s iconv over GNU libiconv
56 CFLAGS += -idirafter /usr/pkg/include
57 LDFLAGS += -Wl,-rpath,/usr/local/lib -Wl,-rpath,/usr/pkg/lib
58 endif
59
60 ifeq ($(UNAME),OpenBSD)
61 CFLAGS += -I${X11BASE}/include
62 LDFLAGS += -liconv
63 LDFLAGS += -L${X11BASE}/lib
64 endif
65
66 ifeq ($(UNAME),FreeBSD)
67 LDFLAGS += -liconv
68 endif
69
70 ifneq (,$(filter Linux GNU GNU/%, $(UNAME)))
71 CFLAGS += -D_GNU_SOURCE
72 endif
73
74 ifeq ($(DEBUG),1)
75 # Extended debugging flags, macros shall be available in gcc
76 CFLAGS += -gdwarf-2
77 CFLAGS += -g3
78 else
79 CFLAGS += -O2
80 endif
81
82 # Don’t print command lines which are run
83 .SILENT:
84
85 # Always remake the following targets
86 .PHONY: install clean dist distclean
87