-# Uncomment this to turn on verbose mode.
-export DH_VERBOSE=1
-
-# This is the debhelper compatibility version to use.
-export DH_COMPAT=3
-
-pkg := ctsim
-prefix := debian/$(pkg)
-
-INSTALL := install
-INSTALLFLAGS := -g root -o root -m 0644
-INSTALLDIRFLAGS := -d -g root -o root -m 0755
-
-SOURCEDIR := $(prefix)/usr/share/common-lisp/source
-REPOSITORYDIR := $(prefix)/usr/share/common-lisp/repositories/uffi
-SYSDIR := $(prefix)/usr/share/common-lisp/systems
-DOCDIR := $(prefix)/usr/share/doc/cl-uffi
+export DH_COMPAT=4
+
+ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
+ CFLAGS += -g
+endif
+ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
+ INSTALL_PROGRAM += -s
+endif
+
+host_arch := $(shell dpkg-architecture -qDEB_HOST_ARCH)
+
+pkg := ctsim
+pkg-p4 := ctsim-pentium4
+pkg-p3 := ctsim-pentium3
+pkg-athlon := ctsim-athlon
+pkg-athlon-mp := ctsim-athlon-mp
+pkg-help := ctsim-help
+pkg-doc := ctsim-doc
+
+ctsim-shared := usr/share/ctsim
+
+prefix := debian/$(pkg)
+prefix-p4 := debian/$(pkg-p4)
+prefix-p3 := debian/$(pkg-p3)
+prefix-athlon := debian/$(pkg-athlon)
+prefix-athlon-mp:= debian/$(pkg-athlon-mp)
+prefix-help := debian/$(pkg-help)
+prefix-doc := debian/$(pkg-doc)
+
+DESTDIR := `pwd`/$(prefix)
+DESTDIR-P4 := `pwd`/$(prefix-p4)
+DESTDIR-P3 := `pwd`/$(prefix-p3)
+DESTDIR-ATHLON := `pwd`/$(prefix-athlon)
+DESTDIR-ATHLON-MP := `pwd`/$(prefix-athlon-mp)
+HELPDIR := `pwd`/$(prefix-help)/$(ctsim-shared)
+doc-dir := usr/share/doc/$(pkg-doc)
+pixmap-dir := usr/X11R6/include/X11/pixmaps