diff --git a/Makefile.am b/Makefile.am
index d678f171..23ed90bc 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -15,6 +15,7 @@ SUBDIRS = doc src man contrib
clean-local:
rm -f build-stamp*
+ rm -rf ngircd.dest
maintainer-clean-local:
rm -rf autom4te.cache
@@ -45,4 +46,27 @@ deb:
[ -f debian/rules ] || ln -s contrib/Debian debian
dpkg-buildpackage -rfakeroot
+osxpkg:
+ @packagemaker >/dev/null 2>&1; [ $$? -ge 1 ] \
+ || ( echo; echo "Error: \"packagemaker\" not found!"; echo; exit 2)
+ make clean
+ ./configure --prefix=/opt/ngircd
+ make xcode
+ make -C contrib/MacOSX de.barton.ngircd.plist
+ mkdir -p ngircd.dest/opt/ngircd/sbin
+ DESTDIR="$$PWD/ngircd.dest" make -C doc install
+ DESTDIR="$$PWD/ngircd.dest" make -C contrib install
+ DESTDIR="$$PWD/ngircd.dest" make -C man install
+ cp contrib/MacOSX/build/Default/ngIRCd \
+ ngircd.dest/opt/ngircd/sbin/ngircd
+ rm ngircd.dest/opt/ngircd/etc/ngircd.conf
+ echo "Have a nice day IRCing!" >ngircd.dest/opt/ngircd/etc/ngircd.motd
+ chmod -R a-s,og-w,a+rX ngircd.dest
+ cd contrib/MacOSX && packagemaker \
+ --doc ngIRCd.pmdoc \
+ --out ../../$(distdir).mpkg
+ rm -f $(distdir).mpkg.zip
+ zip -ro9 $(distdir).mpkg.zip $(distdir).mpkg
+ rm -rf ngircd.dest $(distdir).mpkg
+
# -eof-
diff --git a/configure.in b/configure.in
index f02835fb..7cbc80ac 100644
--- a/configure.in
+++ b/configure.in
@@ -497,6 +497,7 @@ AC_OUTPUT([ \
contrib/Debian/Makefile \
contrib/MacOSX/Makefile \
contrib/MacOSX/ngIRCd.xcodeproj/Makefile \
+ contrib/MacOSX/ngIRCd.pmdoc/Makefile \
])
type dpkg >/dev/null 2>&1
diff --git a/contrib/MacOSX/Makefile.am b/contrib/MacOSX/Makefile.am
index 42847d1e..2f1d141c 100644
--- a/contrib/MacOSX/Makefile.am
+++ b/contrib/MacOSX/Makefile.am
@@ -9,7 +9,7 @@
# Please read the file COPYING, README and AUTHORS for more information.
#
-SUBDIRS = ngIRCd.xcodeproj
+SUBDIRS = ngIRCd.xcodeproj ngIRCd.pmdoc
EXTRA_DIST = de.barton.ngircd.plist.tmpl config.h
diff --git a/contrib/MacOSX/ngIRCd.pmdoc/01ngircd-contents.xml b/contrib/MacOSX/ngIRCd.pmdoc/01ngircd-contents.xml
new file mode 100644
index 00000000..bc1e5a79
--- /dev/null
+++ b/contrib/MacOSX/ngIRCd.pmdoc/01ngircd-contents.xml
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/contrib/MacOSX/ngIRCd.pmdoc/01ngircd.xml b/contrib/MacOSX/ngIRCd.pmdoc/01ngircd.xml
new file mode 100644
index 00000000..66dbd1f0
--- /dev/null
+++ b/contrib/MacOSX/ngIRCd.pmdoc/01ngircd.xml
@@ -0,0 +1 @@
+de.barton.ngircd.daemon.pkg1../../ngircd.dest/parentscripts.postinstall.pathscripts.postinstall.isRelativeTypescripts.preupgrade.pathinstallFrom.isRelativeTypeversionscripts.preinstall.isRelativeTypeidentifierinstallTopreinstall.shpreinstall.sh
\ No newline at end of file
diff --git a/contrib/MacOSX/ngIRCd.pmdoc/02de-contents.xml b/contrib/MacOSX/ngIRCd.pmdoc/02de-contents.xml
new file mode 100644
index 00000000..bc1e5a79
--- /dev/null
+++ b/contrib/MacOSX/ngIRCd.pmdoc/02de-contents.xml
@@ -0,0 +1 @@
+
\ No newline at end of file
diff --git a/contrib/MacOSX/ngIRCd.pmdoc/02de.xml b/contrib/MacOSX/ngIRCd.pmdoc/02de.xml
new file mode 100644
index 00000000..59b52023
--- /dev/null
+++ b/contrib/MacOSX/ngIRCd.pmdoc/02de.xml
@@ -0,0 +1 @@
+de.barton.ngircd.launchscript.pkg1de.barton.ngircd.plist/Library/LaunchDaemonsparentscripts.postinstall.pathscripts.postupgrade.pathinstallFrom.isRelativeTypeinstallTo.pathinstallToidentifierpostinstall.shpostinstall.sh
\ No newline at end of file
diff --git a/contrib/MacOSX/ngIRCd.pmdoc/Makefile.am b/contrib/MacOSX/ngIRCd.pmdoc/Makefile.am
new file mode 100644
index 00000000..e11eeb1e
--- /dev/null
+++ b/contrib/MacOSX/ngIRCd.pmdoc/Makefile.am
@@ -0,0 +1,18 @@
+#
+# ngIRCd -- The Next Generation IRC Daemon
+# Copyright (c)2001-2008 Alexander Barton
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+# Please read the file COPYING, README and AUTHORS for more information.
+#
+
+EXTRA_DIST = index.xml \
+ 01ngircd-contents.xml 01ngircd.xml 02de-contents.xml 02de.xml
+
+maintainer-clean-local:
+ rm -f Makefile Makefile.in
+
+# -eof-
diff --git a/contrib/MacOSX/ngIRCd.pmdoc/index.xml b/contrib/MacOSX/ngIRCd.pmdoc/index.xml
new file mode 100644
index 00000000..553e3050
--- /dev/null
+++ b/contrib/MacOSX/ngIRCd.pmdoc/index.xml
@@ -0,0 +1,188 @@
+ngIRCd/Users/alex/Desktop/ngIRCd.mpkgde.barton.ngircdngIRCd – next generation IRC (Internet Relay Chat) server daemon//Library/LaunchDaemons- 01ngircd.xml
- 02de.xml
properties.customizeOptionproperties.titledescriptionproperties.anywhereDomainproperties.systemDomain
\ No newline at end of file
diff --git a/contrib/MacOSX/postinstall.sh b/contrib/MacOSX/postinstall.sh
new file mode 100755
index 00000000..9cca7b48
--- /dev/null
+++ b/contrib/MacOSX/postinstall.sh
@@ -0,0 +1,42 @@
+#!/bin/sh
+# ngIRCd Mac OS X postinstall/postupgrade script
+
+LDPLIST="/Library/LaunchDaemons/de.barton.ngircd.plist"
+
+if [ ! -e /etc/ngircd ]; then
+ echo "Creating symlink: /opt/ngircd/etc -> /etc/ngircd"
+ ln -s /opt/ngircd/etc /etc/ngircd || exit 1
+else
+ echo "/etc/ngircd already exists. Don't create symlink."
+fi
+
+if [ ! -e /opt/ngircd/etc/ngircd.conf ]; then
+ echo "Creating default configuration: /opt/ngircd/etc/ngircd.conf"
+ cp /opt/ngircd/share/doc/ngircd/sample-ngircd.conf \
+ /opt/ngircd/etc/ngircd.conf || exit 1
+else
+ echo "/opt/ngircd/etc/ngircd.conf exists. Don't copy sample file."
+fi
+chmod o-rwx /opt/ngircd/etc/ngircd.conf
+
+if [ -f "$LDPLIST" ]; then
+ echo "Fixing ownership and permissions of LaunchDaemon script ..."
+ chown root:wheel "$LDPLIST" || exit 1
+ chmod 644 "$LDPLIST" || exit 1
+fi
+
+if [ -f /tmp/ngircd_needs_restart ]; then
+ echo "ngIRCd should be (re-)started ..."
+ if [ -r "$LDPLIST" ]; then
+ echo "LaunchDaemon script found, starting daemon ..."
+ launchctl load -w "$LDPLIST" || exit 1
+ echo "OK, LaunchDaemon script loaded successfully."
+ else
+ echo "LaunchDaemon script not installed. Can't start daemon."
+ fi
+else
+ echo "Not loading LaunchDaemon script."
+fi
+rm -f /tmp/ngircd_needs_restart
+
+# -eof-
diff --git a/contrib/MacOSX/preinstall.sh b/contrib/MacOSX/preinstall.sh
new file mode 100755
index 00000000..0e13bacf
--- /dev/null
+++ b/contrib/MacOSX/preinstall.sh
@@ -0,0 +1,25 @@
+#!/bin/sh
+# ngIRCd Mac OS X preinstall/preupgrade script
+
+LDPLIST="/Library/LaunchDaemons/de.barton.ngircd.plist"
+
+rm -f /tmp/ngircd_needs_restart || exit 1
+if [ -r "$LDPLIST" ]; then
+ echo "LaunchDaemon script found, checking status ..."
+ launchctl list | fgrep "de.barton.ngIRCd" >/dev/null 2>&1
+ if [ $? -eq 0 ]; then
+ # ngIRCd is already running; stop it and touch a
+ # "stamp file" so that we know that we have to
+ # restart it after installation/upgrade.
+ echo "ngIRCd is already running; stop it ..."
+ launchctl unload "$LDPLIST" || exit 1
+ echo "Daemon has been stopped."
+ touch /tmp/ngircd_needs_restart || exit 1
+ else
+ echo "ngIRCd is not running."
+ fi
+else
+ echo "LaunchDaemon script not found."
+fi
+
+# -eof-