]> git.pld-linux.org Git - packages/rpm.git/blob - rpm.macros
- support for configuredir in %%configure (but you don't need to use it as in %%confi...
[packages/rpm.git] / rpm.macros
1 # PLD rpm macros
2
3 %__id           @__ID@
4 %__id_u         %{__id} -u 
5 %__chown_Rhf           @__CHOWN_RHF@
6 %__chgrp_Rhf           @__CHGRP_RHF@
7
8 %_fixowner       [ `%{__id_u}` = '0' ] && %{__chown_Rhf} root.@ROOT_GROUP@
9 %_fixgroup       true
10 %_fixperms             %{__chmod} -Rf @FIXPERMS@
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
17 %_sharedstatedir /var/lib
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
26 %_defaultdocdir  %{_usr}/share/doc
27 #-----------------------------------------------------------------
28 # CFLAGS and LDFLAGS used to build
29
30 %debugcflags    -O0 -g -Wall
31 %rpmcflags      %{?debug:%debugcflags}%{!?debug:%optflags}
32 %rpmldflags     %{!?debug:-s}
33
34 # kernel compiler
35 %kgcc           gcc
36 %kgcc_package   gcc
37
38 # Build system path macros.
39 #
40 %__libtoolize           libtoolize --copy --force
41 %__gettextize { \
42     if ! gettextize --version | grep -q '0\.10\.' ; then \
43         if grep -qs 'AM_GNU_GETTEXT.*external' configure.{ac,in} ; then \
44             gettextize --copy --force --no-changelog; \
45         else \
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; \
53     fi; \
54 }
55 %__autopoint            autopoint --force
56 %__automake             automake -a -c -f --foreign
57 %__autoconf             autoconf %{?debug:-Wall}
58
59 #-----------------------------------------------------------------
60 %configure2_13 { \
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 ; \
66  CPPFLAGS="${CPPFLAGS:-}" ; export CPPFLAGS ; \
67  %{?__cc:CC=%{__cc} ; export CC ; } \
68  %{?__cxx:CXX=%{__cxx} ; export CXX ; } \
69  %{?configuredir:%{configuredir}}%{!?configuredir:.}/configure \
70         --host=%{_target_platform} \
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
86 #----------------------------------------------------------------
87 %configure { \
88         %{?configuredir:%{configuredir}}%{!?configuredir:.}/configure \
89         LDFLAGS="${LDFLAGS:-%rpmldflags}" \
90         CFLAGS="${CFLAGS:-%rpmcflags}" \
91         CXXFLAGS="${CXXFLAGS:-%rpmcflags}" \
92         FFLAGS="${FFLAGS:-%rpmcflags}" \
93         CPPFLAGS="${CPPFLAGS:-}" \
94         %{?__cc:CC=%{__cc}} \
95         %{?__cxx:CXX=%{__cxx}} \
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
112 # Location of autoconf macros
113 %_aclocaldir    %(aclocal --print-ac-dir)
114
115 # Location of omf files
116 %_omf_dest_dir  %(scrollkeeper-config --omfdir)
117
118 # Location of pkgconfig files
119 %_pkgconfigdir  /usr/lib/pkgconfig
120
121 # Location of top applink dir
122 %_applnkdir     /usr/X11R6/share/applnk
123
124 # Location of desktop files
125 %_desktopdir    /usr/share/applications
126
127 # Location pixmaps for applnk/desktop files
128 %_pixmapsdir    /usr/share/pixmaps
129
130 # Location of fonts directories
131 %_fontsdir      /usr/share/fonts
132
133 # Location of Gtk and associated libraries documentation
134 %_gtkdocdir  %{_defaultdocdir}/gtk-doc/html
135
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
145 # The directory holding Linux kernel sources
146 %_kernelsrcdir  /usr/src/linux
147
148 # If non-empty "debug" macro defined, add "dbg" suffix to release number
149 %_rpmfilename           %%{NAME}-%%{VERSION}-%%{RELEASE}%{?debug:dbg}.%%{ARCH}.rpm
150
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)")
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)
161
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
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 { \
187 echo "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;} \
208         echo "Strip executable binaries, archives and shared object files."; \
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`; \
214         elfarchiveslist=`echo $filelist | xargs -r file | \
215                 awk '/current ar archive/ {print $1}' | cut -d: -f1`; \
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; \
221         fi; \
222         if [ -n "$elfarchiveslist" ]; then \
223                 strip --strip-debug --remove-section=.note  --remove-section=.comment $elfarchiveslist; \
224         fi; } \
225 } }
226
227 #-----------------------------------------------------------------
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 { \
234 %{!?no_install_post_compress_modules: \
235 echo "Compress kernel modules if any."; \
236     %{?verbose:set -x;} \
237     if test -d $RPM_BUILD_ROOT/lib/modules ; then \
238        find $RPM_BUILD_ROOT/lib/modules -name \*.o -type f -print | \
239        xargs -r %{__gzip} -9nf; \
240            find $RPM_BUILD_ROOT/lib/modules -name \*.o -type l -printf "%p %l\n" | \
241            while read a b; do ln -sf $b.gz $a.gz; rm -f $a; done; \
242     fi; \
243 } }
244
245 %_source_payload        w9.gzdio
246 %_binary_payload        w9.bzdio
247
248 #-----------------------------------------------------------------
249 # Update all GConf2 schemas
250 #
251 # Requires: GConf2
252 #
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 \
257 }
258
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.
264 # - compress kernel modules if any
265
266 ###################################################################
267 # Requires/Provides automation
268 # exceptions system by Jacek Konieczny <jajcus@pld.org.pl>
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}\
276 %{?_noautocompressdoc:_autoreqprov=y}\
277 if [ "$_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 \
286 fi \
287 %{?_noautocompressdoc:echo '%{_noautocompressdoc}' > %{_builddir}/__rpm_noautocompressdoc}\
288 %{nil}
289
290 %__os_install_post \
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}\
298 %{__spec_install_post_compress_modules}\
299 %{__arch_install_post}\
300 %{nil}
301
302 %__spec_clean_pre       %{___build_pre}\
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}\
310 %{?_noautocompressdoc:_autoreqprov=y}\
311 if [ "$_autoreqprov" = "y" ] ; then \
312         rm -f %{_builddir}/__rpm_* \
313 fi \
314 %{nil}
315
316
317 #%_noautoreqfiles       "%{_defaultdocdir}.*" "%{_examplesdir}.*"
318 #%_noautoreq            %{nil}
319 #%_noautoreqdep         %{nil}
320 #%_noautoprovfiles      %{nil}
321 #%_noautoprov           %{nil}
322 %_missing_doc_files_terminate_build     1%{nil}
323 %_unpackaged_files_terminate_build      %{nil}
This page took 0.059699 seconds and 4 git commands to generate.