8 SYSCONFDIR=$(PREFIX)/etc
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)
14 # An easier way to get CFLAGS and LDFLAGS falling back in case there's
15 # no pkg-config support for certain libraries
16 cflags_for_lib = $(shell pkg-config --silence-errors --cflags $(1))
17 ldflags_for_lib = $(shell pkg-config --exists $(1) && pkg-config --libs $(1) || echo -l$(2))
22 # unused-function, unused-label, unused-variable are turned on by -Wall
23 # We don’t want unused-parameter because of the use of many callbacks
24 CFLAGS += -Wunused-value
26 CFLAGS += -I/usr/local/include
27 CFLAGS += $(call cflags_for_lib, xcb-event)
28 CFLAGS += $(call cflags_for_lib, xcb-property)
29 CFLAGS += $(call cflags_for_lib, xcb-keysyms)
30 CFLAGS += $(call cflags_for_lib, xcb-atom)
31 CFLAGS += $(call cflags_for_lib, xcb-aux)
32 CFLAGS += $(call cflags_for_lib, xcb-icccm)
33 CFLAGS += $(call cflags_for_lib, xcb-xinerama)
34 CFLAGS += $(call cflags_for_lib, xcb-randr)
35 CFLAGS += $(call cflags_for_lib, xcb)
36 CFLAGS += $(call cflags_for_lib, xcursor)
37 CFLAGS += $(call cflags_for_lib, x11)
38 CFLAGS += $(call cflags_for_lib, yajl)
39 CFLAGS += $(call cflags_for_lib, libev)
40 CFLAGS += -DI3_VERSION=\"${GIT_VERSION}\"
41 CFLAGS += -DSYSCONFDIR=\"${SYSCONFDIR}\"
44 LDFLAGS += $(call ldflags_for_lib, xcb-event, xcb-event)
45 LDFLAGS += $(call ldflags_for_lib, xcb-property, xcb-property)
46 LDFLAGS += $(call ldflags_for_lib, xcb-keysyms, xcb-keysyms)
47 LDFLAGS += $(call ldflags_for_lib, xcb-atom, xcb-atom)
48 LDFLAGS += $(call ldflags_for_lib, xcb-aux, xcb-aux)
49 LDFLAGS += $(call ldflags_for_lib, xcb-icccm, xcb-icccm)
50 LDFLAGS += $(call ldflags_for_lib, xcb-xinerama, xcb-xinerama)
51 LDFLAGS += $(call ldflags_for_lib, xcb-randr, xcb-randr)
52 LDFLAGS += $(call ldflags_for_lib, xcb, xcb)
53 LDFLAGS += $(call ldflags_for_lib, xcursor, Xcursor)
54 LDFLAGS += $(call ldflags_for_lib, x11, X11)
55 LDFLAGS += $(call ldflags_for_lib, yajl, yajl)
56 LDFLAGS += $(call ldflags_for_lib, libev, ev)
57 LDFLAGS += -L/usr/local/lib -L/usr/pkg/lib
59 ifeq ($(UNAME),NetBSD)
60 # We need -idirafter instead of -I to prefer the system’s iconv over GNU libiconv
61 CFLAGS += -idirafter /usr/pkg/include
62 LDFLAGS += -Wl,-rpath,/usr/local/lib -Wl,-rpath,/usr/pkg/lib
65 ifeq ($(UNAME),OpenBSD)
66 CFLAGS += -I${X11BASE}/include
68 LDFLAGS += -L${X11BASE}/lib
71 ifeq ($(UNAME),FreeBSD)
75 ifneq (,$(filter Linux GNU GNU/%, $(UNAME)))
76 CFLAGS += -D_GNU_SOURCE
80 # Extended debugging flags, macros shall be available in gcc
85 CFLAGS += -freorder-blocks-and-partition
88 # Don’t print command lines which are run
91 # Always remake the following targets
92 .PHONY: install clean dist distclean