]>
Commit | Line | Data |
---|---|---|
f9ab3660 | 1 | # |
56ee4433 ER |
2 | # Replace: |
3 | # MODULE_NAME with real module name | |
4 | # MODULE_DIR with required directory name | |
5 | # PACKAGE_NAME with package name | |
5ff61201 | 6 | # |
f9ab3660 | 7 | # Conditional build: |
f9ab3660 | 8 | %bcond_without kernel # don't build kernel modules |
7f898902 | 9 | %bcond_without userspace # don't build userspace programs |
f9ab3660 | 10 | %bcond_with verbose # verbose build (V=1) |
4e1a22e1 | 11 | |
5adcc8ae JR |
12 | %if 0%{?_pld_builder:1} && %{with kernel} && %{with userspace} |
13 | %{error:kernel and userspace cannot be built at the same time on PLD builders} | |
14 | exit 1 | |
15 | %endif | |
16 | ||
56ee4433 ER |
17 | %if %{without userspace} |
18 | # nothing to be placed to debuginfo package | |
19 | %define _enable_debug_packages 0 | |
20 | %endif | |
f9ab3660 PS |
21 | # |
22 | # main package. | |
23 | # | |
4916acb7 | 24 | %define rel 0.1 |
56ee4433 | 25 | %define pname PACKAGE_NAME |
62d8299f | 26 | Summary: - |
ce39d734 | 27 | Summary(pl.UTF-8): - |
b07c5c38 | 28 | Name: %{pname}%{?_pld_builder:%{?with_kernel:-kernel}}%{_alt_kernel} |
b0d894d8 | 29 | Version: 0.1 |
b07c5c38 | 30 | Release: %{rel}%{?_pld_builder:%{?with_kernel:@%{_kernel_ver_str}}} |
96f971dd | 31 | #License: - (enter GPL/LGPL/BSD/BSD-like/other license name here) |
aab781ab | 32 | Group: Base/Kernel |
56ee4433 | 33 | Source0: %{pname}-%{version}.tar.gz |
62d8299f | 34 | # Source0-md5: - |
96f971dd | 35 | #Source1: - |
62d8299f | 36 | # Source1-md5: - |
56ee4433 | 37 | #Patch0: %{pname}-what.patch |
96f971dd | 38 | #URL: - |
d3b4d5e6 JR |
39 | BuildRequires: rpmbuild(macros) >= 1.701 |
40 | %{?with_kernel:%{expand:%buildrequires_kernel kernel%%{_alt_kernel}-module-build >= 3:2.6.20.2}} | |
96f971dd | 41 | #BuildRequires: - |
ecd953f6 | 42 | #Requires(postun): - |
96f971dd ER |
43 | #Requires(pre,post): - |
44 | #Requires(preun): - | |
96f971dd ER |
45 | #Requires: - |
46 | #Provides: - | |
47 | #Obsoletes: - | |
48 | #Conflicts: - | |
62d8299f PS |
49 | BuildRoot: %{tmpdir}/%{name}-%{version}-root-%(id -u -n) |
50 | ||
51 | %description | |
52 | ||
9be49f18 | 53 | %description -l pl.UTF-8 |
f9ab3660 | 54 | |
5adcc8ae JR |
55 | # kernel subpackages definition. |
56 | ||
57 | %define kernel_pkg()\ | |
58 | %package -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME\ | |
59 | Summary: Linux driver for MODULE_NAME\ | |
60 | Summary(pl.UTF-8): Sterownik dla Linuksa do MODULE_NAME\ | |
61 | Release: %{rel}@%{_kernel_ver_str}\ | |
62 | Group: Base/Kernel\ | |
63 | Requires(post,postun): /sbin/depmod\ | |
5adcc8ae JR |
64 | %requires_releq_kernel\ |
65 | Requires(postun): %releq_kernel\ | |
5adcc8ae JR |
66 | \ |
67 | %description -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME\ | |
68 | This is driver for MODULE_NAME for Linux.\ | |
69 | \ | |
70 | This package contains Linux module.\ | |
71 | \ | |
72 | %description -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME -l pl.UTF-8\ | |
73 | Sterownik dla Linuksa do MODULE_NAME.\ | |
74 | \ | |
75 | Ten pakiet zawiera moduł jądra Linuksa.\ | |
76 | \ | |
77 | %if %{with kernel}\ | |
78 | %files -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME\ | |
79 | %defattr(644,root,root,755)\ | |
80 | /lib/modules/%{_kernel_ver}/kernel/MODULE_DIR/*.ko*\ | |
81 | %endif\ | |
82 | \ | |
83 | %post -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME\ | |
84 | %depmod %{_kernel_ver}\ | |
85 | \ | |
86 | %postun -n kernel%{_alt_kernel}-MODULE_DIR-MODULE_NAME\ | |
87 | %depmod %{_kernel_ver}\ | |
88 | %{nil} | |
89 | ||
90 | %define build_kernel_pkg()\ | |
91 | %build_kernel_modules -m MODULE_NAME\ | |
92 | \ | |
93 | # modules placed in subdirectory:\ | |
94 | %build_kernel_modules -C path/to/dir -m MODULE_NAME,MODULE2\ | |
95 | \ | |
96 | # need to pass additional options to make modules:\ | |
97 | %build_kernel_modules VAR1=value1 VAR2=value2 -m MODULE_NAME\ | |
98 | \ | |
99 | # optional patching:\ | |
100 | %build_kernel_modules -m MODULE_NAME <<'EOF'\ | |
101 | # Your script here:\ | |
102 | if grep -q "CONFIG_SOME_OPTION" o/.config; then\ | |
103 | sed 's/some/change/' file.c.orig > file.c\ | |
104 | else\ | |
105 | cat file.c.orig > file.c\ | |
106 | fi\ | |
107 | # Don't do it this way unless it depends on kernel options or something\ | |
108 | # you can't check before\ | |
109 | EOF\ | |
110 | \ | |
111 | # install to local directory, this makes building for multiple kernels easy\ | |
112 | %install_kernel_modules -D installed -m MODULE_NAME -d kernel/MODULE_DIR\ | |
113 | \ | |
114 | # to avoid conflict with in-kernel modules, and prepare modprobe config:\ | |
115 | %install_kernel_modules -D installed -s current -n NAME -m MODULE_NAME -d kernel/MODULE_DIR\ | |
116 | %{nil} | |
117 | ||
118 | %define install_kernel_pkg()\ | |
119 | # any additional, per-module, tasks needed at install,\ | |
120 | # like blacklisting in-kernel module to always load this one\ | |
121 | install -d $RPM_BUILD_ROOT/etc/modprobe.d/%{_kernel_ver}\ | |
122 | # blacklist kernel module\ | |
123 | cat > $RPM_BUILD_ROOT/etc/modprobe.d/%{_kernel_ver}/MODULE_NAME.conf <<'EOF'\ | |
124 | blacklist MODULE_NAME\ | |
125 | alias MODULE_NAME MODULE_NAME-current\ | |
126 | EOF\ | |
127 | %{nil} | |
128 | ||
d3b4d5e6 | 129 | %{?with_kernel:%{expand:%create_kernel_packages}} |
f9ab3660 | 130 | |
61855f4e | 131 | %prep |
56ee4433 ER |
132 | %setup -q -n %{pname}-%{version} |
133 | ||
1e940dea | 134 | # prepare makefile: |
135 | cat > path/to/dir/Makefile << EOF | |
136 | ||
137 | obj-m += MODULE_NAME.o MODULE2.o | |
138 | ||
139 | MODULE_NAME-objs := file1.o file2.o \ | |
140 | file3.o file4.o file5.o | |
141 | ||
142 | MODULE2-objs := file6.o file7.o file8.o | |
143 | ||
144 | CFLAGS += -DCONFIG_MODULE_NAME_SOME_OPTION=1 | |
145 | %{?debug:CFLAGS += -DCONFIG_MODULE_NAME_DEBUG=1} | |
146 | EOF | |
61855f4e | 147 | |
f9ab3660 | 148 | %build |
d3b4d5e6 JR |
149 | %{?with_kernel:%{expand:%build_kernel_packages}} |
150 | ||
f9ab3660 PS |
151 | %if %{with userspace} |
152 | ||
f9ab3660 PS |
153 | %endif |
154 | ||
f9ab3660 PS |
155 | %install |
156 | rm -rf $RPM_BUILD_ROOT | |
5adcc8ae | 157 | install -d $RPM_BUILD_ROOT |
f9ab3660 | 158 | |
f9ab3660 | 159 | %if %{with kernel} |
d3b4d5e6 | 160 | %{expand:%install_kernel_packages} |
5adcc8ae | 161 | cp -a installed/* $RPM_BUILD_ROOT |
f9ab3660 PS |
162 | %endif |
163 | ||
d3b4d5e6 JR |
164 | %if %{with userspace} |
165 | ||
166 | %endif | |
167 | ||
f9ab3660 PS |
168 | %clean |
169 | rm -rf $RPM_BUILD_ROOT | |
170 | ||
f9ab3660 | 171 | %if %{with userspace} |
e85ad390 | 172 | %files |
f9ab3660 | 173 | %defattr(644,root,root,755) |
f9ab3660 | 174 | %endif |