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 up # don't build UP module
9 %bcond_without smp # don't build SMP module
10 %bcond_without userspace # don't build userspace programs
11 %bcond_with verbose # verbose build (V=1)
14 %undefine with_dist_kernel
27 #License: - (enter GPL/LGPL/BSD/BSD-like/other license name here)
29 Source0: %{name}-%{version}.tar.gz
33 #Patch0: %{name}-what.patch
36 %{?with_dist_kernel:BuildRequires: kernel%{_alt_kernel}-module-build >= 3:2.6.14}
37 BuildRequires: rpmbuild(macros) >= 1.330
41 #Requires(pre,post): -
47 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
55 %package -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME
56 Summary: Linux driver for MODULE_NAME
57 Summary(pl): Sterownik dla Linuksa do MODULE_NAME
58 Release: %{_rel}@%{_kernel_ver_str}
60 Requires(post,postun): /sbin/depmod
61 %if %{with dist_kernel}
62 %requires_releq_kernel_up
63 Requires(postun): %releq_kernel_up
66 %description -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME
67 This is driver for MODULE_NAME for Linux.
69 This package contains Linux module.
71 %description -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME -l pl
72 Sterownik dla Linuksa do MODULE_NAME.
74 Ten pakiet zawiera modu³ j±dra Linuksa.
76 %package -n kernel%{_alt_kernel}-smp-MODULE_DIR-MODULE_NAME
77 Summary: Linux SMP driver for MODULE_NAME
78 Summary(pl): Sterownik dla Linuksa SMP do MODULE_NAME
79 Release: %{_rel}@%{_kernel_ver_str}
81 Requires(post,postun): /sbin/depmod
82 %if %{with dist_kernel}
83 %requires_releq_kernel_smp
84 Requires(postun): %releq_kernel_smp
87 %description -n kernel%{_alt_kernel}-smp-MODULE_DIR-MODULE_NAME
88 This is driver for MODULE_NAME for Linux.
90 This package contains Linux SMP module.
92 %description -n kernel%{_alt_kernel}-smp-MODULE_DIR-MODULE_NAME -l pl
93 Sterownik dla Linuksa do MODULE_NAME.
95 Ten pakiet zawiera modu³ j±dra Linuksa SMP.
99 cat > path/to/dir/Makefile << EOF
101 obj-m += MODULE_NAME.o MODULE2.o
103 MODULE_NAME-objs := file1.o file2.o \
104 file3.o file4.o file5.o
106 MODULE2-objs := file6.o file7.o file8.o
108 CFLAGS += -DCONFIG_MODULE_NAME_SOME_OPTION=1
109 %{?debug:CFLAGS += -DCONFIG_MODULE_NAME_DEBUG=1}
113 %if %{with userspace}
119 %build_kernel_modules -m MODULE_NAME
121 # modules placed in subdirectory:
122 %build_kernel_modules -C path/to/dir -m MODULE_NAME,MODULE2
124 # need to pass additional options to make modules:
125 %build_kernel_modules VAR1=value1 VAR2=value2 -m MODULE_NAME
128 %build_kernel_modules -m MODULE_NAME <<'EOF'
130 if grep -q "CONFIG_SOME_OPTION" o/.config; then
131 sed 's/some/change/' file.c.orig > file.c
133 cat file.c.orig > file.c
135 # Don't do it this way unless it depends on kernel options or something
136 # you can't check before
142 rm -rf $RPM_BUILD_ROOT
144 %if %{with userspace}
150 %install_kernel_modules -m MODULE_NAME -d MODULE_DIR
152 # to avoid conflict with in-kernel modules, and prepare modprobe config:
153 %install_kernel_modules -s current -n NAME -m MODULE_NAME -d MODULE_DIR
157 rm -rf $RPM_BUILD_ROOT
159 %post -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME
160 %depmod %{_kernel_ver}
162 %postun -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME
163 %depmod %{_kernel_ver}
165 %post -n kernel%{_alt_kernel}-smp-MODULE_DIR-MODULE_NAME
166 %depmod %{_kernel_ver}smp
168 %postun -n kernel%{_alt_kernel}-smp-MODULE_DIR-MODULE_NAME
169 %depmod %{_kernel_ver}smp
172 %if %{with up} || %{without dist_kernel}
173 %files -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME
174 %defattr(644,root,root,755)
175 /lib/modules/%{_kernel_ver}/MODULE_DIR/*.ko*
178 %if %{with smp} && %{with dist_kernel}
179 %files -n kernel%{_alt_kernel}-smp-MODULE_DIR-MODULE_NAME
180 %defattr(644,root,root,755)
181 /lib/modules/%{_kernel_ver}smp/MODULE_DIR/*.ko*
185 %if %{with userspace}
187 %defattr(644,root,root,755)