+## Makefile for tig
+
+all:
+
+# Include setting from the configure script
+-include config.make
+
+prefix ?= $(HOME)
+bindir ?= $(prefix)/bin
+mandir ?= $(prefix)/man
+datarootdir ?= $(prefix)/share
+docdir ?= $(datarootdir)/doc
+# DESTDIR=
+
+# Get version either via git or from VERSION file. Allow either
+# to be overwritten by setting DIST_VERSION on the command line.
+ifneq (,$(wildcard .git))
+GITDESC = $(subst tig-,,$(shell git describe))
+WTDIRTY = $(if $(shell git diff-index HEAD 2>/dev/null),-dirty)
+VERSION = $(GITDESC)$(WTDIRTY)
+else
+VERSION = $(shell test -f VERSION && cat VERSION || echo "unknown-version")
+endif
+ifdef DIST_VERSION
+VERSION = $(DIST_VERSION)
+endif
+
+# Split the version "TAG-OFFSET-gSHA1-DIRTY" into "TAG OFFSET"
+# and append 0 as a fallback offset for "exact" tagged versions.
+RPM_VERLIST = $(filter-out g% dirty,$(subst -, ,$(VERSION))) 0
+RPM_VERSION = $(word 1,$(RPM_VERLIST))
+RPM_RELEASE = $(word 2,$(RPM_VERLIST))$(if $(WTDIRTY),.dirty)
+
+LDLIBS ?= -lcurses
+CFLAGS ?= -Wall -O2
+DFLAGS = -g -DDEBUG -Werror