Files
calc/rpm.mk
Landon Curt Noll ac0d84eef8 Release v2.12.9.0
Added notes to help/unexpected about:

    display() will limit the number of digits printed after decimal point

    %d will format after the decimal point for non-integer numeric values

    %x will format as fractions for non-integer numeric values

    fprintf(fd, "%d\n", huge_value) may need fflush(fd) to finish

Fixed Makefile dependencies for the args.h rule.

Fixed Makefile cases where echo with -n is used.  On some systems,
/bin/sh does not use -n, so we must call /bin/echo -n instead
via the ${ECHON} Makefile variable.

Add missing standard tools to sub-Makefiles to make them
easier to invoke directly.

Sort lists of standard tool Makefile variables and remove duplicates.

Declare the SHELL at the top of Makefiles.

Fixed the depend rule in the custom Makefile.

Improved the messages produced by the depend in the Makefiles.

Changed the UNUSED define in have_unused.h to be a macro with
a parameter.  Changed all use of UNUSED in *.c to be UNUSED(x).

Removed need for HAVE_UNUSED in building the have_unused.h file.

 CCBAN is given to ${CC} in order to control if banned.h is in effect.

 The banned.h attempts to ban the use of certain dangerous functions
 that, if improperly used, could compromise the computational integrity
 if calculations.

 In the case of calc, we are motivated in part by the desire for calc
 to correctly calculate: even during extremely long calculations.

 If UNBAN is NOT defined, then calling certain functions
 will result in a call to a non-existent function (link error).

 While we do NOT encourage defining UNBAN, there may be
 a system / compiler environment where re-defining a
 function may lead to a fatal compiler complication.
 If that happens, consider compiling as:

    make clobber all chk CCBAN=-DUNBAN

 as see if this is a work-a-round.

 If YOU discover a need for the -DUNBAN work-a-round, PLEASE tell us!
 Please send us a bug report.  See the file:

    BUGS

 or the URL:

    http://www.isthe.com/chongo/tech/comp/calc/calc-bugrept.html

 for how to send us such a bug report.

 Added the building of have_ban_pragma.h, which will determine
 if "#pragma GCC poison func_name" is supported.  If it is not,
 or of HAVE_PRAGMA_GCC_POSION=-DHAVE_NO_PRAGMA_GCC_POSION, then
 banned.h will have no effect.

 Fixed building of the have_getpgid.h file.
 Fixed building of the have_getprid.h file.
 Fixed building of the have_getsid.h file.
 Fixed building of the have_gettime.h file.
 Fixed building of the have_strdup.h file.
 Fixed building of the have_ustat.h file.
 Fixed building of the have_rusage.h file.

 Added HAVE_NO_STRLCPY to control if we want to test if
 the system has a strlcpy() function.  This in turn produces
 the have_strlcpy.h file wherein the symbol HAVE_STRLCPY will
 be defined, or not depending if the system comes with a
 strlcpy() function.

 If the system does not have a strlcpy() function, we
 compile our own strlcpy() function.  See strl.c for details.

 Added HAVE_NO_STRLCAT to control if we want to test if
 the system has a strlcat() function.  This in turn produces
 the have_strlcat.h file wherein the symbol HAVE_STRLCAT will
 be defined, or not depending if the system comes with a
 strlcat() function.

 If the system does not have a strlcat() function, we
 compile our own strlcat() function.  See strl.c for details.

 Fixed places were <string.h>, using #ifdef HAVE_STRING_H
 for legacy systems that do not have that include file.

 Added ${H} Makefile symbol to control the announcement
 of forming and having formed hsrc related files.  By default
 H=@ (announce hsrc file formation) vs. H=@: to silence hsrc
 related file formation.

 Explicitly turn off quiet mode (set Makefile variable ${Q} to
 be empty) when building rpms.

 Improved and fixed the hsrc build process.

 Forming rpms is performed in verbose mode to assist debugging
 to the rpm build process.

 Compile custom code, if needed, after main code is compiled.
2021-03-11 01:54:28 -08:00

325 lines
9.5 KiB
Makefile

#!/bin/make
#****h* calc/rpm.mk
#
# rpm.mk - Makefile for building rpm packages for calc
#
# Copyright (C) 2003,2014,2021 Petteri Kettunen and Landon Curt Noll
#
# Calc is open software; you can redistribute it and/or modify it under
# the terms of the version 2.1 of the GNU Lesser General Public License
# as published by the Free Software Foundation.
#
# Calc is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
# or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General
# Public License for more details.
#
# A copy of version 2.1 of the GNU Lesser General Public License is
# distributed with calc under the filename COPYING-LGPL. You should have
# received a copy with calc; if not, write to Free Software Foundation, Inc.
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# Under source code control: 2003/02/16 20:21:39
# File existed as early as: 2003
#
# chongo <was here> /\oo/\ http://www.isthe.com/chongo/
# Share and enjoy! :-) http://www.isthe.com/chongo/tech/comp/calc/
#
# calculator by David I. Bell with help/mods from others
# Makefile by Petteri Kettunen with modifications from Landon Curt Noll
# IMPORTANT NOTE: The rpm process assumes that ~/.rpmmacros contains
# the following:
#
# %_topdir /var/tmp/rpmbuild
# %_tmppath %{_topdir}/tmp
# %_builddir %{_topdir}/BUILD
# %_rpmdir %{_topdir}/RPMS
# %_sourcedir %{_topdir}/SOURCES
# %_specdir %{_topdir}/SPECS
# %_srcrpmdir %{_topdir}/SRPMS
# %_buildroot %{_topdir}/BUILDROOT
# %_rpmfilename %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}.rpm
#
# If you are signing the rpms, you also need:
#
# %_signature gpg
# %_gpg_path ~/.gnupg
# %_gpg_name __YOUR_NAME_HERE__
# %_gpgbin /usr/bin/gpg
# IMPORTANT NOTE: Unless the package redhat-rpm-config is installed,
# the calc-debuginfo rpm will not be created.
#
# IMPORTANT NOTE: These packages are important for general
# rpm processing:
#
# rpm
# rpm-python
# rpmlint
# rpm-build
# rpm-libs
# redhat-rpm-config
# setup
#
SHELL= /bin/sh
RPMBUILD_TOOL= rpmbuild
TARCH= x86_64
RPMBUILD_OPTION= -ba --target=$(TARCH) --buildroot=${RPM_BUILD_ROOT}
RPM_TOOL= rpm
SED= sed
FIND= find
BZIP2_PROG= bzip2
TAR= tar
RM= rm
LS= ls
CPIO= cpio
CP= cp
EGREP= egrep
MKDIR= mkdir
GREP= grep
SORT= sort
CHMOD= chmod
LN= ln
# rpm-related parameters
#
NAME= calc
PROJECT_NAME= ${NAME}
PROJECT_VERSION=
PROJECT_RELEASE=
PROJECT= ${PROJECT_NAME}-${PROJECT_VERSION}
SPECFILE= ${PROJECT_NAME}.spec
TARBALL= ${PROJECT}.${TAR}.bz2
RPMx86_64= ${PROJECT}-${PROJECT_RELEASE}.${TARCH}.rpm
DRPMx86_64= \
${PROJECT_NAME}-devel-${PROJECT_VERSION}-${PROJECT_RELEASE}.${TARCH}.rpm
SRPM= ${PROJECT}-${PROJECT_RELEASE}.src.rpm
# NOTE: RPM_TOP must be the same as %_topdir in ~/.rpmmacros
RPM_TOP= /var/tmp/rpmbuild
RPM_BUILD_ROOT= ${RPM_TOP}/BUILDROOT
TMPDIR= ${RPM_TOP}/tmp
# Makefile debug
#
# Q=@ do not echo internal Makefile actions (quiet mode)
# Q= echo internal Makefile actions (debug / verbose mode)
#
# H=@: do not report hsrc file formation progress
# H=@ do echo hsrc file formation progress
#
# S= >/dev/null 2>&1 slience ${CC} output during hsrc file formation
# S= full ${CC} output during hsrc file formation
#
# E= 2>/dev/null slience command stderr during hsrc file formation
# E= full command stderr during hsrc file formation
#
# V=@: do not echo debug statements (quiet mode)
# V=@ do echo debug statements (debug / verbose mode)
#
#Q=
Q=@
#
S= >/dev/null 2>&1
#S=
#
E= 2>/dev/null
#E=
#
#H=@:
H=@
#
V=@:
#V=@
all: ver_calc calc.spec
${V} echo '=-=-=-=-= rpm.mk start of $@ rule =-=-=-=-='
PROJECT_VERSION="`./ver_calc`"; \
PROJECT_RELEASE="`${SED} -n \
-e '/^Release:/s/^Release: *//p' calc.spec.in`"; \
$(MAKE) -f rpm.mk rpm \
PROJECT_VERSION="$$PROJECT_VERSION" \
PROJECT_RELEASE="$$PROJECT_RELEASE" Q= S= E=
${V} echo '=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='
pkgme: $(PROJECT_NAME)-spec.${TAR}.bz2
ver_calc:
${V} echo '=-=-=-=-= rpm.mk start of $@ rule =-=-=-=-='
$(MAKE) -f Makefile ver_calc Q= S= E=
${V} echo '=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='
.PHONY: vers
vers:
${V} echo '=-=-=-=-= rpm.mk start of $@ rule =-=-=-=-='
$(MAKE) -f Makefile ver_calc Q= S= E=
${V} echo '=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='
calc.spec: calc.spec.in ver_calc
${V} echo '=-=-=-=-= rpm.mk start of $@ rule =-=-=-=-='
${RM} -f calc.spec
${SED} -e 's/<<<PROJECT_VERSION>>>/'"`./ver_calc`"/g \
calc.spec.in > calc.spec
${V} echo '=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='
.PHONY: srcpkg
srcpkg: make_rhdir
${V} echo '=-=-=-=-= rpm.mk start of $@ rule =-=-=-=-='
${V} echo RPM_TOP="${RPM_TOP}"
${V} echo RPM_BUILD_ROOT="${RPM_BUILD_ROOT}"
${V} echo PROJECT_VERSION="${PROJECT_VERSION}"
${V} echo PROJECT_RELEASE="${PROJECT_RELEASE}"
${RM} -rf "$(TMPDIR)/$(PROJECT)"
${FIND} . -depth -print | \
${EGREP} -v '/RCS|/CVS|/NOTES|/\.|\.out$$|\.safe$$\.tar\.bz2$$' | \
${EGREP} -v '/old[._-]|\.old$$|\.tar\.gz$$|/ver_calc$$' | \
LANG=C ${SORT} | \
${CPIO} -dumpv "$(TMPDIR)/$(PROJECT)"
${RM} -f "$(TMPDIR)/$(PROJECT)/Makefile"
${SED} -e 's/^CCWERR=[ ]*-Werror/CCWERR=/' \
-e 's/^#.*CCWERR=.*-Werror$$/#/' \
-e 's/^CHECK= check/CHECK= true/' \
Makefile > "$(TMPDIR)/$(PROJECT)/Makefile"
${CHMOD} 0444 "$(TMPDIR)/$(PROJECT)/Makefile"
cd "$(TMPDIR)"; ${TAR} cf - "$(PROJECT)" | \
${BZIP2_PROG} --best -c -z > "$(RPM_TOP)/SOURCES/$(TARBALL)"
${V} echo '=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='
.PHONY: rpm
rpm: srcpkg calc.spec
${V} echo '=-=-=-=-= rpm.mk start of $@ rule =-=-=-=-='
${V} echo RPM_TOP="${RPM_TOP}"
${V} echo RPM_BUILD_ROOT="${RPM_BUILD_ROOT}"
${V} echo PROJECT_VERSION="${PROJECT_VERSION}"
${V} echo PROJECT_RELEASE="${PROJECT_RELEASE}"
$(MAKE) -f Makefile clean Q= S= E=
${CP} "$(SPECFILE)" "$(RPM_TOP)/SPECS/$(SPECFILE)"
${RM} -f "$(RPM_TOP)/RPMS/$(TARCH)/$(RPMx86_64)"
${RM} -f "$(RPM_TOP)/RPMS/$(TARCH)/$(DRPMx86_64)"
${RM} -f "$(RPM_TOP)/SRPMS/$(SRPM)"
${RPMBUILD_TOOL} ${RPMBUILD_OPTION} "$(RPM_TOP)/SPECS/$(SPECFILE)"
@if [ ! -f "$(RPM_TOP)/SRPMS/$(SRPM)" ]; then \
echo "SRPMS/$(SRPM) not found" 1>&2; \
exit 3; \
fi
@echo
${V} echo '=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='
.PHONY: make_rhdir
make_rhdir:
${V} echo '=-=-=-=-= rpm.mk start of $@ rule =-=-=-=-='
${V} echo RPM_TOP="${RPM_TOP}"
${V} echo RPM_BUILD_ROOT="${RPM_BUILD_ROOT}"
${V} echo PROJECT_VERSION="${PROJECT_VERSION}"
${V} echo PROJECT_RELEASE="${PROJECT_RELEASE}"
for subdir in "" BUILD RPMS SOURCES SPECS SRPMS tmp; do \
i="$(RPM_TOP)/$$subdir"; \
if [ ! -d "$$i" ] ; then \
${MKDIR} -p "$$i"; \
fi; \
if [ ! -d "$$i" ] ; then \
echo "FATAL: unable to create: $$i" 1>&2; \
exit 4; \
fi; \
if [ ! -w "$$i" ] ; then \
${CHMOD} +w "$$i"; \
fi; \
if [ ! -w "$$i" ] ; then \
echo "FATAL: unable to make writable: $$i" 1>&2; \
exit 5; \
fi; \
done;
${V} echo '=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='
.PHONY: -preclean
rpm-preclean:
${V} echo '=-=-=-=-= ${MAKE_FILE} start of $@ rule =-=-=-=-='
${Q} if [ -n "$(RPM_TOP)" ]; then \
if [ -d "$(RPM_TOP)" ]; then \
echo ${RM} -rf "$(RPM_TOP)"; \
${RM} -rf "$(RPM_TOP)"; \
fi; \
if [ -d "$(RPM_TOP)" ]; then \
echo "FATAL: cannot rm -rf $(RPM_TOP)" 1>&2; \
exit 1; \
fi; \
echo ${MKDIR} -p "$(RPM_TOP)"; \
${MKDIR} -p "$(RPM_TOP)"; \
if [ ! -d "$(RPM_TOP)" ]; then \
echo "FATAL: cannot mkdir -p $(RPM_TOP)" 1>&2; \
exit 1; \
fi; \
else \
echo "FATAL: make symbol RPM_TOP is empty" 1>&2; \
exit 2; \
fi
${V} echo '=-=-=-=-= ${MAKE_FILE} end of $@ rule =-=-=-=-='
# date format for spec file
.PHONY: logdate
logdate:
echo "`date +'* %a %b %d %Y'` `whoami`"
.PHONY: chkpkg
chkpkg:
${V} echo '=-=-=-=-= rpm.mk start of $@ rule =-=-=-=-='
for i in "$(RPM_TOP)/RPMS/$(TARCH)/$(RPMx86_64)" \
"$(RPM_TOP)/RPMS/$(TARCH)/$(DRPMx86_64)" \
"$(RPM_TOP)/SRPMS/$(SRPM)" ; do \
echo "***** start $$i" ; \
${RPM_TOOL} -qpi "$$"i ; \
echo "***** files $$i" ; \
${RPM_TOOL} -qpl "$$i" ; \
echo "***** end $$i" ; \
done ;
${V} echo '=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='
.PHONY: chksys
chksys:
${V} echo '=-=-=-=-= rpm.mk start of $@ rule =-=-=-=-='
${RPM_TOOL} -qa | ${GREP} "$(PROJECT_NAME)"
${RPM_TOOL} -qa | ${GREP} "$(PROJECT_NAME)-devel"
${V} echo '=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='
.PHONY: test
test: ver_calc
${V} echo '=-=-=-=-= rpm.mk start of $@ rule =-=-=-=-='
@if [ X"`id -u`" != X"0" ]; then \
echo "test needs to install, must be root to test" 1>&2; \
exit 6; \
fi
$(MAKE) -f rpm.mk PROJECT_VERSION="`./ver_calc`" installrpm \
chksys Q= S= E=
${V} echo '=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='
.PHONY: installrpm
installrpm:
${V} echo '=-=-=-=-= rpm.mk start of $@ rule =-=-=-=-='
@if [ X"`id -u`" != X"0" ]; then \
echo "must be root to install RPMs" 1>&2; \
exit 7; \
fi
${RPM_TOOL} -ivh "$(RPM_TOP)/RPMS/$(TARCH)/$(RPMx86_64)"
${RPM_TOOL} -ivh "$(RPM_TOP)/RPMS/$(TARCH)/$(DRPMx86_64)"
${V} echo '=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='
.PHONY: uninstallrpm
uninstallrpm:
${V} echo '=-=-=-=-= rpm.mk start of $@ rule =-=-=-=-='
@if [ X"`id -u`" != X"0" ]; then \
echo "must be root to uninstall RPMs" 1>&2; \
exit 8; \
fi
${RPM_TOOL} -e "$(PROJECT_NAME)-devel"
${RPM_TOOL} -e "$(PROJECT_NAME)"
${V} echo '=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='
$(PROJECT_NAME)-spec.${TAR}.bz2: rpm.mk $(PROJECT_NAME).spec.in
${V} echo '=-=-=-=-= rpm.mk start of $@ rule =-=-=-=-='
${RM} -f "$@"
${TAR} cf - "$^" | ${BZIP2_PROG} --best -c -z > "$@"
${V} echo '=-=-=-=-= rpm.mk end of $@ rule =-=-=-=-='
#****