allow rpm to custom systemd installation
[platform/upstream/rpm.git] / packaging / rpm-tizen_macros
1 # directories
2 %_infodir               %{_prefix}/share/info
3 %_mandir                %{_prefix}/share/man
4 %_sysconfdir            /etc
5 %_localstatedir         /var
6 %_defaultdocdir         %{_usr}/share/doc/packages
7
8 # _rootprefix can be set to (/,%{_prefix}) to customize systemd installation)
9 %_rootprefix %{_prefix}
10 %_unitdir_user %{_prefix}/lib/systemd/user
11 %_unitdir %{_rootprefix}/lib/systemd/system
12
13 # package build macros
14 # %make_install           make install DESTDIR=%{?buildroot}
15 # %makeinstall            make DESTDIR=%{?buildroot:%{buildroot}} install
16 %rb_arch                %(echo %{_host_cpu}-linux | sed -e "s/i686/i586/" -e "s/armv5tel/armv4l/" -e "s/hppa2.0/hppa/")
17 %rb_ver                 %(/usr/bin/ruby -e 'puts VERSION.sub(/\\\.\\\d$/, "")')
18
19 # external kernel module helper macro(s)
20 %kernel_devel_uname_r %(/bin/rpm -q --provides $(/bin/rpm -q --whatprovides kernel-devel-uname-r) | sed -ne 's,kernel-devel-uname-r = ,, p')
21 %kernel_release %(/bin/rpm -q --queryformat '%{RPMTAG_VERSION}-%{RPMTAG_RELEASE}' $(/bin/rpm -q --whatprovides kernel))
22 %kernel_name    %(/bin/rpm -q --queryformat '%{RPMTAG_NAME}' $(/bin/rpm -q --whatprovides kernel))
23
24 # this script calls all scripts in /usr/lib/rpm/brp-tizen.d
25 %__os_install_post  \
26         /usr/lib/rpm/brp-compress \
27         /usr/lib/rpm/brp-tizen  \
28         %{!?disable_docs_package:/usr/lib/rpm/tizen/find-docs.sh %{buildroot}} \
29 %{nil}
30
31 # macro: %configure_kernel_source
32 #
33 #
34 %configure_kernel_source() \
35         if test -d /usr/src/linux ; then \
36             pushd /usr/src/linux \
37             test -f .config || cp arch/%_arch/defconfig.default .config \
38             yes "" | make oldconfig \
39             make dep \
40             popd \
41         fi \
42         %nil
43
44 %install_info(:-:) \
45     ALL_ARGS=(%{**}) \
46     NUM_ARGS=${#ALL_ARGS[@]} \
47     if test -x /sbin/install-info ; then \
48         if test -e "${ALL_ARGS[$((NUM_ARGS-1))]}" ; then \
49             /sbin/install-info "${ALL_ARGS[@]}" \
50         fi \
51     fi ; 
52
53 %install_info_delete(:-:) \
54     ALL_ARGS=(%{**}) \
55     NUM_ARGS=${#ALL_ARGS[@]} \
56     if test -x /sbin/install-info ; then \
57         if ! test -e "${ALL_ARGS[$((NUM_ARGS-1))]}" ; then \
58             /sbin/install-info --quiet --delete "${ALL_ARGS[@]}" \
59         fi ; \
60     fi ; 
61
62 # find-supplements.ksyms parses this macro directly out of the spec file:
63 %supplements_kernel_module() \
64     %{expand:%(if ! rpm -q kernel-syms > /dev/null; then echo "%fail Please add the kernel-syms package to BuildRequires"; fi)}
65
66 %do_profiling 1
67 %cflags_profile_generate -fprofile-generate
68 %cflags_profile_feedback -fprofile-use
69
70
71
72 # Tizen
73 #
74 %configure \
75   CFLAGS="${CFLAGS:-%optflags}" ; export CFLAGS ; \
76   CXXFLAGS="${CXXFLAGS:-%optflags}" ; export CXXFLAGS ; \
77   FFLAGS="${FFLAGS:-%optflags -I%_fmoddir}" ; export FFLAGS ; \
78   ./configure --build=%{_build} --host=%{_host} \\\
79         --program-prefix=%{?_program_prefix} \\\
80         --prefix=%{_prefix} \\\
81         --exec-prefix=%{_exec_prefix} \\\
82         --bindir=%{_bindir} \\\
83         --sbindir=%{_sbindir} \\\
84         --sysconfdir=%{_sysconfdir} \\\
85         --datadir=%{_datadir} \\\
86         --includedir=%{_includedir} \\\
87         --libdir=%{_libdir} \\\
88         --libexecdir=%{_libexecdir} \\\
89         --localstatedir=%{_localstatedir} \\\
90         --sharedstatedir=%{_sharedstatedir} \\\
91         --mandir=%{_mandir} \\\
92         --infodir=%{_infodir}
93
94
95 %reconfigure \
96   CFLAGS="${CFLAGS:-%optflags}" ; export CFLAGS ; \
97   CXXFLAGS="${CXXFLAGS:-%optflags}" ; export CXXFLAGS ; \
98   FFLAGS="${FFLAGS:-%optflags -I%_fmoddir}" ; export FFLAGS ; \
99   autoreconf -v --install --force || exit 1 \
100   ./configure --build=%{_build} --host=%{_host} \\\
101         --program-prefix=%{?_program_prefix} \\\
102         --prefix=%{_prefix} \\\
103         --exec-prefix=%{_exec_prefix} \\\
104         --bindir=%{_bindir} \\\
105         --sbindir=%{_sbindir} \\\
106         --sysconfdir=%{_sysconfdir} \\\
107         --datadir=%{_datadir} \\\
108         --includedir=%{_includedir} \\\
109         --libdir=%{_libdir} \\\
110         --libexecdir=%{_libexecdir} \\\
111         --localstatedir=%{_localstatedir} \\\
112         --sharedstatedir=%{_sharedstatedir} \\\
113         --mandir=%{_mandir} \\\
114         --infodir=%{_infodir}
115
116 %autogen \
117   CFLAGS="${CFLAGS:-%optflags}" ; export CFLAGS ; \
118   CXXFLAGS="${CXXFLAGS:-%optflags}" ; export CXXFLAGS ; \
119   FFLAGS="${FFLAGS:-%optflags -I%_fmoddir}" ; export FFLAGS ; \
120   ./autogen.sh --build=%{_build} --host=%{_host} \\\
121         --program-prefix=%{?_program_prefix} \\\
122         --prefix=%{_prefix} \\\
123         --exec-prefix=%{_exec_prefix} \\\
124         --bindir=%{_bindir} \\\
125         --sbindir=%{_sbindir} \\\
126         --sysconfdir=%{_sysconfdir} \\\
127         --datadir=%{_datadir} \\\
128         --includedir=%{_includedir} \\\
129         --libdir=%{_libdir} \\\
130         --libexecdir=%{_libexecdir} \\\
131         --localstatedir=%{_localstatedir} \\\
132         --sharedstatedir=%{_sharedstatedir} \\\
133         --mandir=%{_mandir} \\\
134         --infodir=%{_infodir}
135
136
137 %makeinstall \
138   %{__make} \\\
139         prefix=%{?buildroot:%{buildroot}}%{_prefix} \\\
140         exec_prefix=%{?buildroot:%{buildroot}}%{_exec_prefix} \\\
141         bindir=%{?buildroot:%{buildroot}}%{_bindir} \\\
142         sbindir=%{?buildroot:%{buildroot}}%{_sbindir} \\\
143         sysconfdir=%{?buildroot:%{buildroot}}%{_sysconfdir} \\\
144         datadir=%{?buildroot:%{buildroot}}%{_datadir} \\\
145         includedir=%{?buildroot:%{buildroot}}%{_includedir} \\\
146         libdir=%{?buildroot:%{buildroot}}%{_libdir} \\\
147         libexecdir=%{?buildroot:%{buildroot}}%{_libexecdir} \\\
148         localstatedir=%{?buildroot:%{buildroot}}%{_localstatedir} \\\
149         sharedstatedir=%{?buildroot:%{buildroot}}%{_sharedstatedir} \\\
150         mandir=%{?buildroot:%{buildroot}}%{_mandir} \\\
151         infodir=%{?buildroot:%{buildroot}}%{_infodir} \\\
152   install
153
154
155 %make_install \
156   %{__make} \\\
157         DESTDIR=%{?buildroot:%{buildroot}} \\\
158         INSTALL_ROOT=%{?buildroot:%{buildroot}} \\\
159   install  \
160   rm -f %{?buildroot:%{buildroot}}%{_infodir}/dir \
161   find %{?buildroot:%{buildroot}} -regex ".*\\.la$" | xargs rm -f -- \
162   %{!?keepstatic:find %{?buildroot:%{buildroot}} -regex ".*\\.a$" | xargs rm -f --}
163
164 %_smp_mflags %([ -z "$RPM_BUILD_NCPUS" ] \\\
165         && RPM_BUILD_NCPUS="`/usr/bin/getconf _NPROCESSORS_ONLN`"; \\\
166         [ "$RPM_BUILD_NCPUS" -gt 1 ] && echo "-j$RPM_BUILD_NCPUS")
167
168 %lang_package(n:f:) \
169 %package %{-n:-n %{-n*}-}locale \
170 Summary: Translations and Locale for package %{name}\
171 Requires: %{-n:%{-n*}}%{!-n:%{name}} = %{version} \
172 Provides: %{-n:%{-n*}}%{!-n:%{name}}-lang-all = %{version} \
173 BuildArch:  noarch \
174 %description %{-n:-n %{-n*}-}locale\
175 This package provides translations for package %{name}.\
176 %files %{-n:-n %{-n*}-}locale -f %{-f:%{-f*}.lang} %{!-f:%{name}.lang}\
177 %defattr(-,root,root,-)\
178 %{nil}
179
180 %docs_package \
181 %package docs \
182 Summary: Documentation for package %{name}\
183 AutoReqProv: 0\
184 %description docs\
185 This package provides documentation for package %{name}.\
186 %files docs -f documentation.list\
187 %defattr(-,root,root,-)\
188 %{nil}
189
190 # Bad hack to set $LANG to C during all RPM builds
191 %prep \
192 %%prep\
193 LANG=C\
194 export LANG\
195 unset DISPLAY\
196 %{nil}
197
198 %build %%build\
199 LANG=C\
200 export LANG\
201 unset DISPLAY\
202 CFLAGS="%optflags" ; export CFLAGS ; \
203 CXXFLAGS="${CXXFLAGS:-%optflags}" ; export CXXFLAGS ; \
204 FFLAGS="${FFLAGS:-%optflags -I%_fmoddir}" ; export FFLAGS ; \
205 LD_AS_NEEDED=1; export LD_AS_NEEDED ; \
206 %{nil}
207
208 %install %{?_enable_debug_packages:%{?buildsubdir:%{debug_package}}}\
209 %%install\
210 LANG=C\
211 export LANG\
212 unset DISPLAY\
213 rm -rf %{?buildroot:%{buildroot}} \
214 mkdir -p %{?buildroot:%{buildroot}} \
215 %{nil}
216
217
218 %clean %%clean\
219 rm -rf %{?buildroot:%{buildroot}} \
220 %{nil}
221
222 %find_lang      /usr/lib/rpm/find-lang.sh %{buildroot}
223 %find_docs      /usr/lib/rpm/tizen/find-docs.sh %{buildroot}
224
225
226
227 #==============================================================================
228 # ---- default .desktop directories per the desktop-entry freedesktop.org spec
229
230 %_desktopdir    %{_datadir}/applications
231
232 #==============================================================================
233 # ---- Generic auto req/prov filtering macros
234 #
235 # http://fedoraproject.org/wiki/PackagingDrafts/AutoProvidesAndRequiresFiltering
236
237 # prevent anything matching from being scanned for provides
238 %filter_provides_in(P) %{expand: \
239 %global __filter_prov_cmd %{?__filter_prov_cmd} %{__grep} -v %{-P} '%*' | \
240 }
241
242 # prevent anything matching from being scanned for requires
243 %filter_requires_in(P) %{expand: \
244 %global __filter_req_cmd %{?__filter_req_cmd} %{__grep} -v %{-P} '%*' | \
245 }
246
247 # filter anything matching out of the provides stream
248 %filter_from_provides() %{expand: \
249 %global __filter_from_prov %{?__filter_from_prov} | %{__sed} -e '%*' \
250 }
251
252 # filter anything matching out of the requires stream
253 %filter_from_requires() %{expand: \
254 %global __filter_from_req %{?__filter_from_req} | %{__sed} -e '%*' \
255 }
256
257 # actually set up the filtering bits
258 %filter_setup %{expand: \
259 %global _use_internal_dependency_generator 0 \
260 %global __deploop() while read FILE; do /usr/lib/rpm/rpmdeps -%{1} ${FILE}; done | /bin/sort -u \
261 %global __find_provides /bin/sh -c "%{?__filter_prov_cmd} %{__deploop P} %{?__filter_from_prov}" \
262 %global __find_requires /bin/sh -c "%{?__filter_req_cmd}  %{__deploop R} %{?__filter_from_req}" \
263 }
264
265 %remove_docs \
266   rm -rf %{?buildroot:%{buildroot}}%{_infodir} \
267   rm -rf %{?buildroot:%{buildroot}}%{_defaultdocdir} \
268   rm -rf %{?buildroot:%{buildroot}}%{_datadir}/doc/%{name} \
269   rm -rf %{?buildroot:%{buildroot}}%{_datadir}/doc/%{name}-%{version} \
270   rm -rf %{?buildroot:%{buildroot}}%{_datadir}/gtk-doc \
271   rm -rf %{?buildroot:%{buildroot}}%{_datadir}/doc \
272   rm -rf %{?buildroot:%{buildroot}}%{_datadir}/man \
273   find %{?buildroot:%{buildroot}} -regex ".*/man/man./.*\.[0-9]" | xargs rm -f -- \
274   find %{?buildroot:%{buildroot}} -regex ".*/man/../man./.*\.[0-9]" | xargs rm -f -- \
275   find %{?buildroot:%{buildroot}} -regex ".*/man/man./.*\.[0-9]pm" | xargs rm -f --
276
277
278 %install_service() \
279 mkdir -p %{buildroot}/%{_unitdir}/%{1} \
280 ln -s ../%{2}  %{buildroot}/%{_unitdir}/%{1}/%{2}  \
281 %{nil}
282
283
284 %_fontsdir               %{_usr}/share/fonts
285 %_ttfontsdir             %{_fontsdir}/truetype
286 %_miscfontsdir           %{_fontsdir}/misc
287 %_fontsconfdir           %{_sysconfdir}/fonts
288 %_fontsconfddir          %{_fontsconfdir}/conf.d
289 %_fontsconfavaildir      %{_datadir}/%{name}/conf.avail
290
291 %devel_package \
292 %package devel \
293 Summary: Development files for package %{name}\
294 Group: Development\
295 %description devel\
296 This package provides header files and other developer releated files for package %{name}.\
297 %files devel \
298 %{_includedir}/*\
299 %{_libdir}/pkgconfig/*.pc\
300 %{_libdir}/*.so\
301 %{nil}
302
303 %devel_desc This package contains all necessary include files and libraries needed \
304 to develop applications that require %{name}.\
305 %{nil}
306