]> git.pld-linux.org Git - packages/rpm.git/blame - rpm.macros
- rpm4.1
[packages/rpm.git] / rpm.macros
CommitLineData
a8bf9720
AF
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
cd33aab7
AM
21#-----------------------------------------------------------------
22# CFLAGS and LDFLAGS used to build
23
24%debugcflags -O0 -g
25%rpmcflags %{?debug:%debugcflags}%{!?debug:%optflags}
26%rpmldflags %{!?debug:-s}
27
a544555d 28# kernel compiler
7c956c69
KT
29%kgcc gcc
30%kgcc_package gcc
a544555d 31
5f9f9bd7 32#-----------------------------------------------------------------
33# Build system path macros.
34#
35%__libtoolize libtoolize --copy --force
fa4547da
JB
36%__gettextize gettextize --copy --force
37%__automake automake -a -c -f --foreign
4413e4a3 38%__autoconf autoconf %{?debug:-Wall}
5f9f9bd7 39
cd33aab7 40#-----------------------------------------------------------------
9f0287b5 41%configure2_13 { \
cd33aab7
AM
42 if [ -n "$LINGUAS" ]; then unset LINGUAS; fi; \
43 LDFLAGS="${LDFLAGS:-%rpmldflags}" ; export LDFLAGS ; \
44 CFLAGS="${CFLAGS:-%rpmcflags}" ; export CFLAGS ; \
45 CXXFLAGS="${CXXFLAGS:-%rpmcflags}" ; export CXXFLAGS ; \
46 FFLAGS="${FFLAGS:-%rpmcflags}" ; export FFLAGS ; \
c55f2219 47 CPPFLAGS="${CPPFLAGS:-}" ; export CPPFLAGS ; \
700ee83b
AM
48 %{?__cc:CC=%{__cc} ; export CC ; } \
49 %{?__cxx:CXX=%{__cxx} ; export CXX ; } \
a640d5c2 50 %{?configuredir:%{configuredir}}%{?!configuredir:.}/configure \
fa74a11c 51 --host=%{_target_platform} \
cd33aab7
AM
52 --prefix=%{_prefix} \
53 --exec-prefix=%{_exec_prefix} \
54 --bindir=%{_bindir} \
55 --sbindir=%{_sbindir} \
56 --sysconfdir=%{_sysconfdir} \
57 --datadir=%{_datadir} \
58 --includedir=%{_includedir} \
59 --libdir=%{_libdir} \
60 --libexecdir=%{_libexecdir} \
61 --localstatedir=%{_localstatedir} \
62 --sharedstatedir=%{_sharedstatedir} \
63 --mandir=%{_mandir} \
64 --infodir=%{_infodir} \
65}
66
85f82bec 67#----------------------------------------------------------------
9f0287b5 68%configure {./configure \
85f82bec
AF
69 LDFLAGS="${LDFLAGS:-%rpmldflags}" \
70 CFLAGS="${CFLAGS:-%rpmcflags}" \
71 CXXFLAGS="${CXXFLAGS:-%rpmcflags}" \
72 FFLAGS="${FFLAGS:-%rpmcflags}" \
418d9760 73 CPPFLAGS="${CPPFLAGS:-}" \
9f0287b5
AF
74 %{?__cc:CC=%{__cc}} \
75 %{?__cxx:CXX=%{__cxx}} \
85f82bec
AF
76 --build=%{_target_platform} \
77 --prefix=%{_prefix} \
78 --exec-prefix=%{_exec_prefix} \
79 --bindir=%{_bindir} \
80 --sbindir=%{_sbindir} \
81 --sysconfdir=%{_sysconfdir} \
82 --datadir=%{_datadir} \
83 --includedir=%{_includedir} \
84 --libdir=%{_libdir} \
85 --libexecdir=%{_libexecdir} \
86 --localstatedir=%{_localstatedir} \
87 --sharedstatedir=%{_sharedstatedir} \
88 --mandir=%{_mandir} \
89 --infodir=%{_infodir} \
90}
91
cd33aab7
AM
92# Location of autoconf macros
93%_aclocaldir %(aclocal --print-ac-dir)
94
32720a50
AM
95# Location of omf files
96%_omf_dest_dir %(scrollkeeper-config --omfdir)
97
c5eece2c 98# Location of pkgconfig files
895ccc5b 99%_pkgconfigdir /usr/lib/pkgconfig
c5eece2c 100
cd33aab7
AM
101# Location of top applink dir
102%_applnkdir /usr/X11R6/share/applnk
103
104# Location pixmaps for applnk/desktop files
105%_pixmapsdir /usr/X11R6/share/pixmaps
106
c5eece2c
JB
107# Location of fonts directories
108%_fontsdir /usr/share/fonts
109
cd33aab7
AM
110# Current date
111%date %(LC_ALL="C" date +"%a %b %d %Y")
112
113# tmp directory
114%tmpdir %(echo "${TMPDIR:-/tmp}")
115
116# Example files, programs, scripts...
117%_examplesdir /usr/src/examples
118
bd63739a 119# The directory holding Linux kernel sources
120%_kernelsrcdir /usr/src/linux
121
cd33aab7 122# If non-empty "debug" macro defined, add "dbg" suffix to release number
8dea1306 123%_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}%{?debug:dbg}.%%{ARCH}.rpm
cd33aab7 124
0cdbc762 125# requires name = version-release
8dea1306 126%requires_releq() %(LC_ALL="C" rpm -q --queryformat 'Requires:%%{NAME} = %%{VERSION}-%%{RELEASE}' %1| grep -v "is not")
127%requires_kernel_releq() %(LC_ALL="C" rpm -q --queryformat 'Prereq:kernel = %%{VERSION}-%%{RELEASE}' kernel-headers | grep -v "is not")
128%requires_releq_kernel_up() %(LC_ALL="C" rpm -q --queryformat 'Prereq:kernel-up = %%{VERSION}-%%{RELEASE}' kernel-headers | grep -v "is not")
129%requires_releq_kernel_smp() %(LC_ALL="C" rpm -q --queryformat 'Prereq:kernel-smp = %%{VERSION}-%%{RELEASE}' kernel-headers | grep -v "is not")
130
131# kernel version-release handling
132%__kernel_ver %(grep UTS_RELEASE %{_kernelsrcdir}/include/linux/version.h 2>/dev/null | cut -d'"' -f2)
133%__kernel_rel %(LC_ALL="C" rpm -qf %{_kernelsrcdir}/include/linux/version.h --queryformat "%{RELEASE}" | grep -v "is not")
134%_kernel_ver %(echo %{__kernel_ver}%{!?_without_dist_kernel:-%{__kernel_rel}})
135%_kernel_ver_str %(echo %{_kernel_ver} | sed s/-/_/g)
fd4d8ee0 136
c2c27a5a 137# sgml macros
138%xmlcat_add() /usr/bin/xmlcatalog --noout --add nextCatalog \"\" %1 /etc/xml/catalog
139%xmlcat_del() /usr/bin/xmlcatalog --noout --del %1 /etc/xml/catalog
140%xmlcat_add_rewrite /usr/bin/xmlcatalog --noout --add rewriteSystem
141%xmlcat_create() /usr/bin/xmlcatalog --noout --create %1
142%sgmlcat_add() /usr/bin/install-catalog --add %1 %2 > /dev/null
143%sgmlcat_del() /usr/bin/install-catalog --remove %1 %2 > /dev/null
144%docbook_sgmlcat_fix() { for l in \
145'' \
146' -- default decl --' \
147'DTDDECL "-//OASIS//DTD DocBook XML V%2//EN" "../../xml.dcl"' \
148' -- hacks for opensp --' \
149'SYSTEM "file://%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd" "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
150'SYSTEM "http://www.oasis-open.org/docbook/xml/%2/docbookx.dtd" "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
151'' \
152; do echo $l; done >> %1 \
153}
154
cd33aab7
AM
155#-----------------------------------------------------------------
156# find and gzip all files in %{_mandir} and %{infodir}
157#
158# Requires: xargs, find
159#
160#%no_install_post_compress_docs 1
161%__spec_install_post_compress_docs { \
162echo "Compress man and info pages."; \
163%{!?no_install_post_compress_docs: \
164 %{?verbose:set -x;} \
165 for i in /usr/share/man /usr/X11R6/man /usr/share/info; do \
166 if [ -d "$RPM_BUILD_ROOT$i" ]; then \
167 find "$RPM_BUILD_ROOT$i" -name \*.bz2 -print | xargs -r %{__bzip2} -df; \
168 find "$RPM_BUILD_ROOT$i" -name \*.gz -print | xargs -r %{__gzip} -dnf; \
169 find "$RPM_BUILD_ROOT$i" -type f -print | xargs -r %{__gzip} -9nf; \
170 fi; \
171 done; \
172} }
173
174#-----------------------------------------------------------------
175# Strip executable binaries and shared object files
176#
177# Requires: find, awk, strip, cut, xargs
178#
179#%no_install_post_strip 1
180%__spec_install_post_strip {%{!?debug: \
181%{!?no_install_post_strip: \
182 %{?verbose:set -x;} \
183 echo "Strip executable binaries and shared object files."; \
184 filelist=`find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*"`; \
185 elfexelist=`echo $filelist | xargs -r file | \
186 awk '/ELF.*executable/ {print $1}' | cut -d: -f1`; \
187 elfsharedlist=`echo $filelist | xargs -r file | \
188 awk '/LF.*shared object/ {print $1}' | cut -d: -f1`; \
189 if [ -n "$elfexelist" ]; then \
190 strip --remove-section=.note --remove-section=.comment $elfexelist; \
191 fi; \
192 if [ -n "$elfsharedlist" ]; then \
193 strip --strip-unneeded --remove-section=.note --remove-section=.comment $elfsharedlist; \
194 fi; } \
195} }
93b46c00 196#-----------------------------------------------------------------
22a54b3e 197# remove all RPATH from executable binaries and shared object files
198#
199# Requires: find, awk, strip, cut, xargs
200#
201#%no_install_post_chrpath 1
202%__spec_install_post_chrpath {%{!?debug: \
203%{!?no_install_post_chrpath: \
204 %{?verbose:set -x;} \
205 echo "Remove RPATH from executable binaries and shared object files."; \
206 filelist=`find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*"`; \
207 elfexelist=`echo $filelist | xargs -r file | \
208 awk '/ELF.*executable/ {print $1}' | cut -d: -f1`; \
209 elfsharedlist=`echo $filelist | xargs -r file | \
210 awk '/LF.*shared object/ {print $1}' | cut -d: -f1`; \
211 if [ -n "$elfexelist$elfsharedlist" ]; then \
212 chrpath -d $elfexelist $elfsharedlist; \
18588aa0 213 fi; } \
22a54b3e 214} }
215#-----------------------------------------------------------------
93b46c00 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 { \
222echo "Compress kernel modules if any."; \
223%{!?no_install_post_compress_modules: \
224 %{?verbose:set -x;} \
390bdd1d
MM
225 if test -d $RPM_BUILD_ROOT/lib/modules ; then \
226 find $RPM_BUILD_ROOT/lib/modules -name \*.o -print | \
227 xargs -r %{__gzip} -9nf; \
228 fi; \
93b46c00 229} }
cd33aab7
AM
230
231%_source_payload w9.gzdio
232%_binary_payload w9.bzdio
233
234#-----------------------------------------------------------------
235# post %install sequence:
236# - autodeps exceptions
237# - compress all man and info pages,
238# - strip all ELF executables and ELF shared objects if not %debug.
239
240###################################################################
241# Requires/Provides automation
242# exceptions system by Jacek Konieczny <jajcus@pld.org.pl>
f10da3d9
JK
243%__spec_prep_pre \
244_autoreqprov=n \
245%{?_noautoreqfiles:_autoreqprov=y}\
246%{?_noautoreq:_autoreqprov=y}\
247%{?_noautoreqdep:_autoreqprov=y}\
248%{?_noautoprovfiles:_autoreqprov=y}\
249%{?_noautoprov:_autoreqprov=y}\
5701c444 250%{?_noautocompressdoc:_autoreqprov=y}\
f10da3d9
JK
251if [ "$_autoreqprov" = "y" ] ; then \
252 if [ -f %{_builddir}/__rpm_lock ] ; then \
253 echo "Some package using \%_noauto* macros is already being built" >&2 \
254 echo "If it is not true delete %{_builddir}/__rpm_lock" >&2 \
255 exit 1 \
256 else \
257 rm -f %{_builddir}/__rpm_*\
258 touch %{_builddir}/__rpm_lock \
259 fi \
260fi \
5701c444 261%{?_noautocompressdoc:echo '%{_noautocompressdoc}' > %{_builddir}/__rpm_noautocompressdoc}\
cd33aab7
AM
262%{nil}
263
81bcf939 264%__os_install_post \
cd33aab7
AM
265%{?_noautoreqfiles:for f in %{_noautoreqfiles} ; do echo %{?buildroot:%{buildroot}}$f >> %{_builddir}/__rpm_noautoreqfiles ; done }\
266%{?_noautoreq:for f in %{_noautoreq} ; do echo "$f" >> %{_builddir}/__rpm_noautoreq ; done }\
267%{?_noautoreqdep:for f in %{_noautoreqdep} ; do echo "$f" >> %{_builddir}/__rpm_noautoreqdep ; done }\
268%{?_noautoprovfiles:for f in %{_noautoprovfiles} ; do echo %{?buildroot:%{buildroot}}$f >> %{_builddir}/__rpm_noautoprovfiles ; done }\
269%{?_noautoprov:for f in %{_noautoprov} ; do echo "$f" >> %{_builddir}/__rpm_noautoprov ; done }\
270%{__spec_install_post_strip}\
22a54b3e 271%{__spec_install_post_chrpath}\
cd33aab7 272%{__spec_install_post_compress_docs}\
93b46c00 273%{__spec_install_post_compress_modules}\
cd33aab7 274%{__arch_install_post}\
cd33aab7
AM
275%{nil}
276
277%__spec_clean_pre %{___build_pre}\
f10da3d9
JK
278_autoreqprov=n \
279%{?_noautoreqfiles:_autoreqprov=y}\
280%{?_noautoreq:_autoreqprov=y}\
281%{?_noautoreqdep:_autoreqprov=y}\
282%{?_noautoprovfiles:_autoreqprov=y}\
283%{?_noautoprov:_autoreqprov=y}\
284%{?_noautoreqfiles:_autoreqprov=y}\
5701c444 285%{?_noautocompressdoc:_autoreqprov=y}\
f10da3d9
JK
286if [ "$_autoreqprov" = "y" ] ; then \
287 rm -f %{_builddir}/__rpm_* \
288fi \
cd33aab7
AM
289%{nil}
290
291
292#%_noautoreqfiles "%{_defaultdocdir}.*" "%{_examplesdir}.*"
293#%_noautoreq %{nil}
294#%_noautoreqdep %{nil}
295#%_noautoprovfiles %{nil}
296#%_noautoprov %{nil}
This page took 0.091823 seconds and 4 git commands to generate.