diff --git a/Makefile b/Makefile
index 742b86129..e3129aa39 100644
--- a/Makefile
+++ b/Makefile
@@ -46,6 +46,8 @@ destdir   :=
 # Fallback to defaults but allow to get the values from environment.
 PREFIX    ?= $(prefix)
 DESTDIR   ?= $(destdir)
+DATADIR   ?= $(PKGID)
+DOCDIR    ?= $(PKGID)/doc
 
 #-------------------------------------------------------------------------------
 # Installation paths
@@ -54,8 +56,8 @@ DESTPATH    := $(DESTDIR)$(PREFIX)
 BINPATH     := $(DESTPATH)/bin
 DATAPATH    := $(DESTPATH)/share
 MANPATH     := $(DATAPATH)/man
-PKGDATAPATH := $(DATAPATH)/$(PKGID)
-PKGDOCPATH  := $(PKGDATAPATH)/doc
+PKGDATAPATH := $(DATAPATH)/$(DATADIR)
+PKGDOCPATH  := $(DATAPATH)/$(DOCDIR)
 
 #-------------------------------------------------------------------------------
 # Generic Makefile variables
@@ -190,7 +192,7 @@ uninstall-program: uninstall-exec uninstall-doc
 
 .PHONY: install-all uninstall-all
 # Full installation through Cabal: main + wrappers + user docs + lib + lib docs
-install-all: install-program
+install-all: build-all install-program
 	destdir=$(DESTDIR); \
 	# Older Cabal versions have no '--destdir' option.
 	if $(BUILDCMD) copy --help | grep -q '\-\-destdir'; then \
diff --git a/debian/rules b/debian/rules
index aeb66d74e..8e3dc240f 100755
--- a/debian/rules
+++ b/debian/rules
@@ -12,6 +12,8 @@
 THIS    := $(shell sed -ne 's/^Source: \(.*\)/\1/p' debian/control)
 PREFIX  := /usr
 DESTDIR := debian/$(THIS)
+DATADIR := $(THIS)
+DOCDIR  := doc/$(THIS)
 
 # Uncomment this to turn on verbose mode.
 #export DH_VERBOSE=1
@@ -29,7 +31,7 @@ HCFLAGS+=-O0
 endif
 
 # Export all variables which will be used in various stages of build process.
-export PREFIX DESTDIR HCFLAGS
+export PREFIX DESTDIR DATADIR DOCDIR HCFLAGS
 
 configure: configure-stamp
 configure-stamp: