]> git.pld-linux.org Git - packages/rpm-build-macros.git/blame - rpm.macros
- more macros: %rc_inetd_post{,un}
[packages/rpm-build-macros.git] / rpm.macros
CommitLineData
9c404149
AM
1#-----------------------------------------------------------------
2# CFLAGS and LDFLAGS used to build
3
4%debugcflags -O0 -g
5%rpmcflags %{?debug:%debugcflags}%{!?debug:%optflags}
6%rpmldflags %{!?debug:-s}
7
8#-----------------------------------------------------------------
9f4ce098 9%configure2_13 { \
9c404149
AM
10 if [ -n "$LINGUAS" ]; then unset LINGUAS; fi; \
11 LDFLAGS="${LDFLAGS:-%rpmldflags}" ; export LDFLAGS ; \
12 CFLAGS="${CFLAGS:-%rpmcflags}" ; export CFLAGS ; \
13 CXXFLAGS="${CXXFLAGS:-%rpmcflags}" ; export CXXFLAGS ; \
14 FFLAGS="${FFLAGS:-%rpmcflags}" ; export FFLAGS ; \
15 ./configure \
2a7cfd3f 16 --host=%{_target_platform} \
9c404149
AM
17 --prefix=%{_prefix} \
18 --exec-prefix=%{_exec_prefix} \
19 --bindir=%{_bindir} \
20 --sbindir=%{_sbindir} \
21 --sysconfdir=%{_sysconfdir} \
22 --datadir=%{_datadir} \
23 --includedir=%{_includedir} \
24 --libdir=%{_libdir} \
25 --libexecdir=%{_libexecdir} \
26 --localstatedir=%{_localstatedir} \
27 --sharedstatedir=%{_sharedstatedir} \
28 --mandir=%{_mandir} \
29 --infodir=%{_infodir} \
30}
31
4a6b0d54 32#----------------------------------------------------------------
9f4ce098 33%configure {./configure \
4a6b0d54
AF
34 LDFLAGS="${LDFLAGS:-%rpmldflags}" \
35 CFLAGS="${CFLAGS:-%rpmcflags}" \
36 CXXFLAGS="${CXXFLAGS:-%rpmcflags}" \
37 FFLAGS="${FFLAGS:-%rpmcflags}" \
9f4ce098
AF
38 %{?__cc:CC=%{__cc}} \
39 %{?__cxx:CXX=%{__cxx}} \
4a6b0d54
AF
40 --build=%{_target_platform} \
41 --prefix=%{_prefix} \
42 --exec-prefix=%{_exec_prefix} \
43 --bindir=%{_bindir} \
44 --sbindir=%{_sbindir} \
45 --sysconfdir=%{_sysconfdir} \
46 --datadir=%{_datadir} \
47 --includedir=%{_includedir} \
48 --libdir=%{_libdir} \
49 --libexecdir=%{_libexecdir} \
50 --localstatedir=%{_localstatedir} \
51 --sharedstatedir=%{_sharedstatedir} \
52 --mandir=%{_mandir} \
53 --infodir=%{_infodir} \
54}
55
9c404149
AM
56#------------------------------------------------------------------------------
57# The GNUconfigure macro does the following:
58# update config.guess and config.sub.
59# regenerate all autoconf/automake files
60# optionally change to a directory (make the directory if requested).
61# run configure with correct prefix, platform, and CFLAGS.
62# optionally restore current directory.
63#
64# Based on autogen.sh from GNOME and orginal GNUconfigure
65#
66%GNUconfigure(MCs:) \
67 %{-C:_mydir="`pwd`"; %{-M: %{__mkdir} -p %{-C*};} cd %{-C*}} \
68 dirs="`find ${_mydir} -name configure.in -print`"; export dirs; \
69 for coin in `echo ${dirs}` \
70do \
71 dr=`dirname ${coin}`; \
72if test -f ${dr}/NO-AUTO-GEN; then \
73 : \
74else \
75 macrodirs=`sed -n -e 's,AM_ACLOCAL_INCLUDE(\(.*\)),\1,gp' < ${coin}`; \
76 ( cd ${dr}; \
77 aclocalinclude="${ACLOCAL_FLAGS}"; \
78 for k in ${macrodirs}; do \
79 if test -d ${k}; then \
80 aclocalinclude="${aclocalinclude} -I ${k}"; \
81 ##else \
82 ## echo "**Warning**: No such directory \`${k}'. Ignored." \
83 fi \
84 done \
85 if grep "^AM_GNU_GETTEXT" configure.in >/dev/null; then \
86 if grep "sed.*POTFILES" configure.in >/dev/null; then \
87 : do nothing -- we still have an old unmodified configure.in \
88 else \
89 test -r ${dr}/aclocal.m4 || touch ${dr}/aclocal.m4; \
90 echo "no" | gettextize --force --copy; \
91 test -r ${dr}/aclocal.m4 && %{__chmod} u+w ${dr}/aclocal.m4; \
92 fi \
93 fi \
94 if grep "^AM_PROG_LIBTOOL" configure.in >/dev/null; then \
95 %{__libtoolize} --force --copy; \
96 fi \
97 aclocal ${aclocalinclude}; \
98 if grep "^AM_CONFIG_HEADER" configure.in >/dev/null; then \
99 %{__autoheader}; \
100 fi \
101 echo "Running automake --gnu ${am_opt} ..."; \
102 %{__automake} --add-missing --gnu ${am_opt}; \
103 %{__autoconf}; \
104 ); \
105 fi \
106done \
107 %{-C:${_mydir}}%{!-C:.}/%{configure} \
108 %{-C:cd ${_mydir}; unset _mydir}
109
110# Location of autoconf macros
111%_aclocaldir %(aclocal --print-ac-dir)
112
e987a186 113# Location of pkgconfig files
d7021551 114%_pkgconfigdir /usr/lib/pkgconfig
e987a186 115
9c404149
AM
116# Location of top applink dir
117%_applnkdir /usr/X11R6/share/applnk
118
119# Location pixmaps for applnk/desktop files
120%_pixmapsdir /usr/X11R6/share/pixmaps
121
e987a186
JB
122# Location of fonts directories
123%_fontsdir /usr/share/fonts
124
9c404149
AM
125# Current date
126%date %(LC_ALL="C" date +"%a %b %d %Y")
127
128# tmp directory
129%tmpdir %(echo "${TMPDIR:-/tmp}")
130
131# Example files, programs, scripts...
132%_examplesdir /usr/src/examples
133
134# If non-empty "debug" macro defined, add "dbg" suffix to release number
135%_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}%{?debug:dbg}.%%{ARCH}.rpm
136
137#-----------------------------------------------------------------
138# find and gzip all files in %{_mandir} and %{infodir}
139#
140# Requires: xargs, find
141#
142#%no_install_post_compress_docs 1
143%__spec_install_post_compress_docs { \
144echo "Compress man and info pages."; \
145%{!?no_install_post_compress_docs: \
146 %{?verbose:set -x;} \
147 for i in /usr/share/man /usr/X11R6/man /usr/share/info; do \
148 if [ -d "$RPM_BUILD_ROOT$i" ]; then \
149 find "$RPM_BUILD_ROOT$i" -name \*.bz2 -print | xargs -r %{__bzip2} -df; \
150 find "$RPM_BUILD_ROOT$i" -name \*.gz -print | xargs -r %{__gzip} -dnf; \
151 find "$RPM_BUILD_ROOT$i" -type f -print | xargs -r %{__gzip} -9nf; \
152 fi; \
153 done; \
154} }
155
156#-----------------------------------------------------------------
157# Strip executable binaries and shared object files
158#
159# Requires: find, awk, strip, cut, xargs
160#
161#%no_install_post_strip 1
162%__spec_install_post_strip {%{!?debug: \
163%{!?no_install_post_strip: \
164 %{?verbose:set -x;} \
165 echo "Strip executable binaries and shared object files."; \
166 filelist=`find $RPM_BUILD_ROOT -type f ! -regex ".*ld-[0-9.]*so.*"`; \
167 elfexelist=`echo $filelist | xargs -r file | \
168 awk '/ELF.*executable/ {print $1}' | cut -d: -f1`; \
169 elfsharedlist=`echo $filelist | xargs -r file | \
170 awk '/LF.*shared object/ {print $1}' | cut -d: -f1`; \
171 if [ -n "$elfexelist" ]; then \
172 strip --remove-section=.note --remove-section=.comment $elfexelist; \
173 fi; \
174 if [ -n "$elfsharedlist" ]; then \
175 strip --strip-unneeded --remove-section=.note --remove-section=.comment $elfsharedlist; \
176 fi; } \
177} }
178
179%_source_payload w9.gzdio
180%_binary_payload w9.bzdio
181
182#-----------------------------------------------------------------
183# post %install sequence:
184# - autodeps exceptions
185# - compress all man and info pages,
186# - strip all ELF executables and ELF shared objects if not %debug.
187
188###################################################################
189# Requires/Provides automation
190# exceptions system by Jacek Konieczny <jajcus@pld.org.pl>
7126cc1b
JK
191%__spec_prep_pre \
192_autoreqprov=n \
193%{?_noautoreqfiles:_autoreqprov=y}\
194%{?_noautoreq:_autoreqprov=y}\
195%{?_noautoreqdep:_autoreqprov=y}\
196%{?_noautoprovfiles:_autoreqprov=y}\
197%{?_noautoprov:_autoreqprov=y}\
198if [ "$_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 \
207fi \
9c404149
AM
208%{nil}
209
210%__spec_install_post \
211%{?_noautoreqfiles:for f in %{_noautoreqfiles} ; do echo %{?buildroot:%{buildroot}}$f >> %{_builddir}/__rpm_noautoreqfiles ; done }\
212%{?_noautoreq:for f in %{_noautoreq} ; do echo "$f" >> %{_builddir}/__rpm_noautoreq ; done }\
213%{?_noautoreqdep:for f in %{_noautoreqdep} ; do echo "$f" >> %{_builddir}/__rpm_noautoreqdep ; done }\
214%{?_noautoprovfiles:for f in %{_noautoprovfiles} ; do echo %{?buildroot:%{buildroot}}$f >> %{_builddir}/__rpm_noautoprovfiles ; done }\
215%{?_noautoprov:for f in %{_noautoprov} ; do echo "$f" >> %{_builddir}/__rpm_noautoprov ; done }\
216%{__spec_install_post_strip}\
217%{__spec_install_post_compress_docs}\
218%{__arch_install_post}\
219%{__os_install_post}\
220%{nil}
221
222%__spec_clean_pre %{___build_pre}\
7126cc1b
JK
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}\
230if [ "$_autoreqprov" = "y" ] ; then \
231 rm -f %{_builddir}/__rpm_* \
232fi \
9c404149
AM
233%{nil}
234
235
236#%_noautoreqfiles "%{_defaultdocdir}.*" "%{_examplesdir}.*"
237#%_noautoreq %{nil}
238#%_noautoreqdep %{nil}
239#%_noautoprovfiles %{nil}
240#%_noautoprov %{nil}
241
2b9c07b4 242#-----------------------------------------------------------------
243# Kernel version related stuff
244#
245%_kernel_ver %(grep UTS_RELEASE /usr/src/linux/include/linux/version.h 2>/dev/null | cut -d'"' -f2)
246%_kernel24 %(echo %{_kernel_ver} | grep -q '2\.[012]\.' ; echo $?)
247%_kernel_series %{?_kernel24:2.4}%{!?_kernel24:2.2}
248%conflicts_kernel_ver Conflicts: kernel < %{_kernel_ver}, kernel > %{_kernel_ver}
cee7caca 249%conflicts_kernel_series Conflicts: kernel %{?_kernel24:<} {!?_kernel24:>=} 2.3.0
2b9c07b4 250
251#-----------------------------------------------------------------
252# Macros commonly used in %{pre,post}{un,}
253#
254# Usage:
94769e3f 255# [NAME=lircd;] [DESC="lirc daemon";] %chkconfig_post
256# [NAME=lircd;] %chkconfig_preun
2b9c07b4 257# %fix_info_dir (in %post)
94769e3f 258# GID=51; GROUP=http; [NAME=apache;] %groupadd (in %pre)
259# [UID=51;] USER=http; GROUP=http; COMMENT="HTTP User"
260# [HOMEDIR="/home/users/httpd [-m]";] [SHELL=/bin/false;]
261# [NAME=apache;] %useradd (in %pre)
2b9c07b4 262# GROUP=http; %groupdel (in %postun)
263# USER=http; %userdel (in %postun)
94769e3f 264# %rc_inetd_post
265# %rc_inetd_postun
2b9c07b4 266#
94769e3f 267%chkconfig_post [ -z "$NAME" ] && NAME=%{name} \
268/sbin/chkconfig --add $NAME \
269[ -z "$DESC" ] && DESC=$NAME
2b9c07b4 270if [ -f /var/lock/subsys/$NAME ]; then \
271 /etc/rc.d/init.d/$NAME restart >&2 \
272else \
94769e3f 273 echo "Run \\"/etc/rc.d/init.d/$NAME start\\" to start $DESC." >&2 \
2b9c07b4 274fi
275
94769e3f 276%chkconfig_preun [ -z "$NAME" ] && NAME=%{name} \
277if [ "$1" = "0" ]; then \
2b9c07b4 278 if [ -f /var/lock/subsys/$NAME ]; then \
279 /etc/rc.d/init.d/$NAME stop >&2 \
280 fi \
281 /sbin/chkconfig --del $NAME \
282fi
283
284%fix_info_dir [ ! -x /usr/sbin/fix-info-dir ] || /usr/sbin/fix-info-dir -c %{_infodir} > /dev/null 2>&1
285
94769e3f 286%groupadd [ -z "$NAME" ] && NAME=%{name} \
287[ -n "$GID" ] && GID="-g $GID" \
288if [ -n "`getgid $GROUP`" ]; then \
2b9c07b4 289 if [ "`getgid $GROUP`" != "$GID" ]; then \
94769e3f 290 echo "Warning: group $GROUP doesn't have gid=$GID. Correct this before installing $NAME." 1>&2 \
2b9c07b4 291 exit 1 \
292 fi \
293else \
94769e3f 294 /usr/sbin/groupadd $GID -r -f $GROUP \
2b9c07b4 295fi
296
94769e3f 297%useradd [ -z "$NAME" ] && NAME=%{name} \
298[ -z "$HOMEDIR" ] && HOMEDIR=/home/users/$NAME \
299[ -n "$UID" ] && UID="-u $UID -r"
300if [ -n "`id -u $USER 2>/dev/null`" ]; then \
2b9c07b4 301 if [ "`id -u $USER`" != "$UID" ]; then \
94769e3f 302 echo "Warning: user $USER doesn't have uid=$UID. Correct this before installing $NAME." 1>&2 \
2b9c07b4 303 exit 1 \
304 fi \
305else \
306 test -z "$SHELL" && SHELL=/bin/false \
94769e3f 307 /usr/sbin/useradd $UID -d "$HOMEDIR" -s $SHELL -c "$COMMENT" -g $GROUP $USER 1>&2 \
2b9c07b4 308fi
309
310%groupdel if [ "$1" = "0" ]; then \
311 /usr/sbin/groupdel $GROUP \
312fi
9c404149 313
2b9c07b4 314%userdel if [ "$1" = "0" ]; then \
315 /usr/sbin/userdel $USER \
316fi
94769e3f 317
318%rc_inetd_post if [ -f /var/lock/subsys/rc-inetd ]; then \
319 /etc/rc.d/init.d/rc-inetd restart 1>&2 \
320else \
321 echo "Type \"/etc/rc.d/init.d/rc-inetd start\" to start inet server" 1>&2 \
322fi
323
324%rc_inetd_postun if [ -f /var/lock/subsys/rc-inetd ]; then \
325 /etc/rc.d/init.d/rc-inetd restart \
326fi
This page took 0.107576 seconds and 4 git commands to generate.