--- tolua-4.0a.orig/src/lib/Makefile
+++ tolua-4.0a/src/lib/Makefile
@@ -13,14 +13,34 @@
 	tolua_eh.o \
 	tolua_bd.o
 
+OPIC=	\
+	tolua_lb_p.o \
+	tolua_rg_p.o \
+	tolua_tt_p.o \
+	tolua_tm_p.o \
+	tolua_gp_p.o \
+	tolua_eh_p.o \
+	tolua_bd_p.o
+
+
 T= $(TOLUA)/lib/libtolua.a
+SHARED = $(TOLUA)/lib/libtolua.so
 
-all: $T
+all: $T $(SHARED)
 
 $T: $(OBJS)
 	$(AR) $@ $(OBJS)
 	$(RANLIB) $@
 
+$(SHARED): CFLAGS+=-fPIC
+$(SHARED): $(OPIC)
+	$(CC) $(LIB) $(CFLAGS) -shared -Wl,-soname=libtolua.so.0 $(OPIC) -o $@.0.0.0
+	ln -s libtolua.so.0.0.0 $@.0
+	ln -s libtolua.so.0 $@
+
+%_p.o: %.c
+	$(CC) -c $(CFLAGS) -o $@ $<
+
 clean:
-	rm -f $(OBJS) $T
+	rm -f $(OBJS) $(OPIC) $T $(SHARED) $(SHARED).0 $(SHARED).0.0.0
 
--- tolua-4.0a.orig/src/bin/Makefile
+++ tolua-4.0a/src/bin/Makefile
@@ -13,7 +13,7 @@
 all: $T
 
 $T: $(OBJS)
-	$(CC) -o $@ $(OBJS) $(LIB) -L$(TOLUA)/lib -ltolua -llua -llualib -lm
+	$(CC) -o $@ $(OBJS) $(LIB) -L$(TOLUA)/lib -ltolua -llua40 -llualib40 -lm
 
 clean:
 	rm -f $(OBJS) $T
--- tolua-4.0a.orig/config
+++ tolua-4.0a/config
@@ -20,8 +20,8 @@
 AR= ar rcu
 
 # set lua path
-LUA=/usr/local/lua
-LUAINC=$(LUA)/include
+LUA=/usr
+LUAINC=$(LUA)/include/lua40
 LUALIB=$(LUA)/lib
 
 # == END OF USER SETTINGS. DO NOT CHANGE ANYTHING BELOW THIS LINE ============
--- tolua-4.0a.orig/debian/postinst
+++ tolua-4.0a/debian/postinst
@@ -0,0 +1,48 @@
+#! /bin/sh
+# postinst script for #PACKAGE#
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <postinst> `configure' <most-recently-configured-version>
+#        * <old-postinst> `abort-upgrade' <new version>
+#        * <conflictor's-postinst> `abort-remove' `in-favour' <package>
+#          <new-version>
+#        * <deconfigured's-postinst> `abort-deconfigure' `in-favour'
+#          <failed-install-package> <version> `removing'
+#          <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+#
+# quoting from the policy:
+#     Any necessary prompting should almost always be confined to the
+#     post-installation script, and should be protected with a conditional
+#     so that unnecessary prompting doesn't happen if a package's
+#     installation fails and the `postinst' is called with `abort-upgrade',
+#     `abort-remove' or `abort-deconfigure'.
+
+case "$1" in
+    configure)
+
+    ;;
+
+    abort-upgrade|abort-remove|abort-deconfigure)
+
+    ;;
+
+    *)
+        echo "postinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
+
+
--- tolua-4.0a.orig/debian/postrm
+++ tolua-4.0a/debian/postrm
@@ -0,0 +1,38 @@
+#! /bin/sh
+# postrm script for #PACKAGE#
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <postrm> `remove'
+#        * <postrm> `purge'
+#        * <old-postrm> `upgrade' <new-version>
+#        * <new-postrm> `failed-upgrade' <old-version>
+#        * <new-postrm> `abort-install'
+#        * <new-postrm> `abort-install' <old-version>
+#        * <new-postrm> `abort-upgrade' <old-version>
+#        * <disappearer's-postrm> `disappear' <r>overwrit>r> <new-version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+       purge|remove|upgrade|failed-upgrade|abort-install|abort-upgrade|disappear)
+
+
+        ;;
+
+    *)
+        echo "postrm called with unknown argument \`$1'" >&2
+        exit 1
+
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
--- tolua-4.0a.orig/debian/changelog
+++ tolua-4.0a/debian/changelog
@@ -0,0 +1,38 @@
+tolua (4.0a-2.backports.org.1) unstable; urgency=low
+
+  * recompiled for http://www.backports.org/
+
+ -- Norbert Tretkowski <tretkowski@inittab.de>  Mon, 15 Dec 2003 21:31:55 +0100
+
+tolua (4.0a-3) unstable; urgency=low
+
+  * Changed -Wl,-shared to -shared in src/lib/Makefile to fix building
+    on hppa (Closes: #155688)
+
+ -- Jimmy Kaplowitz <jimmy@debian.org>  Wed, 07 Aug 2002 01:38:44 -0400
+
+tolua (4.0a-2) unstable; urgency=low
+
+  * Add a runtime library package. (Closes: #148721)
+  * Do add an extra dependency as per #146983 ;-)
+  * Move the tolua binary to the -dev package.
+  * Rename the binary packages to libtolua*; set a Conflicts: in the -dev
+    package.
+  * Write a small manpage.
+  * Bump debhelper build-depends and set DH_COMPAT=4, to be able to use the new
+    dh_makeshlibs behaviour. Use dh_install instead of dh_movefiles.
+  * All of the above changes are due to Filip Van Raemdonck. Thanks very much.
+  * Expand Filip's man page by adapting tolua's built-in help output.
+  * Add Provides: and Replaces: to the -dev package as well, to ensure that
+    upgrades work as expected.
+  * Make the libtolua-dev package depend on the same version of the libtolua0
+    package.
+
+ -- Jimmy Kaplowitz <jimmy@debian.org>  Mon,  5 Aug 2002 03:26:18 -0400
+
+tolua (4.0a-1) unstable; urgency=low
+
+  * Initial Release.
+
+ -- Jimmy Kaplowitz <jimmy@debian.org>  Tue, 30 Apr 2002 01:37:09 -0400
+
--- tolua-4.0a.orig/debian/libtolua0.dirs
+++ tolua-4.0a/debian/libtolua0.dirs
@@ -0,0 +1 @@
+usr/lib
--- tolua-4.0a.orig/debian/rules
+++ tolua-4.0a/debian/rules
@@ -0,0 +1,116 @@
+#!/usr/bin/make -f
+# Sample debian/rules that uses debhelper.
+# GNU copyright 1997 to 1999 by Joey Hess.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+# This is the debhelper compatibility version to use.
+export DH_COMPAT=4
+
+
+ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
+	CFLAGS += -g
+endif
+ifeq (,$(findstring nostrip,$(DEB_BUILD_OPTIONS)))
+	INSTALL_PROGRAM += -s
+endif
+
+# shared library versions, option 1
+version=2.0.5
+major=2
+# option 2, assuming the library is created as src/.libs/libfoo.so.2.0.5 or so
+#version=`ls src/.libs/lib*.so.* | \
+# awk '{if (match($$0,/[0-9]+\.[0-9]+\.[0-9]+$$/)) print substr($$0,RSTART)}'`
+#major=`ls src/.libs/lib*.so.* | \
+# awk '{if (match($$0,/\.so\.[0-9]+$$/)) print substr($$0,RSTART+4)}'`
+
+configure: configure-stamp
+configure-stamp:
+	dh_testdir
+	# Add here commands to configure the package.
+
+	touch configure-stamp
+
+
+build: build-stamp
+build-stamp: configure-stamp 
+	dh_testdir
+
+	# Add here commands to compile the package.
+	$(MAKE)
+
+	touch build-stamp
+
+clean:
+	dh_testdir
+	dh_testroot
+	rm -f build-stamp configure-stamp
+
+	# Add here commands to clean up after the build process.
+	-$(MAKE) clean
+
+	dh_clean
+
+install: build
+	dh_testdir
+	dh_testroot
+	dh_clean -k
+	dh_installdirs
+
+	# Add here commands to install the package into debian/tmp
+	install -d -o root -g root -m 0755 debian/tmp/usr/bin \
+		debian/tmp/usr/include debian/tmp/usr/lib
+	install -o root -g root -m 0755 bin/tolua debian/tmp/usr/bin/tolua
+	install -o root -g root -m 0644 include/tolua.h \
+		debian/tmp/usr/include/tolua.h
+	# for some reason install doesn't handle the symlinks
+	cp -ar lib/libtolua* \
+		debian/tmp/usr/lib/
+
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+	dh_testdir
+	dh_testroot
+	dh_install
+
+#	dh_installdebconf	
+	dh_installdocs -A README
+#	dh_installexamples
+#	dh_installmenu
+#	dh_installlogrotate
+#	dh_installemacsen
+#	dh_installpam
+#	dh_installmime
+#	dh_installinit
+#	dh_installcron
+	dh_installman -plibtolua-dev debian/tolua.1
+#	dh_installinfo
+	dh_undocumented
+	dh_installchangelogs 
+#	dh_link
+	dh_strip
+	dh_compress
+	dh_fixperms
+	dh_makeshlibs -V
+	dh_installdeb
+#	dh_perl
+	DH_VERBOSE=1 dh_shlibdeps
+	# The below hack is necessary to prevent libtolua0
+	# from showing up twice in libtolua-dev's Depends line
+	sed -e 's/, libtolua0 (>= [^)][^)]*)//' \
+		< debian/libtolua-dev.substvars \
+		> debian/libtolua-dev.substvars.new \
+		&& mv debian/libtolua-dev.substvars.new \
+		      debian/libtolua-dev.substvars
+	dh_gencontrol
+	dh_md5sums
+	dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
--- tolua-4.0a.orig/debian/tolua.1
+++ tolua-4.0a/debian/tolua.1
@@ -0,0 +1,44 @@
+.\" Hey, Emacs!  This is an -*- nroff -*- source file.
+.\"
+.\" This manpage is in the public domain.
+.\"
+
+.TH tolua 1 "04 Aug 2002" "" "Tolua"
+
+.SH NAME
+tolua \- lua language binding development helper program
+
+.SH SYNOPSIS
+tolua
+[ \fBoptions\fP ]
+.I file
+
+.SH DESCRIPTION
+.I tolua
+is a program to help in building applications using the tolua library for
+the Lua scripting language.
+
+.SH OPTIONS
+Command line options are:
+.IP "-v"
+Print version information.
+.IP "-o \fIfile\fP"
+Set output file; default is stdout.
+.IP "-H \fIfile\fP"
+Create include file.
+.IP "-n \fIname\fP"
+Set package name; default is input file root name.
+.IP "-p"
+Parse only.
+.IP "-P"
+Parse and print structure information (for debugging).
+.IP "-h"
+Print usage information.
+.P
+Should the input file be omitted, stdin is assumed; in that case, the package
+name must be explicitly set.
+
+.SH AUTHOR
+This manual page was written by Filip Van Raemdonck <mechanix@debian.org> and
+Jimmy Kaplowitz <jimmy@debian.org> for the Debian GNU/Linux system (but may be
+used by others).
--- tolua-4.0a.orig/debian/libtolua-dev.dirs
+++ tolua-4.0a/debian/libtolua-dev.dirs
@@ -0,0 +1,4 @@
+usr/bin
+usr/include
+usr/lib
+usr/share/man/man1
--- tolua-4.0a.orig/debian/control
+++ tolua-4.0a/debian/control
@@ -0,0 +1,38 @@
+Source: tolua
+Priority: optional
+Section: devel
+Maintainer: Jimmy Kaplowitz <jimmy@debian.org>
+Build-Depends: debhelper (>= 4), liblua40-dev, liblualib40-dev
+Standards-Version: 3.5.6.1
+
+Package: libtolua0
+Section: libs
+Architecture: any
+Depends: ${shlibs:Depends}
+Description: Tool to integrate C/C++ code with Lua - runtime libraries
+ tolua is a tool that greatly simplifies the integration of C/C++ code with
+ Lua. Based on a cleaned header file, tolua automatically generates the
+ binding code to access C/C++ features from Lua. Using Lua API and tag
+ method facilities, tolua maps C/C++ constants, external variables,
+ functions, classes, and methods to Lua. 
+ .
+ This package contains the tolua runtime libraries, for applications that have
+ been built with tolua.
+
+Package: libtolua-dev
+Section: devel
+Architecture: any
+Depends: ${shlibs:Depends}, libtolua0 (= ${Source-Version}), liblua40-dev
+Provides: tolua, tolua-dev
+Conflicts: tolua, tolua-dev
+Replaces: tolua, tolua-dev
+Description: Tool to integrate C/C++ code with Lua - development files
+ tolua is a tool that greatly simplifies the integration of C/C++ code with
+ Lua. Based on a cleaned header file, tolua automatically generates the
+ binding code to access C/C++ features from Lua. Using Lua API and tag
+ method facilities, tolua maps C/C++ constants, external variables,
+ functions, classes, and methods to Lua. 
+ .
+ This package contains all files necessary to develop applications which use
+ tolua.
+
--- tolua-4.0a.orig/debian/preinst
+++ tolua-4.0a/debian/preinst
@@ -0,0 +1,44 @@
+#! /bin/sh
+# preinst script for #PACKAGE#
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <new-preinst> `install'
+#        * <new-preinst> `install' <old-version>
+#        * <new-preinst> `upgrade' <old-version>
+#        * <old-preinst> `abort-upgrade' <new-version>
+#
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+    install|upgrade)
+#        if [ "$1" = "upgrade" ]
+#        then
+#            start-stop-daemon --stop --quiet --oknodo  \
+#                --pidfile /var/run/#PACKAGE#.pid  \
+#                --exec /usr/sbin/#PACKAGE# 2>/dev/null || true
+#        fi
+    ;;
+
+    abort-upgrade)
+    ;;
+
+    *)
+        echo "preinst called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
+
+
--- tolua-4.0a.orig/debian/prerm
+++ tolua-4.0a/debian/prerm
@@ -0,0 +1,39 @@
+#! /bin/sh
+# prerm script for #PACKAGE#
+#
+# see: dh_installdeb(1)
+
+set -e
+
+# summary of how this script can be called:
+#        * <prerm> `remove'
+#        * <old-prerm> `upgrade' <new-version>
+#        * <new-prerm> `failed-upgrade' <old-version>
+#        * <conflictor's-prerm> `remove' `in-favour' <package> <new-version>
+#        * <deconfigured's-prerm> `deconfigure' `in-favour'
+#          <package-being-installed> <version> `removing'
+#          <conflicting-package> <version>
+# for details, see http://www.debian.org/doc/debian-policy/ or
+# the debian-policy package
+
+
+case "$1" in
+    remove|upgrade|deconfigure)
+#       install-info --quiet --remove /usr/info/#PACKAGE#.info.gz
+        ;;
+    failed-upgrade)
+        ;;
+    *)
+        echo "prerm called with unknown argument \`$1'" >&2
+        exit 1
+    ;;
+esac
+
+# dh_installdeb will replace this with shell code automatically
+# generated by other debhelper scripts.
+
+#DEBHELPER#
+
+exit 0
+
+
--- tolua-4.0a.orig/debian/libtolua0.install
+++ tolua-4.0a/debian/libtolua0.install
@@ -0,0 +1 @@
+debian/tmp/usr/lib/lib*.so.*
--- tolua-4.0a.orig/debian/libtolua-dev.install
+++ tolua-4.0a/debian/libtolua-dev.install
@@ -0,0 +1,4 @@
+debian/tmp/usr/bin/tolua
+debian/tmp/usr/include/*
+debian/tmp/usr/lib/lib*.a
+debian/tmp/usr/lib/lib*.so
--- tolua-4.0a.orig/debian/copyright
+++ tolua-4.0a/debian/copyright
@@ -0,0 +1,15 @@
+This package was debianized by Jimmy Kaplowitz <jimmy@debian.org> on
+Tue, 30 Apr 2002 01:37:09 -0400.
+
+It was downloaded from ftp://ftp.tecgraf.puc-rio.br/pub/users/celes/tolua/
+
+Upstream Author(s): Waldemar Celes <celes@tecgraf.puc-rio.br>
+
+Copyright:
+
+Quoted from the README file accompanying tolua:
+
+ 'tolua is freely available; you can redistribute it and/or modify it.
+  The software provided hereunder is on an "as is" basis, and
+  the author has no obligation to provide maintenance, support,
+  updates, enhancements, or modifications.'
--- tolua-4.0a.orig/debian/watch
+++ tolua-4.0a/debian/watch
@@ -0,0 +1,5 @@
+# Example watch control file for uscan
+# Rename this file to "watch" and then you can run the "uscan" command
+# to check for upstream updates and more.
+# Site		Directory		Pattern			Version	Script
+ftp.tecgraf.puc-rio.br	/pub/users/celes/tolua/	tolua-(.*)\.tar\.gz	debian	uupdate
