]> git.pld-linux.org Git - packages/rpm.git/blob - rpm.macros
a8e4f0ccd9e12d774ba83be9cac6c4f12d506910
[packages/rpm.git] / rpm.macros
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
21 #-----------------------------------------------------------------
22 # CFLAGS and LDFLAGS used to build
23
24 %debugcflags    -O0 -g
25 %rpmcflags      %{?debug:%debugcflags}%{!?debug:%optflags}
26 %rpmldflags     %{!?debug:-s}
27
28 # kernel compiler
29 %kgcc           gcc
30 %kgcc_package   gcc
31
32 #-----------------------------------------------------------------
33 # Build system path macros.
34 #
35 %__libtoolize           libtoolize --copy --force
36 %__automake             automake -a -c -f --foreing
37 %__autoconf             autoconf %{?debug:-Wall}
38
39 #-----------------------------------------------------------------
40 %configure2_13 { \
41  if [ -n "$LINGUAS" ]; then unset LINGUAS; fi; \
42  LDFLAGS="${LDFLAGS:-%rpmldflags}" ; export LDFLAGS ; \
43  CFLAGS="${CFLAGS:-%rpmcflags}" ; export CFLAGS ; \
44  CXXFLAGS="${CXXFLAGS:-%rpmcflags}" ; export CXXFLAGS ; \
45  FFLAGS="${FFLAGS:-%rpmcflags}" ; export FFLAGS ; \
46  CPPFLAGS="${CPPFLAGS:-}" ; export CPPFLAGS ; \
47  %{?__cc:CC=%{__cc} ; export CC ; } \
48  %{?__cxx:CXX=%{__cxx} ; export CXX ; } \
49  ./configure \
50         --host=%{_target_platform} \
51         --prefix=%{_prefix} \
52         --exec-prefix=%{_exec_prefix} \
53         --bindir=%{_bindir} \
54         --sbindir=%{_sbindir} \
55         --sysconfdir=%{_sysconfdir} \
56         --datadir=%{_datadir} \
57         --includedir=%{_includedir} \
58         --libdir=%{_libdir} \
59         --libexecdir=%{_libexecdir} \
60         --localstatedir=%{_localstatedir} \
61         --sharedstatedir=%{_sharedstatedir} \
62         --mandir=%{_mandir} \
63         --infodir=%{_infodir} \
64 }
65
66 #----------------------------------------------------------------
67 %configure {./configure \
68         LDFLAGS="${LDFLAGS:-%rpmldflags}" \
69         CFLAGS="${CFLAGS:-%rpmcflags}" \
70         CXXFLAGS="${CXXFLAGS:-%rpmcflags}" \
71         FFLAGS="${FFLAGS:-%rpmcflags}" \
72         CPPFLAGS="${CPPFLAGS:-%rpmcflags}" \
73         %{?__cc:CC=%{__cc}} \
74         %{?__cxx:CXX=%{__cxx}} \
75         --build=%{_target_platform} \
76         --prefix=%{_prefix} \
77         --exec-prefix=%{_exec_prefix} \
78         --bindir=%{_bindir} \
79         --sbindir=%{_sbindir} \
80         --sysconfdir=%{_sysconfdir} \
81         --datadir=%{_datadir} \
82         --includedir=%{_includedir} \
83         --libdir=%{_libdir} \
84         --libexecdir=%{_libexecdir} \
85         --localstatedir=%{_localstatedir} \
86         --sharedstatedir=%{_sharedstatedir} \
87         --mandir=%{_mandir} \
88         --infodir=%{_infodir} \
89 }
90
91 # Location of autoconf macros
92 %_aclocaldir    %(aclocal --print-ac-dir)
93
94 # Location of omf files
95 %_omf_dest_dir  %(scrollkeeper-config --omfdir)
96
97 # Location of pkgconfig files
98 %_pkgconfigdir  /usr/lib/pkgconfig
99
100 # Location of top applink dir
101 %_applnkdir      /usr/X11R6/share/applnk
102
103 # Location pixmaps for applnk/desktop files
104 %_pixmapsdir    /usr/X11R6/share/pixmaps
105
106 # Location of fonts directories
107 %_fontsdir      /usr/share/fonts
108
109 # Current date
110 %date           %(LC_ALL="C" date +"%a %b %d %Y")
111
112 # tmp directory
113 %tmpdir         %(echo "${TMPDIR:-/tmp}")
114
115 # Example files, programs, scripts...
116 %_examplesdir   /usr/src/examples
117
118 # The directory holding Linux kernel sources
119 %_kernelsrcdir  /usr/src/linux
120
121 # If non-empty "debug" macro defined, add "dbg" suffix to release number
122 %_rpmfilename   %%{NAME}-%%{VERSION}-%%{RELEASE}%{?debug:dbg}.%%{ARCH}.rpm
123
124 # requires name = version-release
125 %requires_releq()               %(LC_ALL="C" rpm -q --queryformat 'Requires:%%{NAME} = %%{VERSION}-%%{RELEASE}' %1| grep -v "is not")
126 %requires_kernel_releq()        %(LC_ALL="C" rpm -q --queryformat 'Prereq:kernel = %%{VERSION}-%%{RELEASE}' kernel-headers | grep -v "is not")
127 %requires_releq_kernel_up()     %(LC_ALL="C" rpm -q --queryformat 'Prereq:kernel-up = %%{VERSION}-%%{RELEASE}' kernel-headers | grep -v "is not")
128 %requires_releq_kernel_smp()    %(LC_ALL="C" rpm -q --queryformat 'Prereq:kernel-smp = %%{VERSION}-%%{RELEASE}' kernel-headers | grep -v "is not")
129
130 # kernel version-release handling
131 %__kernel_ver    %(grep UTS_RELEASE %{_kernelsrcdir}/include/linux/version.h 2>/dev/null | cut -d'"' -f2)
132 %__kernel_rel    %(LC_ALL="C" rpm -qf %{_kernelsrcdir}/include/linux/version.h --queryformat "%{RELEASE}" | grep -v "is not")
133 %_kernel_ver     %(echo %{__kernel_ver}%{!?_without_dist_kernel:-%{__kernel_rel}})
134 %_kernel_ver_str %(echo %{_kernel_ver} | sed s/-/_/g)
135
136 #-----------------------------------------------------------------
137 # find and gzip all files in %{_mandir} and %{infodir}
138 #
139 # Requires: xargs, find
140 #
141 #%no_install_post_compress_docs 1
142 %__spec_install_post_compress_docs { \
143 echo "Compress man and info pages."; \
144 %{!?no_install_post_compress_docs: \
145         %{?verbose:set -x;} \
146         for i in /usr/share/man /usr/X11R6/man /usr/share/info; do \
147                 if [ -d "$RPM_BUILD_ROOT$i" ]; then \
148                         find "$RPM_BUILD_ROOT$i" -name \*.bz2 -print | xargs -r %{__bzip2} -df; \
149                         find "$RPM_BUILD_ROOT$i" -name \*.gz -print | xargs -r %{__gzip} -dnf; \
150                         find "$RPM_BUILD_ROOT$i" -type f -print | xargs -r %{__gzip} -9nf; \
151                 fi; \
152         done; \
153 } }
154
155 #-----------------------------------------------------------------
156 # Strip executable binaries and shared object files
157 #
158 # Requires: find, awk, strip, cut, xargs
159 #
160 #%no_install_post_strip 1
161 %__spec_install_post_strip {%{!?debug: \
162 %{!?no_install_post_strip: \
163         %{?verbose:set -x;} \
164         echo "Strip executable binaries and shared object files."; \
165         filelist=`find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*"`; \
166         elfexelist=`echo $filelist | xargs -r file | \
167                 awk '/ELF.*executable/ {print $1}' | cut -d: -f1`; \
168         elfsharedlist=`echo $filelist | xargs -r file | \
169                 awk '/LF.*shared object/ {print $1}' | cut -d: -f1`; \
170         if [ -n "$elfexelist" ]; then \
171                 strip --remove-section=.note  --remove-section=.comment $elfexelist; \
172         fi; \
173         if [ -n "$elfsharedlist" ]; then \
174                 strip --strip-unneeded --remove-section=.note  --remove-section=.comment $elfsharedlist; \
175         fi; } \
176 } }
177
178 %_source_payload        w9.gzdio
179 %_binary_payload        w9.bzdio
180
181 #-----------------------------------------------------------------
182 # post %install sequence:
183 # - autodeps exceptions
184 # - compress all man and info pages,
185 # - strip all ELF executables and ELF shared objects if not %debug.
186
187 ###################################################################
188 # Requires/Provides automation
189 # exceptions system by Jacek Konieczny <jajcus@pld.org.pl>
190 %__spec_prep_pre \
191 _autoreqprov=n \
192 %{?_noautoreqfiles:_autoreqprov=y}\
193 %{?_noautoreq:_autoreqprov=y}\
194 %{?_noautoreqdep:_autoreqprov=y}\
195 %{?_noautoprovfiles:_autoreqprov=y}\
196 %{?_noautoprov:_autoreqprov=y}\
197 %{?_noautocompressdoc:_autoreqprov=y}\
198 if [ "$_autoreqprov" = "y" ] ; then \
199     if [ -f %{_builddir}/__rpm_lock ] ; then \
200         echo "Some package using \%_noauto*  macros is already being built" >&2 \
201         echo "If it is not true delete %{_builddir}/__rpm_lock" >&2 \
202         exit 1 \
203     else \
204         rm -f %{_builddir}/__rpm_*\
205         touch %{_builddir}/__rpm_lock \
206     fi \
207 fi \
208 %{?_noautocompressdoc:echo '%{_noautocompressdoc}' > %{_builddir}/__rpm_noautocompressdoc}\
209 %{nil}
210
211 %__os_install_post \
212 %{?_noautoreqfiles:for f in %{_noautoreqfiles} ; do echo %{?buildroot:%{buildroot}}$f >> %{_builddir}/__rpm_noautoreqfiles ; done }\
213 %{?_noautoreq:for f in %{_noautoreq} ; do echo "$f" >> %{_builddir}/__rpm_noautoreq ; done }\
214 %{?_noautoreqdep:for f in %{_noautoreqdep} ; do echo "$f" >> %{_builddir}/__rpm_noautoreqdep ; done }\
215 %{?_noautoprovfiles:for f in %{_noautoprovfiles} ; do echo %{?buildroot:%{buildroot}}$f >> %{_builddir}/__rpm_noautoprovfiles ; done }\
216 %{?_noautoprov:for f in %{_noautoprov} ; do echo "$f" >> %{_builddir}/__rpm_noautoprov ; done }\
217 %{__spec_install_post_strip}\
218 %{__spec_install_post_compress_docs}\
219 %{__arch_install_post}\
220 %{nil}
221
222 %__spec_clean_pre       %{___build_pre}\
223 _autoreqprov=n \
224 %{?_noautoreqfiles:_autoreqprov=y}\
225 %{?_noautoreq:_autoreqprov=y}\
226 %{?_noautoreqdep:_autoreqprov=y}\
227 %{?_noautoprovfiles:_autoreqprov=y}\
228 %{?_noautoprov:_autoreqprov=y}\
229 %{?_noautoreqfiles:_autoreqprov=y}\
230 %{?_noautocompressdoc:_autoreqprov=y}\
231 if [ "$_autoreqprov" = "y" ] ; then \
232         rm -f %{_builddir}/__rpm_* \
233 fi \
234 %{nil}
235
236
237 #%_noautoreqfiles       "%{_defaultdocdir}.*" "%{_examplesdir}.*"
238 #%_noautoreq            %{nil}
239 #%_noautoreqdep         %{nil}
240 #%_noautoprovfiles      %{nil}
241 #%_noautoprov           %{nil}
This page took 0.042445 seconds and 2 git commands to generate.