mirror of
https://github.com/lcn2/calc.git
synced 2025-08-19 01:13:27 +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.
496 lines
14 KiB
Makefile
496 lines
14 KiB
Makefile
#!/bin/make
|
|
#
|
|
# custom - makefile for calc custom routines
|
|
#
|
|
# Copyright (C) 1999-2006,2014,2017-2018,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: 1997/03/09 02:28:54
|
|
# File existed as early as: 1997
|
|
#
|
|
# 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
|
|
|
|
|
|
# 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 durings 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.
|
|
#
|
|
CCBAN= -UUNBAN
|
|
#CCBAN= -DUNBAN
|
|
|
|
|
|
#if 0 /* start of skip for non-Gnu makefiles */
|
|
##############################################################################
|
|
#-=-=-=-=-=-=-=-=- Identify the target machine, if possible -=-=-=-=-=-=-=-=-#
|
|
##############################################################################
|
|
|
|
# NOTE: You can force a target value by defining target as in:
|
|
#
|
|
# make ...__optional_arguments_... target=value
|
|
|
|
# Try uname -s if the target was not already set on the make command line
|
|
#
|
|
ifeq ($(target),)
|
|
target=$(shell uname -s 2>/dev/null)
|
|
endif
|
|
#endif /* end of skip for non-Gnu makefiles */
|
|
|
|
##############################################################################
|
|
#-=-=-=-=-=-=-=-=- You may want to change some values below -=-=-=-=-=-=-=-=-#
|
|
##############################################################################
|
|
|
|
# The custom calc resource files to install
|
|
#
|
|
# Put your custom calc resource files here.
|
|
#
|
|
CUSTOM_CALC_FILES= argv.cal halflen.cal pzasusb8.cal pmodm127.cal register.cal
|
|
|
|
# The custom help files to install
|
|
#
|
|
# Put your custom help files here.
|
|
#
|
|
CUSTOM_HELP= argv devnull help sysinfo pzasusb8 pmodm127 register
|
|
|
|
# Any .h files that are needed by programs that use
|
|
# libcustcalc${LIB_EXT_VERSION}
|
|
#
|
|
# Put any .h files that you add which might be useful to other
|
|
# programs here.
|
|
#
|
|
CUSTOM_H_SRC=
|
|
|
|
# Any .c files that are needed to build libcustcalc${LIB_EXT_VERSION}.
|
|
#
|
|
# Don't put ${REQUIRED_SRC} files in this list.
|
|
#
|
|
# There MUST be a .c in CUSTOM_SRC for every .o in CUSTOM_OBJ.
|
|
#
|
|
# Put your custom .c files here.
|
|
#
|
|
CUSTOM_SRC= c_argv.c c_devnull.c c_help.c c_sysinfo.c c_pzasusb8.c \
|
|
c_pmodm127.c c_register.c
|
|
|
|
# Any .o files that are needed by program that use
|
|
# libcustcalc${LIB_EXT_VERSION}.
|
|
#
|
|
# Don't put ${REQUIRED_OBJ} files in this list.
|
|
#
|
|
# There MUST be a .c in CUSTOM_SRC for every .o in CUSTOM_OBJ.
|
|
#
|
|
# Put your custom .o files here.
|
|
#
|
|
CUSTOM_OBJ= c_argv.o c_devnull.o c_help.o c_sysinfo.o c_pzasusb8.o \
|
|
c_pmodm127.o c_register.o
|
|
|
|
##############################################################################
|
|
#-=-=-=-=-=-=- Defaults in case you want to build from this dir -=-=-=-=-=-=-#
|
|
##############################################################################
|
|
|
|
# Normally, the upper level makefile will set these values. We provide
|
|
# a default here just in case you want to build from this directory.
|
|
#
|
|
# Makefile debug
|
|
#
|
|
# Q=@ do not echo internal makefile actions (quiet mode)
|
|
# Q= echo internal makefile actions (debug / verbose mode)
|
|
#
|
|
#Q=
|
|
Q=@
|
|
|
|
####
|
|
# Normally, the upper level makefile will set these values. We provide
|
|
# a default here just in case you want to build from this directory.
|
|
####
|
|
|
|
# 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 related 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
|
|
# ${CUSTOMCALDIR} where custom *.cal files are installed
|
|
# ${CUSTOMHELPDIR} where custom help files are installed
|
|
# ${CUSTOMINCDIR} where custom .h 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
|
|
# CUSTOMCALDIR= ${CALC_SHAREDIR}/custom
|
|
# CUSTOMHELPDIR= ${CALC_SHAREDIR}/custhelp
|
|
# CUSTOMINCDIR= ${CALC_INCDIR}/custom
|
|
# SCRIPTDIR= ${BINDIR}/cscript
|
|
#
|
|
HELPDIR= ${CALC_SHAREDIR}/help
|
|
CALC_INCDIR= ${INCDIR}/calc
|
|
CUSTOMCALDIR= ${CALC_SHAREDIR}/custom
|
|
CUSTOMHELPDIR= ${CALC_SHAREDIR}/custhelp
|
|
CUSTOMINCDIR= ${CALC_INCDIR}/custom
|
|
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=
|
|
|
|
# Debug/Optimize options for ${CC} and ${LCC}
|
|
#
|
|
# Select DEBUG= -O2 -gstabs+ -DWINDOZ for DJGPP.
|
|
#
|
|
#DEBUG=
|
|
#
|
|
#DEBUG= -O
|
|
#DEBUG= -O -g
|
|
#DEBUG= -O -g3
|
|
#
|
|
#DEBUG= -O1
|
|
#DEBUG= -O1 -g
|
|
#DEBUG= -O1 -g3
|
|
#
|
|
#DEBUG= -O2
|
|
#DEBUG= -O2 -g
|
|
#DEBUG= -O2 -g3
|
|
#DEBUG= -O2 -ipa
|
|
#DEBUG= -O2 -g3 -ipa
|
|
#
|
|
#DEBUG= -O3
|
|
#DEBUG= -O3 -g
|
|
DEBUG= -O3 -g3
|
|
#DEBUG= -O3 -ipa
|
|
#DEBUG= -O3 -g3 -ipa
|
|
#
|
|
#DEBUG= -g
|
|
#DEBUG= -g3
|
|
#DEBUG= -gx
|
|
#DEBUG= -WM,-g
|
|
#
|
|
#DEBUG= -O2 -gstabs+ -DWINDOZ
|
|
|
|
# Some systems require one to use ranlib to add a symbol table to
|
|
# a *.a link library. Set RANLIB to the utility that performs this
|
|
# action. Set RANLIB to : if your system does not need such a utility.
|
|
#
|
|
RANLIB=ranlib
|
|
#RANLIB=:
|
|
|
|
# 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
|
|
#MAKE_FILE=
|
|
|
|
# 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
|
|
|
|
# If you do not wish to use purify, set PURIFY to an empty string.
|
|
#
|
|
# If in doubt, use PURIFY=
|
|
#
|
|
#PURIFY= purify
|
|
#PURIFY= purify -m71-engine
|
|
#PURIFY= purify -logfile=pure.out
|
|
#PURIFY= purify -m71-engine -logfile=pure.out
|
|
PURIFY=
|
|
|
|
# If you want to use a debugging link library such as a malloc debug link
|
|
# library, or need to add special ld flags after the calc link libraries
|
|
# are included, set ${LD_DEBUG} below.
|
|
#
|
|
# If in doubt, set LD_DEBUG to empty.
|
|
#
|
|
#LD_DEBUG= -lmalloc_cv
|
|
LD_DEBUG=
|
|
|
|
# When doing a:
|
|
#
|
|
# make check
|
|
# make chk
|
|
# make debug
|
|
#
|
|
# the ${CALC_ENV} is used to supply the proper environment variables
|
|
# to calc. Most people will simply need 'CALCPATH=./cal' to ensure
|
|
# that these debug rules will only use calc resource files under the
|
|
# local source directory. The longer lines (with MALLOC_VERBOSE=1 ...)
|
|
# are useful for SGI IRIX people who have 'WorkShop Performance Tools'
|
|
# and who also set 'LD_DEBUG= -lmalloc_cv' above.
|
|
#
|
|
# If in doubt, use CALC_ENV= CALCPATH=./cal.
|
|
#
|
|
CALC_ENV= CALCPATH=./cal
|
|
#CALC_ENV= CALCPATH=./cal MALLOC_VERBOSE=1 MALLOC_TRACING=1 \
|
|
# MALLOC_FASTCHK=1 MALLOC_FULLWARN=1
|
|
#CALC_ENV= CALCPATH=./cal MALLOC_VERBOSE=1 MALLOC_TRACING=1 \
|
|
# MALLOC_FASTCHK=1 MALLOC_FULLWARN=1 MALLOC_CLEAR_FREE=1 \
|
|
# MALLOC_CLEAR_MALLOC=1
|
|
|
|
# By default, custom builtin functions may only be executed if calc
|
|
# is given the -C option. This is because custom builtin functions
|
|
# may invoke non-standard or non-portable code. One may completely
|
|
# disable custom builtin functions by not compiling any of code
|
|
#
|
|
# ALLOW_CUSTOM= -DCUSTOM # allow custom only if -C is given
|
|
# ALLOW_CUSTOM= # disable custom even if -C is given
|
|
#
|
|
# If in doubt, use ALLOW_CUSTOM= -DCUSTOM
|
|
#
|
|
ALLOW_CUSTOM= -DCUSTOM
|
|
#ALLOW_CUSTOM=
|
|
|
|
# Some out of date operating systems require / want an executable to
|
|
# end with a certain file extension. Some compile systems such as
|
|
# Cygwin build calc as calc.exe. The EXT variable is used to denote
|
|
# the extension required by such.
|
|
#
|
|
# EXT= # normal Un*x / Linux / GNU/Linux systems
|
|
# EXT=.exe # windoz / Cygwin
|
|
#
|
|
# If in doubt, use EXT=
|
|
#
|
|
EXT=
|
|
#EXT=.exe
|
|
|
|
# The default calc versions
|
|
#
|
|
VERSION= 2.12.9.0
|
|
|
|
# Names of shared libraries with versions
|
|
#
|
|
LIB_EXT= .so
|
|
LIB_EXT_VERSION= ${LIB_EXT}.${VERSION}
|
|
|
|
# standard tools
|
|
#
|
|
AR= ar
|
|
AWK= awk
|
|
CHMOD= chmod
|
|
CMP= cmp
|
|
CO= co
|
|
CP= cp
|
|
FMT= fmt
|
|
GREP= egrep
|
|
LN= ln
|
|
MAKE= make
|
|
MAKEDEPEND= makedepend
|
|
MKDIR= mkdir
|
|
MV= mv
|
|
RM= rm
|
|
RMDIR= rmdir
|
|
SED= sed
|
|
SORT= sort
|
|
TOUCH= touch
|
|
TRUE= true
|
|
|
|
# EXTRA_CFLAGS are flags given to ${CC} when compiling C files
|
|
# EXTRA_LDFLAGS are flags given to ${CC} when linking progs
|
|
#
|
|
# Both CFLAGS and LDFLAGS are left blank in this Makefile by
|
|
# default so that users may use them on the make command line
|
|
# to always the way that C is compiled and files are linked
|
|
# respectively. For example:
|
|
#
|
|
# make all EXTRA_CFLAGS="-DMAGIC" EXTRA_LDFLAGS="-lmagic"
|
|
#
|
|
# NOTE: These should be left blank in this Makefile to make it
|
|
# easier to add stuff on the command line. If you want to
|
|
# to change the way calc is compiled by this Makefile, change
|
|
# the appropriate host target section below or a flag above.
|
|
#
|
|
EXTRA_CFLAGS=
|
|
EXTRA_LDFLAGS=
|
|
|
|
# COMMON_CFLAGS are the common ${CC} flags used for all progs, both
|
|
# intermediate and final calc and calc related progs
|
|
#
|
|
COMMON_CFLAGS= -DCALC_SRC ${ALLOW_CUSTOM} ${CCWARN} ${CCMISC} ${EXTRA_CFLAGS}
|
|
|
|
# COMMON_LDFLAGS are the common flags used for linking all progs, both
|
|
# intermediate and final calc and calc related progs
|
|
#
|
|
COMMON_LDFLAGS= ${EXTRA_LDFLAGS}
|
|
|
|
###########################################
|
|
# Set the default compile flags for ${CC} #
|
|
###########################################
|
|
|
|
#if 0 /* start of skip for non-Gnu makefiles */
|
|
|
|
# Required flags to compile C files for calc
|
|
#
|
|
# ICFLAGS are given to ${CC} for intermediate progs used to help compile calc
|
|
# CFLAGS are given to ${CC} for calc progs other than intermediate progs
|
|
#
|
|
# NOTE: This does not work for: make-XYZ-only and BLD_TYPE != make-XYZ-only
|
|
#
|
|
ifeq ($(BLD_TYPE),calc-static-only)
|
|
ICFLAGS= ${COMMON_CFLAGS} ${CCBAN} ${CC_STATIC}
|
|
else
|
|
ICFLAGS= ${COMMON_CFLAGS} ${CCBAN} ${CC_SHARE}
|
|
endif
|
|
CFLAGS= ${ICFLAGS} ${CCOPT}
|
|
|
|
# Required flags to link files for calc
|
|
#
|
|
# ILDFLAGS for ${CC} in linking intermediate progs used to help compile calc
|
|
# LDFLAGS for ${CC} in linking calc progs other than intermediate progs
|
|
#
|
|
ILDFLAGS= ${COMMON_LDFLAGS}
|
|
LDFLAGS= ${LD_DEBUG} ${ILDFLAGS}
|
|
|
|
#endif /* end of skip for non-Gnu makefiles */
|