--- neko-1.8.1.orig/debian/neko.1
+++ neko-1.8.1/debian/neko.1
@@ -0,0 +1,19 @@
+.TH NEKO 1 "Oct 31, 2006" ""
+.SH NAME
+neko \- Neko virtual machine.
+.SH SYNOPSIS
+.B neko
+.I file.n
+.SH DESCRIPTION
+.B neko
+is a command-line tool for running Neko bytecode.
+.PP
+Neko can be called from the Apache2 web server via the module
+mod_neko2 contained in package libapache2-mod-neko.
+.SH AUTHOR
+Neko is written by Nicolas Cannasse for Motion-Twin.
+.SH SEE ALSO
+.BR "nekoc" (1),
+.BR "nekotools" (1).
+.SH WEB
+.IR "http://nekovm.org" .
--- neko-1.8.1.orig/debian/changelog
+++ neko-1.8.1/debian/changelog
@@ -0,0 +1,271 @@
+neko (1.8.1-2~bpo40+1) etch-backports; urgency=low
+
+  * Backport to Etch, using debhelper verison 5.
+
+ -- Jens Peter Secher <jps@debian.org>  Wed, 09 Sep 2009 21:17:00 +0200
+
+neko (1.8.1-2~bpo50+1) lenny-backports; urgency=low
+
+  * Backport to Lenny (no change).
+
+ -- Jens Peter Secher <jps@debian.org>  Wed, 09 Sep 2009 20:50:05 +0200
+
+neko (1.8.1-2) unstable; urgency=low
+
+  * Do not install broken mysql5.ndll library.  The dynamically linked
+    mysql.ndll works fine for all versions of MySql.
+    (Closes: #542024)
+  * Build-Depend on generic libmysqlclient-dev instead of specific
+    version.
+  * Fixed build failure on kFreeBSD, thanks to Cyril Brulebois.
+    (Closes: #543995)
+  * Bumped the Standards-Version to 3.8.3, no changes.
+
+ -- Jens Peter Secher <jps@debian.org>  Wed, 09 Sep 2009 14:40:17 +0200
+
+neko (1.8.1-1~bpo40+1) etch-backports; urgency=low
+
+  * Backport to Etch (no change).
+
+ -- Jens Peter Secher <jps@debian.org>  Wed, 29 Jul 2009 23:44:05 +0200
+
+neko (1.8.1-1~bpo50+1) lenny-backports; urgency=low
+
+  * Backport to Lenny (no change).
+
+ -- Jens Peter Secher <jps@debian.org>  Wed, 29 Jul 2009 22:37:05 +0200
+
+neko (1.8.1-1) unstable; urgency=low
+
+  * New upstream version.
+  * Bump SONAME to libneko.0.1 and make libneko0 conflict with previous
+    version of neko-dev.
+  * Change libapache2-mod-neko package section to httpd, and updated
+    Standards-Version to 3.8.2.
+  * Removed obsolete patch tora-pwrite-diversion.diff.
+  * Added tora-missing-include.diff to include stdlib.h.
+  * Added mysql-missing-include.diff to include stdlib.h.
+    
+ -- Jens Peter Secher <jps@debian.org>  Tue, 28 Jul 2009 22:32:00 +0200
+
+neko (1.8.0-4) unstable; urgency=low
+
+  * Fix broken NDLLs (shared libraries) by reverting some of the previous
+    changes.
+
+ -- Jens Peter Secher <jps@debian.org>  Sat, 28 Mar 2009 09:40:24 +0100
+
+neko (1.8.0-3) unstable; urgency=low
+
+  * Fix build failure on MIPS by tightening up the linking process.
+  * Make neko-dev architecture independent since there are no binary files
+    in neko-dev.
+  * Bumped the Standards-Version to 3.8.1.
+
+ -- Jens Peter Secher <jps@debian.org>  Thu, 26 Mar 2009 20:00:40 +0100
+
+neko (1.8.0-2) unstable; urgency=low
+
+  * Promoted libneko to a proper shared library living in /usr/lib.
+    (Closes: #509454)    
+  * No need to Build-Conflict with itself because all rpaths have been
+    removed.
+  * Use quilt instead of dpatch for patches, and describe how to use
+    quilt in Debian.source (thanks to Russ Allbery).
+  * Strip all shared libraries.
+  * Put test.n and test.neko in examples directory.
+  * Added a Vcs-Hg control filed to indicate the location of the public
+    repository.
+  * Bumped the Standards-Version to 3.8.0.
+
+ -- Jens Peter Secher <jps@debian.org>  Sat, 14 Mar 2009 21:01:12 +0100
+
+neko (1.8.0-1) experimental; urgency=low
+
+  * New upstream release.
+  * Bumped debhelper version to 6.
+
+ -- Jens Peter Secher <jps@debian.org>  Sat, 04 Oct 2008 16:44:58 +0200
+
+neko (1.7.1-1~bpo40+1) etch-backports; urgency=low
+
+  * Backport to Etch (no change).
+
+ -- Jens Peter Secher <jps@debian.org>  Sun, 03 Aug 2008 13:32:05 +0200
+
+neko (1.7.1-1) unstable; urgency=low
+
+  * New upstream release.
+  * Call dh_makeshlibs before dh_installdeb in debian/rules.
+  * Define _GNU_SOURCE to get threads to work.
+
+ -- Jens Peter Secher <jps@debian.org>  Thu, 31 Jul 2008 13:17:14 +0200
+
+neko (1.7.0-1) unstable; urgency=low
+
+  * New upstream release.
+
+ -- Jens Peter Secher <jps@debian.org>  Thu, 27 Mar 2008 20:53:37 +0100
+
+neko (1.6.0-4~bpo40+2) etch-backports; urgency=low
+
+  * Pass version extracted by dpkg-parsechangelog to dh_makeshlibs instead
+    of error prone hard-coding.
+
+ -- Jens Peter Secher <jps@debian.org>  Tue, 27 Nov 2007 21:09:43 +0100
+
+neko (1.6.0-4~bpo40+1) etch-backports; urgency=low
+
+  * Without the Homepage field.
+
+ -- Jens Peter Secher <jps@debian.org>  Tue, 27 Nov 2007 21:09:43 +0100
+
+neko (1.6.0-4) unstable; urgency=low
+
+  * Give libneko a proper SONAME to avoid breakage by new dpkg-shlibdeps.
+  * Avoid a lot of unnecessary shared library dependencies.
+  * Place the apache module in section web.
+  * Use the Homepage field in the control file.
+  * Bump debhelper to version 5.
+
+ -- Jens Peter Secher <jps@debian.org>  Mon, 26 Nov 2007 19:03:00 +0100
+
+neko (1.6.0-3) unstable; urgency=low
+
+  * Fixed missing reference to shared mysqlclient library.
+
+ -- Jens Peter Secher <jps@debian.org>  Tue, 13 Nov 2007 00:42:42 +0100
+
+neko (1.6.0-2~bpo40+1) etch-backports; urgency=low
+
+  * Backport to Etch (no change).
+
+ -- Jens Peter Secher <jps@debian.org>  Sat, 08 Sep 2007 14:16:50 +0200
+
+neko (1.6.0-2) unstable; urgency=low
+
+  * Support non-stripped builds (DEB_BUILD_OPTIONS=nostrip).
+    (Closes: #437609)
+
+ -- Jens Peter Secher <jps@debian.org>  Sat, 18 Aug 2007 22:34:21 +0200
+
+neko (1.6.0-1) unstable; urgency=low
+
+  * New upstream release, which obsoletes 75-kfreebsd-defines.dpatch and
+    incorporates 50-embed-endianess.dpatch .
+  * New build-depends libgtk2.0-dev.
+  * Update man pages.
+
+ -- Jens Peter Secher <jps@debian.org>  Thu, 26 Jul 2007 23:39:47 +0200
+
+neko (1.5.3-6) unstable; urgency=low
+
+  * Drop support for obsolete Apache 1.
+    (Closes: #429139)
+  * Provide Apache 2 module as seperate package.
+
+ -- Jens Peter Secher <jps@debian.org>  Sat, 16 Jun 2007 20:25:06 +0200
+
+neko (1.5.3-5bpo1) stable; urgency=low
+
+  * Backport to Etch (no change).
+
+ -- Jens Peter Secher <jps@debian.org>  Sun, 27 May 2007 10:57:37 +0200
+
+neko (1.5.3-5) unstable; urgency=low
+
+  * Compile with -DEAPI.
+    (Closes: #415803)
+
+ -- Jens Peter Secher <jps@debian.org>  Thu, 22 Mar 2007 20:48:35 +0100
+
+neko (1.5.3-4) unstable; urgency=low
+
+  * Fix FTBFS on GNU/kFreeBSD, thanks to Cyril Brulebois.
+    (Closes: #414123)
+
+ -- Jens Peter Secher <jps@debian.org>  Sat, 10 Mar 2007 15:26:46 +0100
+
+neko (1.5.3-3) unstable; urgency=low
+
+  * Fix endianess problem in embedded-code loader.
+    (Closes: #412567)
+  
+ -- Jens Peter Secher <jps@debian.org>  Sat,  3 Mar 2007 11:32:21 +0100
+
+neko (1.5.3-2) unstable; urgency=low
+
+  * It turned out that binaries cannot really be stripped, so no
+    stripping.
+
+ -- Jens Peter Secher <jps@debian.org>  Sat, 24 Feb 2007 16:42:32 +0100
+
+neko (1.5.3-1) unstable; urgency=low
+
+  * New upstream release.
+  * The bootable vm implementation changed, so now binaries are now
+    stripped, and the aligment patch has become obsolete.
+
+ -- Jens Peter Secher <jps@debian.org>  Thu, 22 Feb 2007 00:19:25 +0100
+
+neko (1.5.2-3) unstable; urgency=low
+
+  * Fix build failure on various architectures by aligning bytecode at 16
+    byte offset.
+    (Closes: #406033)
+
+ -- Jens Peter Secher <jps@debian.org>  Mon,  8 Jan 2007 22:55:16 +0100
+
+neko (1.5.2-2) unstable; urgency=low
+
+  * Neko modules now work for non-threaded Apache 2.2, that is, it works
+    for apache2-mpm-prefork.
+
+ -- Jens Peter Secher <jps@debian.org>  Wed,  3 Jan 2007 23:12:04 +0100
+
+neko (1.5.2-1) experimental; urgency=low
+
+  * New upstream release.
+  * Unfortunately Apache 2.2 still hangs when serving Neko files, but I am
+    leaving the setup in case others figure out why.
+  * Build-Conflicts with itself because the hardcoded rpath gets in the
+    way when different versions of the VM do not agree.
+
+ -- Jens Peter Secher <jps@debian.org>  Wed, 29 Nov 2006 22:50:48 +0100
+
+neko (1.5-3) experimental; urgency=low
+
+  * Register Apache 1.3 module automatically if Apcahe is installed.
+  * Register Apache 2.2 modules automatically if Apcahe is installed.
+
+ -- Jens Peter Secher <jps@debian.org>  Tue, 21 Nov 2006 22:59:48 +0100
+
+neko (1.5-2) experimental; urgency=low
+
+  * Note to ftpmasters: Neko is written in Neko, so the files boot/* are
+    needed to bootstrap the compiler.  The source for them is in src/*.
+
+ -- Jens Peter Secher <jps@debian.org>  Tue, 21 Nov 2006 22:17:50 +0100
+
+neko (1.5-1bpo1) stable; urgency=low
+
+  * Fit dependencies and include directories so that is is possible to
+    backport to sarge.
+
+ -- Jens Peter Secher <jps@debian.org>  Sat, 11 Nov 2006 12:55:24 +0100
+
+neko (1.5-1) experimental; urgency=low
+
+  * Manpages written for the three executable.
+  * The executables searches for the libneko.so by use of -rpath in
+    /usr/lib/neko since we do not want this private library to end up in
+    /usr/lib.
+  * The dynamic modules /usr/lib/neko/*.ndll are not stripped because they
+    are created as concatenations of the virtual machine bootloader and
+    some bytecode, which makes stripping impossible (cf. OCaml Packaging
+    Policy).  Lintian overrides included for not stripping.
+  * The additional Apache modules are placed in /usr/lib/neko, but not
+    registered with Apache automatically, which avoids a dependency on
+    Apache until we have made proper arrangements with the Apache team.
+
+ -- Jens Peter Secher <jps@debian.org>  Mon,  6 Nov 2006 23:58:34 +0100
--- neko-1.8.1.orig/debian/control
+++ neko-1.8.1/debian/control
@@ -0,0 +1,68 @@
+Source: neko
+Section: interpreters
+Priority: optional
+Maintainer: Jens Peter Secher <jps@debian.org>
+Standards-Version: 3.8.3
+Build-Depends: debhelper, quilt, pkg-config, libgc-dev, apache2-threaded-dev, libmysqlclient-dev, libsqlite3-dev, libpcre3-dev, libapr1-dev, libgtk2.0-dev
+Vcs-Hg: http://hg.debian.org/hg/collab-maint/neko/neko
+Homepage: http://nekovm.org
+
+Package: libneko0
+Architecture: any
+Section: libs
+Depends: ${shlibs:Depends}
+Conflicts: neko (<< 1.8.0-2), neko-dev (<< 1.8.1)
+Description: Lightweight virtual machine - shared library
+ Neko provides a common runtime for several different languages,
+ including JavaScript and haXe.
+ .
+ This is the shared library implementing the Neko virtual machine.
+ .
+ Neko was written by Nicolas Cannasse.
+
+Package: neko-dev
+Architecture: all
+Section: libdevel
+Depends: libneko0 (>= ${source:Version})
+Conflicts: neko (<< 1.8.0-2)
+Description: Lightweight virtual machine - development
+ Neko provides a common runtime for several different languages,
+ including JavaScript and haXe.
+ .
+ The virtual machine is both very lightweight and well optimized.  It
+ can be easily embedded into other applications, and libraries are
+ directly accessible using the C foreign function interface.
+ .
+ This package includes the header files for development using the Neko
+ virtual machine.
+ .
+ Neko was written by Nicolas Cannasse.
+
+Package: neko
+Architecture: any
+Depends: ${shlibs:Depends}
+Suggests: libapache2-mod-neko, neko-dev
+Description: Lightweight virtual machine - compiler and tools
+ Neko provides a common runtime for several different languages,
+ including JavaScript and haXe.
+ .
+ The compiler converts a source file (.neko) into a bytecode file (.n)
+ that can be executed with the Virtual Machine.  You can use the
+ compiler as standalone commandline executable separated from the
+ virtual machine, or as a Neko library to perform compile-and-run for
+ interactive languages.
+ . 
+ Neko was written by Nicolas Cannasse.
+
+Package: libapache2-mod-neko
+Architecture: all
+Section: httpd
+Depends: neko (>= ${source:Version}), apache2-mpm-prefork
+Description: Apache module for running server-side Neko programs
+ Neko provides a common runtime for several different languages,
+ including JavaScript and haXe.
+ .
+ This package includes a module for Apache 2 so that you can
+ dynamically generate server-side web pages from Apache.
+ .
+ Neko was written by Nicolas Cannasse.
--- neko-1.8.1.orig/debian/neko.lintian-overrides
+++ neko-1.8.1/debian/neko.lintian-overrides
@@ -0,0 +1,7 @@
+# Lintian overrides for neko.
+#
+# The dynamic modules /usr/lib/neko/*.ndll are not stripped because they
+# are created as concatenations of the virtual machine bootloader and
+# some bytecode, which makes stripping impossible (cf. OCaml Packaging
+# Policy).
+neko binary: unstripped-binary-or-object
--- neko-1.8.1.orig/debian/README.source
+++ neko-1.8.1/debian/README.source
@@ -0,0 +1,49 @@
+This package uses quilt to manage all modifications to the upstream
+source.  Changes are stored in the source package as diffs in
+debian/patches and applied during the build.
+
+To get the fully patched source after unpacking the source package, cd to
+the root level of the source package and run:
+
+    quilt push -a
+
+The last patch listed in debian/patches/series will become the current
+patch.
+
+To add a new set of changes, first run quilt push -a, and then run:
+
+    quilt new <patch>
+
+where <patch> is a descriptive name for the patch, used as the filename in
+debian/patches.  Then, for every file that will be modified by this patch,
+run:
+
+    quilt add <file>
+
+before editing those files.  You must tell quilt with quilt add what files
+will be part of the patch before making changes or quilt will not work
+properly.  After editing the files, run:
+
+    quilt refresh
+
+to save the results as a patch.
+
+Alternately, if you already have an external patch and you just want to
+add it to the build system, run quilt push -a and then:
+
+    quilt import -P <patch> /path/to/patch
+    quilt push -a
+
+(add -p 0 to quilt import if needed). <patch> as above is the filename to
+use in debian/patches.  The last quilt push -a will apply the patch to
+make sure it works properly.
+
+To remove an existing patch from the list of patches that will be applied,
+run:
+
+    quilt delete <patch>
+
+You may need to run quilt pop -a to unapply patches first before running
+this command.
+
+ -- Jens Peter Secher <jps@debian.org>, Sat, 14 Mar 2009 21:09:54 +0100
--- neko-1.8.1.orig/debian/nekoc.1
+++ neko-1.8.1/debian/nekoc.1
@@ -0,0 +1,16 @@
+.TH NEKOC 1 "Oct 31, 2006" ""
+.SH NAME
+nekoc \- compile Neko programs to Neko bytecode.
+.SH SYNOPSIS
+.B nekoc
+.I file.neko
+.SH DESCRIPTION
+.B nekoc
+is a command-line compiler which compiles Neko programs into Neko bytecode.
+.SH AUTHOR
+Neko is written by Nicolas Cannasse for Motion-Twin.
+.SH SEE ALSO
+.BR "neko" (1),
+.BR "nekotools" (1).
+.SH WEB
+.IR "http://nekovm.org" .
--- neko-1.8.1.orig/debian/neko.load
+++ neko-1.8.1/debian/neko.load
@@ -0,0 +1 @@
+LoadModule neko_module /usr/lib/neko/mod_neko2.ndll
--- neko-1.8.1.orig/debian/compat
+++ neko-1.8.1/debian/compat
@@ -0,0 +1 @@
+5
--- neko-1.8.1.orig/debian/copyright
+++ neko-1.8.1/debian/copyright
@@ -0,0 +1,23 @@
+This is the Debian packaging of the Neko virtual machine, compiled by
+Jens Peter Secher <jps@debian.org>.
+
+The original source was downloaded from http://nekovm.org.
+
+---[ Neko License begin ]---
+
+  Copyright (C) 2005-2008 Motion-Twin
+
+  This library is free software; you can redistribute it and/or
+  modify it under the terms of the GNU Lesser General Public				
+  License as published by the Free Software Foundation; either				
+  version 2.1 of the License, or (at your option) any later version.		
+  
+  This library is distributed in the hope that it will be useful,
+  but WITHOUT ANY WARRANTY; without even the implied warranty of			
+  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU		
+  Lesser General Public License or the LICENSE file for more details.		
+
+---[ Neko License end ]---
+
+The full GNU Lesser General Public License is located in the file
+/usr/share/common-licenses/LGPL-2.1 on a Debian system.
--- neko-1.8.1.orig/debian/neko.conf
+++ neko-1.8.1/debian/neko.conf
@@ -0,0 +1,4 @@
+<IfModule mod_neko.c>
+        AddHandler neko-handler .n
+        DirectoryIndex index.n
+</IfModule>
--- neko-1.8.1.orig/debian/neko-dev.install
+++ neko-1.8.1/debian/neko-dev.install
@@ -0,0 +1,3 @@
+bin/*.so usr/lib
+vm/neko*.h usr/include
+
--- neko-1.8.1.orig/debian/nekotools.1
+++ neko-1.8.1/debian/nekotools.1
@@ -0,0 +1,23 @@
+.TH NEKOTOOLS 1 "Oct 31, 2006" ""
+.SH NAME
+nekotools \- tools for running Neko programs.
+.SH SYNOPSIS
+.B nekotools [options]
+.SH OPTIONS
+.TP
+.B server
+start a neko web server.  The server can be configured through
+.IR "http://localhost:2000/server:config" .
+.TP
+.BI "boot " file.n
+build an standalone executable.
+.SH DESCRIPTION
+.B nekotools
+is a command-line tool to create executables from Neko bytecode.
+.SH AUTHOR
+Neko is written by Nicolas Cannasse for Motion-Twin.
+.SH SEE ALSO
+.BR "neko" (1),
+.BR "nekotools" (1).
+.SH WEB
+.IR "http://nekovm.org" .
--- neko-1.8.1.orig/debian/libapache2-mod-neko.install
+++ neko-1.8.1/debian/libapache2-mod-neko.install
@@ -0,0 +1,3 @@
+debian/neko.conf etc/apache2/mods-available
+debian/neko.load etc/apache2/mods-available
+
--- neko-1.8.1.orig/debian/neko.install
+++ neko-1.8.1/debian/neko.install
@@ -0,0 +1,4 @@
+bin/*.ndll usr/lib/neko
+bin/neko usr/bin
+bin/nekoc usr/bin
+bin/nekotools usr/bin
--- neko-1.8.1.orig/debian/patches/soname-strip.diff
+++ neko-1.8.1/debian/patches/soname-strip.diff
@@ -0,0 +1,127 @@
+## soname-strip.diff by Jens Peter Secher <jps@debian.org>
+##
+## Make it possible to override the stripping of the neko executable
+## prior to building rest of compiler tools and introduce a proper
+## SONAME for libneko.
+
+Index: neko/Makefile
+===================================================================
+--- neko.orig/Makefile	2009-07-28 22:03:49.000000000 +0200
++++ neko/Makefile	2009-07-28 22:10:37.000000000 +0200
+@@ -4,24 +4,17 @@
+ 
+ CFLAGS = -Wall -O3 -fPIC -fomit-frame-pointer -I vm -D_GNU_SOURCE
+ EXTFLAGS = -pthread
+-MAKESO = $(CC) -shared -WBsymbolic
+-LIBNEKO_NAME = libneko.so
++MAJOR=0
++MINOR=1
++MAKESO = $(CC) -shared
++LIBNEKO_NAME = libneko.so.${MAJOR}.${MINOR}
+ LIBNEKO_LIBS = -ldl -lgc -lm
+ NEKOVM_FLAGS = -Lbin -lneko
+-STD_NDLL_FLAGS = ${NEKOVM_FLAGS}
++STD_NDLL_FLAGS = -lm
+ INSTALL_FLAGS =
+ 
+ NEKO_EXEC = LD_LIBRARY_PATH=../bin:${LD_LIBRARY_PATH} NEKOPATH=../boot:../bin ../bin/neko
+ 
+-# For OSX
+-#
+-# MACOSX = 1
+-
+-# For OSX Universal Binaries
+-#
+-# OSX_UNIVERSAL = 1
+-
+-
+ # For 64 bit
+ #
+ # CFLAGS += -D_64BITS
+@@ -34,51 +27,6 @@
+ #
+ # CFLAGS += -DLOW_MEM
+ 
+-# For MINGW/MSYS
+-
+-ifeq (${WIN32}, 1)
+-CFLAGS = -g -Wall -O3 -momit-leaf-frame-pointer -I vm -I /usr/local/include
+-EXTFLAGS =
+-MAKESO = $(CC) -O -shared
+-LIBNEKO_NAME = neko.dll
+-LIBNEKO_LIBS = -Lbin -lgc
+-STD_NDLL_FLAGS = ${NEKOVM_FLAGS} -lws2_32
+-endif
+-
+-### OSX SPECIFIC
+-
+-ifeq (${UNIVERSAL},1)
+-MACOSX=1
+-OSX_UNIVERSAL=1
+-endif
+-
+-ifeq (${MACOSX}, 1)
+-export MACOSX_DEPLOYMENT_TARGET=10.3
+-EXTFLAGS =
+-MAKESO = ${CC}
+-LIBNEKO_NAME = libneko.dylib
+-LIBNEKO_INSTALL = -install_name @executable_path/${LIBNEKO_NAME}
+-LIBNEKO_LIBS = -ldl -lgc -lm -dynamiclib -single_module ${LIBNEKO_INSTALL}
+-NEKOVM_FLAGS = -L${PWD}/bin -lneko
+-STD_NDLL_FLAGS = -bundle -undefined dynamic_lookup ${NEKOVM_FLAGS}
+-
+-ifeq (${OSX_UNIVERSAL}, 1)
+-
+-export MACOSX_DEPLOYMENT_TARGET_i386=10.4
+-export MACOSX_DEPLOYMENT_TARGET_ppc=10.3
+-CFLAGS += -arch ppc -arch i386 -L/usr/local/lib -L/opt/local/lib -I/opt/local/include
+-UNIV = libs/include/osx_universal
+-#linking to shared lib (.a) explicitly:
+-LIBNEKO_DEPS = ${UNIV}/libgc.a  -lSystemStubs
+-LIBNEKO_LIBS = ${LIBNEKO_DEPS} -dynamiclib -single_module ${LIBNEKO_INSTALL} ${CFLAGS}
+-NEKOVM_FLAGS = -L${PWD}/bin -lneko
+-STD_NDLL_FLAGS = -bundle ${NEKOVM_FLAGS} ${CFLAGS}
+-INSTALL_FLAGS = -osx-universal
+-
+-endif
+-
+-endif
+-
+ ### MAKE
+ 
+ VM_OBJECTS = vm/stats.o vm/main.o
+@@ -87,9 +35,6 @@
+ 
+ all: createbin libneko neko std compiler libs
+ 
+-universal:
+-	make MACOSX=1 OSX_UNIVERSAL=1
+-
+ createbin:
+ 	-mkdir bin 2>/dev/null
+ 
+@@ -117,17 +62,20 @@
+ 	(cd src; ${NEKO_EXEC} nekoc -link ../boot/nekoml.n nekoml/Main)
+ 
+ bin/${LIBNEKO_NAME}: ${LIBNEKO_OBJECTS}
+-	${MAKESO} ${EXTFLAGS} -o $@ ${LIBNEKO_OBJECTS} ${LIBNEKO_LIBS}
++	${MAKESO} -Wl,-soname,libneko.so.${MAJOR} ${EXTFLAGS} -o $@ ${LIBNEKO_OBJECTS} ${LIBNEKO_LIBS}
++	ln -s ${LIBNEKO_NAME} bin/libneko.so
++	ln -s ${LIBNEKO_NAME} bin/libneko.so.${MAJOR}
+ 
+ bin/neko: $(VM_OBJECTS)
+-	${CC} ${CFLAGS} ${EXTFLAGS} -o $@ ${VM_OBJECTS} ${NEKOVM_FLAGS}
+-	strip bin/neko
++	${CC} ${CFLAGS} -o $@ ${VM_OBJECTS} ${NEKOVM_FLAGS}
+ 
+ bin/std.ndll: ${STD_OBJECTS}
+-	${MAKESO} -o $@ ${STD_OBJECTS} ${STD_NDLL_FLAGS}
++	${MAKESO} ${EXTFLAGS} -o $@ ${STD_OBJECTS} ${STD_NDLL_FLAGS}
+ 
+ clean:
+ 	rm -rf bin/${LIBNEKO_NAME} ${LIBNEKO_OBJECTS} ${VM_OBJECTS}
++	rm -rf bin/libneko.so bin/libneko.so.${MAJOR}
++	rm -rf bin/nekoml.std
+ 	rm -rf bin/neko bin/nekoc bin/nekoml bin/nekotools
+ 	rm -rf bin/std bin/*.ndll bin/*.n libs/*/*.o
+ 	rm -rf src/*.n src/neko/*.n src/nekoml/*.n src/tools/*.n
--- neko-1.8.1.orig/debian/patches/series
+++ neko-1.8.1/debian/patches/series
@@ -0,0 +1,5 @@
+soname-strip.diff
+include-and-link.diff
+tora-missing-include.diff
+mysql-missing-include.diff
+kfreebsd-compile-fix.diff
--- neko-1.8.1.orig/debian/patches/kfreebsd-compile-fix.diff
+++ neko-1.8.1/debian/patches/kfreebsd-compile-fix.diff
@@ -0,0 +1,57 @@
+Description: Fix build failure on GNU/kFreeBSD.
+ Use NEKO_POSIX instead of NEKO_LINUX.
+Author: Cyril Brulebois <kibi@debian.org>
+Bug-Debian: http://bugs.debian.org/543995
+Reviewed-by: Jens Peter Secher <jps@debian.org>
+Forwarded: yes
+Last-Update: 2009-09-09
+
+Index: neko/libs/ui/ui.c
+===================================================================
+--- neko.orig/libs/ui/ui.c	2009-09-09 14:05:50.000000000 +0200
++++ neko/libs/ui/ui.c	2009-09-09 14:06:53.000000000 +0200
+@@ -28,7 +28,7 @@
+ #	define UIEvent		0xFFFFAA00
+ #	define eCall		0x0
+ enum { pFunc = 'func' };
+-#elif defined(NEKO_LINUX)
++#elif defined(NEKO_POSIX)
+ #	include <gtk/gtk.h>
+ #	include <glib.h>
+ #	include <pthread.h>
+@@ -52,7 +52,7 @@
+ 	HWND wnd;
+ #elif defined(NEKO_MAC)
+ 	pthread_t tid;
+-#elif defined(NEKO_LINUX)
++#elif defined(NEKO_POSIX)
+ 	pthread_t tid;
+ 	pthread_mutex_t lock;
+ #endif
+@@ -98,7 +98,7 @@
+ 	return 0;
+ }
+ 
+-#elif defined(NEKO_LINUX)
++#elif defined(NEKO_POSIX)
+ 
+ static gint onSyncCall( gpointer data ) {
+ 	value *r = (value*)data;
+@@ -142,7 +142,7 @@
+ 	data.tid = pthread_self();
+ 	EventTypeSpec ets = { UIEvent, eCall };
+ 	InstallEventHandler(GetApplicationEventTarget(),NewEventHandlerUPP(handleEvents),1,&ets,0,0);
+-#	elif defined(NEKO_LINUX)
++#	elif defined(NEKO_POSIX)
+ 	g_thread_init(NULL);
+ 	gdk_threads_init();
+ 	gtk_init(NULL,NULL);
+@@ -236,7 +236,7 @@
+ 	SetEventParameter(e,pFunc,typeVoidPtr,sizeof(void*),&r);
+ 	PostEventToQueue(GetMainEventQueue(),e,kEventPriorityStandard);
+ 	ReleaseEvent(e);
+-#	elif defined(NEKO_LINUX)
++#	elif defined(NEKO_POSIX)
+ 	// the lock should not be needed because GTK is MT-safe
+ 	// however the GTK lock mechanism is a LOT slower than
+ 	// using a pthread_mutex
--- neko-1.8.1.orig/debian/patches/mysql-missing-include.diff
+++ neko-1.8.1/debian/patches/mysql-missing-include.diff
@@ -0,0 +1,16 @@
+## mysql-missing-include.diff by Jens Peter Secher <jps@debian.org>
+##
+## Include missing declaration of free().
+
+Index: neko/libs/mysql/my_proto/my_proto.c
+===================================================================
+--- neko.orig/libs/mysql/my_proto/my_proto.c	2009-07-28 22:54:44.000000000 +0200
++++ neko/libs/mysql/my_proto/my_proto.c	2009-07-28 22:55:13.000000000 +0200
+@@ -20,6 +20,7 @@
+ /* ************************************************************************ */
+ #include <math.h>
+ #include <string.h>
++#include "stdlib.h"
+ #include "my_proto.h"
+ 
+ #define MAX_PACKET_LENGTH 0xFFFFFF
--- neko-1.8.1.orig/debian/patches/tora-missing-include.diff
+++ neko-1.8.1/debian/patches/tora-missing-include.diff
@@ -0,0 +1,16 @@
+## tora-missing-include.diff by Jens Peter Secher <jps@debian.org>
+##
+## Include missing declaration of free().
+
+Index: neko/libs/mod_tora/protocol.c
+===================================================================
+--- neko.orig/libs/mod_tora/protocol.c	2009-07-28 22:50:07.000000000 +0200
++++ neko/libs/mod_tora/protocol.c	2009-07-28 22:50:31.000000000 +0200
+@@ -17,6 +17,7 @@
+ #include <string.h>
+ #include "protocol.h"
+ #include "socket.h"
++#include "stdlib.h"
+ 
+ struct _protocol {
+ 	PSOCK s;
--- neko-1.8.1.orig/debian/patches/include-and-link.diff
+++ neko-1.8.1/debian/patches/include-and-link.diff
@@ -0,0 +1,136 @@
+## include-and-link.diff by Jens Peter Secher <jps@debian.org>
+##
+## Use the right include directories, shared libraries and cflags.
+## Use -rpath to force search in /usr/lib/neko.
+
+Index: neko/src/tools/install.neko
+===================================================================
+--- neko.orig/src/tools/install.neko	2009-07-30 21:53:25.000000000 +0200
++++ neko/src/tools/install.neko	2009-09-09 13:49:49.000000000 +0200
+@@ -39,11 +39,6 @@
+ // LIBS DATAS
+ 
+ libs = {
+-	mod_neko => {
+-		src => $array("../../vm/stats","mod_neko","cgi"),
+-		inc => "httpd.h",
+-		incname => "Apache 1.3.x"
+-	},
+ 	mod_neko2 => {
+ 		src => $array("../../vm/stats","mod_neko","cgi"),
+ 		inc => $array("httpd.h","apr.h"),
+@@ -55,15 +50,8 @@
+ 	mysql => {
+ 		src => $array("mysql"),
+ 		inc => "mysql.h",
+-		incname => "MySQL 4.+"
+-		lib => "libmysqlclient_r.a",
+-		lparams => "-lz -lssl"
+-	},
+-	mysql5 => {
+-		src => $array("../common/sha1","../common/socket","my_proto/my_proto","my_proto/my_api","mysql"),
+-		inc => $array(),
+-		realdir => "mysql",
+-		cflags => "-Imy_proto -I../common",
++		incname => "MySQL"
++		lparams => "-lmysqlclient"
+ 	},
+ 	regexp => {
+ 		src => $array("regexp"),
+@@ -88,13 +76,7 @@
+ 		inc => switch system { "Mac" => "Carbon.h" default => "gtk/gtk.h" },
+ 		incname => switch system { "Mac" => "Carbon" default => "GTK+2.0" },
+ 		cflags => switch system { "Mac" => "" default => "`pkg-config --cflags gtk+-2.0`" },
+-		lparams => switch system { "Mac" => "-framework Carbon" default => "`pkg-config --libs gtk+-2.0` -lgthread-2.0" },
+-	},
+-	mod_tora => {
+-		src => $array("../common/socket","protocol","mod_tora"),
+-		inc => "httpd.h",
+-		incname => "Apache 1.3.x",
+-		cflags => "-I../common",
++		lparams => switch system { "Mac" => "-framework Carbon" default => "-lgthread-2.0" },
+ 	},
+ 	mod_tora2 => {
+ 		src => $array("../common/socket","protocol","mod_tora"),
+@@ -108,15 +90,14 @@
+ 
+ // PLATFORM
+ 
+-cflags = "-O3 -fPIC";
++cflags = "-O3 -DEAPI -fPIC -pthread $(pkg-config --cflags apr-1)";
+ if( system == "Linux" ) cflags += " -pthread";
+ cc = getenv("CC");
+ if( cc == null ) cc = "gcc";
+ linkcmd = switch system { "BSD" => "ld" default => cc };
+-linkneko = "-lneko";
+ linkoptions = switch system {
+ 	"Mac" => "-bundle -undefined dynamic_lookup -L../../bin"
+-	default => "-shared -L../../bin -pthread"
++	default => "-shared -L../../bin -pthread -lneko" 
+ };
+ nekovm = switch system { "Windows" => "..\\bin\\neko" default => "../bin/neko" };
+ 
+@@ -141,38 +122,15 @@
+ search_includes = function(isap2) {
+ 	var inc1 = $array(
+ 		"/usr/include",
+-		"/usr/local/include/mysql",
+ 		"/usr/include/mysql",
+-		"/usr/local/include",
+ 		"/usr/include/gtk-2.0",
+-		"/opt/local/include",
+-		"/opt/local/include/mysql",
+-		"/Developer/Headers/FlatCarbon",
+ 	);
+ 	var inc2;
+-	if( isap2 )
+-		inc2 = $array(
+-			"/usr/local/apache2/include",
+-			"/usr/include/apache2",
+-			"/opt/local/apache2/include",
+-			"/usr/include/apr-1",
+-			"/usr/include/apr-1.0",
+-			"/usr/include/apr-0",
+-			"/usr/local/include/apr-1",
+-			"/usr/local/include/apr-1.0",
+-			"/usr/local/include/apr-0",
+-			"/opt/local/include/apr-1",
+-			"/opt/local/include/apr-1.0",
+-			"/opt/local/include/apr-0"
+-		);
+-	else
+-		inc2 = $array(
+-			"/usr/apache/include",
+-			"/usr/include/apache-1.3",
+-			"/usr/include/httpd",
+-			"/opt/local/include/apache",
+-			"/usr/local/apache/include"
+-		);
++	inc2 = $array(
++		"/usr/include/apache2",
++		"/usr/include/apr-1",
++		"/usr/include/apr-1.0",
++	);
+ 	return $aconcat($array(inc1,inc2));
+ }
+ 
+@@ -182,10 +140,6 @@
+ 	cwd,
+ 	"/usr/lib",
+ 	"/usr/lib/mysql",
+-	"/usr/local/lib",
+-	"/usr/local/lib/mysql",
+-	"/opt/local/lib",
+-	"/opt/local/lib/mysql",
+ );
+ 
+ exec = function(cmd) {
+@@ -299,8 +253,6 @@
+ 		dir[0] + ".o"
+ 	}));
+ 	var opt = linkoptions;
+-	if( target != "mod_tora" && target != "mod_tora2" )
+-		opt += " "+linkneko;
+ 	var cmd = linkcmd+" "+opt+" "+make("-L",libraries);
+ 	var out = " -o ../../bin/"+target+".ndll ";
+ 	exec(cmd+out+params1+files+params2);
--- neko-1.8.1.orig/debian/libneko0.install
+++ neko-1.8.1/debian/libneko0.install
@@ -0,0 +1,3 @@
+bin/*.so.* usr/lib
+
+
--- neko-1.8.1.orig/debian/libapache2-mod-neko.prerm
+++ neko-1.8.1/debian/libapache2-mod-neko.prerm
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+set -e
+
+DISABLE=/usr/sbin/a2dismod
+
+MODCONF=/usr/sbin/apache-modconf
+MSG="Module neko uninstalled, run /etc/init.d/apache force-reload to disable."
+
+case "$1" in
+    remove|deconfigure)
+        ## Deregister with Apache 2.2.
+        if [ -x $DISABLE ]; then
+            $DISABLE neko || true
+        fi
+        ## Deregister with (obsolete) Apache 1.3.
+        if [ -x $MODCONF ]; then
+            for flavour in apache apache-perl apache-ssl; do
+                if [ -f /etc/$flavour/modules.conf ]; then
+                    $MODCONF $flavour disable mod_neko && echo $MSG
+                fi
+            done
+        fi
+        ;;
+    upgrade|failed-upgrade)
+        ;;
+    *)
+        echo "prerm called with unknown argument \`$1'" >&2
+esac
+
+#DEBHELPER#
+
+exit 0
--- neko-1.8.1.orig/debian/rules
+++ neko-1.8.1/debian/rules
@@ -0,0 +1,69 @@
+#!/usr/bin/make -f
+# debian/rules for neko.
+
+# Compile options
+cflags := -Wall -fPIC -fomit-frame-pointer -I vm -DCOMPACT_TABLE -D_GNU_SOURCE -g
+ifeq (,$(findstring noopt,$(DEB_BUILD_OPTIONS)))
+	cflags += -O3
+else
+	cflags += -O0
+endif
+
+# Use quilt for patching.
+include /usr/share/quilt/quilt.make
+
+build-stamp: patch
+	dh_testdir
+	make CFLAGS="$(cflags)"
+	touch $@
+
+debian := $(CURDIR)/debian
+overrides := usr/share/lintian/overrides
+
+binary-indep: build-stamp
+	dh_testdir
+	dh_testroot
+	dh_install -plibapache2-mod-neko -pneko-dev
+	dh_installdocs -plibapache2-mod-neko -pneko-dev
+	dh_installchangelogs -plibapache2-mod-neko -pneko-dev CHANGES
+	dh_compress -plibapache2-mod-neko -pneko-dev
+	dh_fixperms -plibapache2-mod-neko -pneko-dev
+	dh_installdeb -plibapache2-mod-neko -pneko-dev
+	dh_gencontrol -plibapache2-mod-neko -pneko-dev
+	dh_md5sums -plibapache2-mod-neko -pneko-dev
+	dh_builddeb -plibapache2-mod-neko -pneko-dev
+
+binary-arch: build-stamp
+	dh_testdir
+	dh_testroot
+	dh_install -a
+	mkdir -p $(debian)/neko/$(overrides)
+	cp $(debian)/neko.lintian-overrides $(debian)/neko/$(overrides)/neko
+	dh_installdocs -a
+	dh_installexamples -a
+	dh_installchangelogs -a CHANGES
+	dh_installman -pneko debian/neko.1 debian/nekoc.1 debian/nekotools.1
+	dh_strip -a -Xnekoc -Xnekotools
+	dh_compress -a
+	dh_fixperms -a
+	dh_makeshlibs
+	dh_installdeb -a
+	dh_shlibdeps -a
+	find $(debian) -name '*.ndll' -exec chmod -x '{}' ';'
+	find $(debian) -name '*.neko' -exec chmod -x '{}' ';'
+	dh_gencontrol -a
+	dh_md5sums -a
+	dh_builddeb -a
+
+binary: binary-indep binary-arch
+
+clean: clean-patched unpatch
+
+clean-patched:
+	dh_testdir
+	dh_testroot
+	-rm -f *-stamp
+	make clean
+	dh_clean
+
+.PHONY: binary binary-indep binary-arch build clean clean-patched
--- neko-1.8.1.orig/debian/libapache2-mod-neko.postinst
+++ neko-1.8.1/debian/libapache2-mod-neko.postinst
@@ -0,0 +1,23 @@
+#!/bin/sh
+
+set -e
+
+ENABLE2=/usr/sbin/a2enmod
+
+case "$1" in
+    configure)
+        ## Register with Apache 2.2, if present.
+        if [ -x $ENABLE2 ]; then
+            ## Enable neko module.
+            $ENABLE2 neko
+        fi
+        ;;
+    abort-upgrade|abort-remove|abort-deconfigure)
+        ;;
+    *)
+        echo "postinst called with unknown argument \`$1'" >&2
+esac
+
+#DEBHELPER#
+
+exit 0
--- neko-1.8.1.orig/debian/neko.examples
+++ neko-1.8.1/debian/neko.examples
@@ -0,0 +1,2 @@
+bin/*.n
+src/tools/test.neko
