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