]> git.pld-linux.org Git - packages/rpm-build-macros.git/blame - rpm.macros
- remove empty lines
[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
07163ba3 8%_fixowner [ `%{__id_u}` = '0' ] && %{__chown_Rhf} root:@ROOT_GROUP@
d54662bf 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} \
c0d1b3ad 69 --x-libraries=/usr/X11R6/%{_lib} \
9c404149
AM
70}
71
4a6b0d54 72#----------------------------------------------------------------
57f4166d 73%configure {./configure \
4a6b0d54
AF
74 LDFLAGS="${LDFLAGS:-%rpmldflags}" \
75 CFLAGS="${CFLAGS:-%rpmcflags}" \
76 CXXFLAGS="${CXXFLAGS:-%rpmcflags}" \
77 FFLAGS="${FFLAGS:-%rpmcflags}" \
a2bd5992 78 CPPFLAGS="${CPPFLAGS:-}" \
9f4ce098
AF
79 %{?__cc:CC=%{__cc}} \
80 %{?__cxx:CXX=%{__cxx}} \
4a6b0d54
AF
81 --build=%{_target_platform} \
82 --prefix=%{_prefix} \
83 --exec-prefix=%{_exec_prefix} \
84 --bindir=%{_bindir} \
85 --sbindir=%{_sbindir} \
86 --sysconfdir=%{_sysconfdir} \
87 --datadir=%{_datadir} \
88 --includedir=%{_includedir} \
89 --libdir=%{_libdir} \
90 --libexecdir=%{_libexecdir} \
91 --localstatedir=%{_localstatedir} \
92 --sharedstatedir=%{_sharedstatedir} \
93 --mandir=%{_mandir} \
94 --infodir=%{_infodir} \
c0d1b3ad 95 --x-libraries=/usr/X11R6/%{_lib} \
4a6b0d54
AF
96}
97
7dbab518
MM
98# ------------------------------------------------------------------------
99# Conditional build stuff.
100
101# Check if symbol is defined.
102# Example usage: %if %{defined with_foo} && %{undefined with_bar} ...
103%defined() %{expand:%%{?%{1}:1}%%{!?%{1}:0}}
104%undefined() %{expand:%%{?%{1}:0}%%{!?%{1}:1}}
105
566fa098
MM
106# Shorthand for %{defined with_...}
107%with() %{expand:%%{?with_%{1}:1}%%{!?with_%{1}:0}}
108%without() %{expand:%%{?with_%{1}:0}%%{!?with_%{1}:1}}
109
7dbab518
MM
110# Handle conditional builds. %bcond_with is for case when feature is
111# default off and needs to be activated with --with ... command line
112# switch. %bcond_without is for the dual case.
113#
114# %bcond_with foo defines symbol with_foo if --with foo was specified on
115# command line.
116# %bcond_without foo defines symbol with_foo if --without foo was *not*
117# specified on command line.
118#
119# For example:
120#
121# %bcond_with extra_fonts
122# %bcond_without static
f52f9976 123# %if %{with extra_fonts}
7dbab518
MM
124# ...
125# %endif
f52f9976 126# %ifdef %{with static}
7dbab518
MM
127# ...
128# %endif
129# %{?with_static: ... }
130# %{!?with_static: ... }
131# %{?with_extra_fonts: ... }
132# %{!?with_extra_fonts: ... }
133#
134# The bottom line: never use without_foo, _with_foo nor _without_foo, only
135# with_foo. This way changing default set of bconds for given spec is just
136# a matter of changing single line in it and syntax is more readable.
137%bcond_with() %{expand:%%{?_with_%{1}:%%global with_%{1} 1}}
138%bcond_without() %{expand:%%{!?_without_%{1}:%%global with_%{1} 1}}
139# ------------------------------------------------------------------------
140
9c404149
AM
141# Location of autoconf macros
142%_aclocaldir %(aclocal --print-ac-dir)
143
e2804f99
AM
144# Location of omf files
145%_omf_dest_dir %(scrollkeeper-config --omfdir)
146
e987a186 147# Location of pkgconfig files
9a4e877a 148%_pkgconfigdir /usr/%{_lib}/pkgconfig
e987a186 149
9c404149 150# Location of top applink dir
30562d7e 151%_applnkdir /usr/X11R6/share/applnk
9c404149 152
486b0b5f 153# Location of desktop files
154%_desktopdir /usr/share/applications
155
481463e9 156# Location of pixmaps for applnk/desktop files
e1f0a822 157%_pixmapsdir /usr/share/pixmaps
9c404149 158
481463e9 159# Location of themable icons for applnk/desktop files
b36c8e2a 160%_iconsdir /usr/share/icons
161
e987a186
JB
162# Location of fonts directories
163%_fontsdir /usr/share/fonts
164
b3282f3f 165# Location of Gtk and associated libraries documentation
6eed6d84 166%_gtkdocdir %{_defaultdocdir}/gtk-doc/html
b3282f3f 167
fc4d7771 168# Location of KDE documentation
169%_kdedocdir %{_defaultdocdir}/kde/HTML
170
9c404149
AM
171# Current date
172%date %(LC_ALL="C" date +"%a %b %d %Y")
173
174# tmp directory
175%tmpdir %(echo "${TMPDIR:-/tmp}")
176
177# Example files, programs, scripts...
178%_examplesdir /usr/src/examples
179
8377d27d 180# The directory holding Linux kernel sources
181%_kernelsrcdir /usr/src/linux
182
9c404149 183# If non-empty "debug" macro defined, add "dbg" suffix to release number
8f74418b 184%_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}%{?debug:dbg}.%%{ARCH}.rpm
9c404149 185
8f74418b
MM
186# Requires name = version-release
187%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")
188%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)")
189%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)")
920c76a3 190%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")
01a9f990 191
179fcc7f 192%apache_modules_api %(awk '/#define MODULE_MAGIC_NUMBER_MAJOR/ {print $3}' /usr/include/apache/ap_mmn.h 2>/dev/null || echo ERROR)
b9d5d440 193
194# kernel version-release handling
8fecb226
AM
195%__kernel_ver %([ -f %{_kernelsrcdir}/include/linux/version.h ] && (grep UTS_RELEASE %{_kernelsrcdir}/include/linux/version.h 2>/dev/null | cut -d'"' -f2) || (awk '/^VERSION/ { ver = $0; gsub(/VERSION.*=/, NIL, ver); } /^PATCHLEVEL/ { plev = $0; gsub(/PATCHLEVEL.*=/, NIL, plev); } /^SUBLEVEL/ { slev = $0; gsub(/SUBLEVEL.*=/, NIL, slev); } END { printf("%d.%d.%d", ver, plev, slev); }' %{_kernelsrcdir}/Makefile 2> /dev/null))
196%__kernel_rel %(LC_ALL="C" rpm -qf %{_kernelsrcdir}/include/linux/fs.h --queryformat "%{RELEASE}" | grep -v "is not")
b9d5d440 197%_kernel_ver %(echo %{__kernel_ver}%{!?_without_dist_kernel:-%{__kernel_rel}})
198%_kernel_ver_str %(echo %{_kernel_ver} | sed s/-/_/g)
87be1cf0 199
e00dd7f6 200# sgml macros
201%xmlcat_add() /usr/bin/xmlcatalog --noout --add nextCatalog \"\" %1 /etc/xml/catalog
202%xmlcat_del() /usr/bin/xmlcatalog --noout --del %1 /etc/xml/catalog
203%xmlcat_add_rewrite /usr/bin/xmlcatalog --noout --add rewriteSystem
204%xmlcat_create() /usr/bin/xmlcatalog --noout --create %1
205%sgmlcat_add() /usr/bin/install-catalog --add %1 %2 > /dev/null
206%sgmlcat_del() /usr/bin/install-catalog --remove %1 %2 > /dev/null
207%docbook_sgmlcat_fix() { for l in \
208'' \
209' -- default decl --' \
210'DTDDECL "-//OASIS//DTD DocBook XML V%2//EN" "../../xml.dcl"' \
211' -- hacks for opensp --' \
212'SYSTEM "file://%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd" "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
213'SYSTEM "http://www.oasis-open.org/docbook/xml/%2/docbookx.dtd" "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
214'' \
215; do echo $l; done >> %1 \
216}
217
9c404149
AM
218#-----------------------------------------------------------------
219# find and gzip all files in %{_mandir} and %{infodir}
220#
221# Requires: xargs, find
222#
223#%no_install_post_compress_docs 1
224%__spec_install_post_compress_docs { \
225echo "Compress man and info pages."; \
226%{!?no_install_post_compress_docs: \
227 %{?verbose:set -x;} \
228 for i in /usr/share/man /usr/X11R6/man /usr/share/info; do \
229 if [ -d "$RPM_BUILD_ROOT$i" ]; then \
230 find "$RPM_BUILD_ROOT$i" -name \*.bz2 -print | xargs -r %{__bzip2} -df; \
231 find "$RPM_BUILD_ROOT$i" -name \*.gz -print | xargs -r %{__gzip} -dnf; \
232 find "$RPM_BUILD_ROOT$i" -type f -print | xargs -r %{__gzip} -9nf; \
233 fi; \
234 done; \
235} }
236
237#-----------------------------------------------------------------
238# Strip executable binaries and shared object files
239#
240# Requires: find, awk, strip, cut, xargs
241#
242#%no_install_post_strip 1
243%__spec_install_post_strip {%{!?debug: \
244%{!?no_install_post_strip: \
9f0d4f36
JB
245 %{?verbose:set -x;} \
246 if [ -d "$RPM_BUILD_ROOT" ]; then \
8f74418b 247 echo "Strip executable binaries, archives and shared object files."; \
60ad88f2 248 filelist=`find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*" %{?_noautostrip:! -regex "%{_noautostrip}"}`; \
9c404149
AM
249 elfexelist=`echo $filelist | xargs -r file | \
250 awk '/ELF.*executable/ {print $1}' | cut -d: -f1`; \
251 elfsharedlist=`echo $filelist | xargs -r file | \
252 awk '/LF.*shared object/ {print $1}' | cut -d: -f1`; \
8f74418b
MM
253 elfarchiveslist=`echo $filelist | xargs -r file | \
254 awk '/current ar archive/ {print $1}' | cut -d: -f1`; \
9c404149 255 if [ -n "$elfexelist" ]; then \
60ad88f2 256 %{__strip} --remove-section=.note --remove-section=.comment $elfexelist; \
9c404149
AM
257 fi; \
258 if [ -n "$elfsharedlist" ]; then \
60ad88f2 259 %{__strip} --strip-unneeded --remove-section=.note --remove-section=.comment $elfsharedlist; \
8f74418b
MM
260 fi; \
261 if [ -n "$elfarchiveslist" ]; then \
60ad88f2 262 %{__strip} --strip-debug --remove-section=.note --remove-section=.comment $elfarchiveslist; \
9f0d4f36
JB
263 fi; \
264 fi; } \
9c404149 265} }
fc5d7e20 266#-----------------------------------------------------------------
267# remove all RPATH from executable binaries and shared object files
268#
269# Requires: find, awk, cut, xargs, chrpath, uname
270#
271#%no_install_post_chrpath 1
272%__spec_install_post_chrpath {%{!?debug: \
273%{!?no_install_post_chrpath: \
274 %{?verbose:set -x;} \
9f0d4f36 275if [ -d "$RPM_BUILD_ROOT" ]; then \
fc5d7e20 276echo "Remove RPATH from executable binaries and shared object files."; \
60ad88f2 277find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*" %{?_noautochrpath:! -regex "%{_noautochrpath}"} | xargs -r file | \
fc5d7e20 278 awk '/ELF.*(executable|shared object)/ {print $1}' | cut -d: -f1 | \
279while read file ; do \
280 rpath= ; \
281 chmod u+w "$file"; \
282 for dir in `chrpath -l "$file" | \
283 awk '/RPATH=/ { gsub(/.*RPATH=/,""); gsub(/:/," "); print $0 }'` ; do \
284 case $dir in \
494e368c 285 /home/* | /tmp/* | /usr/lib | /usr/lib64 | /lib | /lib64 | /usr/local/lib | /usr/local/lib64 | /usr/X11R6/lib | /usr/X11R6/lib64 ) \
fc5d7e20 286 echo "remove-rpath: $dir in $file"; \
287 ;; \
288 * ) \
289 if [ "$rpath" = "" ] ; then rpath="$dir" ; \
290 else rpath="$rpath:$dir" ; fi ; \
291 ;; \
292 esac ; \
293 done ; \
294 if [ "$rpath" = "" ] ; then chrpath -d "$file" > /dev/null ; \
295 else chrpath -r "$rpath" "$file" > /dev/null ; fi ; \
9f0d4f36
JB
296done; \
297fi; } \
fc5d7e20 298} }
d72c185f 299#-----------------------------------------------------------------
ccb8ae8d 300# Find and gzip all kernel modules
301#
302# Requires: find
303#
304#%no_install_post_compress_modules 1
305%__spec_install_post_compress_modules { \
ccb8ae8d 306%{!?no_install_post_compress_modules: \
307 %{?verbose:set -x;} \
9f0d4f36
JB
308 if [ -d "$RPM_BUILD_ROOT" ]; then \
309echo "Compress kernel modules if any."; \
d618340e 310 if test -d $RPM_BUILD_ROOT/lib/modules ; then \
a33b1418 311 find $RPM_BUILD_ROOT/lib/modules -name \*o -type f -print | \
d618340e 312 xargs -r %{__gzip} -9nf; \
a33b1418 313 find $RPM_BUILD_ROOT/lib/modules -name \*o -type l -printf "%p %l\n" | \
03b234a5 314 while read a b; do ln -sf $b.gz $a.gz; rm -f $a; done; \
d618340e 315 fi; \
9f0d4f36 316 fi; \
ccb8ae8d 317} }
9c404149
AM
318
319%_source_payload w9.gzdio
320%_binary_payload w9.bzdio
321
83094b62 322#-----------------------------------------------------------------
323# Update all GConf2 schemas
324#
325# Requires: GConf2
326#
7bd8c922 327%gconf_schema_install { umask 022; \
328 GCONF_CONFIG_SOURCE="xml:readwrite:/etc/gconf/gconf.xml.defaults" \
329 /usr/bin/gconftool-2 --makefile-install-rule \
330 /etc/gconf/schemas/*.schemas > /dev/null \
3ee1090a 331}
83094b62 332
9c404149
AM
333#-----------------------------------------------------------------
334# post %install sequence:
335# - autodeps exceptions
336# - compress all man and info pages,
337# - strip all ELF executables and ELF shared objects if not %debug.
8f74418b 338# - compress kernel modules if any
9c404149
AM
339
340###################################################################
341# Requires/Provides automation
342# exceptions system by Jacek Konieczny <jajcus@pld.org.pl>
338726a6 343#
1f8e1151
JK
344%_noautoreqfiles %(sed -e s'/#.*//' /etc/rpm/noautoreqfiles)
345%_noautoprovfiles %(sed -e s'/#.*//' /etc/rpm/noautoprovfiles)
02b58f60 346%_noautoreq %(sed -e s'/#.*//' /etc/rpm/noautoreq)
cbd2607d 347%_noautoreqdep %(sed -e s'/#.*//' /etc/rpm/noautoreqdep)
02b58f60 348%_noautoprov %(sed -e s'/#.*//' /etc/rpm/noautoprov)
338726a6
JB
349#%_noautocompressdoc %{nil}
350#
8f74418b
MM
351%_missing_doc_files_terminate_build 1%{nil}
352%_unpackaged_files_terminate_build %{nil}
8781dc74 353# (X)emacs support
d77dcb61 354%___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
355%_emacs_lispdir %(emacs %___emacs_lispdir_helper)
356%_xemacs_lispdir %(xemacs %___emacs_lispdir_helper)
25043cd4 357
02b58f60
JK
358%__php_provides %{nil}
359%__php_requires %{nil}
360%__perl_provides %{nil}
361%__perl_requires %{nil}
25043cd4
AF
362
363# Perl specific macro definitions.
c853f847
AF
364%perl_privlib %(eval "`%{__perl} -V:installprivlib`"; echo $installprivlib)
365%perl_archlib %(eval "`%{__perl} -V:installarchlib`"; echo $installarchlib)
366%perl_vendorlib %(eval "`%{__perl} -V:installvendorlib`"; echo $installvendorlib)
367%perl_vendorarch %(eval "`%{__perl} -V:installvendorarch`"; echo $installvendorarch)
368%perl_sitelib %(eval "`%{__perl} -V:installsitelib`"; echo $installsitelib)
369%perl_sitearch %(eval "`%{__perl} -V:installsitearch`"; echo $installsitearch)
25043cd4 370
c853f847 371%php_pear_dir %{_datadir}/pear
25043cd4
AF
372
373# Python specific macro definitions.
374# python main version
c853f847 375%py_ver %(echo `python -c "import sys; print sys.version[:3]"`)
25043cd4
AF
376
377# directories
c853f847 378%py_prefix %(echo `python -c "import sys; print sys.prefix"`)
aadb0079 379%py_libdir %{py_prefix}/%{_lib}/python%{py_ver}
ef7ec0a8 380%py_scriptdir %{py_prefix}/share/python%{py_ver}
c853f847 381%py_incdir /usr/include/python%{py_ver}
ef7ec0a8
JK
382%py_sitedir %{py_libdir}/site-packages
383%py_sitescriptdir %{py_scriptdir}/site-packages
c853f847 384%py_dyndir %{py_libdir}/lib-dynload
25043cd4
AF
385
386# pure python modules compilation
c853f847 387%py_comp python -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])"
25043cd4 388
c853f847 389%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
390
391# Software written in Python language require Python with main version
392# unchanged
0bb49594 393%pyrequires_eq() Requires: %1 >= 1:%py_ver %1 < 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 394
0fc5cff8 395# depmod macro
396%depmod() { \
397if [ -e /boot/System.map-%1 ]; then \
398 /sbin/depmod -a -F /boot/System.map-%1 %1; \
399else \
400 if [ -e /boot/System.map ]; then \
401 /sbin/depmod -a -F /boot/System.map %1; \
402 else \
403 /sbin/depmod -a %1; \
404 fi \
405fi; \
406}
407
2afc6e64 408# XMMS specific macros
2d372986
JB
409%xmms_prefix %(xmms-config --prefix)
410%xmms_exec_prefix %(xmms-config --exec-prefix)
411%xmms_version %(xmms-config --version)
412%xmms_datadir %(xmms-config --data-dir)
413%xmms_plugindir %(xmms-config --plugin-dir)
414%xmms_visualization_plugindir %(xmms-config --visualization-plugin-dir)
415%xmms_input_plugindir %(xmms-config --input-plugin-dir)
416%xmms_output_plugindir %(xmms-config --output-plugin-dir)
417%xmms_effect_plugindir %(xmms-config --effect-plugin-dir)
418%xmms_general_plugindir %(xmms-config --general-plugin-dir)
2afc6e64 419
This page took 0.115566 seconds and 4 git commands to generate.