]> git.pld-linux.org Git - packages/rpm-build-macros.git/blame - rpm.macros
- reworked find-*-wrappers, userpmdepswrappers patch, macros and platform macros
[packages/rpm-build-macros.git] / rpm.macros
CommitLineData
d54662bf
AF
1# PLD rpm macros
2
8f74418b
MM
3%__id @__ID@
4%__id_u %{__id} -u
5%__chown_Rhf @__CHOWN_RHF@
6%__chgrp_Rhf @__CHGRP_RHF@
7
d54662bf
AF
8%_fixowner [ `%{__id_u}` = '0' ] && %{__chown_Rhf} root.@ROOT_GROUP@
9%_fixgroup true
8f74418b 10%_fixperms %{__chmod} -Rf @FIXPERMS@
d54662bf 11%_topdir %(echo $HOME)/rpm
9c404149
AM
12#-----------------------------------------------------------------
13# CFLAGS and LDFLAGS used to build
14
8f74418b 15%debugcflags -O0 -g -Wall
9c404149
AM
16%rpmcflags %{?debug:%debugcflags}%{!?debug:%optflags}
17%rpmldflags %{!?debug:-s}
18
ba1fdedc 19# kernel compiler
d2e1bc22 20%kgcc gcc
21%kgcc_package gcc
ba1fdedc 22
33040789 23# Build system path macros.
24#
25%__libtoolize libtoolize --copy --force
83094b62 26%__gettextize { \
afff6d37 27 if ! gettextize --version | grep -q '0\.10\.' ; then \
8a995cff
JB
28 if grep -qs 'AM_GNU_GETTEXT.*external' configure.{ac,in} ; then \
29 gettextize --copy --force --no-changelog; \
97589b6e 30 else \
8a995cff
JB
31 gettextize --copy --force --no-changelog --intl; \
32 fi; \
33 if [ ! -f po/Makevars ]; then \
34 cp -f po/Makevars{.template,}; \
35 fi; \
36 else \
37 gettextize --copy --force; \
83094b62 38 fi; \
8a995cff
JB
39}
40%__autopoint autopoint --force
bcdab9c2 41%__automake automake -a -c -f --foreign
be3a1985 42%__autoconf autoconf %{?debug:-Wall}
33040789 43
9c404149 44#-----------------------------------------------------------------
9f4ce098 45%configure2_13 { \
9c404149
AM
46 if [ -n "$LINGUAS" ]; then unset LINGUAS; fi; \
47 LDFLAGS="${LDFLAGS:-%rpmldflags}" ; export LDFLAGS ; \
48 CFLAGS="${CFLAGS:-%rpmcflags}" ; export CFLAGS ; \
49 CXXFLAGS="${CXXFLAGS:-%rpmcflags}" ; export CXXFLAGS ; \
50 FFLAGS="${FFLAGS:-%rpmcflags}" ; export FFLAGS ; \
8ec1a12b 51 CPPFLAGS="${CPPFLAGS:-}" ; export CPPFLAGS ; \
ae5d93df
AM
52 %{?__cc:CC=%{__cc} ; export CC ; } \
53 %{?__cxx:CXX=%{__cxx} ; export CXX ; } \
8f74418b 54 %{?configuredir:%{configuredir}}%{!?configuredir:.}/configure \
2a7cfd3f 55 --host=%{_target_platform} \
9c404149
AM
56 --prefix=%{_prefix} \
57 --exec-prefix=%{_exec_prefix} \
58 --bindir=%{_bindir} \
59 --sbindir=%{_sbindir} \
60 --sysconfdir=%{_sysconfdir} \
61 --datadir=%{_datadir} \
62 --includedir=%{_includedir} \
63 --libdir=%{_libdir} \
64 --libexecdir=%{_libexecdir} \
65 --localstatedir=%{_localstatedir} \
66 --sharedstatedir=%{_sharedstatedir} \
67 --mandir=%{_mandir} \
68 --infodir=%{_infodir} \
69}
70
4a6b0d54 71#----------------------------------------------------------------
57f4166d 72%configure {./configure \
4a6b0d54
AF
73 LDFLAGS="${LDFLAGS:-%rpmldflags}" \
74 CFLAGS="${CFLAGS:-%rpmcflags}" \
75 CXXFLAGS="${CXXFLAGS:-%rpmcflags}" \
76 FFLAGS="${FFLAGS:-%rpmcflags}" \
a2bd5992 77 CPPFLAGS="${CPPFLAGS:-}" \
9f4ce098
AF
78 %{?__cc:CC=%{__cc}} \
79 %{?__cxx:CXX=%{__cxx}} \
4a6b0d54
AF
80 --build=%{_target_platform} \
81 --prefix=%{_prefix} \
82 --exec-prefix=%{_exec_prefix} \
83 --bindir=%{_bindir} \
84 --sbindir=%{_sbindir} \
85 --sysconfdir=%{_sysconfdir} \
86 --datadir=%{_datadir} \
87 --includedir=%{_includedir} \
88 --libdir=%{_libdir} \
89 --libexecdir=%{_libexecdir} \
90 --localstatedir=%{_localstatedir} \
91 --sharedstatedir=%{_sharedstatedir} \
92 --mandir=%{_mandir} \
93 --infodir=%{_infodir} \
94}
95
7dbab518
MM
96# ------------------------------------------------------------------------
97# Conditional build stuff.
98
99# Check if symbol is defined.
100# Example usage: %if %{defined with_foo} && %{undefined with_bar} ...
101%defined() %{expand:%%{?%{1}:1}%%{!?%{1}:0}}
102%undefined() %{expand:%%{?%{1}:0}%%{!?%{1}:1}}
103
566fa098
MM
104# Shorthand for %{defined with_...}
105%with() %{expand:%%{?with_%{1}:1}%%{!?with_%{1}:0}}
106%without() %{expand:%%{?with_%{1}:0}%%{!?with_%{1}:1}}
107
7dbab518
MM
108# Handle conditional builds. %bcond_with is for case when feature is
109# default off and needs to be activated with --with ... command line
110# switch. %bcond_without is for the dual case.
111#
112# %bcond_with foo defines symbol with_foo if --with foo was specified on
113# command line.
114# %bcond_without foo defines symbol with_foo if --without foo was *not*
115# specified on command line.
116#
117# For example:
118#
119# %bcond_with extra_fonts
120# %bcond_without static
f52f9976 121# %if %{with extra_fonts}
7dbab518
MM
122# ...
123# %endif
f52f9976 124# %ifdef %{with static}
7dbab518
MM
125# ...
126# %endif
127# %{?with_static: ... }
128# %{!?with_static: ... }
129# %{?with_extra_fonts: ... }
130# %{!?with_extra_fonts: ... }
131#
132# The bottom line: never use without_foo, _with_foo nor _without_foo, only
133# with_foo. This way changing default set of bconds for given spec is just
134# a matter of changing single line in it and syntax is more readable.
135%bcond_with() %{expand:%%{?_with_%{1}:%%global with_%{1} 1}}
136%bcond_without() %{expand:%%{!?_without_%{1}:%%global with_%{1} 1}}
137# ------------------------------------------------------------------------
138
9c404149
AM
139# Location of autoconf macros
140%_aclocaldir %(aclocal --print-ac-dir)
141
e2804f99
AM
142# Location of omf files
143%_omf_dest_dir %(scrollkeeper-config --omfdir)
144
e987a186 145# Location of pkgconfig files
d7021551 146%_pkgconfigdir /usr/lib/pkgconfig
e987a186 147
9c404149 148# Location of top applink dir
30562d7e 149%_applnkdir /usr/X11R6/share/applnk
9c404149 150
486b0b5f 151# Location of desktop files
152%_desktopdir /usr/share/applications
153
9c404149 154# Location pixmaps for applnk/desktop files
e1f0a822 155%_pixmapsdir /usr/share/pixmaps
9c404149 156
e987a186
JB
157# Location of fonts directories
158%_fontsdir /usr/share/fonts
159
b3282f3f 160# Location of Gtk and associated libraries documentation
6eed6d84 161%_gtkdocdir %{_defaultdocdir}/gtk-doc/html
b3282f3f 162
9c404149
AM
163# Current date
164%date %(LC_ALL="C" date +"%a %b %d %Y")
165
166# tmp directory
167%tmpdir %(echo "${TMPDIR:-/tmp}")
168
169# Example files, programs, scripts...
170%_examplesdir /usr/src/examples
171
8377d27d 172# The directory holding Linux kernel sources
173%_kernelsrcdir /usr/src/linux
174
9c404149 175# If non-empty "debug" macro defined, add "dbg" suffix to release number
8f74418b 176%_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}%{?debug:dbg}.%%{ARCH}.rpm
9c404149 177
8f74418b
MM
178# Requires name = version-release
179%requires_releq() %(LC_ALL="C" echo '%*' | xargs -r rpm -q --qf 'Requires: %%{name} = %%{epoch}:%%{version}-%%{release}\\n' | sed -e 's/ (none):/ /' -e 's/ 0:/ /' | grep -v "is not")
180%requires_releq_kernel_up() %(LC_ALL="C" rpm -qf --qf 'Prereq: kernel-up = %%{epoch}:%%{version}-%%{release}\\n' %{_kernelsrcdir}/include/linux/version.h | sed -e 's/ (none):/ /' -e 's/ 0:/ /' | grep -vE "(is not|no such)")
181%requires_releq_kernel_smp() %(LC_ALL="C" rpm -qf --qf 'Prereq: kernel-smp = %%{epoch}:%%{version}-%%{release}\\n' %{_kernelsrcdir}/include/linux/version.h | sed -e 's/ (none):/ /' -e 's/ 0:/ /' | grep -vE "(is not|no such)")
01a9f990
AF
182%requires_eq_to %(LC_ALL="C" rpm -q --qf 'Requires: %1 = %%{epoch}:%%{version}\\n' %2 | sed -e 's/ (none):/ /' -e 's/ 0:/ /' | grep -v "is not")
183
184%apache_modules_api %(awk '/#define MODULE_MAGIC_NUMBER_MAJOR/ {print $3}' `apr-config --includedir`/ap_mmn.h)
b9d5d440 185
186# kernel version-release handling
187%__kernel_ver %(grep UTS_RELEASE %{_kernelsrcdir}/include/linux/version.h 2>/dev/null | cut -d'"' -f2)
188%__kernel_rel %(LC_ALL="C" rpm -qf %{_kernelsrcdir}/include/linux/version.h --queryformat "%{RELEASE}" | grep -v "is not")
189%_kernel_ver %(echo %{__kernel_ver}%{!?_without_dist_kernel:-%{__kernel_rel}})
190%_kernel_ver_str %(echo %{_kernel_ver} | sed s/-/_/g)
87be1cf0 191
e00dd7f6 192# sgml macros
193%xmlcat_add() /usr/bin/xmlcatalog --noout --add nextCatalog \"\" %1 /etc/xml/catalog
194%xmlcat_del() /usr/bin/xmlcatalog --noout --del %1 /etc/xml/catalog
195%xmlcat_add_rewrite /usr/bin/xmlcatalog --noout --add rewriteSystem
196%xmlcat_create() /usr/bin/xmlcatalog --noout --create %1
197%sgmlcat_add() /usr/bin/install-catalog --add %1 %2 > /dev/null
198%sgmlcat_del() /usr/bin/install-catalog --remove %1 %2 > /dev/null
199%docbook_sgmlcat_fix() { for l in \
200'' \
201' -- default decl --' \
202'DTDDECL "-//OASIS//DTD DocBook XML V%2//EN" "../../xml.dcl"' \
203' -- hacks for opensp --' \
204'SYSTEM "file://%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd" "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
205'SYSTEM "http://www.oasis-open.org/docbook/xml/%2/docbookx.dtd" "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
206'' \
207; do echo $l; done >> %1 \
208}
209
9c404149
AM
210#-----------------------------------------------------------------
211# find and gzip all files in %{_mandir} and %{infodir}
212#
213# Requires: xargs, find
214#
215#%no_install_post_compress_docs 1
216%__spec_install_post_compress_docs { \
217echo "Compress man and info pages."; \
218%{!?no_install_post_compress_docs: \
219 %{?verbose:set -x;} \
220 for i in /usr/share/man /usr/X11R6/man /usr/share/info; do \
221 if [ -d "$RPM_BUILD_ROOT$i" ]; then \
222 find "$RPM_BUILD_ROOT$i" -name \*.bz2 -print | xargs -r %{__bzip2} -df; \
223 find "$RPM_BUILD_ROOT$i" -name \*.gz -print | xargs -r %{__gzip} -dnf; \
224 find "$RPM_BUILD_ROOT$i" -type f -print | xargs -r %{__gzip} -9nf; \
225 fi; \
226 done; \
227} }
228
229#-----------------------------------------------------------------
230# Strip executable binaries and shared object files
231#
232# Requires: find, awk, strip, cut, xargs
233#
234#%no_install_post_strip 1
235%__spec_install_post_strip {%{!?debug: \
236%{!?no_install_post_strip: \
237 %{?verbose:set -x;} \
8f74418b 238 echo "Strip executable binaries, archives and shared object files."; \
9c404149
AM
239 filelist=`find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*"`; \
240 elfexelist=`echo $filelist | xargs -r file | \
241 awk '/ELF.*executable/ {print $1}' | cut -d: -f1`; \
242 elfsharedlist=`echo $filelist | xargs -r file | \
243 awk '/LF.*shared object/ {print $1}' | cut -d: -f1`; \
8f74418b
MM
244 elfarchiveslist=`echo $filelist | xargs -r file | \
245 awk '/current ar archive/ {print $1}' | cut -d: -f1`; \
9c404149
AM
246 if [ -n "$elfexelist" ]; then \
247 strip --remove-section=.note --remove-section=.comment $elfexelist; \
248 fi; \
249 if [ -n "$elfsharedlist" ]; then \
250 strip --strip-unneeded --remove-section=.note --remove-section=.comment $elfsharedlist; \
8f74418b
MM
251 fi; \
252 if [ -n "$elfarchiveslist" ]; then \
253 strip --strip-debug --remove-section=.note --remove-section=.comment $elfarchiveslist; \
9c404149
AM
254 fi; } \
255} }
fc5d7e20 256#-----------------------------------------------------------------
257# remove all RPATH from executable binaries and shared object files
258#
259# Requires: find, awk, cut, xargs, chrpath, uname
260#
261#%no_install_post_chrpath 1
262%__spec_install_post_chrpath {%{!?debug: \
263%{!?no_install_post_chrpath: \
264 %{?verbose:set -x;} \
265echo "Remove RPATH from executable binaries and shared object files."; \
266if [ "$(uname -m)" != alpha ] ; then \
267find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*" | xargs -r file | \
268 awk '/ELF.*(executable|shared object)/ {print $1}' | cut -d: -f1 | \
269while read file ; do \
270 rpath= ; \
271 chmod u+w "$file"; \
272 for dir in `chrpath -l "$file" | \
273 awk '/RPATH=/ { gsub(/.*RPATH=/,""); gsub(/:/," "); print $0 }'` ; do \
274 case $dir in \
275 /home/* | /tmp/* | /usr/lib | /lib | /usr/local/lib | /usr/X11R6/lib ) \
276 echo "remove-rpath: $dir in $file"; \
277 ;; \
278 * ) \
279 if [ "$rpath" = "" ] ; then rpath="$dir" ; \
280 else rpath="$rpath:$dir" ; fi ; \
281 ;; \
282 esac ; \
283 done ; \
284 if [ "$rpath" = "" ] ; then chrpath -d "$file" > /dev/null ; \
285 else chrpath -r "$rpath" "$file" > /dev/null ; fi ; \
286done; fi; } \
287} }
d72c185f 288#-----------------------------------------------------------------
ccb8ae8d 289# Find and gzip all kernel modules
290#
291# Requires: find
292#
293#%no_install_post_compress_modules 1
294%__spec_install_post_compress_modules { \
ccb8ae8d 295%{!?no_install_post_compress_modules: \
fc1ea397 296echo "Compress kernel modules if any."; \
ccb8ae8d 297 %{?verbose:set -x;} \
d618340e 298 if test -d $RPM_BUILD_ROOT/lib/modules ; then \
fc1ea397 299 find $RPM_BUILD_ROOT/lib/modules -name \*.o -type f -print | \
d618340e 300 xargs -r %{__gzip} -9nf; \
fc1ea397 301 find $RPM_BUILD_ROOT/lib/modules -name \*.o -type l -printf "%p %l\n" | \
03b234a5 302 while read a b; do ln -sf $b.gz $a.gz; rm -f $a; done; \
d618340e 303 fi; \
ccb8ae8d 304} }
9c404149
AM
305
306%_source_payload w9.gzdio
307%_binary_payload w9.bzdio
308
83094b62 309#-----------------------------------------------------------------
310# Update all GConf2 schemas
311#
312# Requires: GConf2
313#
7bd8c922 314%gconf_schema_install { umask 022; \
315 GCONF_CONFIG_SOURCE="xml:readwrite:/etc/gconf/gconf.xml.defaults" \
316 /usr/bin/gconftool-2 --makefile-install-rule \
317 /etc/gconf/schemas/*.schemas > /dev/null \
3ee1090a 318}
83094b62 319
9c404149
AM
320#-----------------------------------------------------------------
321# post %install sequence:
322# - autodeps exceptions
323# - compress all man and info pages,
324# - strip all ELF executables and ELF shared objects if not %debug.
8f74418b 325# - compress kernel modules if any
9c404149
AM
326
327###################################################################
328# Requires/Provides automation
329# exceptions system by Jacek Konieczny <jajcus@pld.org.pl>
7126cc1b
JK
330%__spec_prep_pre \
331_autoreqprov=n \
f07a68c3 332%{?_noautocompressdoc:_autoreqprov=y}\
7126cc1b
JK
333if [ "$_autoreqprov" = "y" ] ; then \
334 if [ -f %{_builddir}/__rpm_lock ] ; then \
335 echo "Some package using \%_noauto* macros is already being built" >&2 \
336 echo "If it is not true delete %{_builddir}/__rpm_lock" >&2 \
337 exit 1 \
338 else \
339 rm -f %{_builddir}/__rpm_*\
340 touch %{_builddir}/__rpm_lock \
341 fi \
342fi \
f07a68c3 343%{?_noautocompressdoc:echo '%{_noautocompressdoc}' > %{_builddir}/__rpm_noautocompressdoc}\
667ceda0 344%{___build_pre}\
9c404149
AM
345%{nil}
346
9c404149
AM
347
348%__spec_clean_pre %{___build_pre}\
7126cc1b 349_autoreqprov=n \
f07a68c3 350%{?_noautocompressdoc:_autoreqprov=y}\
7126cc1b
JK
351if [ "$_autoreqprov" = "y" ] ; then \
352 rm -f %{_builddir}/__rpm_* \
353fi \
9c404149
AM
354%{nil}
355
356
357#%_noautoreqfiles "%{_defaultdocdir}.*" "%{_examplesdir}.*"
358#%_noautoreq %{nil}
359#%_noautoreqdep %{nil}
360#%_noautoprovfiles %{nil}
361#%_noautoprov %{nil}
8f74418b
MM
362%_missing_doc_files_terminate_build 1%{nil}
363%_unpackaged_files_terminate_build %{nil}
8781dc74 364# (X)emacs support
d77dcb61 365%___emacs_lispdir_helper -batch -q -eval '(while load-path (princ (concat (car load-path) "\\n")) (setq load-path (cdr load-path)))' 2> /dev/null|sed -n '/\\(.*\\/x\\?emacs\\/site-lisp\\)\\/\\?$/{s,,\\1,p;q;}'
8781dc74
AF
366%_emacs_lispdir %(emacs %___emacs_lispdir_helper)
367%_xemacs_lispdir %(xemacs %___emacs_lispdir_helper)
25043cd4
AF
368
369%__php_provides @RPMCONFIGDIR@/php.prov
370%__php_requires @RPMCONFIGDIR@/php.req
371
372# Perl specific macro definitions.
c853f847
AF
373%perl_privlib %(eval "`%{__perl} -V:installprivlib`"; echo $installprivlib)
374%perl_archlib %(eval "`%{__perl} -V:installarchlib`"; echo $installarchlib)
375%perl_vendorlib %(eval "`%{__perl} -V:installvendorlib`"; echo $installvendorlib)
376%perl_vendorarch %(eval "`%{__perl} -V:installvendorarch`"; echo $installvendorarch)
377%perl_sitelib %(eval "`%{__perl} -V:installsitelib`"; echo $installsitelib)
378%perl_sitearch %(eval "`%{__perl} -V:installsitearch`"; echo $installsitearch)
25043cd4 379
c853f847 380%php_pear_dir %{_datadir}/pear
25043cd4
AF
381
382# Python specific macro definitions.
383# python main version
c853f847 384%py_ver %(echo `python -c "import sys; print sys.version[:3]"`)
25043cd4
AF
385
386# directories
c853f847
AF
387%py_prefix %(echo `python -c "import sys; print sys.prefix"`)
388%py_libdir %{py_prefix}/lib/python%{py_ver}
389%py_incdir /usr/include/python%{py_ver}
390%py_sitedir %{py_libdir}/site-packages
391%py_dyndir %{py_libdir}/lib-dynload
25043cd4
AF
392
393# pure python modules compilation
c853f847 394%py_comp python -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])"
25043cd4 395
c853f847 396%py_ocomp python -O -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])"
25043cd4
AF
397
398# Software written in Python language require Python with main version
399# unchanged
c853f847 400%pyrequires_eq() Requires: %1 >= %py_ver %1 < %(echo `python -c "import sys; import string; ver=sys.version[:3].split('.'); ver[1]=str(int(ver[1])+1); print string.join(ver, '.')"`)
25043cd4 401
0fc5cff8 402# depmod macro
403%depmod() { \
404if [ -e /boot/System.map-%1 ]; then \
405 /sbin/depmod -a -F /boot/System.map-%1 %1; \
406else \
407 if [ -e /boot/System.map ]; then \
408 /sbin/depmod -a -F /boot/System.map %1; \
409 else \
410 /sbin/depmod -a %1; \
411 fi \
412fi; \
413}
414
This page took 0.112338 seconds and 4 git commands to generate.