# norootforbuild

BuildRequires: kernel-source kernel-syms module-init-tools

Name:         fcpci
License:      Proprietary
Group:        System/Kernel
Summary:      Kernel CAPI driver for Fritz!Card PCI
Version:      0.1
Release:      0
Source0:      ftp://ftp.avm.de/cardware/fritzcrd.pci/linux/suse.93/fcpci-suse93-3.11-07.tar.gz
Source1:      ftp://ftp.avm.de/cardware/fritzcrd.pci/linux_64bit/suse.93/fcpci-suse93-64bit-3.11-07.tar.gz
Source2:      files
Patch0:       fritz-tools.diff
Patch1:       fritz-config.diff
Patch2:       fritz_pci.diff
Patch3:       fritz_irq.diff
Patch4:       fritz_driver_init.diff
Patch5:       tools2.diff
Patch6:       ctr_reset.diff
Patch7:       strncpy.diff
BuildRoot:    %{_tmppath}/%{name}-%{version}-build

%suse_kernel_module_package kdump um -f %_sourcedir/files

%description
Kernel driver for Fritz!Card PCI

%package KMP
Summary: Kernel Modules for Fritz!Card PCI
Group: System/Kernel

%description KMP
Kernel Modules for Fritz!Card PCI

%prep
%ifarch x86_64
%setup -n fritz -T -b 1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1




%else
%setup -n fritz -T -b 0
%patch0 -p1
%patch1 -p1
%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1



%endif
OBJ=`find . -name '*lib.o'`
for i in $OBJ; do
mv $i $i.old
objcopy -L memcmp \
	-L memcpy \
	-L memmove \
	-L memset \
	-L strcat \
	-L strcmp \
	-L strcpy \
	-L strlen \
	-L strncmp \
	-L strncpy \
	$i.old $i
done
set -- *
mkdir source
mv "$@" source/
mkdir obj

%build
export EXTRA_CFLAGS='-DVERSION=\"%version\"'
for flavor in %flavors_to_build; do
    rm -rf obj/$flavor
    cp -r source obj/$flavor
    make -C /usr/src/linux-obj/%_target_cpu/$flavor modules \
	M=$PWD/obj/$flavor/src LIBDIR=$PWD/obj/$flavor/lib
done

%install
cd source
mkdir -p $RPM_BUILD_ROOT/%{_defaultdocdir}/%{name}
install -m 644 CAPI20_Errormessages.txt $RPM_BUILD_ROOT/%{_defaultdocdir}/%{name}/
install -m 644 install_passive-d.html $RPM_BUILD_ROOT/%{_defaultdocdir}/%{name}/
install -m 644 install_passive-e.html $RPM_BUILD_ROOT/%{_defaultdocdir}/%{name}/
install -m 644 license.txt $RPM_BUILD_ROOT/%{_defaultdocdir}/%{name}/
cd ..

export INSTALL_MOD_PATH=$RPM_BUILD_ROOT
export INSTALL_MOD_DIR=updates
for flavor in %flavors_to_build; do
    make -C /usr/src/linux-obj/%_target_cpu/$flavor modules_install \
	 M=$PWD/obj/$flavor/src
done

%changelog
