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
31 Name: %{pname}%{_alt_kernel}
34 #License: - (enter GPL/LGPL/BSD/BSD-like/other license name here)
36 Source0: %{pname}-%{version}.tar.gz
40 #Patch0: %{pname}-what.patch
43 %{?with_dist_kernel:BuildRequires: kernel%{_alt_kernel}-module-build >= 3:2.6.20.2}
44 BuildRequires: rpmbuild(macros) >= 1.379
48 #Requires(pre,post): -
54 BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
58 %description -l pl.UTF-8
62 %package -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME
63 Summary: Linux driver for MODULE_NAME
64 Summary(pl.UTF-8): Sterownik dla Linuksa do MODULE_NAME
65 Release: %{rel}@%{_kernel_ver_str}
67 Requires(post,postun): /sbin/depmod
68 %if %{with dist_kernel}
69 %requires_releq_kernel
70 Requires(postun): %releq_kernel
73 %description -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME
74 This is driver for MODULE_NAME for Linux.
76 This package contains Linux module.
78 %description -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME -l pl.UTF-8
79 Sterownik dla Linuksa do MODULE_NAME.
81 Ten pakiet zawiera moduł jądra Linuksa.
84 %setup -q -n %{pname}-%{version}
87 cat > path/to/dir/Makefile << EOF
89 obj-m += MODULE_NAME.o MODULE2.o
91 MODULE_NAME-objs := file1.o file2.o \
92 file3.o file4.o file5.o
94 MODULE2-objs := file6.o file7.o file8.o
96 CFLAGS += -DCONFIG_MODULE_NAME_SOME_OPTION=1
97 %{?debug:CFLAGS += -DCONFIG_MODULE_NAME_DEBUG=1}
101 %if %{with userspace}
107 %build_kernel_modules -m MODULE_NAME
109 # modules placed in subdirectory:
110 %build_kernel_modules -C path/to/dir -m MODULE_NAME,MODULE2
112 # need to pass additional options to make modules:
113 %build_kernel_modules VAR1=value1 VAR2=value2 -m MODULE_NAME
116 %build_kernel_modules -m MODULE_NAME <<'EOF'
118 if grep -q "CONFIG_SOME_OPTION" o/.config; then
119 sed 's/some/change/' file.c.orig > file.c
121 cat file.c.orig > file.c
123 # Don't do it this way unless it depends on kernel options or something
124 # you can't check before
130 rm -rf $RPM_BUILD_ROOT
132 %if %{with userspace}
138 %install_kernel_modules -m MODULE_NAME -d kernel/MODULE_DIR
140 # to avoid conflict with in-kernel modules, and prepare modprobe config:
141 %install_kernel_modules -s current -n NAME -m MODULE_NAME -d kernel/MODULE_DIR
145 rm -rf $RPM_BUILD_ROOT
147 %post -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME
148 %depmod %{_kernel_ver}
150 %postun -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME
151 %depmod %{_kernel_ver}
154 %files -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME
155 %defattr(644,root,root,755)
156 /lib/modules/%{_kernel_ver}/kernel/MODULE_DIR/*.ko*
159 %if %{with userspace}
161 %defattr(644,root,root,755)