diff --git a/Makefile b/Makefile
index c049e89..7241985 100644
--- a/Makefile
+++ b/Makefile
@@ -1,11 +1,11 @@
 srcdir     :=$(shell pwd)
 
-CFLAGS= -O
+CFLAGS?= -O
 fixed-flags = -I$(srcdir) -I$(srcdir)/box
 all-C-flags:= -ansi $(fixed-flags) $(CFLAGS)
 non-ansi-flags :=  $(fixed-flags) $(CFLAGS)
 
-CC = gcc # some compiler for ANSI/ISO C
+CC ?= gcc # some compiler for ANSI/ISO C
 
 # These settings should also be used in subdirectories:
 export CC all-C-flags fixed-flags CFLAGS
@@ -24,20 +24,29 @@ GAP_objects=$(common_objects) gapprint.o gapgetl.o
 
 # Global organisation (phony targets)
 
-.PHONY: install all script finish no_readline
+.PHONY: preinstall all finish no_readline
 .PHONY:	math_functions binding_functions
 
 # The first target makes everything to get an operational LiE program
-install: all script INFO.a
+preinstall: all INFO.a
+
+install:
+	install -d $(DESTDIR)/usr/bin
+	install -d $(DESTDIR)/usr/share/lie
+	install Lie.exe $(DESTDIR)/usr/bin/Lie.exe
+	install lie $(DESTDIR)/usr/bin/lie
+	install -m 644 *.ind $(DESTDIR)/usr/share/lie
+	install -m 644 INFO.a $(DESTDIR)/usr/share/lie
+	install -m 644 INFO.* $(DESTDIR)/usr/share/lie
+	install -d $(DESTDIR)/usr/share/man/man1
+	install debian/lie.1 $(DESTDIR)/usr/share/man/man1
 
 # To 'make all', we first descend into the subdirectories, and afterwards
 # return to finish here.
 
-all:
-	$(MAKE) math_functions binding_functions
-	$(MAKE) finish
+all: math_functions binding_functions finish
 
-finish: Lie.exe LEARN.ind INFO.ind # do not call 'make finish' directly
+finish: lie Lie.exe LEARN.ind INFO.ind # do not call 'make finish' directly
 
 math_functions:
 	$(MAKE) -C box all
@@ -82,13 +91,13 @@ gapgetl.o: getl.c
 # been set to the most recent one of object files in the respective
 # subdirectories, whence taking that dummy file as dependency suffices.
 
-date.o: date.c $(objects) box/.last_compiled static/.last_compiled
+date.o: date.c $(objects) math_functions binding_functions
 	$(CC) -ansi -c date.c
-gapdate.o: date.c $(GAP_objects) box/.last_compiled static/.last_compiled
+gapdate.o: date.c $(GAP_objects) math_functions binding_functions
 	$(CC) -ansi -c -o gapdate.o date.c
 
-Lie.exe: date.o
-	$(CC) -o Lie.exe $(objects) date.o static/*.o box/*.o -lreadline
+Lie.exe: math_functions binding_functions date.o
+	$(CC) -o Lie.exe $(LDFLAGS) $(objects) date.o static/*.o box/*.o -lreadline -lncurses
 	chmod g+w Lie.exe
 Liegap.exe: gapdate.o
 	$(CC) -o Liegap.exe $(GAP_objects) gapdate.o static/*.o box/*.o
@@ -101,8 +110,8 @@ noreadline: math_functions binding_functions $(common_objects) print.o
 	chmod g+w Lie.exe
 	$(MAKE) LEARN.ind INFO.ind script INFO.a
 
-script:
-	./make_lie
+lie:
+	./make_lie $(DESTDIR)
 
 INFO.ind:	INFO.0 INFO.1 INFO.2 INFO.3 INFO.4 infoind
 	./infoind
@@ -115,7 +124,7 @@ infoind: util/infoind.c
 learnind: util/learnind.c
 	$(MAKE) -C util ../learnind
 
-INFO.a: progs/maxsub progs/maxsub0 progs/eqrank
+INFO.a: Lie.exe progs/maxsub progs/maxsub0 progs/eqrank
 	rm -f INFO.a
 	./Lie.exe < progs/maxsub
 
@@ -123,5 +132,8 @@ INFO.a: progs/maxsub progs/maxsub0 progs/eqrank
 clean:
 	$(MAKE) -C box clean
 	$(MAKE) -C static clean
-	rm -f *~ *.o parser.[ch] INFO.a LEARN.ind
-	rm -f Lie.exe Liegap.exe infoind learnind util/*.o
+	rm -f *~ *.o parser.[ch] INFO.a LEARN.ind INFO.ind
+	rm -f lie Lie.exe Liegap.exe infoind learnind util/*.o
+	rm -f debian/lie/usr/bin/Lie.exe
+	rm -f debian/lie/usr/bin/lie
+	rm -f debian/lie/usr/share/lie/*
diff --git a/debian/lie.1 b/debian/lie.1
new file mode 100644
index 0000000..10bf50d
--- /dev/null
+++ b/debian/lie.1
@@ -0,0 +1,27 @@
+.TH LIE 1 "December 12, 2006" "" ""
+
+.SH NAME
+LiE -  A computer algebra package for Lie group computations
+.SH SYNOPSIS
+.BR "lie"
+.SH DESCRIPTION
+.B LiE
+LiE is a computer algebra system that is specialised in computations
+involving (reductive) Lie groups and their representations.
+
+Full documentation about the program and the underlying mathematics
+can be found in /usr/share/doc/lie/manual.dvi.
+
+Run-time help can be obtained by typing '?' for a list of help entries
+or '?help' for help information.
+
+See the web page at
+.BR "http://young.sp2mi.univ-poitiers.fr/~marc/LiE/"
+for the CWEBx source code.
+.SH AUTHORS
+LiE was written by Arjeh M. Cohen <amc@win.tue.nl>, Marc van Leeuwen
+<maavl@mathlabo.univ-poitiers.fr> and Bert Lisser.
+.PP
+This manual page was written by Kasper Peeters
+<kasper.peeters@aei.mpg.de>, for the Debian project (but may be used
+by others).
diff --git a/lie b/lie
new file mode 100644
index 0000000..5a7a906
--- /dev/null
+++ b/lie
@@ -0,0 +1,4 @@
+#!/bin/sh
+PTH=`which ${0} | sed -e 's/bin\/lie//'`
+
+exec ${PTH}/bin/Lie.exe initfile ${PTH}/share/lie
diff --git a/lie_script b/lie_script
index 76f3701..62972c0 100644
--- a/lie_script
+++ b/lie_script
@@ -1,2 +1,3 @@
-LD=actual directory gets substituted here
-exec $LD/Lie.exe initfile $LD
+#!/bin/sh
+#LD=actual directory gets substituted here
+exec /usr/bin/Lie.exe initfile /usr/share/lie
diff --git a/make_lie b/make_lie
index 5f059d7..1b5320b 100755
--- a/make_lie
+++ b/make_lie
@@ -1,3 +1,3 @@
 #!/bin/sh
-sed -e "s!LD=.*!LD=`/bin/pwd`!"  <lie_script >lie
+sed -e "s!LD=.*!LD=$1!"  <lie_script >lie
 chmod a+x lie
