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