Index: build_tools/mkspec
===================================================================
--- build_tools/mkspec	(revision 0)
+++ build_tools/mkspec	(revision 0)
@@ -0,0 +1,146 @@
+#!/bin/sh -x
+#
+#	Output a simple RPM spec file that will hopefully work for
+#	most distributions. The majority of this is taken from
+#	the mkspec file in the linux kernel.
+#
+#	Modified for zaptel by Daniel Hazelbaker
+#		2007 <daniel@highdesertchurch.com>
+#
+
+echo "#"
+echo "# Create some variables for use later."
+echo "#"
+echo "%{!?kernel: %{expand: %%define kernel %(uname -r)}}"
+echo "%define kversion %(echo %{kernel} | sed -e s/smp// -)"
+echo "%define krelver %(echo %{kversion} | tr -s '-' '_')"
+echo "%if %(echo %{kernel} | grep -c smp)"
+echo "        %{expand:%%define ksmp -smp}"
+echo "%endif"
+echo "%define perlver %(eval \`perl -V:version\`; echo \"\$version\")"
+echo ""
+
+echo "Summary: Telephony interface support"
+echo "Name: zaptel"
+echo "Version: `echo $ZAPTELVERSION | sed s/-//g`"
+echo "Release: `build_tools/mkrevision`"
+echo "License: GPL"
+echo "Group: System Environment/Libraries"
+echo "URL: http://www.asterisk.org/"
+echo "Source0: http://downloads.digium.com/pub/zaptel/releases/%{name}-%{version}.tar.gz"
+echo "BuildRequires: kernel-devel = %{kversion}, newt-devel, perl"
+echo "Provides: %{name}-devel = %{version}-%{release}"
+echo "BuildRoot: /var/tmp/%{name}-%{version}-root"
+echo ""
+
+echo "%description"
+echo "This package contains the libraries, device entries, startup scripts and tools"
+echo "needed to use Digium telephony hardware. This includes the pseudo TDM"
+echo "interfaces."
+echo ""
+echo "You will also need to install a kernel modules package matching your current"
+echo "kernel for everything to work."
+echo ""
+
+echo "%package -n kernel%{?ksmp}-module-zaptel"
+echo "Summary: Kernel modules required for some hardware to operate with Zaptel"
+echo "Group: System Environment/Kernel"
+echo "Release: %{release}_%{krelver}.rf"
+echo "Requires: kernel%{?ksmp} = %{kversion}, /sbin/depmod"
+echo "Provides: kernel-modules"
+echo "%{?ksmp:Provides: kernel-module-zaptel = %{version}-%{release}_%{krelver}}"
+echo ""
+
+echo "%description -n kernel%{?ksmp}-module-zaptel"
+echo "This package contains the zaptel kernel modules for the Linux kernel package :"
+echo "%{kversion} (%{_target_cpu}%{?ksmp:, SMP})."
+echo ""
+echo ""
+
+echo "%prep"
+echo "%setup -n %{name}-%{version}"
+echo ""
+echo ""
+
+echo "%build"
+echo "%configure"
+echo "%{__make} %{?_smp_mflags}"
+echo ""
+echo ""
+
+echo "%install"
+echo "%{__rm} -rf %{buildroot}"
+echo "# Install checks the presence of this file to decide which to modify"
+echo "%{__mkdir_p} %{buildroot}%{_sysconfdir}/modprobe.d"
+echo "# Main install"
+echo "%{__make} DESTDIR=%{buildroot} install"
+echo "%{__make} DESTDIR=%{buildroot} config"
+echo ""
+echo "# Move kernel modules in the \"kernel\" subdirectory, also get smp right"
+echo "%{__mkdir_p} %{buildroot}/lib/modules/%{kernel}/kernel"
+echo "%{__mv} %{buildroot}/lib/modules/%{kernel}/misc %{buildroot}/lib/modules/%{kernel}/kernel/"
+echo ""
+echo ""
+
+echo "%clean"
+echo "rm -rf %{buildroot}"
+echo ""
+echo ""
+
+echo "%post"
+echo "/sbin/ldconfig"
+echo ""
+echo "%postun"
+echo "/sbin/ldconfig"
+echo ""
+echo ""
+
+echo "%post -n kernel%{?ksmp}-module-zaptel"
+echo "/sbin/depmod -a -F /boot/System.map-%{kernel} %{kernel} &>/dev/null || :"
+echo ""
+echo "%postun -n kernel%{?ksmp}-module-zaptel"
+echo "/sbin/depmod -a -F /boot/System.map-%{kernel} %{kernel} &>/dev/null || :"
+echo ""
+echo ""
+
+echo "%files"
+echo "%defattr(-, root, root, 0755)"
+echo "%doc README LICENSE zaptel.conf.sample ifcfg-hdlc0 ifup-hdlc"
+echo "%doc xpp/README.fxotune README.hpec"
+echo "%config(noreplace) %{_sysconfdir}/sysconfig/zaptel"
+echo "%config(noreplace) %{_sysconfdir}/zaptel.conf"
+echo "%{_sysconfdir}/rc.d/init.d/zaptel"
+echo "%{_includedir}/zaptel/"
+echo "%{_sbindir}/*"
+echo "/sbin/*"
+echo "%{_libdir}/libtonezone.*"
+echo "%{_mandir}/man8/*"
+echo "/usr/share/zaptel/"
+
+if [ -f "./ChangeLog" ]; then
+    echo "%doc ChangeLog"
+fi
+
+if [ -n "$DYNFS" ]; then
+    echo "%{_sysconfdir}/udev/rules.d/zaptel.rules"
+else
+    echo "/dev/zap/*"
+fi
+
+if [ -z `echo $MENUSELECT_MODULES | grep -v xpp` ]; then
+    echo "%doc xpp/README.Astribank"
+    echo "%{_sysconfdir}/hotplug/usb/xpp*"
+    echo "%{_sysconfdir}/udev/rules.d/xpp*"
+    echo "%{_libdir}/perl5/site_perl/%{perlver}/Zaptel.pm"
+    echo "%{_libdir}/perl5/site_perl/%{perlver}/Zaptel/"
+fi
+
+if [ -z `echo $MENUSELECT_MODULES | grep wcusb` ]; then
+    echo "%doc README.fxsusb"
+fi
+
+echo ""
+
+echo "%files -n kernel%{?ksmp}-module-zaptel"
+echo "%defattr(-, root, root, 0755)"
+echo "/lib/modules/%{kernel}/kernel/misc/"

Property changes on: build_tools/mkspec
___________________________________________________________________
Name: svn:executable
   + *

Index: build_tools/mkrevision
===================================================================
--- build_tools/mkrevision	(revision 0)
+++ build_tools/mkrevision	(revision 0)
@@ -0,0 +1,28 @@
+#!/bin/sh
+#
+# Build a revision number that will continue to increase until
+# a make dist-clean is run.
+#
+
+#
+# Get an existing revision number or start at 1.
+#
+if [ -e .revision ]; then
+    REVISION=`cat .revision`
+else
+    REVISION="1"
+fi
+
+#
+# Save revision number for next run.
+#
+echo $[$REVISION + 1] > .revision
+
+#
+# If we are an svn build then add 10,000 to the revision number
+#
+if [ -e .svn ]; then
+    REVISION=$[$REVISION + 10000]
+fi
+
+echo "$REVISION"

Property changes on: build_tools/mkrevision
___________________________________________________________________
Name: svn:executable
   + *

Index: build_tools/make_tarball
===================================================================
--- build_tools/make_tarball	(revision 0)
+++ build_tools/make_tarball	(revision 0)
@@ -0,0 +1,65 @@
+#!/bin/sh
+#
+# Script to generate a tarball at the given location of the zaptel
+# tree. First parameter must be given and should be the tarball
+# target name to use. Second parameter is also required and is the
+# path the spec file expects to have the tarball extract to.
+#
+
+if [ -z "$1" -o -z "$2" ]; then
+	echo "Usage: ./make_tarball <filename> <extraction_base_path>"
+	echo "Example: ./make_tarball /tmp/zaptel-1.4.0.tar.gz zaptel-1.4"
+	exit 1
+fi
+
+TARBALL="$1"
+ZAPTELPATH="$2"
+BUILDPATH="`basename \`pwd\``"
+
+#
+# Check if we need to rename our folder to be the correct
+# folder name, it must be zaptel-x.y.z[.r]. Also check for a
+# folder that already exists with that name to move it aside.
+#
+if [ "$ZAPTELPATH" != "$BUILDPATH" ]; then
+	restorepath="yes"
+	if [ -e "../$ZAPTELPATH" ]; then
+		restoreoriginal="yes"
+	fi
+fi
+
+#
+# Move into parent folder for all operations.
+#
+cd ..
+
+#
+# If we need to move paths around then do so.
+#
+if [ "$restorepath" == "yes" ]; then
+	if [ "$restoreoriginal" == "yes" ]; then
+		mv "$ZAPTELPATH" "$ZAPTELPATH".save$$
+	fi
+	ln -s "$BUILDPATH" "$ZAPTELPATH"
+fi
+
+#
+# Create the tarball.
+#
+tar -cz --exclude .svn -f "$1" "$ZAPTELPATH"/.
+EXITVAL="$?"
+
+#
+# Restore the original folder names if necessary.
+#
+if [ "$restorepath" == "yes" ]; then
+	rm -f "$ZAPTELPATH"
+	if [ "$restoreoriginal" == "yes" ]; then
+		mv "$ZAPTELPATH".save$$ "$ZAPTELPATH"
+	fi
+fi
+
+#
+# Make sure we exit with whatever error code tar gave us.
+#
+exit $EXITVAL

Property changes on: build_tools/make_tarball
___________________________________________________________________
Name: svn:executable
   + *

Index: Makefile
===================================================================
--- Makefile	(revision 3921)
+++ Makefile	(working copy)
@@ -571,7 +571,7 @@
 	@$(MAKE) -C menuselect dist-clean
 	@$(MAKE) -C firmware dist-clean
 	rm -f makeopts menuselect.makeopts menuselect-tree
-	rm -f config.log config.status
+	rm -f config.log config.status .revision zaptel.spec
 
 config.status: configure
 	@CFLAGS="" ./configure
@@ -596,8 +596,20 @@
 	@echo "Generating input for menuselect ..."
 	@build_tools/make_tree > $@
 
-.PHONY: menuselect distclean dist-clean clean version.h all _all install b410p devices programs modules tests devel data stackcheck install-udev config update install-programs install-modules install-include install-libs install-utils-subdirs utils-subdirs uninstall-modules
+zaptel.spec: build_tools/mkspec
+	ZAPTELVERSION=$(ZAPTELVERSION) DYNFS=$(DYNFS) \
+		MENUSELECT_MODULES=$(MENUSELECT_MODULES) \
+		build_tools/mkspec > $@
 
+rpm: zaptel.spec
+	$(MAKE) clean
+	build_tools/make_tarball "/tmp/zaptel-$(subst -,,$(ZAPTELVERSION)).tar.gz" \
+				"zaptel-$(subst -,,$(ZAPTELVERSION))"
+	rpmbuild -ta /tmp/zaptel-$(subst -,,$(ZAPTELVERSION)).tar.gz
+	rm -f /tmp/zaptel-$(subst -,,$(ZAPTELVERSION)).tar.gz
+
+.PHONY: menuselect distclean dist-clean clean version.h all _all install b410p devices programs modules tests devel data stackcheck install-udev config update install-programs install-modules install-include install-libs install-utils-subdirs utils-subdirs uninstall-modules rpm zaptel.spec
+
 endif
 
 #end of: ifneq ($(KBUILD_EXTMOD),)
