modified: SpatialOmicsCoord.py
[GalaxyCodeBases.git] / c_cpp / etc / calc / rpm.mk
blob996351df2a1511b5f66ba0b2e53867461e13d4fa
1 #!/bin/make
2 #****h* calc/rpm.mk
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
36 # the following:
38 # %_signature gpg
39 # %_gpg_path ~/.gnupg
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
58 # rpm processing:
60 # rpm
61 # rpm-python
62 # rpmlint
63 # rpm-build
64 # rpm-libs
65 # redhat-rpm-config
67 # setup
69 SHELL= /bin/sh
70 RPMBUILD_TOOL= rpmbuild
71 TARCH= i686
72 RPMBUILD_OPTION= -ba --target=$(TARCH)
73 RPM_TOOL= rpm
74 SED= sed
75 FIND= find
76 BZIP2_PROG= bzip2
77 TAR= tar
78 RM= rm
79 LS= ls
80 CPIO= cpio
81 CP= cp
82 EGREP= egrep
83 MKDIR= mkdir
84 GREP= grep
85 SORT= sort
86 CHMOD= chmod
87 LN= ln
89 # rpm-related parameters
91 NAME= calc
92 PROJECT_NAME= ${NAME}
93 PROJECT_VERSION=
94 PROJECT_RELEASE=
95 PROJECT= ${PROJECT_NAME}-${PROJECT_VERSION}
96 SPECFILE= ${PROJECT_NAME}.spec
97 TARBALL= ${PROJECT}.${TAR}.bz2
98 RPM686= ${PROJECT}-${PROJECT_RELEASE}.${TARCH}.rpm
99 DRPM686= \
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
105 # Makefile debug
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)
115 V=@:
116 #V=@
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
130 ver_calc:
131 ${V} echo '=-=-=-=-= rpm.mk start of $@ rule =-=-=-=-='
132 $(MAKE) -f Makefile ver_calc
133 ${V} echo '=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='
135 .PHONY: vers
136 vers:
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 =-=-=-=-='
143 ${RM} -f calc.spec
144 ${SED} -e 's/<<<PROJECT_VERSION>>>/'"`./ver_calc`"/g \
145 calc.spec.in > calc.spec
146 ${V} echo '=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='
148 .PHONY: srcpkg
149 srcpkg: make_rhdir
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$$' | \
158 LANG=C ${SORT} | \
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 =-=-=-=-='
170 .PHONY: rpm
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; \
184 exit 3; \
186 @echo
187 ${V} echo '=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='
189 .PHONY: make_rhdir
190 make_rhdir:
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 \
198 ${MKDIR} -p "$$i"; \
199 fi; \
200 if [ ! -d "$$i" ] ; then \
201 echo "FATAL: unable to create: $$i" 1>&2; \
202 exit 4; \
203 fi; \
204 if [ ! -w "$$i" ] ; then \
205 ${CHMOD} +w "$$i"; \
206 fi; \
207 if [ ! -w "$$i" ] ; then \
208 echo "FATAL: unable to make writable: $$i" 1>&2; \
209 exit 5; \
210 fi; \
211 done;
212 ${V} echo '=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='
214 .PHONY: -preclean
215 rpm-preclean:
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)"; \
221 fi; \
222 if [ -d "$(RPM_TOP)" ]; then \
223 echo "FATAL: cannot rm -rf $(RPM_TOP)" 1>&2; \
224 exit 1; \
225 fi; \
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; \
230 exit 1; \
231 fi; \
232 else \
233 echo "FATAL: make symbol RPM_TOP is empty" 1>&2; \
234 exit 2; \
236 ${V} echo '=-=-=-=-= ${MAKE_FILE} end of $@ rule =-=-=-=-='
238 # date format for spec file
239 .PHONY: logdate
240 logdate:
241 echo "`date +'* %a %b %d %Y'` `whoami`"
243 .PHONY: chkpkg
244 chkpkg:
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" ; \
254 done ;
255 ${V} echo '=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='
257 .PHONY: chksys
258 chksys:
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 =-=-=-=-='
264 .PHONY: test
265 test: ver_calc
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; \
269 exit 6; \
271 $(MAKE) -f rpm.mk PROJECT_VERSION="`./ver_calc`" installrpm chksys
272 ${V} echo '=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='
274 .PHONY: installrpm
275 installrpm:
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; \
279 exit 7; \
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 =-=-=-=-='
285 .PHONY: uninstallrpm
286 uninstallrpm:
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; \
290 exit 8; \
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 =-=-=-=-='
298 ${RM} -f "$@"
299 ${TAR} cf - "$^" | ${BZIP2_PROG} --best -c -z > "$@"
300 ${V} echo '=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='
302 #****