+CFLAGS+=-std=gnu99
+CFLAGS+=-pedantic
+CPPFLAGS+=-DSYSCONFDIR=\"$(SYSCONFDIR)\"
+CPPFLAGS+=-DVERSION=\"${I3STATUS_VERSION}\"
+CFLAGS+=-Iinclude
+LIBS+=-lconfuse
+LIBS+=-lyajl
+LIBS+=-lpulse
+LIBS+=-lm
+LIBS+=-lpthread
+
+ifeq ($(wildcard .git),)
+ # not in git repository
+ VERSION := $(shell [ -f $(TOPDIR)/I3STATUS_VERSION ] && cat $(TOPDIR)/I3STATUS_VERSION | cut -d '-' -f 1)
+ I3STATUS_VERSION := '$(shell [ -f $(TOPDIR)/I3STATUS_VERSION ] && cat $(TOPDIR)/I3STATUS_VERSION)'
+else
+ VERSION:=$(shell git describe --tags --abbrev=0)
+ I3STATUS_VERSION:="$(shell git describe --tags --always) ($(shell git log --pretty=format:%cd --date=short -n1))"
+endif
+OS:=$(shell uname)
+
+ifeq ($(OS),Linux)
+CPPFLAGS+=-DLINUX
+CPPFLAGS+=-D_GNU_SOURCE
+CFLAGS += $(shell pkg-config --cflags libnl-genl-3.0)
+LIBS += $(shell pkg-config --libs libnl-genl-3.0)
+LIBS+=-lasound
+endif
+
+ifeq ($(OS),GNU/kFreeBSD)
+LIBS+=-lbsd
+endif
+
+ifneq (, $(filter $(OS), DragonFly FreeBSD OpenBSD))
+CFLAGS+=-I/usr/local/include/
+LDFLAGS+=-L/usr/local/lib/
+endif
+
+ifeq ($(OS),NetBSD)
+LIBS+=-lprop
+endif
+
+# This probably applies for any pkgsrc based system
+ifneq (, $(filter $(OS), NetBSD DragonFly))
+CFLAGS+=-I/usr/pkg/include/
+LDFLAGS+=-L/usr/pkg/lib/
+endif
+
+V ?= 0
+ifeq ($(V),0)
+# Don’t print command lines which are run
+.SILENT:
+endif