]> git.pld-linux.org Git - packages/rpm-build-macros.git/blame - rpm.macros
- allow patch without trailing slash
[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#----------------------------------------------------------------
57f4166d 87%configure {./configure \
4a6b0d54
AF
88 LDFLAGS="${LDFLAGS:-%rpmldflags}" \
89 CFLAGS="${CFLAGS:-%rpmcflags}" \
90 CXXFLAGS="${CXXFLAGS:-%rpmcflags}" \
91 FFLAGS="${FFLAGS:-%rpmcflags}" \
a2bd5992 92 CPPFLAGS="${CPPFLAGS:-}" \
9f4ce098
AF
93 %{?__cc:CC=%{__cc}} \
94 %{?__cxx:CXX=%{__cxx}} \
4a6b0d54
AF
95 --build=%{_target_platform} \
96 --prefix=%{_prefix} \
97 --exec-prefix=%{_exec_prefix} \
98 --bindir=%{_bindir} \
99 --sbindir=%{_sbindir} \
100 --sysconfdir=%{_sysconfdir} \
101 --datadir=%{_datadir} \
102 --includedir=%{_includedir} \
103 --libdir=%{_libdir} \
104 --libexecdir=%{_libexecdir} \
105 --localstatedir=%{_localstatedir} \
106 --sharedstatedir=%{_sharedstatedir} \
107 --mandir=%{_mandir} \
108 --infodir=%{_infodir} \
109}
110
9c404149
AM
111# Location of autoconf macros
112%_aclocaldir %(aclocal --print-ac-dir)
113
e2804f99
AM
114# Location of omf files
115%_omf_dest_dir %(scrollkeeper-config --omfdir)
116
e987a186 117# Location of pkgconfig files
d7021551 118%_pkgconfigdir /usr/lib/pkgconfig
e987a186 119
9c404149 120# Location of top applink dir
30562d7e 121%_applnkdir /usr/X11R6/share/applnk
9c404149 122
486b0b5f 123# Location of desktop files
124%_desktopdir /usr/share/applications
125
9c404149 126# Location pixmaps for applnk/desktop files
e1f0a822 127%_pixmapsdir /usr/share/pixmaps
9c404149 128
e987a186
JB
129# Location of fonts directories
130%_fontsdir /usr/share/fonts
131
b3282f3f 132# Location of Gtk and associated libraries documentation
6eed6d84 133%_gtkdocdir %{_defaultdocdir}/gtk-doc/html
b3282f3f 134
9c404149
AM
135# Current date
136%date %(LC_ALL="C" date +"%a %b %d %Y")
137
138# tmp directory
139%tmpdir %(echo "${TMPDIR:-/tmp}")
140
141# Example files, programs, scripts...
142%_examplesdir /usr/src/examples
143
8377d27d 144# The directory holding Linux kernel sources
145%_kernelsrcdir /usr/src/linux
146
9c404149 147# If non-empty "debug" macro defined, add "dbg" suffix to release number
8f74418b 148%_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}%{?debug:dbg}.%%{ARCH}.rpm
9c404149 149
8f74418b
MM
150# Requires name = version-release
151%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")
152%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)")
153%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 154
155# kernel version-release handling
156%__kernel_ver %(grep UTS_RELEASE %{_kernelsrcdir}/include/linux/version.h 2>/dev/null | cut -d'"' -f2)
157%__kernel_rel %(LC_ALL="C" rpm -qf %{_kernelsrcdir}/include/linux/version.h --queryformat "%{RELEASE}" | grep -v "is not")
158%_kernel_ver %(echo %{__kernel_ver}%{!?_without_dist_kernel:-%{__kernel_rel}})
159%_kernel_ver_str %(echo %{_kernel_ver} | sed s/-/_/g)
87be1cf0 160
e00dd7f6 161# sgml macros
162%xmlcat_add() /usr/bin/xmlcatalog --noout --add nextCatalog \"\" %1 /etc/xml/catalog
163%xmlcat_del() /usr/bin/xmlcatalog --noout --del %1 /etc/xml/catalog
164%xmlcat_add_rewrite /usr/bin/xmlcatalog --noout --add rewriteSystem
165%xmlcat_create() /usr/bin/xmlcatalog --noout --create %1
166%sgmlcat_add() /usr/bin/install-catalog --add %1 %2 > /dev/null
167%sgmlcat_del() /usr/bin/install-catalog --remove %1 %2 > /dev/null
168%docbook_sgmlcat_fix() { for l in \
169'' \
170' -- default decl --' \
171'DTDDECL "-//OASIS//DTD DocBook XML V%2//EN" "../../xml.dcl"' \
172' -- hacks for opensp --' \
173'SYSTEM "file://%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd" "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
174'SYSTEM "http://www.oasis-open.org/docbook/xml/%2/docbookx.dtd" "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
175'' \
176; do echo $l; done >> %1 \
177}
178
9c404149
AM
179#-----------------------------------------------------------------
180# find and gzip all files in %{_mandir} and %{infodir}
181#
182# Requires: xargs, find
183#
184#%no_install_post_compress_docs 1
185%__spec_install_post_compress_docs { \
186echo "Compress man and info pages."; \
187%{!?no_install_post_compress_docs: \
188 %{?verbose:set -x;} \
189 for i in /usr/share/man /usr/X11R6/man /usr/share/info; do \
190 if [ -d "$RPM_BUILD_ROOT$i" ]; then \
191 find "$RPM_BUILD_ROOT$i" -name \*.bz2 -print | xargs -r %{__bzip2} -df; \
192 find "$RPM_BUILD_ROOT$i" -name \*.gz -print | xargs -r %{__gzip} -dnf; \
193 find "$RPM_BUILD_ROOT$i" -type f -print | xargs -r %{__gzip} -9nf; \
194 fi; \
195 done; \
196} }
197
198#-----------------------------------------------------------------
199# Strip executable binaries and shared object files
200#
201# Requires: find, awk, strip, cut, xargs
202#
203#%no_install_post_strip 1
204%__spec_install_post_strip {%{!?debug: \
205%{!?no_install_post_strip: \
206 %{?verbose:set -x;} \
8f74418b 207 echo "Strip executable binaries, archives and shared object files."; \
9c404149
AM
208 filelist=`find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*"`; \
209 elfexelist=`echo $filelist | xargs -r file | \
210 awk '/ELF.*executable/ {print $1}' | cut -d: -f1`; \
211 elfsharedlist=`echo $filelist | xargs -r file | \
212 awk '/LF.*shared object/ {print $1}' | cut -d: -f1`; \
8f74418b
MM
213 elfarchiveslist=`echo $filelist | xargs -r file | \
214 awk '/current ar archive/ {print $1}' | cut -d: -f1`; \
9c404149
AM
215 if [ -n "$elfexelist" ]; then \
216 strip --remove-section=.note --remove-section=.comment $elfexelist; \
217 fi; \
218 if [ -n "$elfsharedlist" ]; then \
219 strip --strip-unneeded --remove-section=.note --remove-section=.comment $elfsharedlist; \
8f74418b
MM
220 fi; \
221 if [ -n "$elfarchiveslist" ]; then \
222 strip --strip-debug --remove-section=.note --remove-section=.comment $elfarchiveslist; \
9c404149
AM
223 fi; } \
224} }
8f74418b 225
d72c185f 226#-----------------------------------------------------------------
ccb8ae8d 227# Find and gzip all kernel modules
228#
229# Requires: find
230#
231#%no_install_post_compress_modules 1
232%__spec_install_post_compress_modules { \
ccb8ae8d 233%{!?no_install_post_compress_modules: \
fc1ea397 234echo "Compress kernel modules if any."; \
ccb8ae8d 235 %{?verbose:set -x;} \
d618340e 236 if test -d $RPM_BUILD_ROOT/lib/modules ; then \
fc1ea397 237 find $RPM_BUILD_ROOT/lib/modules -name \*.o -type f -print | \
d618340e 238 xargs -r %{__gzip} -9nf; \
fc1ea397 239 find $RPM_BUILD_ROOT/lib/modules -name \*.o -type l -printf "%p %l\n" | \
03b234a5 240 while read a b; do ln -sf $b.gz $a.gz; rm -f $a; done; \
d618340e 241 fi; \
ccb8ae8d 242} }
9c404149
AM
243
244%_source_payload w9.gzdio
245%_binary_payload w9.bzdio
246
83094b62 247#-----------------------------------------------------------------
248# Update all GConf2 schemas
249#
250# Requires: GConf2
251#
7bd8c922 252%gconf_schema_install { umask 022; \
253 GCONF_CONFIG_SOURCE="xml:readwrite:/etc/gconf/gconf.xml.defaults" \
254 /usr/bin/gconftool-2 --makefile-install-rule \
255 /etc/gconf/schemas/*.schemas > /dev/null \
3ee1090a 256}
83094b62 257
9c404149
AM
258#-----------------------------------------------------------------
259# post %install sequence:
260# - autodeps exceptions
261# - compress all man and info pages,
262# - strip all ELF executables and ELF shared objects if not %debug.
8f74418b 263# - compress kernel modules if any
9c404149
AM
264
265###################################################################
266# Requires/Provides automation
267# exceptions system by Jacek Konieczny <jajcus@pld.org.pl>
7126cc1b
JK
268%__spec_prep_pre \
269_autoreqprov=n \
270%{?_noautoreqfiles:_autoreqprov=y}\
271%{?_noautoreq:_autoreqprov=y}\
272%{?_noautoreqdep:_autoreqprov=y}\
273%{?_noautoprovfiles:_autoreqprov=y}\
274%{?_noautoprov:_autoreqprov=y}\
f07a68c3 275%{?_noautocompressdoc:_autoreqprov=y}\
7126cc1b
JK
276if [ "$_autoreqprov" = "y" ] ; then \
277 if [ -f %{_builddir}/__rpm_lock ] ; then \
278 echo "Some package using \%_noauto* macros is already being built" >&2 \
279 echo "If it is not true delete %{_builddir}/__rpm_lock" >&2 \
280 exit 1 \
281 else \
282 rm -f %{_builddir}/__rpm_*\
283 touch %{_builddir}/__rpm_lock \
284 fi \
285fi \
f07a68c3 286%{?_noautocompressdoc:echo '%{_noautocompressdoc}' > %{_builddir}/__rpm_noautocompressdoc}\
9c404149
AM
287%{nil}
288
ef437f4b 289%__os_install_post \
9c404149
AM
290%{?_noautoreqfiles:for f in %{_noautoreqfiles} ; do echo %{?buildroot:%{buildroot}}$f >> %{_builddir}/__rpm_noautoreqfiles ; done }\
291%{?_noautoreq:for f in %{_noautoreq} ; do echo "$f" >> %{_builddir}/__rpm_noautoreq ; done }\
292%{?_noautoreqdep:for f in %{_noautoreqdep} ; do echo "$f" >> %{_builddir}/__rpm_noautoreqdep ; done }\
293%{?_noautoprovfiles:for f in %{_noautoprovfiles} ; do echo %{?buildroot:%{buildroot}}$f >> %{_builddir}/__rpm_noautoprovfiles ; done }\
294%{?_noautoprov:for f in %{_noautoprov} ; do echo "$f" >> %{_builddir}/__rpm_noautoprov ; done }\
295%{__spec_install_post_strip}\
296%{__spec_install_post_compress_docs}\
ccb8ae8d 297%{__spec_install_post_compress_modules}\
9c404149 298%{__arch_install_post}\
9c404149
AM
299%{nil}
300
301%__spec_clean_pre %{___build_pre}\
7126cc1b
JK
302_autoreqprov=n \
303%{?_noautoreqfiles:_autoreqprov=y}\
304%{?_noautoreq:_autoreqprov=y}\
305%{?_noautoreqdep:_autoreqprov=y}\
306%{?_noautoprovfiles:_autoreqprov=y}\
307%{?_noautoprov:_autoreqprov=y}\
308%{?_noautoreqfiles:_autoreqprov=y}\
f07a68c3 309%{?_noautocompressdoc:_autoreqprov=y}\
7126cc1b
JK
310if [ "$_autoreqprov" = "y" ] ; then \
311 rm -f %{_builddir}/__rpm_* \
312fi \
9c404149
AM
313%{nil}
314
315
316#%_noautoreqfiles "%{_defaultdocdir}.*" "%{_examplesdir}.*"
317#%_noautoreq %{nil}
318#%_noautoreqdep %{nil}
319#%_noautoprovfiles %{nil}
320#%_noautoprov %{nil}
8f74418b
MM
321%_missing_doc_files_terminate_build 1%{nil}
322%_unpackaged_files_terminate_build %{nil}
8781dc74 323# (X)emacs support
d77dcb61 324%___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
325%_emacs_lispdir %(emacs %___emacs_lispdir_helper)
326%_xemacs_lispdir %(xemacs %___emacs_lispdir_helper)
This page took 0.102198 seconds and 4 git commands to generate.