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