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