diff --git a/Makefile b/Makefile
index 6741a127..09017ec9 100755
--- a/Makefile
+++ b/Makefile
@@ -2,8 +2,13 @@
#
package=davical
-version=$(shell cat VERSION)
-snapshot : version = $(shell sed -n 's:\([0-9\.]*\)[-a-f0-9-]*:\1:p' VERSION)-git$(shell git rev-parse --short HEAD)
+majorversion = $(shell sed -n 's:\([0-9\.]*\)[-a-f0-9-]*:\1:p' VERSION)
+gitrev = 0
+version = $(majorversion)
+issnapshot = 0
+snapshot : gitrev = $(shell git rev-parse --short HEAD)
+snapshot : version = $(majorversion)-git$(gitrev)
+snapshot : issnapshot = 1
all: htdocs/always.php built-docs built-po
@@ -27,10 +32,15 @@ htdocs/always.php: scripts/build-always.sh VERSION dba/davical.sql inc/always.ph
#
release: built-docs VERSION
-ln -s . $(package)-$(version)
+ sed 's:@@VERSION@@:$(majorversion):' davical.spec.in | \
+ sed 's:@@ISSNAPSHOT@@:$(issnapshot):' | \
+ sed 's:@@GITREV@@:$(gitrev):' > davical.spec
+ echo "git ls-files |grep -v '.git'|sed -e s:^:$(package)-$(version)/:"
tar czf ../$(package)-$(version).tar.gz \
--no-recursion --dereference $(package)-$(version) \
$(shell git ls-files |grep -v '.git'|sed -e s:^:$(package)-$(version)/:) \
- $(shell find $(package)-$(version)/docs/api/ ! -name "phpdoc.ini" )
+ $(shell find $(package)-$(version)/docs/api/ ! -name "phpdoc.ini" ) \
+ davical.spec
rm $(package)-$(version)
snapshot: release
@@ -39,6 +49,7 @@ clean:
rm -f built-docs built-po
-find . -name "*~" -delete
rm docs/translation.pdf
+ rm davical.spec
clean-all: clean
-find docs/api/* ! -name "phpdoc.ini" ! -name ".gitignore" -delete
diff --git a/config/apache-davical.conf b/config/apache-davical.conf
new file mode 100644
index 00000000..ec84c2d0
--- /dev/null
+++ b/config/apache-davical.conf
@@ -0,0 +1,17 @@
+# DAViCal Calendar Server
+
+Alias /davical /usr/share/davical/htdocs
+
+
+ DirectoryIndex index.php index.html
+ AllowOverride None
+ Order allow,deny
+ Allow from all
+ AcceptPathInfo On
+ php_value include_path /usr/share/php/awl/inc
+ php_value magic_quotes_gpc 0
+ php_value register_globals 0
+ php_value error_reporting "E_ALL & ~E_NOTICE"
+ php_value default_charset "utf-8"
+
+
diff --git a/davical.spec.in b/davical.spec.in
new file mode 100644
index 00000000..44035ee6
--- /dev/null
+++ b/davical.spec.in
@@ -0,0 +1,64 @@
+%define issnapshot @@ISSNAPSHOT@@
+%define gitrev @@GITREV@@
+
+%if 0%{issnapshot}
+%define snapshotversionstring .%{gitrev}git
+%define snapshotpackagestring -git%{gitrev}
+%endif
+
+Name: davical
+Summary: CalDAV Server
+Version: @@VERSION@@
+Release: 1%{?snapshotversionstring}%{?dist}
+Group: System Environment/Daemons
+License: GPL and LGPL
+Source: http://debian.mcmillan.net.nz/packages/davical/davical-%{version}%{?snapshotpackagestring}.tar.gz
+
+URL: http://davical.org/
+BuildArch: noarch
+BuildRequires: php-awl
+BuildRequires: sed
+Requires: php php-gettext php-pgsql
+Requires: postgresql postgresql-server
+Requires: php-awl
+Requires: perl-YAML
+Requires: perl-DBD-Pg
+
+%description
+The DAViCal CalDAV Server is designed to trivially store
+CalDAV calendars, such as those from Evolution, Sunbird/Lightning,
+Mulberry, iCal, iPhone or SOHO Organizer, in a central location,
+providing shared calendars, free/busy publication and a basic
+administration interface.
+
+
+%prep
+%setup -q -n "davical-%{version}%{?snapshotpackagestring}"
+
+%build
+sed -i "s#set_include_path('../inc:../htdocs:/usr/share/awl/inc');#set_include_path('/usr/share/davical/inc:/usr/share/davical/htdocs:/usr/share/php/awl/inc');#" scripts/sync-remote-caldav.php
+sed -i 's:../../awl/inc:%{_datadir}/php/awl/inc:' htdocs/always.php
+sed -i 's:AWL_LOCATION="../awl":AWL_LOCATION="%{_datadir}/php/awl":' scripts/po/rebuild-translations.sh
+make
+
+%install
+install -D -p -m 755 scripts/sync-remote-caldav.php %{buildroot}/%{_bindir}/sync-remote-caldav
+
+mkdir -p %{buildroot}%{_datadir}/%{name}
+cp -a dba htdocs locale inc %{buildroot}/%{_datadir}/%{name}
+
+install -D -p -m 644 config/example-config.php %{buildroot}/%{_sysconfdir}/%{name}/config.php
+
+install -D -p -m 644 config/apache-davical.conf %{buildroot}/%{_sysconfdir}/httpd/conf.d/davical.conf
+
+%files
+%defattr(-,root,root)
+%{_datadir}/%{name}/*
+%config(noreplace) %{_sysconfdir}/%{name}/config.php
+%config(noreplace) %{_sysconfdir}/httpd/conf.d/%{name}.conf
+%{_bindir}/sync-remote-caldav
+%doc README ChangeLog
+
+%changelog
+* Tue Feb 22 2011 Felix Möller - 0.9.9.4
+- Initial Version of DAViCal package