mirror of
https://github.com/lcn2/calc.git
synced 2025-08-16 01:03:29 +03:00
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.
416 lines
11 KiB
Makefile
416 lines
11 KiB
Makefile
#!/bin/make
|
|
#
|
|
# cal - makefile for calc standard resource files
|
|
#
|
|
# Copyright (C) 1999-2006,2017,2021 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: 1991/07/21 05:00:54
|
|
# File existed as early as: 1991
|
|
#
|
|
# 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 Landon Curt Noll
|
|
|
|
|
|
# The shell used by this Makefile
|
|
#
|
|
# On some systems, /bin/sh is a rather reduced shell with
|
|
# deprecated behavor.
|
|
#
|
|
# If your system has a up to date, bash shell, then
|
|
# you may wish to use:
|
|
#
|
|
# SHELL= /bin/bash
|
|
#
|
|
# On some systems such as macOS, the bash shell is very
|
|
# far behind to the point wehre is cannot be depended on.
|
|
# On such systems, the zsh may be a much better alternative
|
|
# shell for this Makefile to use:
|
|
#
|
|
# SHELL= /bin/zsh
|
|
#
|
|
SHELL= /bin/sh
|
|
#SHELL= /bin/bash
|
|
#SHELL= /bin/zsh
|
|
|
|
|
|
####
|
|
# Normally, the upper level makefile will set these values. We provide
|
|
# a default here just in case you want to build from this directory.
|
|
####
|
|
|
|
# Normally certain files depend on the Makefile. If the Makefile is
|
|
# changed, then certain steps should be redone. If MAKE_FILE is
|
|
# set to Makefile, then these files will depend on Makefile. If
|
|
# MAKE_FILE is empty, then they wont.
|
|
#
|
|
# If in doubt, set MAKE_FILE to Makefile
|
|
#
|
|
MAKE_FILE= Makefile
|
|
|
|
# Controlling file makefile basename (without the path)
|
|
#
|
|
# This is the basename same of the makefile that may/does/will drive
|
|
# this makefile.
|
|
#
|
|
# If in doubt, set TOP_MAKE_FILE to Makefile
|
|
#
|
|
TOP_MAKE_FILE= Makefile
|
|
|
|
# Where the system include (.h) files are kept
|
|
#
|
|
# For DJGPP, select:
|
|
#
|
|
# INCDIR= /dev/env/DJDIR/include
|
|
#
|
|
# If in doubt, set:
|
|
#
|
|
# INCDIR= /usr/include
|
|
#
|
|
|
|
#INCDIR= /usr/local/include
|
|
#INCDIR= /dev/env/DJDIR/include
|
|
INCDIR= /usr/include
|
|
|
|
# where to install calc realted things
|
|
#
|
|
# ${BINDIR} where to install calc binary files
|
|
# ${LIBDIR} where calc link library (*.a) files are installed
|
|
# ${CALC_SHAREDIR} where to install calc help, .cal, startup, config files
|
|
#
|
|
# NOTE: The install rule prepends installation paths with ${T}, which
|
|
# by default is empty. If ${T} is non-empty, then installation
|
|
# locations will be relative to the ${T} directory.
|
|
#
|
|
# For DJGPP, select:
|
|
#
|
|
# BINDIR= /dev/env/DJDIR/bin
|
|
# LIBDIR= /dev/env/DJDIR/lib
|
|
# CALC_SHAREDIR= /dev/env/DJDIR/share/calc
|
|
#
|
|
# If in doubt, set:
|
|
#
|
|
# BINDIR= /usr/bin
|
|
# LIBDIR= /usr/lib
|
|
# CALC_SHAREDIR= /usr/share/calc
|
|
#
|
|
#BINDIR= /usr/local/bin
|
|
#BINDIR= /dev/env/DJDIR/bin
|
|
BINDIR= /usr/bin
|
|
|
|
#LIBDIR= /usr/local/lib
|
|
#LIBDIR= /dev/env/DJDIR/lib
|
|
LIBDIR= /usr/lib
|
|
|
|
#CALC_SHAREDIR= /usr/local/lib/calc
|
|
#CALC_SHAREDIR= /dev/env/DJDIR/share/calc
|
|
CALC_SHAREDIR= /usr/share/calc
|
|
|
|
# By default, these values are based CALC_SHAREDIR, INCDIR, BINDIR
|
|
# ---------------------------------------------------------------
|
|
# ${HELPDIR} where the help directory is installed
|
|
# ${CALC_INCDIR} where the calc include files are installed
|
|
# ${SCRIPTDIR} where calc shell scripts are installed
|
|
#
|
|
# NOTE: The install rule prepends installation paths with ${T}, which
|
|
# by default is empty. If ${T} is non-empty, then installation
|
|
# locations will be relative to the ${T} directory.
|
|
#
|
|
# If in doubt, set:
|
|
#
|
|
# HELPDIR= ${CALC_SHAREDIR}/help
|
|
# CALC_INCDIR= ${INCDIR}/calc
|
|
# SCRIPTDIR= ${BINDIR}/cscript
|
|
#
|
|
HELPDIR= ${CALC_SHAREDIR}/help
|
|
CALC_INCDIR= ${INCDIR}/calc
|
|
SCRIPTDIR= ${BINDIR}/cscript
|
|
|
|
# T - top level directory under which calc will be installed
|
|
#
|
|
# The calc install is performed under ${T}, the calc build is
|
|
# performed under /. The purpose for ${T} is to allow someone
|
|
# to install calc somewhere other than into the system area.
|
|
#
|
|
# For example, if:
|
|
#
|
|
# BINDIR= /usr/bin
|
|
# LIBDIR= /usr/lib
|
|
# CALC_SHAREDIR= /usr/share/calc
|
|
#
|
|
# and if:
|
|
#
|
|
# T= /var/tmp/testing
|
|
#
|
|
# Then the installation locations will be:
|
|
#
|
|
# calc binary files: /var/tmp/testing/usr/bin
|
|
# calc link library: /var/tmp/testing/usr/lib
|
|
# calc help, .cal ...: /var/tmp/testing/usr/share/calc
|
|
# ... etc ... /var/tmp/testing/...
|
|
#
|
|
# If ${T} is empty, calc is installed under /, which is the same
|
|
# top of tree for which it was built. If ${T} is non-empty, then
|
|
# calc is installed under ${T}, as if one had to chroot under
|
|
# ${T} for calc to operate.
|
|
#
|
|
# If in doubt, use T=
|
|
#
|
|
T=
|
|
|
|
# Makefile debug
|
|
#
|
|
# Q=@ do not echo internal makefile actions (quiet mode)
|
|
# Q= echo internal makefile actions (debug / verbose mode)
|
|
#
|
|
#Q=
|
|
Q=@
|
|
|
|
# standard tools
|
|
#
|
|
CHMOD= chmod
|
|
CMP= cmp
|
|
CO= co
|
|
CP= cp
|
|
FMT= fmt
|
|
MKDIR= mkdir
|
|
MV= mv
|
|
RM= rm
|
|
RMDIR= rmdir
|
|
SED= sed
|
|
SORT= sort
|
|
TOUCH= touch
|
|
TRUE= true
|
|
|
|
# The calc files to install
|
|
#
|
|
# This list is produced by the detaillist rule when no WARNINGS are detected.
|
|
#
|
|
# Please use:
|
|
#
|
|
# make calc_files_list
|
|
#
|
|
# to keep this list in nice sorted order.
|
|
#
|
|
CALC_FILES= README alg_config.cal beer.cal bernoulli.cal \
|
|
bernpoly.cal bigprime.cal bindings brentsolve.cal chi.cal chrem.cal \
|
|
constants.cal deg.cal dms.cal dotest.cal ellip.cal factorial.cal \
|
|
factorial2.cal gvec.cal hello.cal hms.cal infinities.cal intfile.cal \
|
|
intnum.cal lambertw.cal linear.cal lnseries.cal lucas.cal \
|
|
lucas_chk.cal mersenne.cal mfactor.cal mod.cal natnumset.cal pell.cal \
|
|
pi.cal pix.cal pollard.cal poly.cal prompt.cal psqrt.cal qtime.cal \
|
|
quat.cal randbitrun.cal randmprime.cal randombitrun.cal randomrun.cal \
|
|
randrun.cal regress.cal repeat.cal screen.cal seedrandom.cal \
|
|
set8700.cal set8700.line smallfactors.cal solve.cal \
|
|
specialfunctions.cal statistics.cal strings.cal sumsq.cal sumtimes.cal \
|
|
surd.cal test1700.cal test2300.cal test2600.cal test2700.cal \
|
|
test3100.cal test3300.cal test3400.cal test3500.cal test4000.cal \
|
|
test4100.cal test4600.cal test5100.cal test5200.cal test8400.cal \
|
|
test8500.cal test8600.cal test8900.cal toomcook.cal unitfrac.cal \
|
|
varargs.cal xx_print.cal zeta2.cal
|
|
|
|
# These calc files are now obsolete and are removed by the install rule.
|
|
#
|
|
DEAD_CALC_FILES= lucas_tbl.cal
|
|
|
|
# These files are found (but not built) in the distribution
|
|
#
|
|
DISTLIST= ${CALC_FILES} ${MAKE_FILE}
|
|
|
|
# These files are used to make (but not built) a calc .a link library
|
|
#
|
|
CALCLIBLIST=
|
|
|
|
all: ${CALC_FILES} ${MAKE_FILE} .all
|
|
|
|
# used by the upper level Makefile to determine of we have done all
|
|
#
|
|
.all:
|
|
${RM} -f .all
|
|
${TOUCH} .all
|
|
|
|
##
|
|
#
|
|
# File list generation. You can ignore this section.
|
|
#
|
|
#
|
|
# We will form the names of source files as if they were in a
|
|
# sub-directory called calc/cal.
|
|
#
|
|
# NOTE: Due to bogus shells found on one common system we must have
|
|
# an non-empty else clause for every if condition. *sigh*
|
|
#
|
|
##
|
|
|
|
distlist: ${DISTLIST}
|
|
${Q} for i in ${DISTLIST} /dev/null; do \
|
|
if [ X"$$i" != X"/dev/null" ]; then \
|
|
echo cal/$$i; \
|
|
fi; \
|
|
done
|
|
|
|
distdir:
|
|
${Q} echo cal
|
|
|
|
calcliblist:
|
|
${Q} for i in ${CALCLIBLIST} /dev/null; do \
|
|
if [ X"$$i" != X"/dev/null" ]; then \
|
|
echo cal/$$i; \
|
|
fi; \
|
|
done
|
|
|
|
# These next rule help form the ${CALC_FILES} makefile variables above.
|
|
#
|
|
calc_files_list:
|
|
${Q} -(find . -mindepth 1 -maxdepth 1 -type f -name '*.cal' -print | \
|
|
while read i; do \
|
|
echo $$i; \
|
|
done; \
|
|
echo '--first_line--'; \
|
|
echo README; \
|
|
echo set8700.line; \
|
|
echo bindings) | \
|
|
${SED} -e 's:^\./::' | LANG=C ${SORT} | ${FMT} -70 | \
|
|
${SED} -e '1s/--first_line--/CALC_FILES=/' -e '2,$$s/^/ /' \
|
|
-e 's/$$/ \\/' -e '$$s/ \\$$//'
|
|
|
|
##
|
|
#
|
|
# rpm rules
|
|
#
|
|
##
|
|
|
|
echo_inst_files:
|
|
${Q} for i in ${CALC_FILES} /dev/null; do \
|
|
if [ X"$$i" != X"/dev/null" ]; then \
|
|
echo __file__ ${CALC_SHAREDIR}/$$i; \
|
|
fi; \
|
|
done
|
|
|
|
##
|
|
#
|
|
# Utility rules
|
|
#
|
|
##
|
|
|
|
clean:
|
|
|
|
clobber: clean
|
|
${RM} -f .all
|
|
-${Q} if [ -e .DS_Store ]; then \
|
|
echo ${RM} -rf .DS_Store; \
|
|
${RM} -rf .DS_Store; \
|
|
fi
|
|
-${Q} for i in ${DEAD_CALC_FILES} /dev/null; do \
|
|
if [ "$$i" = "/dev/null" ]; then \
|
|
continue; \
|
|
fi; \
|
|
if [ -e "${T}${CALC_SHAREDIR}/$$i" ]; then \
|
|
echo "${RM} -f ${T}${CALC_SHAREDIR}/$$i"; \
|
|
${RM} -f ${T}${CALC_SHAREDIR}/$$i; \
|
|
fi; \
|
|
if [ -e "./$$i" ]; then \
|
|
echo "${RM} -f ./$$i"; \
|
|
${RM} -f ./$$i; \
|
|
fi; \
|
|
done
|
|
|
|
# install everything
|
|
#
|
|
# NOTE: Keep the uninstall rule in reverse order to the install rule
|
|
#
|
|
install: all
|
|
-${Q} if [ ! -d ${T}${CALC_SHAREDIR} ]; then \
|
|
echo ${MKDIR} -p ${T}${CALC_SHAREDIR}; \
|
|
${MKDIR} -p ${T}${CALC_SHAREDIR}; \
|
|
if [ ! -d "${T}${CALC_SHAREDIR}" ]; then \
|
|
echo ${MKDIR} -p "${T}${CALC_SHAREDIR}"; \
|
|
${MKDIR} -p "${T}${CALC_SHAREDIR}"; \
|
|
fi; \
|
|
echo ${CHMOD} 0755 ${T}${CALC_SHAREDIR}; \
|
|
${CHMOD} 0755 ${T}${CALC_SHAREDIR}; \
|
|
else \
|
|
${TRUE}; \
|
|
fi
|
|
${Q} for i in ${CALC_FILES} /dev/null; do \
|
|
if [ "$$i" = "/dev/null" ]; then \
|
|
continue; \
|
|
fi; \
|
|
if ${CMP} -s $$i ${T}${CALC_SHAREDIR}/$$i; then \
|
|
${TRUE}; \
|
|
else \
|
|
${RM} -f ${T}${CALC_SHAREDIR}/$$i.new; \
|
|
${CP} -f $$i ${T}${CALC_SHAREDIR}/$$i.new; \
|
|
${CHMOD} 0444 ${T}${CALC_SHAREDIR}/$$i.new; \
|
|
${MV} -f ${T}${CALC_SHAREDIR}/$$i.new ${T}${CALC_SHAREDIR}/$$i;\
|
|
echo "installed ${T}${CALC_SHAREDIR}/$$i"; \
|
|
fi; \
|
|
done
|
|
${Q} for i in ${DEAD_CALC_FILES} /dev/null; do \
|
|
if [ "$$i" = "/dev/null" ]; then \
|
|
continue; \
|
|
fi; \
|
|
if [ -e "${T}${CALC_SHAREDIR}/$$i" ]; then \
|
|
echo "${RM} -f ${T}${CALC_SHAREDIR}/$$i"; \
|
|
${RM} -f ${T}${CALC_SHAREDIR}/$$i; \
|
|
fi; \
|
|
if [ -e "./$$i" ]; then \
|
|
echo "${RM} -f ./$$i"; \
|
|
${RM} -f ./$$i; \
|
|
fi; \
|
|
done
|
|
|
|
# Try to remove everything that was installed
|
|
#
|
|
# NOTE: Keep the uninstall rule in reverse order to the install rule
|
|
#
|
|
uninstall:
|
|
- ${Q} for i in ${DEAD_CALC_FILES} /dev/null; do \
|
|
if [ "$$i" = "/dev/null" ]; then \
|
|
continue; \
|
|
fi; \
|
|
if [ -e "${T}${CALC_SHAREDIR}/$$i" ]; then \
|
|
echo "${RM} -f ${T}${CALC_SHAREDIR}/$$i"; \
|
|
${RM} -f ${T}${CALC_SHAREDIR}/$$i; \
|
|
fi; \
|
|
if [ -e "./$$i" ]; then \
|
|
echo "${RM} -f ./$$i"; \
|
|
${RM} -f ./$$i; \
|
|
fi; \
|
|
done
|
|
-${Q} for i in ${CALC_FILES} /dev/null; do \
|
|
if [ "$$i" = "/dev/null" ]; then \
|
|
continue; \
|
|
fi; \
|
|
if [ -f "${T}${CALC_SHAREDIR}/$$i" ]; then \
|
|
${RM} -f "${T}${CALC_SHAREDIR}/$$i"; \
|
|
if [ -f "${T}${CALC_SHAREDIR}/$$i" ]; then \
|
|
echo "cannot uninstall ${T}${CALC_SHAREDIR}/$$i"; \
|
|
else \
|
|
echo "un-installed ${T}${CALC_SHAREDIR}/$$i"; \
|
|
fi; \
|
|
fi; \
|
|
done
|
|
-${Q} for i in ${CALC_SHAREDIR}; do \
|
|
if [ -d "${T}$$i" ]; then \
|
|
${RMDIR} "${T}$$i" 2>/dev/null; \
|
|
echo "cleaned up ${T}$$i"; \
|
|
fi; \
|
|
done
|