3 # MODULE_NAME with real module name
4 # MODULE_DIR with required directory name
5 # PACKAGE_NAME with package name
8 %bcond_without dist_kernel # allow non-distribution kernel
9 %bcond_without kernel # don't build kernel modules
10 %bcond_without userspace # don't build userspace programs
11 %bcond_with verbose # verbose build (V=1)
14 %undefine with_dist_kernel
16 %if "%{_alt_kernel}" != "%{nil}"
17 %undefine with_userspace
19 %if %{without userspace}
20 # nothing to be placed to debuginfo package
21 %define _enable_debug_packages 0
28 %define pname PACKAGE_NAME
35 #License: - (enter GPL/LGPL/BSD/BSD-like/other license name here)
37 Source0: %{pname}-%{version}.tar.gz
41 #Patch0: %{pname}-what.patch
44 %{?with_dist_kernel:BuildRequires: kernel%{_alt_kernel}-module-build >= 3:2.6.20.2}
45 BuildRequires: rpmbuild(macros) >= 1.379
49 #Requires(pre,post): -
55 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
59 %description -l pl.UTF-8
63 %package -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME
64 Summary: Linux driver for MODULE_NAME
65 Summary(pl.UTF-8): Sterownik dla Linuksa do MODULE_NAME
66 Release: %{rel}@%{_kernel_ver_str}
68 Requires(post,postun): /sbin/depmod
69 %if %{with dist_kernel}
70 %requires_releq_kernel
71 Requires(postun): %releq_kernel
74 %description -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME
75 This is driver for MODULE_NAME for Linux.
77 This package contains Linux module.
79 %description -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME -l pl.UTF-8
80 Sterownik dla Linuksa do MODULE_NAME.
82 Ten pakiet zawiera moduł jądra Linuksa.
85 %setup -q -n %{pname}-%{version}
88 cat > path/to/dir/Makefile << EOF
90 obj-m += MODULE_NAME.o MODULE2.o
92 MODULE_NAME-objs := file1.o file2.o \
93 file3.o file4.o file5.o
95 MODULE2-objs := file6.o file7.o file8.o
97 CFLAGS += -DCONFIG_MODULE_NAME_SOME_OPTION=1
98 %{?debug:CFLAGS += -DCONFIG_MODULE_NAME_DEBUG=1}
102 %if %{with userspace}
108 %build_kernel_modules -m MODULE_NAME
110 # modules placed in subdirectory:
111 %build_kernel_modules -C path/to/dir -m MODULE_NAME,MODULE2
113 # need to pass additional options to make modules:
114 %build_kernel_modules VAR1=value1 VAR2=value2 -m MODULE_NAME
117 %build_kernel_modules -m MODULE_NAME <<'EOF'
119 if grep -q "CONFIG_SOME_OPTION" o/.config; then
120 sed 's/some/change/' file.c.orig > file.c
122 cat file.c.orig > file.c
124 # Don't do it this way unless it depends on kernel options or something
125 # you can't check before
131 rm -rf $RPM_BUILD_ROOT
133 %if %{with userspace}
139 %install_kernel_modules -m MODULE_NAME -d kernel/MODULE_DIR
141 # to avoid conflict with in-kernel modules, and prepare modprobe config:
142 %install_kernel_modules -s current -n NAME -m MODULE_NAME -d kernel/MODULE_DIR
146 rm -rf $RPM_BUILD_ROOT
148 %post -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME
149 %depmod %{_kernel_ver}
151 %postun -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME
152 %depmod %{_kernel_ver}
155 %files -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME
156 %defattr(644,root,root,755)
157 /lib/modules/%{_kernel_ver}/kernel/MODULE_DIR/*.ko*
160 %if %{with userspace}
162 %defattr(644,root,root,755)