]> git.sur5r.net Git - i3/i3/blob - common.mk
implement configure requests, adapt testcase
[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 LDFLAGS += -lm
25 LDFLAGS += -lxcb-event
26 LDFLAGS += -lxcb-property
27 LDFLAGS += -lxcb-keysyms
28 LDFLAGS += -lxcb-atom
29 LDFLAGS += -lxcb-aux
30 LDFLAGS += -lxcb-icccm
31 LDFLAGS += -lxcb-xinerama
32 LDFLAGS += -lxcb-randr
33 LDFLAGS += -lxcb
34 LDFLAGS += -lyajl
35 LDFLAGS += -lX11
36 LDFLAGS += -lev
37 LDFLAGS += -L/usr/local/lib -L/usr/pkg/lib
38
39 ifeq ($(UNAME),NetBSD)
40 # We need -idirafter instead of -I to prefer the system’s iconv over GNU libiconv
41 CFLAGS += -idirafter /usr/pkg/include
42 LDFLAGS += -Wl,-rpath,/usr/local/lib -Wl,-rpath,/usr/pkg/lib
43 endif
44
45 ifeq ($(UNAME),OpenBSD)
46 CFLAGS += -I${X11BASE}/include
47 LDFLAGS += -liconv
48 LDFLAGS += -L${X11BASE}/lib
49 endif
50
51 ifeq ($(UNAME),FreeBSD)
52 LDFLAGS += -liconv
53 endif
54
55 ifneq (,$(filter Linux GNU GNU/%, $(UNAME)))
56 CFLAGS += -D_GNU_SOURCE
57 endif
58
59 ifeq ($(DEBUG),1)
60 # Extended debugging flags, macros shall be available in gcc
61 CFLAGS += -gdwarf-2
62 CFLAGS += -g3
63 else
64 CFLAGS += -O2
65 CFLAGS += -freorder-blocks-and-partition
66 endif
67
68 # Don’t print command lines which are run
69 .SILENT:
70
71 # Always remake the following targets
72 .PHONY: install clean dist distclean
73