]> git.pld-linux.org Git - packages/rpm-build-macros.git/blob - rpm.macros
- fixed gettextize
[packages/rpm-build-macros.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 [ -f po/Makevars ]; then \
43         gettextize --copy --force; \
44     elif gettextize --version | grep -q '0\.11\.' ; then \
45         gettextize --copy --force  --intl; \
46             cp -f po/Makevars{.template,}; \
47         else \
48                 gettextize --copy --force; \
49     fi; \
50 }               
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 pixmaps for applnk/desktop files
119 %_pixmapsdir    /usr/X11R6/share/pixmaps
120
121 # Location of fonts directories
122 %_fontsdir      /usr/share/fonts
123
124 # Current date
125 %date           %(LC_ALL="C" date +"%a %b %d %Y")
126
127 # tmp directory
128 %tmpdir         %(echo "${TMPDIR:-/tmp}")
129
130 # Example files, programs, scripts...
131 %_examplesdir   /usr/src/examples
132
133 # The directory holding Linux kernel sources
134 %_kernelsrcdir  /usr/src/linux
135
136 # If non-empty "debug" macro defined, add "dbg" suffix to release number
137 %_rpmfilename           %%{NAME}-%%{VERSION}-%%{RELEASE}%{?debug:dbg}.%%{ARCH}.rpm
138
139 # Requires name = version-release
140 %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")
141 %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)")
142 %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)")
143
144 # kernel version-release handling
145 %__kernel_ver    %(grep UTS_RELEASE %{_kernelsrcdir}/include/linux/version.h 2>/dev/null | cut -d'"' -f2)
146 %__kernel_rel    %(LC_ALL="C" rpm -qf %{_kernelsrcdir}/include/linux/version.h --queryformat "%{RELEASE}" | grep -v "is not")
147 %_kernel_ver     %(echo %{__kernel_ver}%{!?_without_dist_kernel:-%{__kernel_rel}})
148 %_kernel_ver_str %(echo %{_kernel_ver} | sed s/-/_/g)
149
150 # sgml macros
151 %xmlcat_add()            /usr/bin/xmlcatalog --noout --add nextCatalog \"\" %1 /etc/xml/catalog
152 %xmlcat_del()            /usr/bin/xmlcatalog --noout --del %1 /etc/xml/catalog
153 %xmlcat_add_rewrite      /usr/bin/xmlcatalog --noout --add rewriteSystem
154 %xmlcat_create()          /usr/bin/xmlcatalog --noout --create %1
155 %sgmlcat_add()           /usr/bin/install-catalog --add %1 %2 > /dev/null
156 %sgmlcat_del()           /usr/bin/install-catalog --remove %1 %2 > /dev/null
157 %docbook_sgmlcat_fix() { for l in \
158 '' \
159 '  -- default decl --' \
160 'DTDDECL "-//OASIS//DTD DocBook XML V%2//EN" "../../xml.dcl"' \
161 '  -- hacks for opensp --' \
162 'SYSTEM "file://%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd" "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
163 'SYSTEM "http://www.oasis-open.org/docbook/xml/%2/docbookx.dtd"                  "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
164 '' \
165 ; do echo $l; done >> %1 \
166 }
167
168 #-----------------------------------------------------------------
169 # find and gzip all files in %{_mandir} and %{infodir}
170 #
171 # Requires: xargs, find
172 #
173 #%no_install_post_compress_docs 1
174 %__spec_install_post_compress_docs { \
175 echo "Compress man and info pages."; \
176 %{!?no_install_post_compress_docs: \
177         %{?verbose:set -x;} \
178         for i in /usr/share/man /usr/X11R6/man /usr/share/info; do \
179                 if [ -d "$RPM_BUILD_ROOT$i" ]; then \
180                         find "$RPM_BUILD_ROOT$i" -name \*.bz2 -print | xargs -r %{__bzip2} -df; \
181                         find "$RPM_BUILD_ROOT$i" -name \*.gz -print | xargs -r %{__gzip} -dnf; \
182                         find "$RPM_BUILD_ROOT$i" -type f -print | xargs -r %{__gzip} -9nf; \
183                 fi; \
184         done; \
185 } }
186
187 #-----------------------------------------------------------------
188 # Strip executable binaries and shared object files
189 #
190 # Requires: find, awk, strip, cut, xargs
191 #
192 #%no_install_post_strip 1
193 %__spec_install_post_strip {%{!?debug: \
194 %{!?no_install_post_strip: \
195         %{?verbose:set -x;} \
196         echo "Strip executable binaries, archives and shared object files."; \
197         filelist=`find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*"`; \
198         elfexelist=`echo $filelist | xargs -r file | \
199                 awk '/ELF.*executable/ {print $1}' | cut -d: -f1`; \
200         elfsharedlist=`echo $filelist | xargs -r file | \
201                 awk '/LF.*shared object/ {print $1}' | cut -d: -f1`; \
202         elfarchiveslist=`echo $filelist | xargs -r file | \
203                 awk '/current ar archive/ {print $1}' | cut -d: -f1`; \
204         if [ -n "$elfexelist" ]; then \
205                 strip --remove-section=.note  --remove-section=.comment $elfexelist; \
206         fi; \
207         if [ -n "$elfsharedlist" ]; then \
208                 strip --strip-unneeded --remove-section=.note  --remove-section=.comment $elfsharedlist; \
209         fi; \
210         if [ -n "$elfarchiveslist" ]; then \
211                 strip --strip-debug --remove-section=.note  --remove-section=.comment $elfarchiveslist; \
212         fi; } \
213 } }
214
215 #-----------------------------------------------------------------
216 # Find and gzip all kernel modules
217 #
218 # Requires: find
219 #
220 #%no_install_post_compress_modules  1
221 %__spec_install_post_compress_modules { \
222 %{!?no_install_post_compress_modules: \
223 echo "Compress kernel modules if any."; \
224     %{?verbose:set -x;} \
225     if test -d $RPM_BUILD_ROOT/lib/modules ; then \
226        find $RPM_BUILD_ROOT/lib/modules -name \*.o -type f -print | \
227        xargs -r %{__gzip} -9nf; \
228            find $RPM_BUILD_ROOT/lib/modules -name \*.o -type l -printf "%p %l\n" | \
229            while read a b; do ln -sf $b.gz $a.gz; rm -f $a; done; \
230     fi; \
231 } }
232
233 %_source_payload        w9.gzdio
234 %_binary_payload        w9.bzdio
235
236 #-----------------------------------------------------------------
237 # Update all GConf2 schemas
238 #
239 # Requires: GConf2
240 #
241 %gconf_schema_install { \
242     GCONF_CONFIG_SOURCE="" \
243     %{_bindir}/gconftool-2 --makefile-install-rule \
244     /etc/X11/GNOME2/gconf/schemas/*.schemas > /dev/null \
245 }
246
247 #-----------------------------------------------------------------
248 # post %install sequence:
249 # - autodeps exceptions
250 # - compress all man and info pages,
251 # - strip all ELF executables and ELF shared objects if not %debug.
252 # - compress kernel modules if any
253
254 ###################################################################
255 # Requires/Provides automation
256 # exceptions system by Jacek Konieczny <jajcus@pld.org.pl>
257 %__spec_prep_pre \
258 _autoreqprov=n \
259 %{?_noautoreqfiles:_autoreqprov=y}\
260 %{?_noautoreq:_autoreqprov=y}\
261 %{?_noautoreqdep:_autoreqprov=y}\
262 %{?_noautoprovfiles:_autoreqprov=y}\
263 %{?_noautoprov:_autoreqprov=y}\
264 %{?_noautocompressdoc:_autoreqprov=y}\
265 if [ "$_autoreqprov" = "y" ] ; then \
266     if [ -f %{_builddir}/__rpm_lock ] ; then \
267         echo "Some package using \%_noauto*  macros is already being built" >&2 \
268         echo "If it is not true delete %{_builddir}/__rpm_lock" >&2 \
269         exit 1 \
270     else \
271         rm -f %{_builddir}/__rpm_*\
272         touch %{_builddir}/__rpm_lock \
273     fi \
274 fi \
275 %{?_noautocompressdoc:echo '%{_noautocompressdoc}' > %{_builddir}/__rpm_noautocompressdoc}\
276 %{nil}
277
278 %__os_install_post \
279 %{?_noautoreqfiles:for f in %{_noautoreqfiles} ; do echo %{?buildroot:%{buildroot}}$f >> %{_builddir}/__rpm_noautoreqfiles ; done }\
280 %{?_noautoreq:for f in %{_noautoreq} ; do echo "$f" >> %{_builddir}/__rpm_noautoreq ; done }\
281 %{?_noautoreqdep:for f in %{_noautoreqdep} ; do echo "$f" >> %{_builddir}/__rpm_noautoreqdep ; done }\
282 %{?_noautoprovfiles:for f in %{_noautoprovfiles} ; do echo %{?buildroot:%{buildroot}}$f >> %{_builddir}/__rpm_noautoprovfiles ; done }\
283 %{?_noautoprov:for f in %{_noautoprov} ; do echo "$f" >> %{_builddir}/__rpm_noautoprov ; done }\
284 %{__spec_install_post_strip}\
285 %{__spec_install_post_compress_docs}\
286 %{__spec_install_post_compress_modules}\
287 %{__arch_install_post}\
288 %{nil}
289
290 %__spec_clean_pre       %{___build_pre}\
291 _autoreqprov=n \
292 %{?_noautoreqfiles:_autoreqprov=y}\
293 %{?_noautoreq:_autoreqprov=y}\
294 %{?_noautoreqdep:_autoreqprov=y}\
295 %{?_noautoprovfiles:_autoreqprov=y}\
296 %{?_noautoprov:_autoreqprov=y}\
297 %{?_noautoreqfiles:_autoreqprov=y}\
298 %{?_noautocompressdoc:_autoreqprov=y}\
299 if [ "$_autoreqprov" = "y" ] ; then \
300         rm -f %{_builddir}/__rpm_* \
301 fi \
302 %{nil}
303
304
305 #%_noautoreqfiles       "%{_defaultdocdir}.*" "%{_examplesdir}.*"
306 #%_noautoreq            %{nil}
307 #%_noautoreqdep         %{nil}
308 #%_noautoprovfiles      %{nil}
309 #%_noautoprov           %{nil}
310 %_missing_doc_files_terminate_build     1%{nil}
311 %_unpackaged_files_terminate_build      %{nil}
This page took 0.095567 seconds and 4 git commands to generate.