+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
+
+CFLAGS+=$(EXTRA_CFLAGS)
+
+# Fallback for libyajl 1 which did not include yajl_version.h. We need
+# YAJL_MAJOR from that file to decide which code path should be used.
+CFLAGS += -idirafter yajl-fallback
+
+OBJS:=$(sort $(wildcard src/*.c *.c))
+OBJS:=$(OBJS:.c=.o)
+
+ifeq ($(OS),OpenBSD)
+OBJS:=$(filter-out src/pulse.o, $(OBJS))
+LIBS:=$(filter-out -lpulse, $(LIBS))
+endif
+
+src/%.o: src/%.c include/i3status.h
+ $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
+ @echo " CC $<"
+
+%.o: %.c include/%.h
+ $(CC) $(CPPFLAGS) $(CFLAGS) -c -o $@ $<
+ @echo " CC $<"
+
+all: i3status manpage
+
+i3status: ${OBJS}
+ $(CC) $(LDFLAGS) -o $@ $^ $(LIBS)
+ @echo " LD $@"