]> git.pld-linux.org Git - packages/rpm-build-macros.git/blame - rpm.macros
- support for configuredir in %%configure (but you don't need to use it as in %%confi...
[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
AF
11%_topdir %(echo $HOME)/rpm
12%_exec_prefix %{_prefix}
13%_bindir %{_exec_prefix}/bin
14%_sbindir %{_exec_prefix}/sbin
15%_libexecdir %{_exec_prefix}/lib
16%_datadir %{_prefix}/share
8f74418b 17%_sharedstatedir /var/lib
d54662bf
AF
18%_lib lib
19%_libdir %{_exec_prefix}/%{_lib}
20%_includedir %{_prefix}/include
21%_oldincludedir /usr/include
22%_sysconfdir /etc
23%_localstatedir /var
24%_infodir /usr/share/info
25%_mandir %{_prefix}/share/man
8f74418b 26%_defaultdocdir %{_usr}/share/doc
9c404149
AM
27#-----------------------------------------------------------------
28# CFLAGS and LDFLAGS used to build
29
8f74418b 30%debugcflags -O0 -g -Wall
9c404149
AM
31%rpmcflags %{?debug:%debugcflags}%{!?debug:%optflags}
32%rpmldflags %{!?debug:-s}
33
ba1fdedc 34# kernel compiler
d2e1bc22 35%kgcc gcc
36%kgcc_package gcc
ba1fdedc 37
33040789 38# Build system path macros.
39#
40%__libtoolize libtoolize --copy --force
83094b62 41%__gettextize { \
afff6d37 42 if ! gettextize --version | grep -q '0\.10\.' ; then \
8a995cff
JB
43 if grep -qs 'AM_GNU_GETTEXT.*external' configure.{ac,in} ; then \
44 gettextize --copy --force --no-changelog; \
97589b6e 45 else \
8a995cff
JB
46 gettextize --copy --force --no-changelog --intl; \
47 fi; \
48 if [ ! -f po/Makevars ]; then \
49 cp -f po/Makevars{.template,}; \
50 fi; \
51 else \
52 gettextize --copy --force; \
83094b62 53 fi; \
8a995cff
JB
54}
55%__autopoint autopoint --force
bcdab9c2 56%__automake automake -a -c -f --foreign
be3a1985 57%__autoconf autoconf %{?debug:-Wall}
33040789 58
9c404149 59#-----------------------------------------------------------------
9f4ce098 60%configure2_13 { \
9c404149
AM
61 if [ -n "$LINGUAS" ]; then unset LINGUAS; fi; \
62 LDFLAGS="${LDFLAGS:-%rpmldflags}" ; export LDFLAGS ; \
63 CFLAGS="${CFLAGS:-%rpmcflags}" ; export CFLAGS ; \
64 CXXFLAGS="${CXXFLAGS:-%rpmcflags}" ; export CXXFLAGS ; \
65 FFLAGS="${FFLAGS:-%rpmcflags}" ; export FFLAGS ; \
8ec1a12b 66 CPPFLAGS="${CPPFLAGS:-}" ; export CPPFLAGS ; \
ae5d93df
AM
67 %{?__cc:CC=%{__cc} ; export CC ; } \
68 %{?__cxx:CXX=%{__cxx} ; export CXX ; } \
8f74418b 69 %{?configuredir:%{configuredir}}%{!?configuredir:.}/configure \
2a7cfd3f 70 --host=%{_target_platform} \
9c404149
AM
71 --prefix=%{_prefix} \
72 --exec-prefix=%{_exec_prefix} \
73 --bindir=%{_bindir} \
74 --sbindir=%{_sbindir} \
75 --sysconfdir=%{_sysconfdir} \
76 --datadir=%{_datadir} \
77 --includedir=%{_includedir} \
78 --libdir=%{_libdir} \
79 --libexecdir=%{_libexecdir} \
80 --localstatedir=%{_localstatedir} \
81 --sharedstatedir=%{_sharedstatedir} \
82 --mandir=%{_mandir} \
83 --infodir=%{_infodir} \
84}
85
4a6b0d54 86#----------------------------------------------------------------
34e5be8d
AM
87%configure { \
88 %{?configuredir:%{configuredir}}%{!?configuredir:.}/configure \
4a6b0d54
AF
89 LDFLAGS="${LDFLAGS:-%rpmldflags}" \
90 CFLAGS="${CFLAGS:-%rpmcflags}" \
91 CXXFLAGS="${CXXFLAGS:-%rpmcflags}" \
92 FFLAGS="${FFLAGS:-%rpmcflags}" \
a2bd5992 93 CPPFLAGS="${CPPFLAGS:-}" \
9f4ce098
AF
94 %{?__cc:CC=%{__cc}} \
95 %{?__cxx:CXX=%{__cxx}} \
4a6b0d54
AF
96 --build=%{_target_platform} \
97 --prefix=%{_prefix} \
98 --exec-prefix=%{_exec_prefix} \
99 --bindir=%{_bindir} \
100 --sbindir=%{_sbindir} \
101 --sysconfdir=%{_sysconfdir} \
102 --datadir=%{_datadir} \
103 --includedir=%{_includedir} \
104 --libdir=%{_libdir} \
105 --libexecdir=%{_libexecdir} \
106 --localstatedir=%{_localstatedir} \
107 --sharedstatedir=%{_sharedstatedir} \
108 --mandir=%{_mandir} \
109 --infodir=%{_infodir} \
110}
111
9c404149
AM
112# Location of autoconf macros
113%_aclocaldir %(aclocal --print-ac-dir)
114
e2804f99
AM
115# Location of omf files
116%_omf_dest_dir %(scrollkeeper-config --omfdir)
117
e987a186 118# Location of pkgconfig files
d7021551 119%_pkgconfigdir /usr/lib/pkgconfig
e987a186 120
9c404149 121# Location of top applink dir
30562d7e 122%_applnkdir /usr/X11R6/share/applnk
9c404149 123
486b0b5f 124# Location of desktop files
125%_desktopdir /usr/share/applications
126
9c404149 127# Location pixmaps for applnk/desktop files
e1f0a822 128%_pixmapsdir /usr/share/pixmaps
9c404149 129
e987a186
JB
130# Location of fonts directories
131%_fontsdir /usr/share/fonts
132
b3282f3f 133# Location of Gtk and associated libraries documentation
6eed6d84 134%_gtkdocdir %{_defaultdocdir}/gtk-doc/html
b3282f3f 135
9c404149
AM
136# Current date
137%date %(LC_ALL="C" date +"%a %b %d %Y")
138
139# tmp directory
140%tmpdir %(echo "${TMPDIR:-/tmp}")
141
142# Example files, programs, scripts...
143%_examplesdir /usr/src/examples
144
8377d27d 145# The directory holding Linux kernel sources
146%_kernelsrcdir /usr/src/linux
147
9c404149 148# If non-empty "debug" macro defined, add "dbg" suffix to release number
8f74418b 149%_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}%{?debug:dbg}.%%{ARCH}.rpm
9c404149 150
8f74418b
MM
151# Requires name = version-release
152%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")
153%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)")
154%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)")
b9d5d440 155
156# kernel version-release handling
157%__kernel_ver %(grep UTS_RELEASE %{_kernelsrcdir}/include/linux/version.h 2>/dev/null | cut -d'"' -f2)
158%__kernel_rel %(LC_ALL="C" rpm -qf %{_kernelsrcdir}/include/linux/version.h --queryformat "%{RELEASE}" | grep -v "is not")
159%_kernel_ver %(echo %{__kernel_ver}%{!?_without_dist_kernel:-%{__kernel_rel}})
160%_kernel_ver_str %(echo %{_kernel_ver} | sed s/-/_/g)
87be1cf0 161
e00dd7f6 162# sgml macros
163%xmlcat_add() /usr/bin/xmlcatalog --noout --add nextCatalog \"\" %1 /etc/xml/catalog
164%xmlcat_del() /usr/bin/xmlcatalog --noout --del %1 /etc/xml/catalog
165%xmlcat_add_rewrite /usr/bin/xmlcatalog --noout --add rewriteSystem
166%xmlcat_create() /usr/bin/xmlcatalog --noout --create %1
167%sgmlcat_add() /usr/bin/install-catalog --add %1 %2 > /dev/null
168%sgmlcat_del() /usr/bin/install-catalog --remove %1 %2 > /dev/null
169%docbook_sgmlcat_fix() { for l in \
170'' \
171' -- default decl --' \
172'DTDDECL "-//OASIS//DTD DocBook XML V%2//EN" "../../xml.dcl"' \
173' -- hacks for opensp --' \
174'SYSTEM "file://%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd" "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
175'SYSTEM "http://www.oasis-open.org/docbook/xml/%2/docbookx.dtd" "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
176'' \
177; do echo $l; done >> %1 \
178}
179
9c404149
AM
180#-----------------------------------------------------------------
181# find and gzip all files in %{_mandir} and %{infodir}
182#
183# Requires: xargs, find
184#
185#%no_install_post_compress_docs 1
186%__spec_install_post_compress_docs { \
187echo "Compress man and info pages."; \
188%{!?no_install_post_compress_docs: \
189 %{?verbose:set -x;} \
190 for i in /usr/share/man /usr/X11R6/man /usr/share/info; do \
191 if [ -d "$RPM_BUILD_ROOT$i" ]; then \
192 find "$RPM_BUILD_ROOT$i" -name \*.bz2 -print | xargs -r %{__bzip2} -df; \
193 find "$RPM_BUILD_ROOT$i" -name \*.gz -print | xargs -r %{__gzip} -dnf; \
194 find "$RPM_BUILD_ROOT$i" -type f -print | xargs -r %{__gzip} -9nf; \
195 fi; \
196 done; \
197} }
198
199#-----------------------------------------------------------------
200# Strip executable binaries and shared object files
201#
202# Requires: find, awk, strip, cut, xargs
203#
204#%no_install_post_strip 1
205%__spec_install_post_strip {%{!?debug: \
206%{!?no_install_post_strip: \
207 %{?verbose:set -x;} \
8f74418b 208 echo "Strip executable binaries, archives and shared object files."; \
9c404149
AM
209 filelist=`find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*"`; \
210 elfexelist=`echo $filelist | xargs -r file | \
211 awk '/ELF.*executable/ {print $1}' | cut -d: -f1`; \
212 elfsharedlist=`echo $filelist | xargs -r file | \
213 awk '/LF.*shared object/ {print $1}' | cut -d: -f1`; \
8f74418b
MM
214 elfarchiveslist=`echo $filelist | xargs -r file | \
215 awk '/current ar archive/ {print $1}' | cut -d: -f1`; \
9c404149
AM
216 if [ -n "$elfexelist" ]; then \
217 strip --remove-section=.note --remove-section=.comment $elfexelist; \
218 fi; \
219 if [ -n "$elfsharedlist" ]; then \
220 strip --strip-unneeded --remove-section=.note --remove-section=.comment $elfsharedlist; \
8f74418b
MM
221 fi; \
222 if [ -n "$elfarchiveslist" ]; then \
223 strip --strip-debug --remove-section=.note --remove-section=.comment $elfarchiveslist; \
9c404149
AM
224 fi; } \
225} }
8f74418b 226
d72c185f 227#-----------------------------------------------------------------
ccb8ae8d 228# Find and gzip all kernel modules
229#
230# Requires: find
231#
232#%no_install_post_compress_modules 1
233%__spec_install_post_compress_modules { \
ccb8ae8d 234%{!?no_install_post_compress_modules: \
fc1ea397 235echo "Compress kernel modules if any."; \
ccb8ae8d 236 %{?verbose:set -x;} \
d618340e 237 if test -d $RPM_BUILD_ROOT/lib/modules ; then \
fc1ea397 238 find $RPM_BUILD_ROOT/lib/modules -name \*.o -type f -print | \
d618340e 239 xargs -r %{__gzip} -9nf; \
fc1ea397 240 find $RPM_BUILD_ROOT/lib/modules -name \*.o -type l -printf "%p %l\n" | \
03b234a5 241 while read a b; do ln -sf $b.gz $a.gz; rm -f $a; done; \
d618340e 242 fi; \
ccb8ae8d 243} }
9c404149
AM
244
245%_source_payload w9.gzdio
246%_binary_payload w9.bzdio
247
83094b62 248#-----------------------------------------------------------------
249# Update all GConf2 schemas
250#
251# Requires: GConf2
252#
7bd8c922 253%gconf_schema_install { umask 022; \
254 GCONF_CONFIG_SOURCE="xml:readwrite:/etc/gconf/gconf.xml.defaults" \
255 /usr/bin/gconftool-2 --makefile-install-rule \
256 /etc/gconf/schemas/*.schemas > /dev/null \
3ee1090a 257}
83094b62 258
9c404149
AM
259#-----------------------------------------------------------------
260# post %install sequence:
261# - autodeps exceptions
262# - compress all man and info pages,
263# - strip all ELF executables and ELF shared objects if not %debug.
8f74418b 264# - compress kernel modules if any
9c404149
AM
265
266###################################################################
267# Requires/Provides automation
268# exceptions system by Jacek Konieczny <jajcus@pld.org.pl>
7126cc1b
JK
269%__spec_prep_pre \
270_autoreqprov=n \
271%{?_noautoreqfiles:_autoreqprov=y}\
272%{?_noautoreq:_autoreqprov=y}\
273%{?_noautoreqdep:_autoreqprov=y}\
274%{?_noautoprovfiles:_autoreqprov=y}\
275%{?_noautoprov:_autoreqprov=y}\
f07a68c3 276%{?_noautocompressdoc:_autoreqprov=y}\
7126cc1b
JK
277if [ "$_autoreqprov" = "y" ] ; then \
278 if [ -f %{_builddir}/__rpm_lock ] ; then \
279 echo "Some package using \%_noauto* macros is already being built" >&2 \
280 echo "If it is not true delete %{_builddir}/__rpm_lock" >&2 \
281 exit 1 \
282 else \
283 rm -f %{_builddir}/__rpm_*\
284 touch %{_builddir}/__rpm_lock \
285 fi \
286fi \
f07a68c3 287%{?_noautocompressdoc:echo '%{_noautocompressdoc}' > %{_builddir}/__rpm_noautocompressdoc}\
9c404149
AM
288%{nil}
289
ef437f4b 290%__os_install_post \
9c404149
AM
291%{?_noautoreqfiles:for f in %{_noautoreqfiles} ; do echo %{?buildroot:%{buildroot}}$f >> %{_builddir}/__rpm_noautoreqfiles ; done }\
292%{?_noautoreq:for f in %{_noautoreq} ; do echo "$f" >> %{_builddir}/__rpm_noautoreq ; done }\
293%{?_noautoreqdep:for f in %{_noautoreqdep} ; do echo "$f" >> %{_builddir}/__rpm_noautoreqdep ; done }\
294%{?_noautoprovfiles:for f in %{_noautoprovfiles} ; do echo %{?buildroot:%{buildroot}}$f >> %{_builddir}/__rpm_noautoprovfiles ; done }\
295%{?_noautoprov:for f in %{_noautoprov} ; do echo "$f" >> %{_builddir}/__rpm_noautoprov ; done }\
296%{__spec_install_post_strip}\
297%{__spec_install_post_compress_docs}\
ccb8ae8d 298%{__spec_install_post_compress_modules}\
9c404149 299%{__arch_install_post}\
9c404149
AM
300%{nil}
301
302%__spec_clean_pre %{___build_pre}\
7126cc1b
JK
303_autoreqprov=n \
304%{?_noautoreqfiles:_autoreqprov=y}\
305%{?_noautoreq:_autoreqprov=y}\
306%{?_noautoreqdep:_autoreqprov=y}\
307%{?_noautoprovfiles:_autoreqprov=y}\
308%{?_noautoprov:_autoreqprov=y}\
309%{?_noautoreqfiles:_autoreqprov=y}\
f07a68c3 310%{?_noautocompressdoc:_autoreqprov=y}\
7126cc1b
JK
311if [ "$_autoreqprov" = "y" ] ; then \
312 rm -f %{_builddir}/__rpm_* \
313fi \
9c404149
AM
314%{nil}
315
316
317#%_noautoreqfiles "%{_defaultdocdir}.*" "%{_examplesdir}.*"
318#%_noautoreq %{nil}
319#%_noautoreqdep %{nil}
320#%_noautoprovfiles %{nil}
321#%_noautoprov %{nil}
8f74418b
MM
322%_missing_doc_files_terminate_build 1%{nil}
323%_unpackaged_files_terminate_build %{nil}
This page took 0.071272 seconds and 4 git commands to generate.