-%description -l pl
-
-# kernel subpackages.
-
-%package -n kernel-...
-Summary: Linux driver for ...
-Summary(pl): Sterownik dla Linuksa do ...
-Release: %{_rel}@%{_kernel_ver_str}
-Group: Base/Kernel
-Requires(post,postun): /sbin/depmod
-%if %{with dist_kernel}
-%requires_releq_kernel_up
-Requires(postun): %requires_releq_kernel_up
-%endif
-
-%description -n kernel-...
-This is driver for ... for Linux.
-
-This package contains Linux module.
-
-%description -n kernel-... -l pl
-Sterownik dla Linuksa do ...
-
-Ten pakiet zawiera modu³ j±dra Linuksa.
-
-%package -n kernel-smp-...
-Summary: Linux SMP driver for ...
-Summary(pl): Sterownik dla Linuksa SMP do ...
-Release: %{_rel}@%{_kernel_ver_str}
-Group: Base/Kernel
-Requires(post,postun): /sbin/depmod
-%if %{with dist_kernel}
-%requires_releq_kernel_smp
-Requires(postun): %requires_releq_kernel_smp
-%endif
-
-%description -n kernel-smp-...
-This is driver for ... for Linux.
-
-This package contains Linux SMP module.
-
-%description -n kernel-smp-... -l pl
-Sterownik dla Linuksa do ...
-
-Ten pakiet zawiera modu³ j±dra Linuksa SMP.
+%description -l pl.UTF-8
+
+# kernel subpackages definition.
+
+%define kernel_pkg()\
+%package -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME\
+Summary: Linux driver for MODULE_NAME\
+Summary(pl.UTF-8): Sterownik dla Linuksa do MODULE_NAME\
+Release: %{rel}@%{_kernel_ver_str}\
+Group: Base/Kernel\
+Requires(post,postun): /sbin/depmod\
+%requires_releq_kernel\
+Requires(postun): %releq_kernel\
+\
+%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.UTF-8\
+Sterownik dla Linuksa do MODULE_NAME.\
+\
+Ten pakiet zawiera moduł jądra Linuksa.\
+\
+%if %{with kernel}\
+%files -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME\
+%defattr(644,root,root,755)\
+/lib/modules/%{_kernel_ver}/kernel/MODULE_DIR/*.ko*\
+%endif\
+\
+%post -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME\
+%depmod %{_kernel_ver}\
+\
+%postun -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME\
+%depmod %{_kernel_ver}\
+%{nil}
+
+%define build_kernel_pkg()\
+%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\
+\
+# install to local directory, this makes building for multiple kernels easy\
+%install_kernel_modules -D installed -m MODULE_NAME -d kernel/MODULE_DIR\
+\
+# to avoid conflict with in-kernel modules, and prepare modprobe config:\
+%install_kernel_modules -D installed -s current -n NAME -m MODULE_NAME -d kernel/MODULE_DIR\
+%{nil}
+
+%define install_kernel_pkg()\
+# any additional, per-module, tasks needed at install,\
+# like blacklisting in-kernel module to always load this one\
+install -d $RPM_BUILD_ROOT/etc/modprobe.d/%{_kernel_ver}\
+# blacklist kernel module\
+cat > $RPM_BUILD_ROOT/etc/modprobe.d/%{_kernel_ver}/MODULE_NAME.conf <<'EOF'\
+blacklist MODULE_NAME\
+alias MODULE_NAME MODULE_NAME-current\
+EOF\
+%{nil}
+
+%{?with_kernel:%{expand:%create_kernel_packages}}
+
+%prep
+%setup -q -n %{pname}-%{version}
+
+# 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