]> git.pld-linux.org Git - packages/rpm-build-macros.git/blame - rpm.macros
- --as-needed in gcc friendly form inside ldflags only
[packages/rpm-build-macros.git] / rpm.macros
CommitLineData
d54662bf
AF
1# PLD rpm macros
2
f633038a 3# other macros
e05017c1 4%epoch 0
f633038a
AM
5%_enable_debug_packages 1
6
8f74418b
MM
7%__id @__ID@
8%__id_u %{__id} -u
9%__chown_Rhf @__CHOWN_RHF@
10%__chgrp_Rhf @__CHGRP_RHF@
11
07163ba3 12%_fixowner [ `%{__id_u}` = '0' ] && %{__chown_Rhf} root:@ROOT_GROUP@
d54662bf 13%_fixgroup true
16cb1d91 14%_fixperms %{__chmod} -Rf @FIXPERMS@
d54662bf 15%_topdir %(echo $HOME)/rpm
9c404149
AM
16#-----------------------------------------------------------------
17# CFLAGS and LDFLAGS used to build
18
7bec8f51 19%debuginfocflags %{expand:%%define __dic_%{?_enable_debug_packages} 1}%{?__dic_1: -ggdb}%{expand:%%undefine __dic_%{?_enable_debug_packages}}
f633038a 20
8f74418b 21%debugcflags -O0 -g -Wall
515c8674
MM
22%rpmcflags %{?debug:%debugcflags}%{!?debug:%optflags}%{?debuginfocflags} %rpmcxxflags %{rpmcflags} -fvisibility-inlines-hidden
23%rpmldflags -Wl,--as-needed
9c404149 24
ba1fdedc 25# kernel compiler
d2e1bc22 26%kgcc gcc
27%kgcc_package gcc
ba1fdedc 28
33040789 29# Build system path macros.
30#
f93109a0 31%__autoconf autoconf %{?debug:-Wall}
32%__automake automake -a -c -f --foreign
33%__autopoint autopoint --force
34
83094b62 35%__gettextize { \
afff6d37 36 if ! gettextize --version | grep -q '0\.10\.' ; then \
8a995cff
JB
37 if grep -qs 'AM_GNU_GETTEXT.*external' configure.{ac,in} ; then \
38 gettextize --copy --force --no-changelog; \
97589b6e 39 else \
8a995cff
JB
40 gettextize --copy --force --no-changelog --intl; \
41 fi; \
42 if [ ! -f po/Makevars ]; then \
43 cp -f po/Makevars{.template,}; \
44 fi; \
45 else \
46 gettextize --copy --force; \
83094b62 47 fi; \
8a995cff 48}
f93109a0 49
50%__glib_gettextize glib-gettextize --copy --force
51%__gnome_doc_common gnome-doc-common --copy
52%__gtkdocize gtkdocize --copy
53%__intltoolize intltoolize --copy --force
54%__libtoolize libtoolize --copy --force
33040789 55
6a5eda77 56%dependencytracking %{nil}
9c404149 57#-----------------------------------------------------------------
9f4ce098 58%configure2_13 { \
9c404149
AM
59 if [ -n "$LINGUAS" ]; then unset LINGUAS; fi; \
60 LDFLAGS="${LDFLAGS:-%rpmldflags}" ; export LDFLAGS ; \
61 CFLAGS="${CFLAGS:-%rpmcflags}" ; export CFLAGS ; \
f4cc8832 62 CXXFLAGS="${CXXFLAGS:-%rpmcxxflags}" ; export CXXFLAGS ; \
9c404149 63 FFLAGS="${FFLAGS:-%rpmcflags}" ; export FFLAGS ; \
8ec1a12b 64 CPPFLAGS="${CPPFLAGS:-}" ; export CPPFLAGS ; \
8983c4c4
AM
65 %{?__cc:CC="%{__cc}" ; export CC ; } \
66 %{?__cxx:CXX="%{__cxx}" ; export CXX ; } \
8f74418b 67 %{?configuredir:%{configuredir}}%{!?configuredir:.}/configure \
2a7cfd3f 68 --host=%{_target_platform} \
9c404149
AM
69 --prefix=%{_prefix} \
70 --exec-prefix=%{_exec_prefix} \
71 --bindir=%{_bindir} \
72 --sbindir=%{_sbindir} \
73 --sysconfdir=%{_sysconfdir} \
74 --datadir=%{_datadir} \
75 --includedir=%{_includedir} \
76 --libdir=%{_libdir} \
77 --libexecdir=%{_libexecdir} \
78 --localstatedir=%{_localstatedir} \
79 --sharedstatedir=%{_sharedstatedir} \
80 --mandir=%{_mandir} \
81 --infodir=%{_infodir} \
c0d1b3ad 82 --x-libraries=/usr/X11R6/%{_lib} \
93059874 83 %{dependencytracking} \
9c404149
AM
84}
85
4a6b0d54 86#----------------------------------------------------------------
57f4166d 87%configure {./configure \
4a6b0d54
AF
88 LDFLAGS="${LDFLAGS:-%rpmldflags}" \
89 CFLAGS="${CFLAGS:-%rpmcflags}" \
f4cc8832 90 CXXFLAGS="${CXXFLAGS:-%rpmcxxflags}" \
4a6b0d54 91 FFLAGS="${FFLAGS:-%rpmcflags}" \
a2bd5992 92 CPPFLAGS="${CPPFLAGS:-}" \
8983c4c4
AM
93 %{?__cc:CC="%{__cc}"} \
94 %{?__cxx:CXX="%{__cxx}"} \
4a6b0d54
AF
95 --build=%{_target_platform} \
96 --prefix=%{_prefix} \
97 --exec-prefix=%{_exec_prefix} \
98 --bindir=%{_bindir} \
99 --sbindir=%{_sbindir} \
100 --sysconfdir=%{_sysconfdir} \
101 --datadir=%{_datadir} \
102 --includedir=%{_includedir} \
103 --libdir=%{_libdir} \
104 --libexecdir=%{_libexecdir} \
105 --localstatedir=%{_localstatedir} \
106 --sharedstatedir=%{_sharedstatedir} \
107 --mandir=%{_mandir} \
108 --infodir=%{_infodir} \
c0d1b3ad 109 --x-libraries=/usr/X11R6/%{_lib} \
93059874 110 %{dependencytracking} \
4a6b0d54
AF
111}
112
7dbab518 113# ------------------------------------------------------------------------
c80506a3
AM
114# Overloading of some basic macros
115%prep \
116%%prep\
117LANG=C\
118export LANG\
14e77e64 119unset DISPLAY ||:\
6db5639d 120unset LINGUAS ||:\
c80506a3
AM
121%{nil}
122
123%build %%build\
124LANG=C\
125export LANG\
14e77e64 126unset DISPLAY ||:\
6db5639d 127unset LINGUAS ||:\
c80506a3
AM
128%{nil}
129
130%install %{?_enable_debug_packages:%{?buildsubdir:%{debug_package}}}\
131%%install\
132LANG=C\
133export LANG\
14e77e64 134unset DISPLAY ||:\
6db5639d 135unset LINGUAS ||:\
c80506a3
AM
136%{nil}
137
138# ------------------------------------------------------------------------
7dbab518
MM
139# Conditional build stuff.
140
141# Check if symbol is defined.
142# Example usage: %if %{defined with_foo} && %{undefined with_bar} ...
143%defined() %{expand:%%{?%{1}:1}%%{!?%{1}:0}}
144%undefined() %{expand:%%{?%{1}:0}%%{!?%{1}:1}}
145
566fa098
MM
146# Shorthand for %{defined with_...}
147%with() %{expand:%%{?with_%{1}:1}%%{!?with_%{1}:0}}
148%without() %{expand:%%{?with_%{1}:0}%%{!?with_%{1}:1}}
149
7dbab518
MM
150# Handle conditional builds. %bcond_with is for case when feature is
151# default off and needs to be activated with --with ... command line
152# switch. %bcond_without is for the dual case.
153#
154# %bcond_with foo defines symbol with_foo if --with foo was specified on
155# command line.
156# %bcond_without foo defines symbol with_foo if --without foo was *not*
157# specified on command line.
158#
159# For example:
160#
161# %bcond_with extra_fonts
162# %bcond_without static
f52f9976 163# %if %{with extra_fonts}
7dbab518
MM
164# ...
165# %endif
f52f9976 166# %ifdef %{with static}
7dbab518
MM
167# ...
168# %endif
169# %{?with_static: ... }
170# %{!?with_static: ... }
171# %{?with_extra_fonts: ... }
172# %{!?with_extra_fonts: ... }
173#
174# The bottom line: never use without_foo, _with_foo nor _without_foo, only
175# with_foo. This way changing default set of bconds for given spec is just
176# a matter of changing single line in it and syntax is more readable.
177%bcond_with() %{expand:%%{?_with_%{1}:%%global with_%{1} 1}}
178%bcond_without() %{expand:%%{!?_without_%{1}:%%global with_%{1} 1}}
179# ------------------------------------------------------------------------
180
9c404149
AM
181# Location of autoconf macros
182%_aclocaldir %(aclocal --print-ac-dir)
183
e2804f99
AM
184# Location of omf files
185%_omf_dest_dir %(scrollkeeper-config --omfdir)
186
e987a186 187# Location of pkgconfig files
9a4e877a 188%_pkgconfigdir /usr/%{_lib}/pkgconfig
e987a186 189
486b0b5f 190# Location of desktop files
191%_desktopdir /usr/share/applications
86dff2d0 192%_applnkdir ERROR:_applnkdir_is_obsolete_use_desktopdir_instead
486b0b5f 193
481463e9 194# Location of pixmaps for applnk/desktop files
e1f0a822 195%_pixmapsdir /usr/share/pixmaps
9c404149 196
481463e9 197# Location of themable icons for applnk/desktop files
b36c8e2a 198%_iconsdir /usr/share/icons
199
e987a186
JB
200# Location of fonts directories
201%_fontsdir /usr/share/fonts
202
b3282f3f 203# Location of Gtk and associated libraries documentation
6eed6d84 204%_gtkdocdir %{_defaultdocdir}/gtk-doc/html
b3282f3f 205
fc4d7771 206# Location of KDE documentation
207%_kdedocdir %{_defaultdocdir}/kde/HTML
208
5869828c 209# unsermake script
210%__unsermake /usr/share/unsermake/unsermake
211
9c404149
AM
212# Current date
213%date %(LC_ALL="C" date +"%a %b %d %Y")
214
215# tmp directory
216%tmpdir %(echo "${TMPDIR:-/tmp}")
217
218# Example files, programs, scripts...
219%_examplesdir /usr/src/examples
220
8377d27d 221# The directory holding Linux kernel sources
222%_kernelsrcdir /usr/src/linux
223
9c404149 224# If non-empty "debug" macro defined, add "dbg" suffix to release number
8f74418b 225%_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}%{?debug:dbg}.%%{ARCH}.rpm
9c404149 226
8f74418b 227# Requires name = version-release
16cb1d91 228%requires_releq() %(LC_ALL="C" echo '%*' | xargs -r rpm -q --qf 'Requires: %%{name} = %%{epoch}:%%{version}-%%{release}\\n' | sed -e 's/ (none):/ /' | grep -v "is not")
8bf3719d 229
16cb1d91
JB
230%releq_kernel_up() %(LC_ALL="C" rpm -qf --qf 'kernel-up = %%{epoch}:%%{version}-%%{release}\\n' %{_kernelsrcdir}/include/linux/version.h | sed -e 's/ (none):/ /' | grep -vE "(is not|no such)")
231%releq_kernel_smp() %(LC_ALL="C" rpm -qf --qf 'kernel-smp = %%{epoch}:%%{version}-%%{release}\\n' %{_kernelsrcdir}/include/linux/version.h | sed -e 's/ (none):/ /' | grep -vE "(is not|no such)")
232%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):/ /' | grep -vE "(is not|no such)")
233%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):/ /' | grep -vE "(is not|no such)")
8bf3719d 234
16cb1d91 235%requires_eq_to() %(LC_ALL="C" rpm -q --qf 'Requires: %1 = %%{epoch}:%%{version}\\n' %2 | sed -e 's/ (none):/ /' | grep -v "is not")
01a9f990 236
179fcc7f 237%apache_modules_api %(awk '/#define MODULE_MAGIC_NUMBER_MAJOR/ {print $3}' /usr/include/apache/ap_mmn.h 2>/dev/null || echo ERROR)
b9d5d440 238
239# kernel version-release handling
541d11fe 240%__kernel_ver %([ -f %{_kernelsrcdir}/include/linux/version.h ] && (grep UTS_RELEASE %{_kernelsrcdir}/include/linux/version.h 2>/dev/null | head -n 1 | cut -d'"' -f2) || (awk '/^VERSION/ { ver = $0; gsub(/VERSION.*=/, NIL, ver); } /^PATCHLEVEL/ { plev = $0; gsub(/PATCHLEVEL.*=/, NIL, plev); } /^SUBLEVEL/ { slev = $0; gsub(/SUBLEVEL.*=/, NIL, slev); } /^EXTRAVERSION/ { ever = $0; gsub(/EXTRAVERSION.*=/, NIL, ever); gsub(/ /, NIL, ever); } END { printf("%d.%d.%d%s", ver, plev, slev, ever); }' %{_kernelsrcdir}/Makefile 2> /dev/null))
8fecb226 241%__kernel_rel %(LC_ALL="C" rpm -qf %{_kernelsrcdir}/include/linux/fs.h --queryformat "%{RELEASE}" | grep -v "is not")
16cb1d91
JB
242%__kernel_rpmvr %(LC_ALL="C" rpm -qf %{_kernelsrcdir}/include/linux/fs.h --queryformat "%{VERSION}-%{RELEASE}" | grep -v "is not")
243%_kernel_ver %{__kernel_ver}%{?with_dist_kernel:%(echo %{__kernel_ver} | grep -q -e - || echo -%{__kernel_rel})}
f62e856d 244%_kernel_ver_str %(echo %{!?_without_dist_kernel:%{__kernel_rpmvr}}%{?_without_dist_kernel:%{__kernel_ver}} | sed -e 's/-/_/g')
87be1cf0 245
e00dd7f6 246# sgml macros
741b471b 247%xmlcat_add() /usr/bin/xmlcatalog --noout --add nextCatalog \"\" %1 /etc/xml/catalog ;
248%xmlcat_del() /usr/bin/xmlcatalog --noout --del %1 /etc/xml/catalog ;
847db862 249%xmlcat_add_rewrite /usr/bin/xmlcatalog --noout --add rewriteSystem
741b471b 250%xmlcat_create() /usr/bin/xmlcatalog --noout --create %1 ;
251%sgmlcat_add() /usr/bin/install-catalog --add %1 %2 > /dev/null ;
252%sgmlcat_del() /usr/bin/install-catalog --remove %1 %2 > /dev/null ;
e00dd7f6 253%docbook_sgmlcat_fix() { for l in \
254'' \
255' -- default decl --' \
256'DTDDECL "-//OASIS//DTD DocBook XML V%2//EN" "../../xml.dcl"' \
257' -- hacks for opensp --' \
258'SYSTEM "file://%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd" "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
259'SYSTEM "http://www.oasis-open.org/docbook/xml/%2/docbookx.dtd" "%{_datadir}/sgml/docbook/xml-dtd-%2/docbookx.dtd"' \
260'' \
261; do echo $l; done >> %1 \
262}
263
9c404149
AM
264#-----------------------------------------------------------------
265# find and gzip all files in %{_mandir} and %{infodir}
266#
267# Requires: xargs, find
268#
269#%no_install_post_compress_docs 1
270%__spec_install_post_compress_docs { \
9c404149 271%{!?no_install_post_compress_docs: \
822d4d81 272 echo "Compress man and info pages."; \
9c404149
AM
273 %{?verbose:set -x;} \
274 for i in /usr/share/man /usr/X11R6/man /usr/share/info; do \
275 if [ -d "$RPM_BUILD_ROOT$i" ]; then \
276 find "$RPM_BUILD_ROOT$i" -name \*.bz2 -print | xargs -r %{__bzip2} -df; \
277 find "$RPM_BUILD_ROOT$i" -name \*.gz -print | xargs -r %{__gzip} -dnf; \
278 find "$RPM_BUILD_ROOT$i" -type f -print | xargs -r %{__gzip} -9nf; \
279 fi; \
280 done; \
281} }
282
283#-----------------------------------------------------------------
284# Strip executable binaries and shared object files
285#
286# Requires: find, awk, strip, cut, xargs
287#
288#%no_install_post_strip 1
289%__spec_install_post_strip {%{!?debug: \
290%{!?no_install_post_strip: \
9f0d4f36
JB
291 %{?verbose:set -x;} \
292 if [ -d "$RPM_BUILD_ROOT" ]; then \
8f74418b 293 echo "Strip executable binaries, archives and shared object files."; \
60ad88f2 294 filelist=`find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*" %{?_noautostrip:! -regex "%{_noautostrip}"}`; \
9c404149
AM
295 elfexelist=`echo $filelist | xargs -r file | \
296 awk '/ELF.*executable/ {print $1}' | cut -d: -f1`; \
297 elfsharedlist=`echo $filelist | xargs -r file | \
298 awk '/LF.*shared object/ {print $1}' | cut -d: -f1`; \
8f74418b
MM
299 elfarchiveslist=`echo $filelist | xargs -r file | \
300 awk '/current ar archive/ {print $1}' | cut -d: -f1`; \
9c404149 301 if [ -n "$elfexelist" ]; then \
60ad88f2 302 %{__strip} --remove-section=.note --remove-section=.comment $elfexelist; \
9c404149
AM
303 fi; \
304 if [ -n "$elfsharedlist" ]; then \
60ad88f2 305 %{__strip} --strip-unneeded --remove-section=.note --remove-section=.comment $elfsharedlist; \
8f74418b
MM
306 fi; \
307 if [ -n "$elfarchiveslist" ]; then \
60ad88f2 308 %{__strip} --strip-debug --remove-section=.note --remove-section=.comment $elfarchiveslist; \
9f0d4f36
JB
309 fi; \
310 fi; } \
9c404149 311} }
fc5d7e20 312#-----------------------------------------------------------------
313# remove all RPATH from executable binaries and shared object files
314#
315# Requires: find, awk, cut, xargs, chrpath, uname
316#
317#%no_install_post_chrpath 1
318%__spec_install_post_chrpath {%{!?debug: \
319%{!?no_install_post_chrpath: \
320 %{?verbose:set -x;} \
9f0d4f36 321if [ -d "$RPM_BUILD_ROOT" ]; then \
fc5d7e20 322echo "Remove RPATH from executable binaries and shared object files."; \
adb39da4 323find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*" ! -regex ".*/usr/lib[0-9]*/debug/.*" %{?_noautochrpath:! -regex "%{_noautochrpath}"} | xargs -r file | \
5bed2bb7 324 awk '/ELF.*(executable.*dynamically linked|shared object)/ {print $1}' | cut -d: -f1 | \
fc5d7e20 325while read file ; do \
326 rpath= ; \
327 chmod u+w "$file"; \
328 for dir in `chrpath -l "$file" | \
329 awk '/RPATH=/ { gsub(/.*RPATH=/,""); gsub(/:/," "); print $0 }'` ; do \
330 case $dir in \
494e368c 331 /home/* | /tmp/* | /usr/lib | /usr/lib64 | /lib | /lib64 | /usr/local/lib | /usr/local/lib64 | /usr/X11R6/lib | /usr/X11R6/lib64 ) \
fc5d7e20 332 echo "remove-rpath: $dir in $file"; \
333 ;; \
334 * ) \
335 if [ "$rpath" = "" ] ; then rpath="$dir" ; \
336 else rpath="$rpath:$dir" ; fi ; \
337 ;; \
338 esac ; \
339 done ; \
340 if [ "$rpath" = "" ] ; then chrpath -d "$file" > /dev/null ; \
341 else chrpath -r "$rpath" "$file" > /dev/null ; fi ; \
9f0d4f36
JB
342done; \
343fi; } \
fc5d7e20 344} }
d72c185f 345#-----------------------------------------------------------------
ccb8ae8d 346# Find and gzip all kernel modules
347#
348# Requires: find
349#
350#%no_install_post_compress_modules 1
351%__spec_install_post_compress_modules { \
ccb8ae8d 352%{!?no_install_post_compress_modules: \
353 %{?verbose:set -x;} \
9f0d4f36
JB
354 if [ -d "$RPM_BUILD_ROOT" ]; then \
355echo "Compress kernel modules if any."; \
d618340e 356 if test -d $RPM_BUILD_ROOT/lib/modules ; then \
16cb1d91
JB
357 find $RPM_BUILD_ROOT/lib/modules -name \*o -type f -print | \
358 xargs -r %{__gzip} -9nf; \
a33b1418 359 find $RPM_BUILD_ROOT/lib/modules -name \*o -type l -printf "%p %l\n" | \
03b234a5 360 while read a b; do ln -sf $b.gz $a.gz; rm -f $a; done; \
d618340e 361 fi; \
9f0d4f36 362 fi; \
ccb8ae8d 363} }
9c404149
AM
364
365%_source_payload w9.gzdio
366%_binary_payload w9.bzdio
367
83094b62 368#-----------------------------------------------------------------
0e4cb4dd 369# Update GConf2 schemas
83094b62 370#
371# Requires: GConf2
372#
46885239 373%gconf_schema_install() \
374 umask 022; \
f93109a0 375 GCONF_CONFIG_SOURCE="xml:readwrite:/etc/gconf/gconf.xml.defaults" /usr/bin/gconftool-2 --makefile-install-rule /etc/gconf/schemas/%{?1}%{!?1:*.schemas} > /dev/null \
46885239 376 %{nil}
377
378%gconf_schema_uninstall() \
f93109a0 379if [ $1 = 0 ]; then \
46885239 380 umask 022; \
f93109a0 381 GCONF_CONFIG_SOURCE="xml:readwrite:/etc/gconf/gconf.xml.defaults" /usr/bin/gconftool-2 --makefile-uninstall-rule /etc/gconf/schemas/%{?1} > /dev/null \
382fi \
383%{nil}
384
385#-----------------------------------------------------------------
386# Update desktop MIME database
387# requries: desktop-file-utils
388#
389%update_desktop_database_post() \
390 umask 022; \
391 /usr/bin/update-desktop-database; \
392 %{nil}
393
394%update_desktop_database_postun() \
395if [ $1 = 0 ]; then \
396 umask 022; \
397 /usr/bin/update-desktop-database; \
398fi \
399%{nil}
400
401#-----------------------------------------------------------------
402# Update scrollkeeper database
403# requires: scrollkeeper
404#
405%scrollkeeper_update_post() \
f93109a0 406 /usr/bin/scrollkeeper-update -q; \
407 %{nil}
408
409%scrollkeeper_update_postun() \
410if [ $1 = 0 ]; then \
f93109a0 411 /usr/bin/scrollkeeper-update -q; \
412fi \
413%{nil}
414
415#-----------------------------------------------------------------
416# Run ldconfig after installing/deinstalling libraries
417#
418%ldconfig_post() \
419 /sbin/ldconfig; \
420 %{nil}
421
422%ldconfig_postun() \
423if [ $1 = 0 ]; then \
424 /sbin/ldconfig; \
425fi \
426%{nil}
83094b62 427
9c404149
AM
428#-----------------------------------------------------------------
429# post %install sequence:
430# - autodeps exceptions
431# - compress all man and info pages,
432# - strip all ELF executables and ELF shared objects if not %debug.
8f74418b 433# - compress kernel modules if any
9c404149
AM
434
435###################################################################
436# Requires/Provides automation
437# exceptions system by Jacek Konieczny <jajcus@pld.org.pl>
338726a6 438#
2892b5df
JB
439%__noautoreqfiles %(sed -e s'/#.*//' /etc/rpm/noautoreqfiles)%{?_noautoreqfiles: %{_noautoreqfiles}}
440%__noautoprovfiles %(sed -e s'/#.*//' /etc/rpm/noautoprovfiles)%{?_noautoprovfiles: %{_noautoprovfiles}}
441%__noautoreq %(sed -e s'/#.*//' /etc/rpm/noautoreq)%{?_noautoreq: %{_noautoreq}}
442%__noautoreqdep %(sed -e s'/#.*//' /etc/rpm/noautoreqdep)%{?_noautoreqdep: %{_noautoreqdep}}
443%__noautoprov %(sed -e s'/#.*//' /etc/rpm/noautoprov)%{?_noautoprov: %{_noautoprov}}
338726a6
JB
444#%_noautocompressdoc %{nil}
445#
8f74418b
MM
446%_missing_doc_files_terminate_build 1%{nil}
447%_unpackaged_files_terminate_build %{nil}
8781dc74 448# (X)emacs support
d77dcb61 449%___emacs_lispdir_helper -batch -q -eval '(while load-path (princ (concat (car load-path) "\\n")) (setq load-path (cdr load-path)))' 2> /dev/null|sed -n '/\\(.*\\/x\\?emacs\\/site-lisp\\)\\/\\?$/{s,,\\1,p;q;}'
8781dc74
AF
450%_emacs_lispdir %(emacs %___emacs_lispdir_helper)
451%_xemacs_lispdir %(xemacs %___emacs_lispdir_helper)
25043cd4 452
02b58f60
JK
453%__php_provides %{nil}
454%__php_requires %{nil}
455%__perl_provides %{nil}
456%__perl_requires %{nil}
25043cd4
AF
457
458# Perl specific macro definitions.
c853f847
AF
459%perl_privlib %(eval "`%{__perl} -V:installprivlib`"; echo $installprivlib)
460%perl_archlib %(eval "`%{__perl} -V:installarchlib`"; echo $installarchlib)
461%perl_vendorlib %(eval "`%{__perl} -V:installvendorlib`"; echo $installvendorlib)
462%perl_vendorarch %(eval "`%{__perl} -V:installvendorarch`"; echo $installvendorarch)
463%perl_sitelib %(eval "`%{__perl} -V:installsitelib`"; echo $installsitelib)
464%perl_sitearch %(eval "`%{__perl} -V:installsitearch`"; echo $installsitearch)
25043cd4 465
c853f847 466%php_pear_dir %{_datadir}/pear
25043cd4
AF
467
468# Python specific macro definitions.
469# python main version
c853f847 470%py_ver %(echo `python -c "import sys; print sys.version[:3]"`)
25043cd4
AF
471
472# directories
c853f847 473%py_prefix %(echo `python -c "import sys; print sys.prefix"`)
aadb0079 474%py_libdir %{py_prefix}/%{_lib}/python%{py_ver}
ef7ec0a8 475%py_scriptdir %{py_prefix}/share/python%{py_ver}
c853f847 476%py_incdir /usr/include/python%{py_ver}
ef7ec0a8
JK
477%py_sitedir %{py_libdir}/site-packages
478%py_sitescriptdir %{py_scriptdir}/site-packages
c853f847 479%py_dyndir %{py_libdir}/lib-dynload
25043cd4
AF
480
481# pure python modules compilation
c853f847 482%py_comp python -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])"
25043cd4 483
c853f847 484%py_ocomp python -O -c "import compileall; import sys; compileall.compile_dir(sys.argv[1], ddir=sys.argv[1][len('$RPM_BUILD_ROOT'):])"
25043cd4
AF
485
486# Software written in Python language require Python with main version
e63cd81d 487%pyrequires_eq() Requires: %1
25043cd4 488
f12c2314
AF
489
490# Hardlink binary identical .pyc and .pyo files
491# (idea by glen <at> pld-linux <dot> org)
492%__spec_install_post_py_hardlink {\
d56b7e24 493%{!?no_install_post_py_hardlink: \
f12c2314
AF
494[ ! -d "$RPM_BUILD_ROOT" ] || find "$RPM_BUILD_ROOT" -name '*.pyc' | while read a; do \
495 b="$(echo $a|sed -e 's/.pyc$/.pyo/')"; \
496 if cmp -s "$a" "$b"; then \
497 ln -f "$a" "$b"; \
498 fi; \
499done \
500} }
501
502# remove python sources, so that check-files won't complain
503# (idea by glen <at> pld-linux <dot> org)
504%py_postclean() \
505for d in %{py_sitescriptdir} %{py_sitedir}; do \
506 [ ! -d "$RPM_BUILD_ROOT$d" ] || find "$RPM_BUILD_ROOT$d" -name '*.py' -exec rm {} \; ;\
507done \
508%{nil}
509
0fc5cff8 510# depmod macro
511%depmod() { \
f6148427 512umask 022; \
0fc5cff8 513if [ -e /boot/System.map-%1 ]; then \
514 /sbin/depmod -a -F /boot/System.map-%1 %1; \
515else \
516 if [ -e /boot/System.map ]; then \
517 /sbin/depmod -a -F /boot/System.map %1; \
518 else \
519 /sbin/depmod -a %1; \
520 fi \
521fi; \
522}
523
2afc6e64 524# XMMS specific macros
2d372986
JB
525%xmms_prefix %(xmms-config --prefix)
526%xmms_exec_prefix %(xmms-config --exec-prefix)
527%xmms_version %(xmms-config --version)
528%xmms_datadir %(xmms-config --data-dir)
529%xmms_plugindir %(xmms-config --plugin-dir)
530%xmms_visualization_plugindir %(xmms-config --visualization-plugin-dir)
531%xmms_input_plugindir %(xmms-config --input-plugin-dir)
532%xmms_output_plugindir %(xmms-config --output-plugin-dir)
533%xmms_effect_plugindir %(xmms-config --effect-plugin-dir)
534%xmms_general_plugindir %(xmms-config --general-plugin-dir)
2afc6e64 535
1fc7dde4 536%_target_base_arch %(echo %{_target_cpu} | sed 's/i.86/i386/;s/athlon/i386/;s/pentium./i386/;s/amd64/x86_64/')
848c0d68 537
538# user/group checking macros
539#
540# Usage:
541# %userremove myuser
542#
543%userremove /usr/lib/rpm/user_group.sh user del
544%groupremove /usr/lib/rpm/user_group.sh group del
545#
546# Usage:
547# if %usertestrm myuser; then
548# /usr/sbin/userdel -r myuser
549# Note:
550# use these macros only if you need to call userdel/groupdel with
551# a non-standard option or take an extra action; otherwise use the
552# %userremove/%groupremove macros
553#
554%usertestrm /usr/lib/rpm/user_group.sh user testrm
555%grouptestrm /usr/lib/rpm/user_group.sh group testrm
08d9b1f6
JK
556# user group membership management macros
557#
558# Usage:
559# %addusertogroup myuser agroup
560#
561%addusertogroup /usr/lib/rpm/user_group.sh user addtogroup
72fcfcb3 562
563# banner support (useful in {pre,post}{,un} and triggers)
564#
565# Usage:
aa41c920 566# %banner name [-a] [-e] [-n] [-tn] <<EOF
72fcfcb3 567# the banner text, the banner text
aa41c920
ER
568# the banner text, and following line
569#EOF
570# You can use any form of here-document, <<'EOF' <<-EOT will do.
571# NOTE: if your use "<<-EOF", then You can actually indent inside here-document.
572#
72fcfcb3 573# -a - append to the banner
a8b9562a 574# -e - send to stderr instead of stdout
628754cb 575# -n - no show banner (overrides -t)
576# -t - show only, if RPM_SCRIPTVERBOSITY >= n; default n=5
aa41c920 577%banner(aent:) \
1b334fe4 578RPM_SCRIPTVERBOSITY=5 \
579[ -r /etc/sysconfig/rpm ] && . /etc/sysconfig/rpm \
580if [ -x /usr/bin/banner.sh ]; then \
aa41c920 581 CMD="/usr/bin/banner.sh %{-e:--stderr} %{!-n:$([ $RPM_SCRIPTVERBOSITY -ge %{-t:%{-t*}}%{!-t:5} ] && echo -s)} %{!-a:-m}%{-a:-M} %1" \
1b334fe4 582else \
a8b9562a 583 CMD="cat%{-e: >&2}" \
1b334fe4 584fi \
aa41c920 585$CMD %2%{?3: %3} \
72fcfcb3 586%nil
628754cb 587
840e7b00
ER
588# fatal macro. produces recursion and therefore stops rpm build.
589# until there's no legal way of stopping rpmbuild from macros, this is used by
590# %useradd/%groupadd to notify user of wrong usage. glen@pld-linux.org
591%fatal() { %{*} %fatal }
592
90627280
ER
593# useradd/groupadd macros written by glen@pld-linux.org.
594# All rights reserved. Permission to copy is hereby granted.. yada, yada, yada
595#
596# Usage:
597# %useradd [-P package] [-u uid] [-d home_dir] [-s shell] [-c comment]
598# [-g initial_group] [-G group[,...]] login
599#
600# -u uid. REQUIRED
601# -g gid/group. REQUIRED
602# -s defaults to /bin/false
603# -d defaults to /usr/share/empty
604# -c No default
605# -r is accepted but ignored (it's always set)
606# rpm specific flags
607# -P package name. defaults to %{name}
608#
90627280 609%useradd(c:d:e:f:g:G:Mmk:op:s:u:rP:) \
840e7b00
ER
610%{!-u:%fatal -- useradd: Required argument -u missing} \
611%{!-g:%fatal -- useradd: Required argument -g missing} \
612%{!?1:%fatal -- useradd: Required parameter login missing} \
90627280
ER
613if [ -n "`/bin/id -u %{expand:%{%{#}}} 2>/dev/null`" ]; then \
614 if [ "`/bin/id -u %{expand:%{%{#}}}`" != "%{-u*}" ]; then \
615 echo "Error: user %{expand:%{%{#}}} doesn't have uid=%{-u*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \
616 exit 1 \
617 fi \
618else \
619 echo "Adding user %{expand:%{%{#}}} UID=%{-u*}." \
620 /usr/sbin/useradd \\\
621 -u %{-u*} \\\
622 -r \\\
623 -d %{-d*}%{!-d:/usr/share/empty} \\\
624 -s %{-s*}%{!-s:/bin/false} \\\
840e7b00 625 %{-c:-c "%(set -- %{-c*} %{*}; echo $1)"}\\\
90627280
ER
626 -g %{-g*} \\\
627 %{-M} \\\
628 %{-G:-G %{-G*}} \\\
840e7b00 629 %{expand:%{%{#}}} 1>&2 \
90627280
ER
630fi;
631
90627280
ER
632# Usage:
633# %groupadd [-P package] [-g gid] group
634#
635# -g gid. REQUIRED
636#
637# Sample:
638# %groupadd -P %{name}-base -g %{gid} %{name}
639
640%groupadd(g:P:rfo) \
840e7b00
ER
641%{!-g:%fatal -- groupadd: Required argument -g missing} \
642%{!?1:%fatal -- groupadd: Required parameter group missing} \
90627280
ER
643if [ -n "`/usr/bin/getgid %{1}`" ]; then \
644 if [ "`/usr/bin/getgid %{1}`" != "%{-g*}" ]; then \
645 echo "Error: group %{1} doesn't have gid=%{-g*}. Correct this before installing %{-P*}%{!?-P:%{name}}." 1>&2 \
646 exit 1 \
647 fi \
648else \
649 echo "Adding group %{1} GID=%{-g*}." \
840e7b00 650 /usr/sbin/groupadd -g %{-g*} -r %{1} 1>&2 \
90627280 651fi;
This page took 0.409522 seconds and 4 git commands to generate.