4 # rpm.mk - Makefile for building rpm packages for calc
6 # Copyright (C) 2003 Petteri Kettunen and Landon Curt Noll
8 # Calc is open software; you can redistribute it and/or modify it under
9 # the terms of the version 2.1 of the GNU Lesser General Public License
10 # as published by the Free Software Foundation.
12 # Calc is distributed in the hope that it will be useful, but WITHOUT
13 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 # or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
15 # Public License for more details.
17 # A copy of version 2.1 of the GNU Lesser General Public License is
18 # distributed with calc under the filename COPYING-LGPL. You should have
19 # received a copy with calc; if not, write to Free Software Foundation, Inc.
20 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 MAKEFILE_REV
= $$Revision: 30.11 $$
23 # @(#) $Id: rpm.mk,v 30.11 2013/08/11 08:41:38 chongo Exp $
24 # @(#) $Source: /usr/local/src/bin/calc/RCS/rpm.mk,v $
26 # Under source code control: 2003/02/16 20:21:39
27 # File existed as early as: 2003
29 # chongo <was here> /\oo/\ http://www.isthe.com/chongo/
30 # Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
32 # calculator by David I. Bell with help/mods from others
33 # Makefile by Petteri Kettunen with modifications from Landon Curt Noll
35 # IMPORTANT NOTE: The rpm process assumes that ~/.rpmmacros contains
40 # %_gpg_name __YOUR_NAME_HERE__
41 # %_gpgbin /usr/bin/gpg
42 # %_topdir %(echo $HOME)/rpm/%{name}
43 # %_sourcedir %(echo $HOME)/rpm/%{name}/SOURCES
44 # %_specdir %(echo $HOME)/rpm/%{name}/SPECS
45 # %_tmppath %(echo $HOME)/rpm/%{name}/tmp
46 # %_builddir %(echo $HOME)/rpm/%{name}/BUILD
47 # %_buildroot %(echo $HOME)/rpm/%{name}/tmp/build-root
48 # %_rpmdir %(echo $HOME)/rpm/%{name}/RPMS
49 # %_srcrpmdir %(echo $HOME)/rpm/%{name}/SRPMS
50 # %_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm
51 # %packager __YOUR_NAME_HERE__
52 # %vendor __YOUR_ORG_OR_GROUP_OR_COMPANY_HERE__
54 # IMPORTANT NOTE: Unless the package redhat-rpm-config is installed,
55 # the calc-debuginfo rpm will not be created.
57 # IMPORTANT NOTE: These packages are important for general
70 RPMBUILD_TOOL
= rpmbuild
72 RPMBUILD_OPTION
= -ba
--target
=$(TARCH
)
89 # rpm-related parameters
95 PROJECT
= ${PROJECT_NAME}-${PROJECT_VERSION}
96 SPECFILE
= ${PROJECT_NAME}.spec
97 TARBALL
= ${PROJECT}.
${TAR}.bz2
98 RPM686
= ${PROJECT}-${PROJECT_RELEASE}.
${TARCH}.rpm
100 ${PROJECT_NAME}-devel-
${PROJECT_VERSION}-${PROJECT_RELEASE}.
${TARCH}.rpm
101 SRPM
= ${PROJECT}-${PROJECT_RELEASE}.src.rpm
102 RPM_TOP
= ${HOME}/rpm
/${NAME}
103 TMPDIR
= ${RPM_TOP}/tmp
107 # Q=@ do not echo internal Makefile actions (quiet mode)
108 # Q= echo internal Makefile actions (debug / verbose mode)
110 # V=@: do not echo debug statements (quiet mode)
111 # V=@ do echo debug statements (debug / verbose mode)
118 all: ver_calc calc.spec
119 ${V} echo
'=-=-=-=-= rpm.mk start of $@ rule =-=-=-=-='
120 PROJECT_VERSION
="`./ver_calc`"; \
121 PROJECT_RELEASE
="`${SED} -n \
122 -e '/^Release:/s/^Release: *//p' calc.spec.in`"; \
123 $(MAKE
) -f rpm.mk rpm \
124 PROJECT_VERSION
="$$PROJECT_VERSION" \
125 PROJECT_RELEASE
="$$PROJECT_RELEASE"
126 ${V} echo
'=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='
128 pkgme
: $(PROJECT_NAME
)-spec.
${TAR}.bz2
131 ${V} echo
'=-=-=-=-= rpm.mk start of $@ rule =-=-=-=-='
132 $(MAKE
) -f Makefile ver_calc
133 ${V} echo
'=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='
137 ${V} echo
'=-=-=-=-= rpm.mk start of $@ rule =-=-=-=-='
138 $(MAKE
) -f Makefile ver_calc
139 ${V} echo
'=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='
141 calc.spec
: calc.spec.in ver_calc
142 ${V} echo
'=-=-=-=-= rpm.mk start of $@ rule =-=-=-=-='
144 ${SED} -e
's/<<<PROJECT_VERSION>>>/'"`./ver_calc`"/g \
145 calc.spec.in
> calc.spec
146 ${V} echo
'=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='
150 ${V} echo
'=-=-=-=-= rpm.mk start of $@ rule =-=-=-=-='
151 ${V} echo RPM_TOP
="${RPM_TOP}"
152 ${V} echo PROJECT_VERSION
="${PROJECT_VERSION}"
153 ${V} echo PROJECT_RELEASE
="${PROJECT_RELEASE}"
154 ${RM} -rf
"$(TMPDIR)/$(PROJECT)"
155 ${FIND} .
-depth
-print | \
156 ${EGREP} -v
'/RCS|/CVS|/NOTES|/\.|\.out$$|\.safe$$\.tar\.bz2$$' | \
157 ${EGREP} -v
'/old[._-]|\.old$$|\.tar\.gz$$|/ver_calc$$' | \
159 ${CPIO} -dumpv
"$(TMPDIR)/$(PROJECT)"
160 ${RM} -f
"$(TMPDIR)/$(PROJECT)/Makefile"
161 ${SED} -e
's/^CCWERR=[ ]*-Werror/CCWERR=/' \
162 -e
's/^#.*CCWERR=.*-Werror$$/#/' \
163 -e
's/^CHECK= check/CHECK= true/' \
164 Makefile
> "$(TMPDIR)/$(PROJECT)/Makefile"
165 ${CHMOD} 0444 "$(TMPDIR)/$(PROJECT)/Makefile"
166 cd
"$(TMPDIR)"; ${TAR} cf
- "$(PROJECT)" | \
167 ${BZIP2_PROG} --best
-c
-z
> "$(RPM_TOP)/SOURCES/$(TARBALL)"
168 ${V} echo
'=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='
171 rpm
: srcpkg calc.spec
172 ${V} echo
'=-=-=-=-= rpm.mk start of $@ rule =-=-=-=-='
173 ${V} echo RPM_TOP
="${RPM_TOP}"
174 ${V} echo PROJECT_VERSION
="${PROJECT_VERSION}"
175 ${V} echo PROJECT_RELEASE
="${PROJECT_RELEASE}"
176 $(MAKE
) -f Makefile
clean
177 ${CP} "$(SPECFILE)" "$(RPM_TOP)/SPECS/$(SPECFILE)"
178 ${RM} -f
"$(RPM_TOP)/RPMS/$(TARCH)/$(RPM686)"
179 ${RM} -f
"$(RPM_TOP)/RPMS/$(TARCH)/$(DRPM686)"
180 ${RM} -f
"$(RPM_TOP)/SRPMS/$(SRPM)"
181 ${RPMBUILD_TOOL} ${RPMBUILD_OPTION} "$(RPM_TOP)/SPECS/$(SPECFILE)"
182 @if
[ ! -f
"$(RPM_TOP)/SRPMS/$(SRPM)" ]; then \
183 echo
"SRPMS/$(SRPM) not found" 1>&2; \
187 ${V} echo
'=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='
191 ${V} echo
'=-=-=-=-= rpm.mk start of $@ rule =-=-=-=-='
192 ${V} echo RPM_TOP
="${RPM_TOP}"
193 ${V} echo PROJECT_VERSION
="${PROJECT_VERSION}"
194 ${V} echo PROJECT_RELEASE
="${PROJECT_RELEASE}"
195 for subdir in
"" BUILD RPMS SOURCES SPECS SRPMS tmp
; do \
196 i
="$(RPM_TOP)/$$subdir"; \
197 if
[ ! -d
"$$i" ] ; then \
200 if
[ ! -d
"$$i" ] ; then \
201 echo
"FATAL: unable to create: $$i" 1>&2; \
204 if
[ ! -w
"$$i" ] ; then \
207 if
[ ! -w
"$$i" ] ; then \
208 echo
"FATAL: unable to make writable: $$i" 1>&2; \
212 ${V} echo
'=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='
216 ${V} echo
'=-=-=-=-= ${MAKE_FILE} start of $@ rule =-=-=-=-='
217 ${Q} if
[ -n
"$(RPM_TOP)" ]; then \
218 if
[ -d
"$(RPM_TOP)" ]; then \
219 echo
${RM} -rf
"$(RPM_TOP)"; \
220 ${RM} -rf
"$(RPM_TOP)"; \
222 if
[ -d
"$(RPM_TOP)" ]; then \
223 echo
"FATAL: cannot rm -rf $(RPM_TOP)" 1>&2; \
226 echo
${MKDIR} -p
"$(RPM_TOP)"; \
227 ${MKDIR} -p
"$(RPM_TOP)"; \
228 if
[ ! -d
"$(RPM_TOP)" ]; then \
229 echo
"FATAL: cannot mkdir -p $(RPM_TOP)" 1>&2; \
233 echo
"FATAL: make symbol RPM_TOP is empty" 1>&2; \
236 ${V} echo
'=-=-=-=-= ${MAKE_FILE} end of $@ rule =-=-=-=-='
238 # date format for spec file
241 echo
"`date +'* %a %b %d %Y'` `whoami`"
245 ${V} echo
'=-=-=-=-= rpm.mk start of $@ rule =-=-=-=-='
246 for i in
"$(RPM_TOP)/RPMS/$(TARCH)/$(RPM686)" \
247 "$(RPM_TOP)/RPMS/$(TARCH)/$(DRPM686)" \
248 "$(RPM_TOP)/SRPMS/$(SRPM)" ; do \
249 echo
"***** start $$i" ; \
250 ${RPM_TOOL} -qpi
"$$"i
; \
251 echo
"***** files $$i" ; \
252 ${RPM_TOOL} -qpl
"$$i" ; \
253 echo
"***** end $$i" ; \
255 ${V} echo
'=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='
259 ${V} echo
'=-=-=-=-= rpm.mk start of $@ rule =-=-=-=-='
260 ${RPM_TOOL} -qa |
${GREP} "$(PROJECT_NAME)"
261 ${RPM_TOOL} -qa |
${GREP} "$(PROJECT_NAME)-devel"
262 ${V} echo
'=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='
266 ${V} echo
'=-=-=-=-= rpm.mk start of $@ rule =-=-=-=-='
267 @if
[ X
"`id -u`" != X
"0" ]; then \
268 echo
"test needs to install, must be root to test" 1>&2; \
271 $(MAKE
) -f rpm.mk PROJECT_VERSION
="`./ver_calc`" installrpm chksys
272 ${V} echo
'=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='
276 ${V} echo
'=-=-=-=-= rpm.mk start of $@ rule =-=-=-=-='
277 @if
[ X
"`id -u`" != X
"0" ]; then \
278 echo
"must be root to install RPMs" 1>&2; \
281 ${RPM_TOOL} -ivh
"$(RPM_TOP)/RPMS/$(TARCH)/$(RPM686)"
282 ${RPM_TOOL} -ivh
"$(RPM_TOP)/RPMS/$(TARCH)/$(DRPM686)"
283 ${V} echo
'=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='
287 ${V} echo
'=-=-=-=-= rpm.mk start of $@ rule =-=-=-=-='
288 @if
[ X
"`id -u`" != X
"0" ]; then \
289 echo
"must be root to uninstall RPMs" 1>&2; \
292 ${RPM_TOOL} -e
"$(PROJECT_NAME)-devel"
293 ${RPM_TOOL} -e
"$(PROJECT_NAME)"
294 ${V} echo
'=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='
296 $(PROJECT_NAME
)-spec.
${TAR}.bz2
: rpm.mk
$(PROJECT_NAME
).spec.in
297 ${V} echo
'=-=-=-=-= rpm.mk start of $@ rule =-=-=-=-='
299 ${TAR} cf
- "$^" |
${BZIP2_PROG} --best
-c
-z
> "$@"
300 ${V} echo
'=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='