2 # Replace MODULE_NAME with real module name and MODULE_DIR
3 # with required directory name.
6 %bcond_without dist_kernel # allow non-distribution kernel
7 %bcond_without kernel # don't build kernel modules
8 %bcond_without smp # don't build SMP module
9 %bcond_without userspace # don't build userspace programs
10 %bcond_with verbose # verbose build (V=1)
13 %undefine with_dist_kernel
26 #License: - (enter GPL/LGPL/BSD/BSD-like/other license name here)
28 Source0: %{name}-%{version}.tar.gz
32 #Patch0: %{name}-what.patch
35 %{?with_dist_kernel:BuildRequires: kernel%{_alt_kernel}-module-build >= 3:2.6.14}
36 BuildRequires: rpmbuild(macros) >= 1.330
40 #Requires(pre,post): -
46 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
54 %package -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME
55 Summary: Linux driver for MODULE_NAME
56 Summary(pl): Sterownik dla Linuksa do MODULE_NAME
57 Release: %{_rel}@%{_kernel_ver_str}
59 Requires(post,postun): /sbin/depmod
60 %if %{with dist_kernel}
61 %requires_releq_kernel_up
62 Requires(postun): %releq_kernel_up
65 %description -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME
66 This is driver for MODULE_NAME for Linux.
68 This package contains Linux module.
70 %description -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME -l pl
71 Sterownik dla Linuksa do MODULE_NAME.
73 Ten pakiet zawiera modu³ j±dra Linuksa.
75 %package -n kernel%{_alt_kernel}-smp-MODULE_DIR-MODULE_NAME
76 Summary: Linux SMP driver for MODULE_NAME
77 Summary(pl): Sterownik dla Linuksa SMP do MODULE_NAME
78 Release: %{_rel}@%{_kernel_ver_str}
80 Requires(post,postun): /sbin/depmod
81 %if %{with dist_kernel}
82 %requires_releq_kernel_smp
83 Requires(postun): %releq_kernel_smp
86 %description -n kernel%{_alt_kernel}-smp-MODULE_DIR-MODULE_NAME
87 This is driver for MODULE_NAME for Linux.
89 This package contains Linux SMP module.
91 %description -n kernel%{_alt_kernel}-smp-MODULE_DIR-MODULE_NAME -l pl
92 Sterownik dla Linuksa do MODULE_NAME.
94 Ten pakiet zawiera modu³ j±dra Linuksa SMP.
98 cat > path/to/dir/Makefile << EOF
100 obj-m += MODULE_NAME.o MODULE2.o
102 MODULE_NAME-objs := file1.o file2.o \
103 file3.o file4.o file5.o
105 MODULE2-objs := file6.o file7.o file8.o
107 CFLAGS += -DCONFIG_MODULE_NAME_SOME_OPTION=1
108 %{?debug:CFLAGS += -DCONFIG_MODULE_NAME_DEBUG=1}
112 %if %{with userspace}
118 %build_kernel_modules -m MODULE_NAME
120 # modules placed in subdirectory:
121 %build_kernel_modules -C path/to/dir -m MODULE_NAME,MODULE2
123 # need to pass additional options to make modules:
124 %build_kernel_modules VAR1=value1 VAR2=value2 -m MODULE_NAME
127 %build_kernel_modules -m MODULE_NAME <<'EOF'
129 if grep -q "CONFIG_SOME_OPTION" o/.config; then
130 sed 's/some/change/' file.c.orig > file.c
132 cat file.c.orig > file.c
134 # Don't do it this way unless it depends on kernel options or something
135 # you can't check before
141 rm -rf $RPM_BUILD_ROOT
143 %if %{with userspace}
149 %install_kernel_modules -m MODULE_NAME -d MODULE_DIR
151 # to avoid conflict with in-kernel modules, and prepare modprobe config:
152 %install_kernel_modules -s current -n NAME -m MODULE_NAME -d MODULE_DIR
156 rm -rf $RPM_BUILD_ROOT
158 %post -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME
159 %depmod %{_kernel_ver}
161 %postun -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME
162 %depmod %{_kernel_ver}
164 %post -n kernel%{_alt_kernel}-smp-MODULE_DIR-MODULE_NAME
165 %depmod %{_kernel_ver}smp
167 %postun -n kernel%{_alt_kernel}-smp-MODULE_DIR-MODULE_NAME
168 %depmod %{_kernel_ver}smp
171 %files -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME
172 %defattr(644,root,root,755)
173 /lib/modules/%{_kernel_ver}/MODULE_DIR/*.ko*
175 %if %{with smp} && %{with dist_kernel}
176 %files -n kernel%{_alt_kernel}-smp-MODULE_DIR-MODULE_NAME
177 %defattr(644,root,root,755)
178 /lib/modules/%{_kernel_ver}smp/MODULE_DIR/*.ko*
182 %if %{with userspace}
184 %defattr(644,root,root,755)