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