]> git.pld-linux.org Git - packages/rpm.git/blob - rpm.macros
- fixed __spec_prep_pre (missing ___build_pre); ported macros 1.125
[packages/rpm.git] / rpm.macros
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
21 #-----------------------------------------------------------------
22 # CFLAGS and LDFLAGS used to build
23
24 %debugcflags    -O0 -g
25 %rpmcflags      %{?debug:%debugcflags}%{!?debug:%optflags}
26 %rpmldflags     %{!?debug:-s}
27
28 # kernel compiler
29 %kgcc           gcc
30 %kgcc_package   gcc
31
32 #-----------------------------------------------------------------
33 # Build system path macros.
34 #
35 %__libtoolize           libtoolize --copy --force
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 }
50 %__autopoint            autopoint --force
51 %__automake             automake -a -c -f --foreign
52 %__autoconf             autoconf %{?debug:-Wall}
53
54 #-----------------------------------------------------------------
55 %configure2_13 { \
56  if [ -n "$LINGUAS" ]; then unset LINGUAS; fi; \
57  LDFLAGS="${LDFLAGS:-%rpmldflags}" ; export LDFLAGS ; \
58  CFLAGS="${CFLAGS:-%rpmcflags}" ; export CFLAGS ; \
59  CXXFLAGS="${CXXFLAGS:-%rpmcflags}" ; export CXXFLAGS ; \
60  FFLAGS="${FFLAGS:-%rpmcflags}" ; export FFLAGS ; \
61  CPPFLAGS="${CPPFLAGS:-}" ; export CPPFLAGS ; \
62  %{?__cc:CC=%{__cc} ; export CC ; } \
63  %{?__cxx:CXX=%{__cxx} ; export CXX ; } \
64  %{?configuredir:%{configuredir}}%{?!configuredir:.}/configure \
65         --host=%{_target_platform} \
66         --prefix=%{_prefix} \
67         --exec-prefix=%{_exec_prefix} \
68         --bindir=%{_bindir} \
69         --sbindir=%{_sbindir} \
70         --sysconfdir=%{_sysconfdir} \
71         --datadir=%{_datadir} \
72         --includedir=%{_includedir} \
73         --libdir=%{_libdir} \
74         --libexecdir=%{_libexecdir} \
75         --localstatedir=%{_localstatedir} \
76         --sharedstatedir=%{_sharedstatedir} \
77         --mandir=%{_mandir} \
78         --infodir=%{_infodir} \
79 }
80
81 #----------------------------------------------------------------
82 %configure {./configure \
83         LDFLAGS="${LDFLAGS:-%rpmldflags}" \
84         CFLAGS="${CFLAGS:-%rpmcflags}" \
85         CXXFLAGS="${CXXFLAGS:-%rpmcflags}" \
86         FFLAGS="${FFLAGS:-%rpmcflags}" \
87         CPPFLAGS="${CPPFLAGS:-}" \
88         %{?__cc:CC=%{__cc}} \
89         %{?__cxx:CXX=%{__cxx}} \
90         --build=%{_target_platform} \
91         --prefix=%{_prefix} \
92         --exec-prefix=%{_exec_prefix} \
93         --bindir=%{_bindir} \
94         --sbindir=%{_sbindir} \
95         --sysconfdir=%{_sysconfdir} \
96         --datadir=%{_datadir} \
97         --includedir=%{_includedir} \
98         --libdir=%{_libdir} \
99         --libexecdir=%{_libexecdir} \
100         --localstatedir=%{_localstatedir} \
101         --sharedstatedir=%{_sharedstatedir} \
102         --mandir=%{_mandir} \
103         --infodir=%{_infodir} \
104 }
105
106 # Location of autoconf macros
107 %_aclocaldir    %(aclocal --print-ac-dir)
108
109 # Location of omf files
110 %_omf_dest_dir  %(scrollkeeper-config --omfdir)
111
112 # Location of pkgconfig files
113 %_pkgconfigdir  /usr/lib/pkgconfig
114
115 # Location of top applink dir
116 %_applnkdir     /usr/X11R6/share/applnk
117
118 # Location of desktop files
119 %_desktopdir    /usr/X11R6/share/applications
120
121 # Location of pixmaps for applnk/desktop files
122 %_pixmapsdir    /usr/X11R6/share/pixmaps
123
124 # Location of themable icons for applnk/desktop files
125 %_iconsdir      /usr/X11R6/share/icons
126
127 # Location of fonts directories
128 %_fontsdir      /usr/share/fonts
129
130 # Location of Gtk and associated libraries documentation
131 %_gtkdocdir     %{_defaultdocdir}/gtk-doc/html
132
133 # Current date
134 %date           %(LC_ALL="C" date +"%a %b %d %Y")
135
136 # tmp directory
137 %tmpdir         %(echo "${TMPDIR:-/tmp}")
138
139 # Example files, programs, scripts...
140 %_examplesdir   /usr/src/examples
141
142 # The directory holding Linux kernel sources
143 %_kernelsrcdir  /usr/src/linux
144
145 # XMMS specific macros
146 %xmms_prefix                    %(echo `xmms-config --prefix`)
147 %xmms_exec_prefix               %(echo `xmms-config --exec-prefix`)
148 %xmms_version                   %(echo `xmms-config --version`)
149 %xmms_datadir                   %(echo `xmms-config --data-dir`)
150 %xmms_plugindir                 %(echo `xmms-config --plugin-dir`)
151 %xmms_visualization_plugindir   %(echo `xmms-config --visualization-plugin-dir`)
152 %xmms_input_plugindir           %(echo `xmms-config --input-plugin-dir`)
153 %xmms_output_plugindir          %(echo `xmms-config --output-plugin-dir`)
154 %xmms_effect_plugindir          %(echo `xmms-config --effect-plugin-dir`)
155 %xmms_general_plugindir         %(echo `xmms-config --general-plugin-dir`)
156
157 # If non-empty "debug" macro defined, add "dbg" suffix to release number
158 %_rpmfilename   %%{NAME}-%%{VERSION}-%%{RELEASE}%{?debug:dbg}.%%{ARCH}.rpm
159
160 # requires name = version-release
161 %requires_releq()               %(LC_ALL="C" rpm -q --queryformat 'Requires:%%{NAME} = %%{VERSION}-%%{RELEASE}' %1| grep -v "is not")
162 %requires_kernel_releq()        %(LC_ALL="C" rpm -q --queryformat 'Prereq:kernel = %%{VERSION}-%%{RELEASE}' kernel-headers | grep -v "is not")
163 %requires_releq_kernel_up()     %(LC_ALL="C" rpm -q --queryformat 'Prereq:kernel-up = %%{VERSION}-%%{RELEASE}' kernel-headers | grep -v "is not")
164 %requires_releq_kernel_smp()    %(LC_ALL="C" rpm -q --queryformat 'Prereq:kernel-smp = %%{VERSION}-%%{RELEASE}' kernel-headers | grep -v "is not")
165 %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")
166
167 %apache_modules_api %(awk '/#define MODULE_MAGIC_NUMBER_MAJOR/ {print $3}' `apr-config --includedir`/ap_mmn.h)
168
169 # kernel version-release handling
170 %__kernel_ver    %(grep UTS_RELEASE %{_kernelsrcdir}/include/linux/version.h 2>/dev/null | cut -d'"' -f2)
171 %__kernel_rel    %(LC_ALL="C" rpm -qf %{_kernelsrcdir}/include/linux/version.h --queryformat "%{RELEASE}" | grep -v "is not")
172 %_kernel_ver     %(echo %{__kernel_ver}%{!?_without_dist_kernel:-%{__kernel_rel}})
173 %_kernel_ver_str %(echo %{_kernel_ver} | sed s/-/_/g)
174
175 # sgml macros
176 %xmlcat_add()            /usr/bin/xmlcatalog --noout --add nextCatalog \"\" %1 /etc/xml/catalog
177 %xmlcat_del()            /usr/bin/xmlcatalog --noout --del %1 /etc/xml/catalog
178 %xmlcat_add_rewrite      /usr/bin/xmlcatalog --noout --add rewriteSystem
179 %xmlcat_create()          /usr/bin/xmlcatalog --noout --create %1
180 %sgmlcat_add()           /usr/bin/install-catalog --add %1 %2 > /dev/null
181 %sgmlcat_del()           /usr/bin/install-catalog --remove %1 %2 > /dev/null
182 %docbook_sgmlcat_fix() { for l in \
183 '' \
184 '  -- default decl --' \
185 'DTDDECL "-//OASIS//DTD DocBook XML V%2//EN" "../../xml.dcl"' \
186 '  -- hacks for opensp --' \
187 'SYSTEM "file://%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd" "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
188 'SYSTEM "http://www.oasis-open.org/docbook/xml/%2/docbookx.dtd"                  "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
189 '' \
190 ; do echo $l; done >> %1 \
191 }
192
193 #-----------------------------------------------------------------
194 # Update all GConf2 schemas
195 #
196 # Requires: GConf2
197 #
198 %gconf_schema_install { umask 022; \
199     GCONF_CONFIG_SOURCE="xml:readwrite:/etc/gconf/gconf.xml.defaults" \
200     /usr/bin/gconftool-2 --makefile-install-rule \
201     /etc/gconf/schemas/*.schemas > /dev/null \
202 }
203
204 #-----------------------------------------------------------------
205 # find and gzip all files in %{_mandir} and %{infodir}
206 #
207 # Requires: xargs, find
208 #
209 #%no_install_post_compress_docs 1
210 %__spec_install_post_compress_docs { \
211 echo "Compress man and info pages."; \
212 %{!?no_install_post_compress_docs: \
213         %{?verbose:set -x;} \
214         for i in /usr/share/man /usr/X11R6/man /usr/share/info; do \
215                 if [ -d "$RPM_BUILD_ROOT$i" ]; then \
216                         find "$RPM_BUILD_ROOT$i" -name \*.bz2 -print | xargs -r %{__bzip2} -df; \
217                         find "$RPM_BUILD_ROOT$i" -name \*.gz -print | xargs -r %{__gzip} -dnf; \
218                         find "$RPM_BUILD_ROOT$i" -type f -print | xargs -r %{__gzip} -9nf; \
219                 fi; \
220         done; \
221 } }
222
223 #-----------------------------------------------------------------
224 # Strip executable binaries and shared object files
225 #
226 # Requires: find, awk, strip, cut, xargs
227 #
228 #%no_install_post_strip 1
229 %__spec_install_post_strip {%{!?debug: \
230 %{!?no_install_post_strip: \
231         %{?verbose:set -x;} \
232         echo "Strip executable binaries and shared object files."; \
233         filelist=`find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*"`; \
234         elfexelist=`echo $filelist | xargs -r file | \
235                 awk '/ELF.*executable/ {print $1}' | cut -d: -f1`; \
236         elfsharedlist=`echo $filelist | xargs -r file | \
237                 awk '/LF.*shared object/ {print $1}' | cut -d: -f1`; \
238         if [ -n "$elfexelist" ]; then \
239                 strip --remove-section=.note  --remove-section=.comment $elfexelist; \
240         fi; \
241         if [ -n "$elfsharedlist" ]; then \
242                 strip --strip-unneeded --remove-section=.note  --remove-section=.comment $elfsharedlist; \
243         fi; } \
244 } }
245 #-----------------------------------------------------------------
246 # remove all RPATH from executable binaries and shared object files
247 #
248 # Requires: find, awk, cut, xargs, chrpath, uname
249 #
250 #%no_install_post_chrpath       1
251 %__spec_install_post_chrpath {%{!?debug: \
252 %{!?no_install_post_chrpath: \
253         %{?verbose:set -x;} \
254 echo "Remove RPATH from executable binaries and shared object files."; \
255 if [ "$(uname -m)" != alpha ] ; then \
256 find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*" | xargs -r file | \
257         awk '/ELF.*(executable|shared object)/ {print $1}' | cut -d: -f1 | \
258 while read file ; do \
259         rpath= ; \
260         chmod u+w "$file"; \
261         for dir in `chrpath -l "$file" | \
262                     awk '/RPATH=/ { gsub(/.*RPATH=/,""); gsub(/:/," "); print $0 }'` ; do \
263                         case $dir in \
264                         /home/* | /tmp/* | /usr/lib | /lib | /usr/local/lib | /usr/X11R6/lib ) \
265                                 echo "remove-rpath: $dir in $file"; \
266                                 ;; \
267                         * ) \
268                                 if [ "$rpath" = "" ] ; then rpath="$dir" ; \
269                                 else rpath="$rpath:$dir" ; fi ; \
270                                 ;; \
271                         esac ; \
272         done ; \
273         if [ "$rpath" = "" ] ; then chrpath -d "$file" > /dev/null ; \
274         else chrpath -r "$rpath" "$file" > /dev/null ; fi ; \
275 done; fi; } \
276 } }
277 #-----------------------------------------------------------------
278 # Find and gzip all kernel modules
279 #
280 # Requires: find
281 #
282 #%no_install_post_compress_modules  1
283 %__spec_install_post_compress_modules { \
284 %{!?no_install_post_compress_modules: \
285 echo "Compress kernel modules if any."; \
286     %{?verbose:set -x;} \
287     if test -d $RPM_BUILD_ROOT/lib/modules ; then \
288         find $RPM_BUILD_ROOT/lib/modules -name \*.o -type f -print | \
289         xargs -r %{__gzip} -9nf; \
290         find $RPM_BUILD_ROOT/lib/modules -name \*.o -type l -printf "%p %l\n" | \
291         while read a b; do ln -sf $b.gz $a.gz; rm -f $a; done; \
292     fi; \
293 } }
294
295 %_source_payload        w9.gzdio
296 %_binary_payload        w9.bzdio
297
298 #-----------------------------------------------------------------
299 # post %install sequence:
300 # - autodeps exceptions
301 # - compress all man and info pages,
302 # - strip all ELF executables and ELF shared objects if not %debug.
303
304 ###################################################################
305 # Requires/Provides automation
306 # exceptions system by Jacek Konieczny <jajcus@pld.org.pl>
307 %__spec_prep_pre \
308 _autoreqprov=n \
309 %{?_noautoreqfiles:_autoreqprov=y}\
310 %{?_noautoreq:_autoreqprov=y}\
311 %{?_noautoreqdep:_autoreqprov=y}\
312 %{?_noautoprovfiles:_autoreqprov=y}\
313 %{?_noautoprov:_autoreqprov=y}\
314 %{?_noautocompressdoc:_autoreqprov=y}\
315 if [ "$_autoreqprov" = "y" ] ; then \
316     if [ -f %{_builddir}/__rpm_lock ] ; then \
317         echo "Some package using \%_noauto*  macros is already being built" >&2 \
318         echo "If it is not true delete %{_builddir}/__rpm_lock" >&2 \
319         exit 1 \
320     else \
321         rm -f %{_builddir}/__rpm_*\
322         touch %{_builddir}/__rpm_lock \
323     fi \
324 fi \
325 %{?_noautocompressdoc:echo '%{_noautocompressdoc}' > %{_builddir}/__rpm_noautocompressdoc}\
326 %{___build_pre}\
327 %{nil}
328
329 %__os_install_post \
330 %{?_noautoreqfiles:for f in %{_noautoreqfiles} ; do echo %{?buildroot:%{buildroot}}$f >> %{_builddir}/__rpm_noautoreqfiles ; done }\
331 %{?_noautoreq:for f in %{_noautoreq} ; do echo "$f" >> %{_builddir}/__rpm_noautoreq ; done }\
332 %{?_noautoreqdep:for f in %{_noautoreqdep} ; do echo "$f" >> %{_builddir}/__rpm_noautoreqdep ; done }\
333 %{?_noautoprovfiles:for f in %{_noautoprovfiles} ; do echo %{?buildroot:%{buildroot}}$f >> %{_builddir}/__rpm_noautoprovfiles ; done }\
334 %{?_noautoprov:for f in %{_noautoprov} ; do echo "$f" >> %{_builddir}/__rpm_noautoprov ; done }\
335 %{__spec_install_post_strip}\
336 %{__spec_install_post_chrpath}\
337 %{__spec_install_post_compress_docs}\
338 %{__spec_install_post_compress_modules}\
339 %{__arch_install_post}\
340 %{nil}
341
342 %__spec_clean_pre       %{___build_pre}\
343 _autoreqprov=n \
344 %{?_noautoreqfiles:_autoreqprov=y}\
345 %{?_noautoreq:_autoreqprov=y}\
346 %{?_noautoreqdep:_autoreqprov=y}\
347 %{?_noautoprovfiles:_autoreqprov=y}\
348 %{?_noautoprov:_autoreqprov=y}\
349 %{?_noautoreqfiles:_autoreqprov=y}\
350 %{?_noautocompressdoc:_autoreqprov=y}\
351 if [ "$_autoreqprov" = "y" ] ; then \
352         rm -f %{_builddir}/__rpm_* \
353 fi \
354 %{nil}
355
356
357 #%_noautoreqfiles       "%{_defaultdocdir}.*" "%{_examplesdir}.*"
358 #%_noautoreq            %{nil}
359 #%_noautoreqdep         %{nil}
360 #%_noautoprovfiles      %{nil}
361 #%_noautoprov           %{nil}
362
363 # depmod macro
364 %depmod() { \
365 if [ -e /boot/System.map-%1 ]; then \
366         /sbin/depmod -a -F /boot/System.map-%1 %1; \
367 else \
368         if [ -e /boot/System.map ]; then \
369                 /sbin/depmod -a -F /boot/System.map %1; \
370         else \
371                 /sbin/depmod -a %1; \
372         fi \
373 fi; \
374 }
375
376 # ------------------------------------------------------------------------
377 # Conditional build stuff.
378
379 # Check if symbol is defined.
380 # Example usage: %if %{defined with_foo} && %{undefined with_bar} ...
381 %defined()      %{expand:%%{?%{1}:1}%%{!?%{1}:0}}
382 %undefined()    %{expand:%%{?%{1}:0}%%{!?%{1}:1}}
383
384 # Shorthand for %{defined with_...}
385 %with()         %{expand:%%{?with_%{1}:1}%%{!?with_%{1}:0}}
386 %without()      %{expand:%%{?with_%{1}:0}%%{!?with_%{1}:1}}
387
388 # Handle conditional builds. %bcond_with is for case when feature is
389 # default off and needs to be activated with --with ... command line 
390 # switch. %bcond_without is for the dual case.
391 #
392 # %bcond_with foo defines symbol with_foo if --with foo was specified on
393 # command line.
394 # %bcond_without foo defines symbol with_foo if --without foo was *not* 
395 # specified on command line.
396 #
397 # For example:
398 #
399 # %bcond_with extra_fonts
400 # %bcond_without static
401 # %ifdef with_extra_fonts
402 # ...
403 # %endif
404 # %ifdef with_static
405 # ...
406 # %endif
407 # %{?with_static: ... }
408 # %{!?with_static: ... }
409 # %{?with_extra_fonts: ... }
410 # %{!?with_extra_fonts: ... }
411
412 # The bottom line: never use without_foo, _with_foo nor _without_foo, only
413 # with_foo. This way changing default set of bconds for given spec is just
414 # a matter of changing single line in it and syntax is more readable.
415 %bcond_with()           %{expand:%%{?_with_%{1}:%%global with_%{1} 1}}
416 %bcond_without()        %{expand:%%{!?_without_%{1}:%%global with_%{1} 1}}
417 # ------------------------------------------------------------------------
This page took 0.070628 seconds and 3 git commands to generate.