X-Git-Url: http://git.pld-linux.org/?a=blobdiff_plain;f=rpm.macros;h=caa39d88a24f43c6f4b50fe17ce838b6e3824285;hb=03ba8ec16bc31cec04ecc45a0a7f053688e29610;hp=e4803db01168b08a2baa022f74e39dbe14bc17e1;hpb=15caaf77e3551d72b1ba3c70df219223719afe3e;p=packages%2Frpm.git diff --git a/rpm.macros b/rpm.macros index e4803db..caa39d8 100644 --- a/rpm.macros +++ b/rpm.macros @@ -93,6 +93,57 @@ --infodir=%{_infodir} \ } +# ------------------------------------------------------------------------ +# Conditional build stuff. + +# Check if symbol is defined. +# Example usage: %if %{defined with_foo} && %{undefined with_bar} ... +%defined() %{expand:%%{?%{1}:1}%%{!?%{1}:0}} +%undefined() %{expand:%%{?%{1}:0}%%{!?%{1}:1}} + +# Shorthand for %if %{defined ...} +%ifdef() %if %{expand:%%{?%{1}:1}%%{!?%{1}:0}} +%ifndef() %if %{expand:%%{?%{1}:0}%%{!?%{1}:1}} + +# Shorthand for %{defined with_...} +%with() %{expand:%%{?with_%{1}:1}%%{!?with_%{1}:0}} +%without() %{expand:%%{?with_%{1}:0}%%{!?with_%{1}:1}} + +# Shorthand for %if %{with ...} +%ifwith() %if %{expand:%%{?with_%{1}:1}%%{!?with_%{1}:0}} +%ifwithout() %if %{expand:%%{?with_%{1}:0}%%{!?with_%{1}:1}} + +# Handle conditional builds. %bcond_with is for case when feature is +# default off and needs to be activated with --with ... command line +# switch. %bcond_without is for the dual case. +# +# %bcond_with foo defines symbol with_foo if --with foo was specified on +# command line. +# %bcond_without foo defines symbol with_foo if --without foo was *not* +# specified on command line. +# +# For example: +# +# %bcond_with extra_fonts +# %bcond_without static +# %ifdef with_extra_fonts +# ... +# %endif +# %ifdef with_static +# ... +# %endif +# %{?with_static: ... } +# %{!?with_static: ... } +# %{?with_extra_fonts: ... } +# %{!?with_extra_fonts: ... } +# +# The bottom line: never use without_foo, _with_foo nor _without_foo, only +# with_foo. This way changing default set of bconds for given spec is just +# a matter of changing single line in it and syntax is more readable. +%bcond_with() %{expand:%%{?_with_%{1}:%%global with_%{1} 1}} +%bcond_without() %{expand:%%{!?_without_%{1}:%%global with_%{1} 1}} +# ------------------------------------------------------------------------ + # Location of autoconf macros %_aclocaldir %(aclocal --print-ac-dir) @@ -207,7 +258,38 @@ echo "Compress man and info pages."; \ strip --strip-debug --remove-section=.note --remove-section=.comment $elfarchiveslist; \ fi; } \ } } - +#----------------------------------------------------------------- +# remove all RPATH from executable binaries and shared object files +# +# Requires: find, awk, cut, xargs, chrpath, uname +# +#%no_install_post_chrpath 1 +%__spec_install_post_chrpath {%{!?debug: \ +%{!?no_install_post_chrpath: \ + %{?verbose:set -x;} \ +echo "Remove RPATH from executable binaries and shared object files."; \ +if [ "$(uname -m)" != alpha ] ; then \ +find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*" | xargs -r file | \ + awk '/ELF.*(executable|shared object)/ {print $1}' | cut -d: -f1 | \ +while read file ; do \ + rpath= ; \ + chmod u+w "$file"; \ + for dir in `chrpath -l "$file" | \ + awk '/RPATH=/ { gsub(/.*RPATH=/,""); gsub(/:/," "); print $0 }'` ; do \ + case $dir in \ + /home/* | /tmp/* | /usr/lib | /lib | /usr/local/lib | /usr/X11R6/lib ) \ + echo "remove-rpath: $dir in $file"; \ + ;; \ + * ) \ + if [ "$rpath" = "" ] ; then rpath="$dir" ; \ + else rpath="$rpath:$dir" ; fi ; \ + ;; \ + esac ; \ + done ; \ + if [ "$rpath" = "" ] ; then chrpath -d "$file" > /dev/null ; \ + else chrpath -r "$rpath" "$file" > /dev/null ; fi ; \ +done; fi; } \ +} } #----------------------------------------------------------------- # Find and gzip all kernel modules #