diff -N -r -u -w -xautom4te.cache -xaclocal.m4 -xconfigure -xMakefile.in -x'*.tar.gz' feeserver.orig/configure.ac feeserver/configure.ac
--- feeserver.orig/configure.ac	2006-07-22 23:55:31.000000000 +0200
+++ feeserver/configure.ac	2007-04-08 13:24:10.000000000 +0200
@@ -25,12 +25,13 @@
 dnl users choice of --anable/disable-shared
 if test "x$cross_compiling" = "xyes" ; then
  case "${host}" in
- arm*)
-   arm_compiling=yes
- ;;
+ arm*)arm_compiling=yes ;;
+ *)   arm_compiling=no ;; 
  esac
 fi
+AC_MSG_CHECKING(whether we're compiling for arm-linux)
 AM_CONDITIONAL(ARM_COMPILING, test x$arm_compiling = xyes )
+AC_MSG_RESULT($arm_compiling)
 
 dnl ------------------------------------------------------------------
 AC_MSG_CHECKING([whether to enable DCSC simulation])
@@ -235,11 +236,20 @@
 AC_SUBST([DOT_PATH])
 
 dnl ------------------------------------------------------------------
+dnl
+dnl RPM stuff 
+dnl
+RPM_VERSION=`echo $VERSION | tr '-' '_'`
+AC_SUBST(RPM_VERSION)
+
+dnl ------------------------------------------------------------------
 AC_CONFIG_FILES([Makefile 
 		 feeserver/Makefile
 		 feeserver/dcscMsgBufferInterface/Makefile
+		 feeserver.spec
 		 scripts/Makefile
 		 scripts/startFeeServer.sh
+		 scripts/S90feeserver
 		 doc/Makefile
 		 doc/doxygen.conf
 		 rcu-ce-cmds/Makefile])
diff -N -r -u -w -xautom4te.cache -xaclocal.m4 -xconfigure -xMakefile.in -x'*.tar.gz' feeserver.orig/feeserver/Makefile.am feeserver/feeserver/Makefile.am
--- feeserver.orig/feeserver/Makefile.am	2006-05-15 11:19:40.000000000 +0200
+++ feeserver/feeserver/Makefile.am	2007-04-08 13:16:13.000000000 +0200
@@ -19,7 +19,7 @@
 # time (the check in configure is currently missing, always
 # static)
 if ARM_COMPILING
-#ARM_COMPILING_LD_FLAGS	=  -all-static
+ARM_COMPILING_LD_FLAGS	=  -all-static
 endif
 if NEED_DIM
 DIM_LD_ADD		=  $(top_builddir)/dim/libdim.la
@@ -32,7 +32,9 @@
 AM_CPPFLAGS     	+= $(DIM_CPP_FLAGS)
 
 EXTRA_DIST		= README_v0.6.txt	\
-			  README_v0.7.txt
+			  README_v0.7.txt	\
+			  src/Makefile		\
+			  src_ce/Makefile
 
 SUBDIRS			= dcscMsgBufferInterface
 
diff -N -r -u -w -xautom4te.cache -xaclocal.m4 -xconfigure -xMakefile.in -x'*.tar.gz' feeserver.orig/feeserver/src_ce/rcu_issue.cpp feeserver/feeserver/src_ce/rcu_issue.cpp
--- feeserver.orig/feeserver/src_ce/rcu_issue.cpp	2006-07-22 23:51:14.000000000 +0200
+++ feeserver/feeserver/src_ce/rcu_issue.cpp	2007-04-08 15:32:30.000000000 +0200
@@ -612,7 +612,10 @@
 	} else {
 	  iResult=writeDataBlockToRCUMem(pData+sizeof(__u32), iDataSize, parameter, 32, 
 					 u32Address, 0);
-	  if (iResult>=0) iResult++;
+	  // CHOLM - Changed this from 'iResult++', which was wrong,
+	  // since the unit of the return value is in bytes, and we
+	  // are swollowing a whole 32bit word.  
+	  if (iResult>=0) iResult+=sizeof(__u32);
 	  /* the old code
 	  if ((iResult=writeCommandBufferToRCUMem(pDataBuffer, iCount, iAlign, u32Address))>=0) {
 	    if (iResult!=parameter) {
@@ -1077,6 +1080,7 @@
   char* searchKey=NULL;
   char* highlevelKey=NULL;
   int highlevelCmd=0;
+    
   if (size>=2*sizeof(__u32) 
       && (*((__u32*)(pData+size-sizeof(__u32)))&CE_CMD_EM_MASK) 
          == CE_CMD_ENDMARKER) {
@@ -1159,7 +1163,8 @@
 	  __u32 u32tailer=*((__u32*)(pData));
 	  if ((u32tailer&CE_CMD_EM_MASK) != CE_CMD_ENDMARKER) {
 	    if (ceCheckOptionFlag(DEBUG_RELAX_CMD_CHECK)==0) {
-	      CE_Error("missing end marker\n");
+	      CE_Error("missing end marker - got %x=(%x|%x) expected %x\n", 
+		       u32tailer, u32tailer, CE_CMD_EM_MASK, CE_CMD_ENDMARKER);
 	      iResult=-EPROTO;
 	    }
 	  } else {
diff -N -r -u -w -xautom4te.cache -xaclocal.m4 -xconfigure -xMakefile.in -x'*.tar.gz' feeserver.orig/feeserver.spec.in feeserver/feeserver.spec.in
--- feeserver.orig/feeserver.spec.in	1970-01-01 01:00:00.000000000 +0100
+++ feeserver/feeserver.spec.in	2007-04-08 13:30:17.000000000 +0200
@@ -0,0 +1,88 @@
+# -*- mode: rpm-spec -*- 
+%define debug_package 	  %{nil}
+%define __find_provides   %{nil}
+
+#_____________________________________________________________________
+Summary: 	DCS card FeeServer
+Name: 		feeserver
+Version: 	@RPM_VERSION@
+Release: 	3
+License: 	GNU General Public License
+Group: 		System/Servers
+URL: 		http://www.ift.uib.no/~kjeks/download
+Source0: 	%{name}-@VERSION@.tar.gz
+BuildRoot: 	%{_tmppath}/%{name}-%{version}-%{release}-buildroot
+BuildRequires:	arm-uclibc-toolchain 
+BuildArch:	noarch
+AutoReq:	0
+Requires:	nfs-server
+Requires:	rcufw
+
+%description
+This package contains the FeeServer for the DCS cards.  This is 
+specialised for the RCU.  That is, it is linked with an RCU 
+control engine. 
+
+The server is installed in /home/dcs, which can then be served
+via NFS to the DCS boards.   On the DCS boards, the following should be 
+setup
+
+* The NFS directory /home/dcs should be mounted from host this package
+  is installed on.   The directory should be exported with the following 
+  options: 
+	rw
+	sync
+	all_squash
+	anonuid=99
+	anongid=99
+
+* One should create the symbolic link 
+	`/dcs-share/boot' -> `/home/dcs/etc/init.d'
+
+#_____________________________________________________________________
+%prep
+%setup -q -n %{name}-@VERSION@
+./configure	\
+	--host=arm-linux	\
+	--prefix=/home/dcs	\
+	CC=arm-linux-gcc 	\
+	CXX=arm-linux-g++ 	\
+	LD=arm-linux-ld 	\
+	--disable-cxx-api 	\
+	--disable-shared	\
+	--enable-ancient05	\
+	--enable-auto-detection	
+
+%build
+make 
+
+%install
+rm -rf $RPM_BUILD_ROOT
+make install DESTDIR=$RPM_BUILD_ROOT
+mkdir -p $RPM_BUILD_ROOT/home/dcs/var/log
+mkdir -p $RPM_BUILD_ROOT/home/dcs/var/run
+export STRIP=/bin/true
+export OBJDUMP=/bin/true
+
+%clean
+# rm -rf $RPM_BUILD_ROOT
+make distclean > /dev/null 2>&1 
+
+#_____________________________________________________________________
+%files
+%defattr(-,root,root,-)
+%config(noreplace) /home/dcs/etc/sysconfig/feeserver
+%attr(775,nobody,nobody) /home/dcs/var/log
+%attr(775,nobody,nobody) /home/dcs/var/run
+/home/dcs/lib
+/home/dcs/bin
+/home/dcs/etc
+/home/dcs/include
+
+
+#_____________________________________________________________________
+%changelog
+* Sat Apr  7 2007 Christan Holm Christensen <cholm@nbi.dk> 
+- Initial build.
+
+
diff -N -r -u -w -xautom4te.cache -xaclocal.m4 -xconfigure -xMakefile.in -x'*.tar.gz' feeserver.orig/Makefile.am feeserver/Makefile.am
--- feeserver.orig/Makefile.am	2006-05-11 14:12:29.000000000 +0200
+++ feeserver/Makefile.am	2007-04-07 13:35:31.000000000 +0200
@@ -1,7 +1,7 @@
 # $Id: Makefile.am,v 1.7 2006/05/11 12:12:29 richter Exp $
 # Makefile template for the FeeServer with RCU support
 
-EXTRA_DIST		= configure-arm
+EXTRA_DIST		= configure-arm feeserver.spec 
 
 if NEED_DIM
 EXTRA_SUBDIRS		= dim
@@ -21,6 +21,10 @@
 DIST_SUBDIRS		= $(SUBDIRS)
 
 
+rpm: dist
+	sudo rpmbuild -ta $$flags $(distdir).tar.gz
+
+
 #dist_noinst_SCRIPTS	= autogen.sh
 #
 # EOF
diff -N -r -u -w -xautom4te.cache -xaclocal.m4 -xconfigure -xMakefile.in -x'*.tar.gz' feeserver.orig/scripts/feeserver feeserver/scripts/feeserver
--- feeserver.orig/scripts/feeserver	1970-01-01 01:00:00.000000000 +0100
+++ feeserver/scripts/feeserver	2007-04-08 14:05:43.000000000 +0200
@@ -0,0 +1,21 @@
+#
+# The name of the DIM DNS NODE
+#
+DIM_DNS_NODE=alifmddimdns
+
+#
+# The name of the FEE server.  This is here, only to override the 
+# automatically deduced fee server name.  The  script mach2num will
+# try to figure out the name automatically, based on the MAC address
+# of the interface card. 
+#
+# FEE_SERVER_NAME=
+
+# 
+# Set the log level 
+#
+FEE_LOG_LEVEL=0
+
+#
+# EOF
+#
diff -N -r -u -w -xautom4te.cache -xaclocal.m4 -xconfigure -xMakefile.in -x'*.tar.gz' feeserver.orig/scripts/mac2num feeserver/scripts/mac2num
--- feeserver.orig/scripts/mac2num	1970-01-01 01:00:00.000000000 +0100
+++ feeserver/scripts/mac2num	2007-04-07 14:02:37.000000000 +0200
@@ -0,0 +1,12 @@
+#!/bin/sh 
+
+mach=`ifconfig | sed -n -e 's/.*HWaddr //p' | sed -e 's/ *$//'`
+case $mach in
+    *01:0E) num=270 ; name=FMD-FEE_0_0_0 ;; 
+    *01:0F) num=271 ; name=FMD-FEE_0_0_1 ;;
+    *01:10) num=272 ; name=FMD-FEE_0_0_2 ;;
+    *01:11) num=273 ; name=FMD-FEE_0_0_3 ;;
+    *)      num=0   ; name=              ;;
+esac
+FEE_SERVER_NAME=$name
+ 
diff -N -r -u -w -xautom4te.cache -xaclocal.m4 -xconfigure -xMakefile.in -x'*.tar.gz' feeserver.orig/scripts/Makefile.am feeserver/scripts/Makefile.am
--- feeserver.orig/scripts/Makefile.am	2006-03-16 15:54:49.000000000 +0100
+++ feeserver/scripts/Makefile.am	2007-04-08 12:49:02.000000000 +0200
@@ -1,7 +1,12 @@
 #
 #
 #
-bin_SCRIPTS	= startFeeServer.sh
+EXTRA_DIST	= mac2num feeserver 
+bin_SCRIPTS	= startFeeServer.sh mac2num
+defdir		= $(sysconfdir)/sysconfig
+def_DATA	= feeserver
+initdir		= $(sysconfdir)/init.d
+init_SCRIPTS	= S90feeserver
 
 #
 #
diff -N -r -u -w -xautom4te.cache -xaclocal.m4 -xconfigure -xMakefile.in -x'*.tar.gz' feeserver.orig/scripts/S90feeserver.in feeserver/scripts/S90feeserver.in
--- feeserver.orig/scripts/S90feeserver.in	1970-01-01 01:00:00.000000000 +0100
+++ feeserver/scripts/S90feeserver.in	2007-04-08 14:05:08.000000000 +0200
@@ -0,0 +1,38 @@
+#!/bin/sh
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+bindir=@bindir@
+sbindir=@sbindir@
+sysconfdir=@sysconfdir@
+localstatedir=@localstatedir@
+logdir=${localstatedir}/log
+rundir=${localstatedir}/run
+defdir=${sysconfdir}/sysconfig
+
+if test -r ${bindir}/mac2num ; then 
+    . ${bindir}/mac2num
+fi
+if test -r ${defdir}/feeserver ; then 
+    . ${defdir}/feeserver 
+fi
+if test -r ${defdir}/feeserver.${HOST} ; then 
+    . ${defdir}/feeserver.${HOST} 
+fi
+export FEE_SERVER_NAME
+export DIM_DNS_NODE
+export FEE_LOG_LEVEL
+
+if test "x$1" = "xstop" || test "x$1" = "xrestart" ; then 
+    echo -n "Stopping FeeServer for $FEE_SERVER_NAME ... "
+    killall -9 startFeeServer.sh feeserver
+    echo "done"
+    if test "x$1" = "xstop" ; then exit 0 ; fi 
+fi
+
+cd ${bindir}
+echo -n "Starting FeeServer for $FEE_SERVER_NAME ... " 
+./startFeeServer.sh $FEE_SERVER_NAME \
+    > ${logdir}/feeserver.${FEE_SERVER_NAME} 2>&1 &
+echo "$!" > ${rundir}/feeserver.${FEE_SERVER_NAME}.pid
+echo "done (pid $!)"
+
