]> git.pld-linux.org Git - projects/template-specs.git/blob - kernel-module.spec
- BR: rpmbuild(macros) >= 1.330 -- build_kernel_modules fix for kernels 2.6.18
[projects/template-specs.git] / kernel-module.spec
1 #
2 # Replace MODULE_NAME with real module name and MODULE_DIR
3 # with required directory name.
4 #
5 # Conditional build:
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)
11
12 %if !%{with kernel}
13 %undefine       with_dist_kernel
14 %endif
15
16 #
17 # main package.
18 #
19 %define         _rel    0.1
20 Summary:        -
21 Summary(pl):    -
22 Name:           -
23 Version:        -
24 Release:        %{_rel}
25 Epoch:          0
26 #License:       - (enter GPL/LGPL/BSD/BSD-like/other license name here)
27 Group:          -
28 Source0:        %{name}-%{version}.tar.gz
29 # Source0-md5:  -
30 #Source1:       -
31 # Source1-md5:  -
32 #Patch0:        %{name}-what.patch
33 #URL:           -
34 %if %{with kernel}
35 %{?with_dist_kernel:BuildRequires:      kernel%{_alt_kernel}-module-build >= 3:2.6.14}
36 BuildRequires:  rpmbuild(macros) >= 1.330
37 %endif
38 #BuildRequires: -
39 #Requires(postun):      -
40 #Requires(pre,post):    -
41 #Requires(preun):       -
42 #Requires:      -
43 #Provides:      -
44 #Obsoletes:     -
45 #Conflicts:     -
46 BuildRoot:      %{tmpdir}/%{name}-%{version}-root-%(id -u -n)
47
48 %description
49
50 %description -l pl
51
52 # kernel subpackages.
53
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}
58 Group:          Base/Kernel
59 Requires(post,postun):  /sbin/depmod
60 %if %{with dist_kernel}
61 %requires_releq_kernel_up
62 Requires(postun):       %releq_kernel_up
63 %endif
64
65 %description -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME
66 This is driver for MODULE_NAME for Linux.
67
68 This package contains Linux module.
69
70 %description -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME -l pl
71 Sterownik dla Linuksa do MODULE_NAME.
72
73 Ten pakiet zawiera modu³ j±dra Linuksa.
74
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}
79 Group:          Base/Kernel
80 Requires(post,postun):  /sbin/depmod
81 %if %{with dist_kernel}
82 %requires_releq_kernel_smp
83 Requires(postun):       %releq_kernel_smp
84 %endif
85
86 %description -n kernel%{_alt_kernel}-smp-MODULE_DIR-MODULE_NAME
87 This is driver for MODULE_NAME for Linux.
88
89 This package contains Linux SMP module.
90
91 %description -n kernel%{_alt_kernel}-smp-MODULE_DIR-MODULE_NAME -l pl
92 Sterownik dla Linuksa do MODULE_NAME.
93
94 Ten pakiet zawiera modu³ j±dra Linuksa SMP.
95
96 %prep
97 # prepare makefile:
98 cat > path/to/dir/Makefile << EOF
99
100 obj-m += MODULE_NAME.o MODULE2.o
101
102 MODULE_NAME-objs := file1.o file2.o \
103         file3.o file4.o file5.o
104
105 MODULE2-objs := file6.o file7.o file8.o
106
107 CFLAGS += -DCONFIG_MODULE_NAME_SOME_OPTION=1
108 %{?debug:CFLAGS += -DCONFIG_MODULE_NAME_DEBUG=1}
109 EOF
110
111 %build
112 %if %{with userspace}
113
114
115 %endif
116
117 %if %{with kernel}
118 %build_kernel_modules -m MODULE_NAME
119
120 # modules placed in subdirectory:
121 %build_kernel_modules -C path/to/dir -m MODULE_NAME,MODULE2
122
123 # need to pass additional options to make modules:
124 %build_kernel_modules VAR1=value1 VAR2=value2 -m MODULE_NAME
125
126 # optional patching:
127 %build_kernel_modules -m MODULE_NAME <<'EOF'
128 # Your script here:
129 if grep -q "CONFIG_SOME_OPTION" o/.config; then
130         sed 's/some/change/' file.c.orig > file.c
131 else
132         cat file.c.orig > file.c
133 fi
134 # Don't do it this way unless it depends on kernel options or something
135 # you can't check before
136 EOF
137
138 %endif
139
140 %install
141 rm -rf $RPM_BUILD_ROOT
142
143 %if %{with userspace}
144
145
146 %endif
147
148 %if %{with kernel}
149 %install_kernel_modules -m MODULE_NAME -d MODULE_DIR
150
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
153 %endif
154
155 %clean
156 rm -rf $RPM_BUILD_ROOT
157
158 %post   -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME
159 %depmod %{_kernel_ver}
160
161 %postun -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME
162 %depmod %{_kernel_ver}
163
164 %post   -n kernel%{_alt_kernel}-smp-MODULE_DIR-MODULE_NAME
165 %depmod %{_kernel_ver}smp
166
167 %postun -n kernel%{_alt_kernel}-smp-MODULE_DIR-MODULE_NAME
168 %depmod %{_kernel_ver}smp
169
170 %if %{with kernel}
171 %files -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME
172 %defattr(644,root,root,755)
173 /lib/modules/%{_kernel_ver}/MODULE_DIR/*.ko*
174
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*
179 %endif
180 %endif
181
182 %if %{with userspace}
183 %files
184 %defattr(644,root,root,755)
185
186 %endif
This page took 0.083593 seconds and 4 git commands to generate.