# # Replace MODULE_NAME with real module name and MODULE_DIR # with required directory name. # # Conditional build: %bcond_without dist_kernel # allow non-distribution kernel %bcond_without kernel # don't build kernel modules %bcond_without smp # don't build SMP module %bcond_without userspace # don't build userspace programs %bcond_with verbose # verbose build (V=1) %if !%{with kernel} %undefine with_dist_kernel %endif # # main package. # %define _rel 0.1 Summary: - Summary(pl): - Name: - Version: - Release: %{_rel} Epoch: 0 #License: - (enter GPL/LGPL/BSD/BSD-like/other license name here) Group: - Source0: %{name}-%{version}.tar.gz # Source0-md5: - #Source1: - # Source1-md5: - #Patch0: %{name}-what.patch #URL: - %if %{with kernel} %{?with_dist_kernel:BuildRequires: kernel%{_alt_kernel}-module-build >= 3:2.6.14} BuildRequires: rpmbuild(macros) >= 1.329 %endif #BuildRequires: - #Requires(postun): - #Requires(pre,post): - #Requires(preun): - #Requires: - #Provides: - #Obsoletes: - #Conflicts: - BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) %description %description -l pl # kernel subpackages. %package -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME Summary: Linux driver for MODULE_NAME Summary(pl): Sterownik dla Linuksa do MODULE_NAME Release: %{_rel}@%{_kernel_ver_str} Group: Base/Kernel Requires(post,postun): /sbin/depmod %if %{with dist_kernel} %requires_releq_kernel_up Requires(postun): %releq_kernel_up %endif %description -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME This is driver for MODULE_NAME for Linux. This package contains Linux module. %description -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME -l pl Sterownik dla Linuksa do MODULE_NAME. Ten pakiet zawiera moduł jądra Linuksa. %package -n kernel%{_alt_kernel}-smp-MODULE_DIR-MODULE_NAME Summary: Linux SMP driver for MODULE_NAME Summary(pl): Sterownik dla Linuksa SMP do MODULE_NAME Release: %{_rel}@%{_kernel_ver_str} Group: Base/Kernel Requires(post,postun): /sbin/depmod %if %{with dist_kernel} %requires_releq_kernel_smp Requires(postun): %releq_kernel_smp %endif %description -n kernel%{_alt_kernel}-smp-MODULE_DIR-MODULE_NAME This is driver for MODULE_NAME for Linux. This package contains Linux SMP module. %description -n kernel%{_alt_kernel}-smp-MODULE_DIR-MODULE_NAME -l pl Sterownik dla Linuksa do MODULE_NAME. Ten pakiet zawiera moduł jądra Linuksa SMP. %prep # prepare makefile: cat > path/to/dir/Makefile << EOF obj-m += MODULE_NAME.o MODULE2.o MODULE_NAME-objs := file1.o file2.o \ file3.o file4.o file5.o MODULE2-objs := file6.o file7.o file8.o CFLAGS += -DCONFIG_MODULE_NAME_SOME_OPTION=1 %{?debug:CFLAGS += -DCONFIG_MODULE_NAME_DEBUG=1} EOF %build %if %{with userspace} %endif %if %{with kernel} %build_kernel_modules -m MODULE_NAME # modules placed in subdirectory: %build_kernel_modules -C path/to/dir -m MODULE_NAME,MODULE2 # need to pass additional options to make modules: %build_kernel_modules VAR1=value1 VAR2=value2 -m MODULE_NAME # optional patching: %build_kernel_modules -m MODULE_NAME <<'EOF' # Your script here: if grep -q "CONFIG_SOME_OPTION" o/.config; then sed 's/some/change/' file.c.orig > file.c else cat file.c.orig > file.c fi # Don't do it this way unless it depends on kernel options or something # you can't check before EOF %endif %install rm -rf $RPM_BUILD_ROOT %if %{with userspace} %endif %if %{with kernel} %install_kernel_modules -m MODULE_NAME -d MODULE_DIR # to avoid conflict with in-kernel modules, and prepare modprobe config: %install_kernel_modules -s current -n NAME -m MODULE_NAME -d MODULE_DIR %endif %clean rm -rf $RPM_BUILD_ROOT %post -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME %depmod %{_kernel_ver} %postun -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME %depmod %{_kernel_ver} %post -n kernel%{_alt_kernel}-smp-MODULE_DIR-MODULE_NAME %depmod %{_kernel_ver}smp %postun -n kernel%{_alt_kernel}-smp-MODULE_DIR-MODULE_NAME %depmod %{_kernel_ver}smp %if %{with kernel} %files -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME %defattr(644,root,root,755) /lib/modules/%{_kernel_ver}/MODULE_DIR/*.ko* %if %{with smp} && %{with dist_kernel} %files -n kernel%{_alt_kernel}-smp-MODULE_DIR-MODULE_NAME %defattr(644,root,root,755) /lib/modules/%{_kernel_ver}smp/MODULE_DIR/*.ko* %endif %endif %if %{with userspace} %files %defattr(644,root,root,755) %endif