#!/bin/make
#
# (Gerneric calc makefile)
#
# Copyright (c) 1995 David I. Bell and Landon Curt Noll
# Permission is granted to use, distribute, or modify this source,
# provided that this copyright notice remains intact.
#
# Arbitrary precision calculator.
#
# calculator by David I. Bell with help/mods from others
# Makefile by Landon Curt Noll

##############################################################################
#-=-=-=-=-=-=-=-=- You may want to change some values below -=-=-=-=-=-=-=-=-#
##############################################################################

# Determine the type of terminal controls that you want to use
#
#	VARARG value	  meaning
#	------------	  -------
#	(nothing)	  let the makefile guess at what you need
#	-DUSE_TERMIOS	  use struct termios from <termios.h>
#	-DUSE_TERMIO 	  use struct termios from <termio.h>
#	-DUSE_SGTTY    	  use struct sgttyb from <sys/ioctl.h>
#
# If in doubt, leave TERMCONTROL empty.
#
TERMCONTROL=
#TERMCONTROL= -DUSE_TERMIOS
#TERMCONTROL= -DUSE_TERMIO
#TERMCONTROL= -DUSE_SGTTY

# Determine the type of varargs that you want to use
#
#	VARARG value	  meaning
#	------------	  -------
#	(nothing)	  let the makefile guess at what you need
#	STDARG	    	  you have ANSI C and /usr/include/stdarg.h
#	VARARGS	    	  you have /usr/include/varargs.h
#	SIMULATE_STDARG   use simulated ./std_arg.h
#
# If in doubt, leave VARARG empty.
#
VARARG=
#VARARG= STDARG
#VARARG= VARARGS
#VARARG= SIMULATE_STDARG

# If your system does not have a vsprintf() function, you could be in trouble.
#
#	vsprintf(stream, format, ap)
#
# This function works like sprintf except that the 3rd arg is a va_list
# strarg (or varargs) list.  Some old systems do not have vsprintf().
# If you do not have vsprintf(), then calc will try sprintf() and hope
# for the best.
#
# If HAVE_VSPRINTF is empty, this makefile will run the have_vs program
# to determine if vsprintf() is supported.  If HAVE_VSPRINTF is set
# to -DDONT_HAVE_VSPRINTF then calc will hope that sprintf() will work.
#
# If in doubt, leave HAVE_VSPRINTF empty.
#
HAVE_VSPRINTF=
#HAVE_VSPRINTF= -DDONT_HAVE_VSPRINTF

# Determine the byte order of your machine
#
#    Big Endian:	Amdahl, 68k, Pyramid, Mips, Sparc, ...
#    Little Endian:	Vax, 32k, Spim (Dec Mips), i386, i486, ...
#
# If in doubt, leave BYTE_ORDER empty.  This makefile will attempt to
# use BYTE_ORDER in <machine/endian.h> or it will attempt to run
# the endian program.  If you get syntax errors when you compile,
# try forcing the value to be BIG_ENDIAN and run the calc regression
# tests. (see the README file)  If the calc regression tests fail, do
# a make clobber and try LITTLE_ENDIAN.  If that fails, ask a wizard
# for help.
#
BYTE_ORDER=
#BYTE_ORDER= BIG_ENDIAN
#BYTE_ORDER= LITTLE_ENDIAN

# Determine the number of bits in a long
#
# If in doubt, leave LONG_BITS empty.  This makefile will run
# the longbits program to determine the length.
#
LONG_BITS=
#LONG_BITS= 32
#LONG_BITS= 64

# Determine if your compiler supports the long long type and if so, its length
#
# If LONGLONG_BITS is set to nothing, the Makefile will run the longlong
# program to determine if it supports them and if so, their length.
# To disable the use of long longs, set LONGLONG_BITS to 0.
# One may hard code the length of a long long by setting LONGLONG_BITS
# to a non-zero value.
#
# On some machines, using long longs will make the cpu intensive
# jobs run faster.  On others, using long longs make things slower.
# On some systems, the regression test runs slower while cpu bound
# jobs run faster.  On others, the reverse is true.
#
# If in doubt, set LONGLONG_BITS to 0.
#
LONGLONG_BITS= 0
#LONGLONG_BITS=
#LONGLONG_BITS= 64

# Determine if we have the ANSI C fgetpos and fsetpos alternate interface
# to the ftell() and fseek() (with whence set to SEEK_SET) functions.
#
# If HAVE_FPOS is empty, this makefile will run the have_fpos program
# to determine if there is are fgetpos and fsetpos functions.  If HAVE_FPOS
# is set to -DHAVE_NO_FPOS, then calc will use ftell() and fseek().
#
# If in doubt, leave HAVE_FPOS empty.
#
HAVE_FPOS=
#HAVE_FPOS= -DHAVE_NO_FPOS

# Determine if we have ANSI C const.
#
# If HAVE_CONST is empty, this makefile will run the have_const program
# to determine if const is supported.  If HAVE_CONST is set to -DHAVE_NO_CONST,
# then calc will not use const.
#
# If in doubt, leave HAVE_CONST empty.
#
HAVE_CONST=
#HAVE_CONST= -DHAVE_NO_CONST

# Determine if we have uid_t
#
# If HAVE_UID_T is empty, this makefile will run the have_uid_t program
# to determine if const is supported.  If HAVE_UID_T is set to -DHAVE_NO_UID_T,
# then calc will treat uid_t as an unsigned short.  This only matters if
# $HOME is not set and calc must look up the home directory in /etc/passwd.
#
# If in doubt, leave HAVE_UID_T empty.
#
HAVE_UID_T=
#HAVE_UID_T= -DHAVE_NO_UID_T

# Determine if we have memcpy(), memset() and strchr()
#
# If HAVE_NEWSTR is empty, this makefile will run the have_newstr program
# to determine if memcpy(), memset() and strchr() are supported.  If
# HAVE_NEWSTR is set to -DHAVE_NO_NEWSTR, then calc will use bcopy() instead
# of memcpy(), use bfill() instead of memset(), and use index() instead of
# strchr().
#
# If in doubt, leave HAVE_NEWSTR empty.
#
HAVE_NEWSTR=
#HAVE_NEWSTR= -DHAVE_NO_NEWSTR

# where to install binary files
#
BINDIR= /usr/local/bin
#BINDIR= /usr/bin
#BINDIR= /usr/contrib/bin

# where to install the *.cal, *.h and *.a files
#
# ${TOPDIR} is the directory under which the calc directory will be placed.
# ${LIBDIR} is where the *.cal, *.h, *.a, bindings and help dir are installed.
# ${HELPDIR} is where the help directory is installed.
#
TOPDIR= /usr/local/lib
#TOPDIR= /usr/lib
#TOPDIR= /usr/libdata
#TOPDIR= /usr/contrib/lib
#
LIBDIR= ${TOPDIR}/calc
HELPDIR= ${LIBDIR}/help

# where man pages are installed
#
# Use MANDIR= to disable installation of the calc man (source) page.
#
MANDIR=
#MANDIR=/usr/local/man/man1
#MANDIR=/usr/man/man1
#MANDIR=/usr/share/man/man1
#MANDIR=/usr/man/u_man/man1
#MANDIR=/usr/contrib/man/man1

# where cat (formatted man) pages are installed
#
# Use CATDIR= to disable installation of the calc cat (formatted) page.
#
CATDIR=
#CATDIR=/usr/local/man/cat1
#CATDIR=/usr/local/catman/cat1
#CATDIR=/usr/man/cat1
#CATDIR=/usr/share/man/cat1
#CATDIR=/usr/man/u_man/cat1
#CATDIR=/usr/contrib/man/cat1

# extenstion to add on to the calc man page filename
#
# This is ignored if CATDIR is empty.
#
MANEXT= 1
#MANEXT= l

# extenstion to add on to the calc man page filename
#
# This is ignored if CATDIR is empty.
#
CATEXT= 1
#CATEXT= 0
#CATEXT= l

# how to format a man page
#
# If CATDIR is non-empty, then
#     If NROFF is non-empty, then
#	  ${NROFF} ${NROFF_ARG} calc.1 > ${CATDIR}/calc.${CATEXT}
#	  is used to built and install the cat page
#     else (NROFF is empty)
#	  ${MANMAKE} calc.1 ${CATDIR}
#	  is used to built and install the cat page
# else
#     The cat page is not built or installed
#
# If in doubt and you don't want to fool with man pages, set MANDIR
# and CATDIR to empty and ignore the lines below.
#
NROFF= nroff
#NROFF=
#NROFF= groff
NROFF_ARG = -man
#NROFF_ARG = -mandoc
MANMAKE= /usr/local/bin/manmake
#MANMAKE= manmake

# If the $CALCPATH environment variable is not defined, then the following
# path will be search for calc lib routines.
#
CALCPATH= .:./lib:~/lib:${LIBDIR}

# If the $CALCRC environment variable is not defined, then the following
# path will be search for calc lib routines.
#
CALCRC= ${LIBDIR}/startup:~/.calcrc

# If the $CALCBINDINGS environment variable is not defined, then the following
# file will be used for the command line and edit history key bindings.
#
#CALCBINDINGS= ${LIBDIR}/bindings
CALCBINDINGS= ${LIBDIR}/altbind

# If $PAGER is not set, use this program to display a help file
#
CALCPAGER= more
#CALCPAGER= pg
#CALCPAGER= cat
#CALCPAGER= less

# Compile/Debug options for ${CC} and ${LD}
#
DEBUG= -O
#DEBUG= -O2
#DEBUG= -O3
#DEBUG= -g
#DEBUG= -g -O
#DEBUG= -g -O2
#DEBUG= -g3 -O2
#DEBUG= -g -O3
#DEBUG= -gx
#DEBUG= -WM,-g
#DEBUG=

# On systems that have dynamic shared libs, you want want to disable them
# for faster calc startup.
#
NO_SHARED=
#NO_SHARED= -dn
#NO_SHARED= -non_shared

# Some systems require one to use ranlib to add a symbol table to
# a *.a 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=:

# Some systems are able to form lint libs.  How it is formed depends
# on your system.  If you do not care about lint, use : as the
# LINTLIB value.
#
#    System type    LINTLIB recomendation
#
#	BSD	    ${LINT} ${LCFLAGS} ${LINTFLAGS} -u -Ccalc
#	SYSV	    ${LINT} ${LCFLAGS} ${LINTFLAGS} -u -o calc
#	disable     :
#
# If in doubt and you don't care about lint, use LINTLIB= :
#
#LINTLIB= ${LINT} ${LCFLAGS} ${LINTFLAGS} -u -Ccalc
#LINTLIB= ${LINT} ${LCFLAGS} ${LINTFLAGS} -u -o calc
LINTLIB= :

# The lint flags vary from system to system.  Some systems have the
# opposite meaning for the flags below.  Other systems change flag
# meaning altogether.
#
#       System    LINTFLAGS recomendation
#
#	SunOs	  -a -h -v -z
#
# If in doubt and you don't care about lint, set LINTFLAGS to empty.
#
#LINTFLAGS= -a -h -v -z
LINTFLAGS=

# 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, they they wont.
#
# If in doubt, set MAKE_FILE to Makefile
#
MAKE_FILE= Makefile
#MAKE_FILE=

# If you do not wish to use purify, leave PURIFY commented out.
#
# If in doubt, leave PURIFY commented out.
#
#PURIFY= /u2/purify/purify -logfile=pure.out
#PURIFY= /u2/purify/purify

###
#
# Select your compiler type by commenting out one of the cc sets below:
#
# LCFLAGS are flags that both ${CC} and ${LINT} can use
# LDFLAGS are flags that both ${CC} amd ${LD} can use
# CCMAIN are flags for ${CC} when compiling only files with main()
# CCOPT are flags for ${CC} only
# CFLAGS are flags given to ${CC}
# ICFLAGS are given to ${CC} for intermediate progs
# ILDFLAGS are flags given to ${CC} and ${LD} for intermediate progs
#
###
#
# common cc set
#
LCFLAGS= ${MALLOC}
LDFLAGS= ${DEBUG} ${NO_SHARED}
CCMAIN=
CCOPT=
CFLAGS= ${LDFLAGS} ${CCOPT} ${LCFLAGS}
ICFLAGS= ${CFLAGS}
ILDFLAGS= ${LDFLAGS}
CC= ${PURIFY} cc
#
###
#
# SGI IRIX / Mips processors cc set
#
# for better performance, set the following above:
#	DEBUG= -O2
#	If you have the directory /usr/lib/nonshared, then
#		NO_SHARED= -non_shared
# also set above:
#	RANLIB=:
#
#LCFLAGS= ${MALLOC}
#LDFLAGS= ${DEBUG} ${NO_SHARED}
#CCMAIN=
#CCOPT=
#CFLAGS= ${LDFLAGS} ${CCOPT} ${LCFLAGS}
#ICFLAGS=
#ILDFLAGS=
#CC= ${PURIFY} cc
#
###
#
# RS6000 set
#
#LCFLAGS= ${MALLOC}
#LDFLAGS= ${DEBUG} ${NO_SHARED}
#CCMAIN=
#CCOPT=
#CFLAGS= ${LDFLAGS} ${CCOPT} ${LCFLAGS} -qlanglvl=ansi
#ICFLAGS= ${CFLAGS}
#ILDFLAGS= ${LDFLAGS}
#CC= ${PURIFY} cc
#
###
#
# gcc set
#
# for better performance, set the following above:
#     DEBUG= -O above
#
#LCFLAGS= ${MALLOC}
#LDFLAGS= ${DEBUG} ${NO_SHARED}
#CCMAIN=
#CCOPT= -Wall
#CFLAGS= ${LDFLAGS} ${CCOPT} ${LCFLAGS} -ansi
#ICFLAGS= ${CFLAGS}
#ILDFLAGS= ${LDFLAGS}
#CC= ${PURIFY} gcc
#
###
#
# gcc1 set
#
# for better performance, set the following above:
#     DEBUG= -O
#
#LCFLAGS= ${MALLOC}
#LDFLAGS= ${DEBUG} ${NO_SHARED}
#CCMAIN=
#CCOPT= -Wall
#CFLAGS= ${LDFLAGS} ${CCOPT} ${LCFLAGS} -ansi
#ICFLAGS= ${CFLAGS}
#ILDFLAGS= ${LDFLAGS}
#CC= ${PURIFY} gcc1
#
###
#
# gcc2 set
#
# for better performance, set the following above:
#     DEBUG= -O2
#
#LCFLAGS= ${MALLOC}
#LDFLAGS= ${DEBUG} ${NO_SHARED}
#CCMAIN= -Wno-return-type
#CCOPT= -Wall -Wno-implicit -Wno-comment
#CFLAGS= ${LDFLAGS} ${CCOPT} ${LCFLAGS} -ansi
#ICFLAGS= ${CFLAGS}
#ILDFLAGS= ${LDFLAGS}
#CC= ${PURIFY} gcc2
#CC= ${PURIFY} gcc

##############################################################################
#-=-=-=-=-=-=-=-=- Be careful if you change something below -=-=-=-=-=-=-=-=-#
##############################################################################

# standard utilities used during make
#
SHELL= /bin/sh
MAKE= make
SED= sed
SORT= sort
TEE= tee
LINT= lint
CTAGS= ctags
LD= ${CC}
# assume the X11 makedepend tool for the depend rule
MAKEDEPEND= makedepend

#
# the source files which are built into a math library
#
# There MUST be a .o for every .c in LIBOBJS.
#
LIBSRC = comfunc.c commath.c jump.c math_error.c pix.c prime.c \
	qfunc.c qio.c qmath.c qmod.c qtrans.c zfunc.c zio.c zmath.c zmod.c \
	zmul.c zprime.c zrand.c

#
# the object files which are built into a math library
#
# There MUST be a .o for every .c in LIBSRC.
#
LIBOBJS = comfunc.o commath.o jump.o math_error.o pix.o prime.o \
	qfunc.o qio.o qmath.o qmod.o qtrans.o zfunc.o zio.o zmath.o zmod.o \
	zmul.o zprime.o zrand.o

#
# the calculator source files
#
# There MUST be a .c for every .o in CALCOBJS.
#
CALCSRC = addop.c assocfunc.c calc.c codegen.c config.c const.c file.c \
	fnvhash.c func.c hist.c input.c label.c listfunc.c matfunc.c obj.c \
	opcodes.c string.c symbol.c token.c value.c version.c

#
# we build these .o files for calc
#
# There MUST be a .o for every .c in CALCSRC.
#
CALCOBJS = addop.o assocfunc.o calc.o codegen.o config.o const.o file.o \
	fnvhash.o func.o hist.o input.o label.o listfunc.o matfunc.o obj.o \
	opcodes.o string.o symbol.o token.o value.o version.o

# we build these .h files during the make
#
BUILD_H_SRC= args.h config.h endian_calc.h have_malloc.h have_stdlib.h \
	have_string.h longbits.h terminal.h longlong.h have_fpos.h fposval.h \
	have_const.h have_uid_t.h have_newstr.h have_vs.h

# these .c files may be used in the process of building BUILD_H_SRC
#
# There MUST be a .c for every .o in UTIL_OBJS.
#
UTIL_C_SRC= endian.c longbits.c have_vs.c have_newstr.c have_uid_t.c \
	have_const.c fposval.c have_fpos.c longlong.c try_stdarg.c

# these .o files may get built in the process of building BUILD_H_SRC
#
# There MUST be a .o for every .c in UTIL_C_SRC.
#
UTIL_OBJS= endian.o longbits.o have_vs.o have_newstr.o have_uid_t.o \
	have_const.o fposval.o have_fpos.o longlong.o try_strarg.o

# these temp files may be created  (and removed) during the build of BUILD_C_SRC
#
UTIL_TMP= ll_tmp fpos_tmp fposv_tmp const_tmp uid_tmp newstr_tmp vs_tmp

# these utility progs may be used in the process of building BUILD_H_SRC
#
UTIL_PROGS= try_stdarg fposval have_uid_t longlong have_const \
	endian longbits have_newstr have_vs

# these .h files are needed by programs that use libcalc.a
#
LIB_H_SRC= ${BUILD_H_SRC} alloc.h cmath.h jump.h prime.h qmath.h std_arg.h \
	zmath.h qmath.h zmath.h zrand.h

# these .h files are neither built, nor required by libcalc.a
#
CALC_H_SRC= calc.h config.h func.h hist.h label.h opcodes.h std_arg.h \
	string.h symbol.h terminal.h token.h value.h

# complete list of .h files
#
H_SRC = ${CALC_H_SRC} ${LIB_H_SRC}

# complete list of .c files
#
C_SRC = ${LIBSRC} ${CALCSRC} ${UTIL_C_SRC}

# complete list of .o files
#
OBJS= ${LIBOBJS} ${CALCOBJS} ${UTIL_OBJS}

# complete list of progs built
#
PROGS= calc ${UTIL_PROGS}

# complete list of targets
#
TARGETS= calc calc.1 lib/.all help/.all

###
#
# The reason for this Makefile  :-)
#
###

all: ${TARGETS}

calc: libcalc.a ${CALCOBJS}
	${LD} ${LDFLAGS} ${CALCOBJS} libcalc.a -o calc

libcalc.a: ${LIBOBJS} ${MAKE_FILE}
	rm -f libcalc.a
	ar qc libcalc.a ${LIBOBJS}
	${RANLIB} libcalc.a

calc.1: calc.man ${MAKE_FILE}
	rm -f calc.1
	${SED} -e 's:$${LIBDIR}:${LIBDIR}:g' < calc.man > calc.1

##
#
# Special .o files
#
##

calc.o: calc.c ${MAKE_FILE}
	${CC} ${CFLAGS} ${CCMAIN} -c calc.c

hist.o: hist.c ${MAKE_FILE}
	${CC} ${CFLAGS} ${TERMCONTROL} -c hist.c

##
#
# Doing a make check will cause the regression test suite to be executed.
# This rule will try to build anything that needs to be built as well.
#
##

check: all ./lib/regress.cal ./lib/lucas.cal ./lib/lucas_chk.cal \
	./lib/test1700.cal ./lib/surd.cal
	CALCPATH="./lib" ./calc -q read regress
##
#
# The next set of rules cause the .h files BUILD_H_SRC files to be built
# according tot he system and the Makefile variables above.  The hsrc rule
# is a conveient rule to invoke to built all of the BUILD_H_SRC.
#
##

hsrc: ${BUILD_H_SRC}

config.h: ${MAKE_FILE}
	@rm -f config.h
	@echo 'forming config.h'
	@echo '/*' > config.h
	@echo ' * DO NOT EDIT -- generated by the Makefile' >> config.h
	@echo ' */' >> config.h
	@echo '' >> config.h
	@echo '#if !defined(_CONFIG_H_)' >> config.h
	@echo '#define _CONFIG_H_' >> config.h
	@echo '' >> config.h
	@echo '/* the default :-separated search path */' >> config.h
	@echo '#ifndef DEFAULTCALCPATH' >> config.h
	@echo '#define DEFAULTCALCPATH "${CALCPATH}"' >> config.h
	@echo '#endif /* DEFAULTCALCPATH */' >> config.h
	@echo '' >> config.h
	@echo '/* the default :-separated startup file list */' >> config.h
	@echo '#ifndef DEFAULTCALCRC' >> config.h
	@echo '#define DEFAULTCALCRC "${CALCRC}"' >> config.h
	@echo '#endif /* DEFAULTCALCRC */' >> config.h
	@echo '' >> config.h
	@echo '/* the default key bindings file */' >> config.h
	@echo '#ifndef DEFAULTCALCBINDINGS' >> config.h
	@echo '#define DEFAULTCALCBINDINGS "${CALCBINDINGS}"' >> config.h
	@echo '#endif /* DEFAULTCALCBINDINGS */' >> config.h
	@echo '' >> config.h
	@echo '/* the location of the help directory */' >> config.h
	@echo '#ifndef HELPDIR' >> config.h
	@echo '#define HELPDIR "${HELPDIR}"' >> config.h
	@echo '#endif /* HELPDIR */' >> config.h
	@echo '' >> config.h
	@echo '/* the default pager to use */' >> config.h
	@echo '#ifndef DEFAULTCALCPAGER' >> config.h
	@echo '#define DEFAULTCALCPAGER "${CALCPAGER}"' >> config.h
	@echo '#endif /* DEFAULTCALCPAGER */' >> config.h
	@echo '' >> config.h
	@echo '#endif /* _CONFIG_H_ */' >> config.h
	@echo 'config.h formed'

endian_calc.h: endian ${MAKE_FILE}
	@rm -f endian_calc.h
	@echo 'forming endian_calc.h'
	@echo '/*' > endian_calc.h
	@echo ' * DO NOT EDIT -- generated by the Makefile' >> endian_calc.h
	@echo ' */' >> endian_calc.h
	@echo '' >> endian_calc.h
	@echo '#if !defined(_ENDIAN_CALC_H_)' >> endian_calc.h
	@echo '#define _ENDIAN_CALC_H_' >> endian_calc.h
	@echo '' >> endian_calc.h
	@echo '/* what byte order are we? */' >> endian_calc.h
	-@if [ X"${BYTE_ORDER}" = X ]; then \
		if [ -f /usr/include/machine/endian.h ]; then \
			echo '#include <machine/endian.h>' >> endian_calc.h; \
		else \
			./endian >> endian_calc.h; \
		fi; \
	else \
	    echo "#define BYTE_ORDER ${BYTE_ORDER}" >> endian_calc.h; \
	fi
	@echo '' >> endian_calc.h
	@echo '#endif /* _ENDIAN_CALC_H_ */' >> endian_calc.h
	@echo 'endian_calc.h formed'

longbits.h: longbits ${MAKE_FILE}
	@rm -f longbits.h
	@echo 'forming longbits.h'
	@echo '/*' > longbits.h
	@echo ' * DO NOT EDIT -- generated by the Makefile' >> longbits.h
	@echo ' */' >> longbits.h
	@echo '' >> longbits.h
	@echo '#if !defined(_LONGBITS_H_)' >> longbits.h
	@echo '#define _LONGBITS_H_' >> longbits.h
	@echo '' >> longbits.h
	-@if [ X"${LONG_BITS}" = X ]; then \
		./longbits >> longbits.h; \
	else \
		echo "#define LONG_BITS ${LONG_BITS}" >> longbits.h; \
	fi
	@echo '' >> longbits.h
	@echo '#endif /* _LONGBITS_H_ */' >> longbits.h
	@echo 'longbits.h formed'

have_malloc.h: ${MAKE_FILE}
	@rm -f have_malloc.h
	@echo 'forming have_malloc.h'
	@echo '/*' > have_malloc.h
	@echo ' * DO NOT EDIT -- generated by the Makefile' >> have_malloc.h
	@echo ' */' >> have_malloc.h
	@echo '' >> have_malloc.h
	@echo '#if !defined(_HAVE_MALLOC_H_)' >> have_malloc.h
	@echo '#define _HAVE_MALLOC_H_' >> have_malloc.h
	@echo '' >> have_malloc.h
	@echo '/* do we have /usr/include/malloc.h? */' >> have_malloc.h
	-@if [ -f /usr/include/malloc.h ]; then \
		echo '#define HAVE_MALLOC_H  /* yes */' >> have_malloc.h; \
	else \
		echo '#undef HAVE_MALLOC_H  /* no */' >> have_malloc.h; \
	fi
	@echo '' >> have_malloc.h
	@echo '#endif /* _HAVE_MALLOC_H_ */' >> have_malloc.h
	@echo 'have_malloc.h formed'

have_stdlib.h: ${MAKE_FILE}
	@rm -f have_stdlib.h
	@echo 'forming have_stdlib.h'
	@echo '/*' > have_stdlib.h
	@echo ' * DO NOT EDIT -- generated by the Makefile' >> have_stdlib.h
	@echo ' */' >> have_stdlib.h
	@echo '' >> have_stdlib.h
	@echo '#if !defined(_HAVE_STDLIB_H_)' >> have_stdlib.h
	@echo '#define _HAVE_STDLIB_H_' >> have_stdlib.h
	@echo '' >> have_stdlib.h
	@echo '/* do we have /usr/include/stdlib.h? */' >> have_stdlib.h
	-@if [ -f /usr/include/stdlib.h ]; then \
		echo '#define HAVE_STDLIB_H  /* yes */' >> have_stdlib.h; \
	else \
		echo '#undef HAVE_STDLIB_H  /* no */' >> have_stdlib.h; \
	fi
	@echo '' >> have_stdlib.h
	@echo '#endif /* _HAVE_STDLIB_H_ */' >> have_stdlib.h
	@echo 'have_stdlib.h formed'

have_string.h: ${MAKE_FILE}
	@rm -f have_string.h
	@echo 'forming have_string.h'
	@echo '/*' > have_string.h
	@echo ' * DO NOT EDIT -- generated by the Makefile' >> have_string.h
	@echo ' */' >> have_string.h
	@echo '' >> have_string.h
	@echo '#if !defined(_HAVE_STRING_H_)' >> have_string.h
	@echo '#define _HAVE_STRING_H_' >> have_string.h
	@echo '' >> have_string.h
	@echo '/* do we have /usr/include/string.h? */' >> have_string.h
	-@if [ -f /usr/include/string.h ]; then \
		echo '#define HAVE_STRING_H  /* yes */' >> have_string.h; \
	else \
		echo '#undef HAVE_STRING_H  /* no */' >> have_string.h; \
	fi
	@echo '' >> have_string.h
	@echo '#endif /* _HAVE_STRING_H_ */' >> have_string.h
	@echo 'have_string.h formed'

terminal.h: ${MAKE_FILE}
	@rm -f terminal.h
	@echo 'forming terminal.h'
	@echo '/*' > terminal.h
	@echo ' * DO NOT EDIT -- generated by the Makefile' >> terminal.h
	@echo ' */' >> terminal.h
	@echo '' >> terminal.h
	@echo '#if !defined(_TERMINAL_H_)' >> terminal.h
	@echo '#define _TERMINAL_H_' >> terminal.h
	@echo '' >> terminal.h
	@echo '/* determine the type of terminal interface */' >> terminal.h
	@echo '#if !defined(USE_TERMIOS)' >> terminal.h
	@echo '#if !defined(USE_TERMIO)' >> terminal.h
	@echo '#if !defined(USE_SGTTY)' >> terminal.h
	-@if [ -f /usr/include/termios.h ]; then \
		echo '#define USE_TERMIOS  /* <termios.h> */' >> terminal.h; \
		echo '#undef USE_TERMIO    /* <termio.h> */' >> terminal.h; \
		echo '#undef USE_SGTTY     /* <sys/ioctl.h> */' >> terminal.h; \
	elif [ -f /usr/include/termio.h ]; then \
		echo '#undef USE_TERMIOS   /* <termios.h> */' >> terminal.h; \
		echo '#define USE_TERMIO   /* <termio.h> */' >> terminal.h; \
		echo '#undef USE_SGTTY     /* <sys/ioctl.h> */' >> terminal.h; \
	else \
		echo '#undef USE_TERMIOS   /* <termios.h> */' >> terminal.h; \
		echo '#undef USE_TERMIO    /* <termio.h> */' >> terminal.h; \
		echo '#define USE_SGTTY    /* <sys/ioctl.h> */' >> terminal.h; \
	fi
	@echo '#endif' >> terminal.h
	@echo '#endif' >> terminal.h
	@echo '#endif' >> terminal.h
	@echo '' >> terminal.h
	@echo '#endif /* _TERMINAL_H_ */' >> terminal.h
	@echo 'terminal.h formed'

args.h: have_vs.h try_stdarg.c ${MAKE_FILE}
	@rm -f args.h try_stdarg try_stdarg.o
	@echo 'forming args.h'
	@echo '/*' > args.h
	@echo ' * DO NOT EDIT -- generated by the Makefile' >> args.h
	@echo ' */' >> args.h
	@echo '' >> args.h
	@echo '#if !defined(_ARGS_H_)' >> args.h
	@echo '#define _ARGS_H_' >> args.h
	@echo '' >> args.h
	@echo '/* what sort of variable args do we have? */' >> args.h
	-@if [ ! -z "${VARARG}" ]; then \
		echo '#define ${VARARG}' >> args.h; \
	elif [ -f /usr/include/stdarg.h -a -f /usr/include/varargs.h ]; then \
		rm -f try_stdarg.o try_stdarg; \
		${CC} ${ICFLAGS} ${CCMAIN} try_stdarg.c -c; \
		${CC} ${ILDFLAGS} try_stdarg.o -o try_stdarg; \
		if ./try_stdarg; then \
		    echo '#define STDARG' >> args.h; \
		else \
		    echo '#define VARARGS' >> args.h; \
		fi; \
		rm -f try_stdarg try_stdarg.o core core.try_stdarg; \
	elif [ -f /usr/include/stdarg.h ]; then \
		echo '#define STDARG' >> args.h; \
	elif [ -f /usr/include/varargs.h ]; then \
		echo '#define VARARGS' >> args.h; \
	else \
		echo '#define SIMULATE_STDARG' >> args.h; \
	fi
	@echo '' >> args.h
	@echo '#endif /* _ARGS_H_ */' >> args.h
	@echo 'args.h formed'

longlong.h: longlong.c ${MAKE_FILE}
	@rm -f longlong longlong.o ll_tmp longlong.h
	@echo 'forming longlong.h'
	@echo '/*' > longlong.h
	@echo ' * DO NOT EDIT -- generated by the Makefile' >> longlong.h
	@echo ' */' >> longlong.h
	@echo '' >> longlong.h
	@echo '#if !defined(_LONGLONG_H_)' >> longlong.h
	@echo '#define _LONGLONG_H_' >> longlong.h
	@echo '' >> longlong.h
	@echo '/* do we have or want to use a long long type? */' >> longlong.h
	@rm -f longlong.o longlong
	-@${CC} ${ICFLAGS} ${CCMAIN} longlong.c -c 2>/dev/null
	-@${CC} ${ILDFLAGS} longlong.o -o longlong 2>/dev/null
	-@./longlong ${LONGLONG_BITS} > ll_tmp 2>/dev/null
	-@if [ -s ll_tmp ]; then \
		cat ll_tmp >> longlong.h; \
	else \
		echo '#undef HAVE_LONGLONG' >> longlong.h; \
		echo '#define LONGLONG_BITS 0  /* no */' >> longlong.h; \
		echo '' >> longlong.h; \
		echo '/* how to form constants */' >> longlong.h; \
		echo '#if defined(__STDC__) && __STDC__ != 0' >> longlong.h; \
		echo '#define U(x) x ## UL' >> longlong.h; \
		echo '#define L(x) x ## L' >> longlong.h; \
		echo '#else' >> longlong.h; \
		echo '#define U(x) x/**/UL' >> longlong.h; \
		echo '#define L(x) x/**/L' >> longlong.h; \
		echo '#endif' >> longlong.h; \
	fi
	@echo '' >> longlong.h
	@echo '#endif /* _LONGLONG_H_ */' >> longlong.h
	@rm -f longlong longlong.o ll_tmp
	@echo 'longlong.h formed'

have_fpos.h: have_fpos.c ${MAKE_FILE}
	@rm -f have_fpos have_fpos.o fpos_tmp have_fpos.h
	@echo 'forming have_fpos.h'
	@echo '/*' > have_fpos.h
	@echo ' * DO NOT EDIT -- generated by the Makefile' >> have_fpos.h
	@echo ' */' >> have_fpos.h
	@echo '' >> have_fpos.h
	@echo '#if !defined(_HAVE_FPOS_H_)' >> have_fpos.h
	@echo '#define _HAVE_FPOS_H_' >> have_fpos.h
	@echo '' >> have_fpos.h
	@echo '/* do we have fgetpos and fsetpos functions? */' >> have_fpos.h
	@rm -f have_fpos.o have_fpos
	-@${CC} ${ICFLAGS} ${HAVE_FPOS} ${CCMAIN} have_fpos.c -c 2>/dev/null
	-@${CC} ${ILDFLAGS} have_fpos.o -o have_fpos 2>/dev/null
	-@./have_fpos > fpos_tmp 2>/dev/null
	-@if [ -s fpos_tmp ]; then \
		cat fpos_tmp >> have_fpos.h; \
	else \
		echo '#undef HAVE_FPOS  /* no */' >> have_fpos.h; \
		echo '' >> have_fpos.h; \
		echo 'typedef long FILEPOS;' >> have_fpos.h; \
	fi
	@echo '' >> have_fpos.h
	@echo '#endif /* _HAVE_FPOS_H_ */' >> have_fpos.h
	@rm -f have_fpos have_fpos.o fpos_tmp
	@echo 'have_fpos.h formed'

fposval.h: fposval.c have_fpos.h endian_calc.h ${MAKE_FILE}
	@rm -f fposv_tmp fposval fposval.o fposval.h
	@echo 'forming fposval.h'
	@echo '/*' > fposval.h
	@echo ' * DO NOT EDIT -- generated by the Makefile' >> fposval.h
	@echo ' */' >> fposval.h
	@echo '' >> fposval.h
	@echo '#if !defined(_FPOSVAL_H_)' >> fposval.h
	@echo '#define _FPOSVAL_H_' >> fposval.h
	@echo '' >> fposval.h
	@echo '/* what are our file position & size types like? */' >> fposval.h
	@rm -f fposval.o fposval
	-@${CC} ${ICFLAGS} ${CCMAIN} fposval.c -c 2>/dev/null
	-@${CC} ${ILDFLAGS} fposval.o -o fposval 2>/dev/null
	-@./fposval fposv_tmp >> fposval.h 2>/dev/null
	@echo '' >> fposval.h
	@echo '#endif /* _FPOSVAL_H_ */' >> fposval.h
	@rm -f fposval fposval.o fposv_tmp
	@echo 'fposval.h formed'

have_const.h: have_const.c ${MAKE_FILE}
	@rm -f have_const have_const.o const_tmp have_const.h
	@echo 'forming have_const.h'
	@echo '/*' > have_const.h
	@echo ' * DO NOT EDIT -- generated by the Makefile' >> have_const.h
	@echo ' */' >> have_const.h
	@echo '' >> have_const.h
	@echo '#if !defined(_HAVE_CONST_H_)' >> have_const.h
	@echo '#define _HAVE_CONST_H_' >> have_const.h
	@echo '' >> have_const.h
	@echo '/* do we have or want const? */' >> have_const.h
	@rm -f have_const.o have_const
	-@${CC} ${ICFLAGS} ${CCMAIN} ${HAVE_CONST} have_const.c -c 2>/dev/null
	-@${CC} ${ILDFLAGS} have_const.o -o have_const 2>/dev/null
	-@./have_const > const_tmp 2>/dev/null
	-@if [ -s const_tmp ]; then \
		cat const_tmp >> have_const.h; \
	else \
		echo '#undef HAVE_CONST /* no */' >> have_const.h; \
		echo '#undef CONST_TYPE' >> have_const.h; \
		echo '#define CONST_TYPE /* no */' >> have_const.h; \
		echo '' >> have_const.h; \
	fi
	@echo '' >> have_const.h
	@echo '#endif /* _HAVE_CONST_H_ */' >> have_const.h
	@rm -f have_const have_const.o const_tmp
	@echo 'have_const.h formed'

have_uid_t.h: have_uid_t.c ${MAKE_FILE}
	@rm -f have_uid_t have_uid_t.o uid_tmp have_uid_t.h
	@echo 'forming have_uid_t.h'
	@echo '/*' > have_uid_t.h
	@echo ' * DO NOT EDIT -- generated by the Makefile' >> have_uid_t.h
	@echo ' */' >> have_uid_t.h
	@echo '' >> have_uid_t.h
	@echo '#if !defined(_HAVE_UID_T_H_)' >> have_uid_t.h
	@echo '#define _HAVE_UID_T_H_' >> have_uid_t.h
	@echo '' >> have_uid_t.h
	@echo '/* do we have or want uid_t? */' >> have_uid_t.h
	@rm -f have_uid_t.o have_uid_t
	-@${CC} ${ICFLAGS} ${CCMAIN} ${HAVE_UID_T} have_uid_t.c -c 2>/dev/null
	-@${CC} ${ILDFLAGS} have_uid_t.o -o have_uid_t 2>/dev/null
	-@./have_uid_t > uid_tmp 2>/dev/null
	-@if [ -s uid_tmp ]; then \
		cat uid_tmp >> have_uid_t.h; \
	else \
		echo '#undef HAVE_UID_T /* no */' >> have_uid_t.h; \
		echo '' >> have_uid_t.h; \
	fi
	@echo '' >> have_uid_t.h
	@echo '#endif /* _HAVE_UID_T_H_ */' >> have_uid_t.h
	@rm -f have_uid_t have_uid_t.o uid_tmp
	@echo 'have_uid_t.h formed'

have_newstr.h: have_newstr.c ${MAKE_FILE}
	@rm -f have_newstr have_newstr.o newstr_tmp have_newstr.h
	@echo 'forming have_newstr.h'
	@echo '/*' > have_newstr.h
	@echo ' * DO NOT EDIT -- generated by the Makefile' >> have_newstr.h
	@echo ' */' >> have_newstr.h
	@echo '' >> have_newstr.h
	@echo '#if !defined(_HAVE_NEWSTR_H_)' >> have_newstr.h
	@echo '#define _HAVE_NEWSTR_H_' >> have_newstr.h
	@echo '' >> have_newstr.h
	@echo '/* do we have or want memcpy(), memset() & strchr()? */' \
							>> have_newstr.h
	@rm -f have_newstr.o have_newstr
	-@${CC} ${ICFLAGS} ${CCMAIN} ${HAVE_NEWSTR} have_newstr.c -c 2>/dev/null
	-@${CC} ${ILDFLAGS} have_newstr.o -o have_newstr 2>/dev/null
	-@./have_newstr > newstr_tmp 2>/dev/null
	-@if [ -s newstr_tmp ]; then \
		cat newstr_tmp >> have_newstr.h; \
	else \
		echo '#undef HAVE_NEWSTR /* no */' >> have_newstr.h; \
		echo '' >> have_newstr.h; \
	fi
	@echo '' >> have_newstr.h
	@echo '#endif /* _HAVE_NEWSTR_H_ */' >> have_newstr.h
	@rm -f have_newstr have_newstr.o newstr_tmp
	@echo 'have_newstr.h formed'

have_vs.h: have_vs.c ${MAKE_FILE}
	@rm -f have_vs have_vs.o vs_tmp have_vs.h
	@echo 'forming have_vs.h'
	@echo '/*' > have_vs.h
	@echo ' * DO NOT EDIT -- generated by the Makefile' >> have_vs.h
	@echo ' */' >> have_vs.h
	@echo '' >> have_vs.h
	@echo '#if !defined(_HAVE_VS_H_)' >> have_vs.h
	@echo '#define _HAVE_VS_H_' >> have_vs.h
	@echo '' >> have_vs.h
	@echo '/* do we have or want vsprintf()? */' >> have_vs.h
	@rm -f have_vs.o have_vs
	-@${CC} ${ICFLAGS} ${CCMAIN} ${HAVE_VSPRINTF} have_vs.c -c 2>/dev/null
	-@${CC} ${ILDFLAGS} have_vs.o -o have_vs 2>/dev/null
	-@./have_vs chongo was here > vs_tmp 2>/dev/null
	-@if [ -s vs_tmp ]; then \
		cat vs_tmp >> have_vs.h; \
	else \
		echo '#undef HAVE_VS /* no */' >> have_vs.h; \
		echo '' >> have_vs.h; \
	fi
	@echo '' >> have_vs.h
	@echo '#endif /* _HAVE_VS_H_ */' >> have_vs.h
	@rm -f have_vs have_vs.o vs_tmp
	@echo 'have_vs.h formed'

##
#
# These rules are ised in the process of building the BUILD_H_SRC.
#
##

endian.o: endian.c
	${CC} ${ICFLAGS} ${CCMAIN} endian.c -c

endian: endian.o
	${CC} ${ILDFLAGS} endian.o -o endian

longbits.o: longbits.c
	${CC} ${ICFLAGS} ${CCMAIN} longbits.c -c

longbits: longbits.o
	${CC} ${ILDFLAGS} longbits.o -o longbits

##
#
# These two .all rules are used to determine of the lower level
# directory has had its all rule performed.
#
##

lib/.all:
	cd lib; ${MAKE} -f Makefile LIBDIR=${LIBDIR} all

help/.all:
	cd help; ${MAKE} -f Makefile LIBDIR=${LIBDIR} HELPDIR=${HELPDIR} all
##
#
# The BSDI cdrom makefile expects certain files to be pre-built in a sub-dir
# called gen_h.  This rule creats this sub-directory so that the release can
# be shipped off to BSDI.  You can ignore this rule.
#
##

bsdi: ${LIB_H_SRC} calc.1
	-@if [ ! -d gen_h ]; then \
		echo mkdir gen_h; \
		mkdir gen_h; \
	fi
	@for i in ${LIB_H_SRC}; do \
		echo rm -f gen_h/$$i; \
		rm -f gen_h/$$i; \
		echo cp $$i gen_h; \
		cp $$i gen_h; \
		echo chmod 0444 gen_h/$$i; \
		chmod 0444 gen_h/$$i; \
	done
	cd help; ${MAKE} -f Makefile LIBDIR=${LIBDIR} HELPDIR=${HELPDIR} bsdi

##
#
# These rules help with linting.  Adjust ${LINT}, ${LINTLIB}, ${LINTFLAGS}
# and the lint.sed file as needed for your system.
#
##

llib-lcalc.ln: ${BUILD_H_SRC} ${LIBSRC} ${MAKE_FILE}
	rm -f llib-lcalc.ln llib.out
	-touch llib-lcalc.ln
	${LINTLIB} ${LIBSRC} 2>&1 | ${SED} -f lint.sed | ${TEE} llib.out

lint: ${BUILD_H_SRC} ${CALCSRC} llib-lcalc.ln lint.sed ${MAKE_FILE}
	rm -f lint.out
	${LINT} ${LINTFLAGS} ${LCFLAGS} llib-lcalc.ln ${CALCSRC} 2>&1 | \
	    ${SED} -f lint.sed | ${TEE} lint.out

##
#
# Home grown make dependency rules.  Your system make not support
# or have the needed tools.  You can ignore this section.
#
# We will form a skelaton tree of *.c files containing only #include "foo.h"
# lines and .h files containing the same lines surrounded by multiple include
# prevention lines.  This allows us to build a static depend list that will
# satisfy all possible cpp symbol definition combinations.
#
##

depend: hsrc
	@if [ -f Makefile.bak ]; then \
		echo "Makefile.bak exists, remove or move it out of the way"; \
		exit 1; \
	fi
	@echo forming skel
	-@rm -rf skel
	@mkdir skel
	-@for i in ${C_SRC}; do \
		${SED} -n '/^#[	 ]*include[ 	]*"/p' "$$i" > "skel/$$i"; \
	done
	-@for i in ${H_SRC}; do \
		tag="`echo $$i | ${SED} 's/[\.+,:]/_/g'`"; \
		echo "#ifndef $$tag" > "skel/$$i"; \
		echo "#define $$tag" >> "skel/$$i"; \
		${SED} -n '/^#[	 ]*include[	 ]*"/p' "$$i" >> "skel/$$i"; \
		echo '#endif /* '"$$tag"' */' >> "skel/$$i"; \
	done
	-@rm -f skel/makedep.out
	@echo skel formed
	@echo forming dependency list
	@echo "# DO NOT DELETE THIS LINE -- make depend depends on it." > \
	    skel/makedep.out
	@cd skel; ${MAKEDEPEND} -w 1 -m -f makedep.out ${C_SRC}
	-@for i in ${C_SRC}; do \
		echo "$$i" | \
		    ${SED} 's/^\(.*\)\.c/\1.o: \1.c/' >> skel/makedep.out; \
	done
	@echo dependency list formed
	@echo forming new Makefile
	-@rm -f Makefile.bak
	@mv Makefile Makefile.bak
	@${SED} -n '1,/^# DO NOT DELETE THIS LINE/p' Makefile.bak > Makefile
	@echo "" >> Makefile
	@${SED} -n '3,$$p' skel/makedep.out | ${SORT} -u >> Makefile
	@rm -rf skel
	@echo new Makefile formed

##
#
# Utility rules
#
##

tags: ${CALCSRC} ${LIBSRC} ${H_SRC} ${MAKE_FILE}
	${CTAGS} ${CALCSRC} ${LIBSRC} ${H_SRC}

lintclean:
	-rm -f llib-lcalc.ln llib.out lint.out

clean:
	-rm -f ${LIBOBJS}
	-rm -f ${CALCOBJS}
	-rm -f ${UTIL_OBJS}
	-rm -f ${UTIL_TMP}
	-rm -f ${UTIL_PROGS}
	-cd help; ${MAKE} -f Makefile LIBDIR=${LIBDIR} HELPDIR=${HELPDIR} clean
	-cd lib; ${MAKE} -f Makefile LIBDIR=${LIBDIR} clean
	@echo remove files that are obsolete
	-rm -f endian.h stdarg.h libcalcerr.a lib/obj help/obj

clobber: lintclean
	-rm -f ${LIBOBJS}
	-rm -f ${CALCOBJS}
	-rm -f ${UTIL_OBJS}
	-rm -f ${UTIL_TMP}
	-rm -f ${UTIL_PROGS}
	-rm -f tags calc libcalc.a calc.1
	-rm -f ${BUILD_H_SRC}
	-rm -f *_pure_*.[oa]
	-rm -f *.pure_hardlink
	-rm -f *.pure_linkinfo
	-rm -f *.u
	-rm -f calc.pixie calc.rf calc.Counts calc.cord
	-rm -rf gen_h skel Makefile.bak
	-cd help;${MAKE} -f Makefile LIBDIR=${LIBDIR} HELPDIR=${HELPDIR} clobber
	-cd lib; ${MAKE} -f Makefile LIBDIR=${LIBDIR} clobber
	@echo remove files that are obsolete
	-rm -f endian.h stdarg.h libcalcerr.a lib/obj help/obj

install: calc libcalc.a ${LIB_H_SRC} calc.1
	-@if [ ! -d ${LIBDIR} ]; then \
		echo mkdir ${LIBDIR}; \
		mkdir ${LIBDIR}; \
	fi
	-chmod 0755 ${LIBDIR}
	-@if [ ! -d ${HELPDIR} ]; then \
		echo mkdir ${HELPDIR}; \
		mkdir ${HELPDIR}; \
	fi
	-chmod 0755 ${HELPDIR}
	-@if [ ! -d ${BINDIR} ]; then \
		echo mkdir ${BINDIR}; \
		mkdir ${BINDIR}; \
	fi
	-chmod 0755 ${BINDIR}
	rm -f ${BINDIR}/calc
	cp calc ${BINDIR}
	-chmod 0555 ${BINDIR}/calc
	cd help; ${MAKE} -f Makefile \
	    LIBDIR=${LIBDIR} HELPDIR=${HELPDIR} install
	cd lib; ${MAKE} -f Makefile LIBDIR=${LIBDIR} install
	rm -f ${LIBDIR}/libcalc.a
	cp libcalc.a ${LIBDIR}/libcalc.a
	-chmod 0644 ${LIBDIR}/libcalc.a
	${RANLIB} ${LIBDIR}/libcalc.a
	@for i in ${LIB_H_SRC}; do \
		echo rm -f ${LIBDIR}/$$i; \
		rm -f ${LIBDIR}/$$i; \
		echo cp $$i ${LIBDIR}; \
		cp $$i ${LIBDIR}; \
		echo chmod 0444 ${LIBDIR}/$$i; \
		chmod 0444 ${LIBDIR}/$$i; \
	done
	@: If lint was made, install the lint library.
	-@if [ -f llib-lcalc.ln ]; then \
		echo rm -f ${LIBDIR}/llib-lcalc.ln; \
		rm -f ${LIBDIR}/llib-lcalc.ln; \
		echo cp llib-lcalc.ln ${LIBDIR}; \
		cp llib-lcalc.ln ${LIBDIR}; \
		echo chmod 0444 ${LIBDIR}/llib-lcalc.ln; \
		chmod 0444 ${LIBDIR}/llib-lcalc.ln; \
	fi
	-@if [ -z "${MANDIR}" ]; then \
	    echo '$${MANDIR} is empty, calc man page will not be installed'; \
	else \
	    echo "rm -f ${MANDIR}/calc.${MANEXT}"; \
	    rm -f ${MANDIR}/calc.${MANEXT}; \
	    echo "cp calc.1 ${MANDIR}/calc.${MANEXT}"; \
	    cp calc.1 ${MANDIR}/calc.${MANEXT}; \
	    echo "chmod 0444 ${MANDIR}/calc.${MANEXT}"; \
	    chmod 0444 ${MANDIR}/calc.${MANEXT}; \
	fi
	-@if [ -z "${CATDIR}" ]; then \
	    echo '$${CATDIR} is empty, calc cat page will not be installed'; \
	else \
	    if [ -z "${NROFF}" ]; then \
		echo "${MANMAKE} calc.1 ${CATDIR}"; \
		${MANMAKE} calc.1 ${CATDIR}; \
	    else \
		echo "rm -f ${CATDIR}/calc.${CATEXT}"; \
		rm -f ${CATDIR}/calc.${CATEXT}; \
		echo "${NROFF} -mandoc calc.1  > ${CATDIR}/calc.${CATEXT}"; \
		${NROFF} -mandoc calc.1 > ${CATDIR}/calc.${CATEXT}; \
		echo "chmod ${MANMODE} ${MANDIR}/calc.${MANEXT}"; \
		chmod ${MANMODE} ${MANDIR}/calc.${MANEXT}; \
	    fi; \
	fi
	@echo remove files that are obsolete
	-rm -f ${LIBDIR}/endian.h ${LIBDIR}/stdarg.h endian.h stdarg.h
	-rm -f ${LIBDIR}/libcalcerr.a libcalcerr.a

##
#
# make depend stuff
#
##

# DO NOT DELETE THIS LINE -- make depend depends on it.

addop.o: addop.c
addop.o: alloc.h
addop.o: calc.h
addop.o: cmath.h
addop.o: endian_calc.h
addop.o: func.h
addop.o: have_malloc.h
addop.o: have_newstr.h
addop.o: have_stdlib.h
addop.o: have_string.h
addop.o: have_vs.h
addop.o: label.h
addop.o: longbits.h
addop.o: longlong.h
addop.o: opcodes.h
addop.o: qmath.h
addop.o: string.h
addop.o: symbol.h
addop.o: token.h
addop.o: value.h
addop.o: zmath.h
assocfunc.o: alloc.h
assocfunc.o: assocfunc.c
assocfunc.o: cmath.h
assocfunc.o: endian_calc.h
assocfunc.o: have_malloc.h
assocfunc.o: have_newstr.h
assocfunc.o: have_stdlib.h
assocfunc.o: have_string.h
assocfunc.o: have_vs.h
assocfunc.o: longbits.h
assocfunc.o: longlong.h
assocfunc.o: qmath.h
assocfunc.o: value.h
assocfunc.o: zmath.h
calc.o: alloc.h
calc.o: calc.c
calc.o: calc.h
calc.o: cmath.h
calc.o: config.h
calc.o: endian_calc.h
calc.o: func.h
calc.o: have_malloc.h
calc.o: have_newstr.h
calc.o: have_stdlib.h
calc.o: have_string.h
calc.o: have_uid_t.h
calc.o: have_vs.h
calc.o: hist.h
calc.o: label.h
calc.o: longbits.h
calc.o: longlong.h
calc.o: opcodes.h
calc.o: qmath.h
calc.o: symbol.h
calc.o: token.h
calc.o: value.h
calc.o: zmath.h
codegen.o: alloc.h
codegen.o: calc.h
codegen.o: cmath.h
codegen.o: codegen.c
codegen.o: config.h
codegen.o: endian_calc.h
codegen.o: func.h
codegen.o: have_malloc.h
codegen.o: have_newstr.h
codegen.o: have_stdlib.h
codegen.o: have_string.h
codegen.o: have_vs.h
codegen.o: label.h
codegen.o: longbits.h
codegen.o: longlong.h
codegen.o: opcodes.h
codegen.o: qmath.h
codegen.o: string.h
codegen.o: symbol.h
codegen.o: token.h
codegen.o: value.h
codegen.o: zmath.h
comfunc.o: alloc.h
comfunc.o: cmath.h
comfunc.o: comfunc.c
comfunc.o: endian_calc.h
comfunc.o: have_malloc.h
comfunc.o: have_newstr.h
comfunc.o: have_stdlib.h
comfunc.o: have_string.h
comfunc.o: have_vs.h
comfunc.o: longbits.h
comfunc.o: longlong.h
comfunc.o: qmath.h
comfunc.o: zmath.h
commath.o: alloc.h
commath.o: cmath.h
commath.o: commath.c
commath.o: endian_calc.h
commath.o: have_malloc.h
commath.o: have_newstr.h
commath.o: have_stdlib.h
commath.o: have_string.h
commath.o: have_vs.h
commath.o: longbits.h
commath.o: longlong.h
commath.o: qmath.h
commath.o: zmath.h
config.o: alloc.h
config.o: calc.h
config.o: cmath.h
config.o: config.c
config.o: endian_calc.h
config.o: have_malloc.h
config.o: have_newstr.h
config.o: have_stdlib.h
config.o: have_string.h
config.o: have_vs.h
config.o: longbits.h
config.o: longlong.h
config.o: qmath.h
config.o: value.h
config.o: zmath.h
const.o: alloc.h
const.o: calc.h
const.o: cmath.h
const.o: const.c
const.o: endian_calc.h
const.o: have_malloc.h
const.o: have_newstr.h
const.o: have_stdlib.h
const.o: have_string.h
const.o: have_vs.h
const.o: longbits.h
const.o: longlong.h
const.o: qmath.h
const.o: value.h
const.o: zmath.h
endian.o: endian.c
file.o: alloc.h
file.o: args.h
file.o: calc.h
file.o: cmath.h
file.o: endian_calc.h
file.o: file.c
file.o: fposval.h
file.o: have_fpos.h
file.o: have_malloc.h
file.o: have_newstr.h
file.o: have_stdlib.h
file.o: have_string.h
file.o: have_vs.h
file.o: longbits.h
file.o: longlong.h
file.o: qmath.h
file.o: std_arg.h
file.o: value.h
file.o: zmath.h
fnvhash.o: alloc.h
fnvhash.o: cmath.h
fnvhash.o: endian_calc.h
fnvhash.o: fnvhash.c
fnvhash.o: have_malloc.h
fnvhash.o: have_newstr.h
fnvhash.o: have_stdlib.h
fnvhash.o: have_string.h
fnvhash.o: have_vs.h
fnvhash.o: longbits.h
fnvhash.o: longlong.h
fnvhash.o: qmath.h
fnvhash.o: value.h
fnvhash.o: zmath.h
fnvhash.o: zrand.h
fposval.o: endian_calc.h
fposval.o: fposval.c
fposval.o: have_fpos.h
func.o: alloc.h
func.o: calc.h
func.o: cmath.h
func.o: endian_calc.h
func.o: func.c
func.o: func.h
func.o: have_const.h
func.o: have_malloc.h
func.o: have_newstr.h
func.o: have_stdlib.h
func.o: have_string.h
func.o: have_vs.h
func.o: label.h
func.o: longbits.h
func.o: longlong.h
func.o: opcodes.h
func.o: prime.h
func.o: qmath.h
func.o: string.h
func.o: symbol.h
func.o: token.h
func.o: value.h
func.o: zmath.h
func.o: zrand.h
have_const.o: have_const.c
have_fpos.o: have_fpos.c
have_newstr.o: have_newstr.c
have_uid_t.o: have_uid_t.c
have_vs.o: have_vs.c
hist.o: have_string.h
hist.o: hist.c
hist.o: hist.h
hist.o: terminal.h
input.o: alloc.h
input.o: calc.h
input.o: cmath.h
input.o: config.h
input.o: endian_calc.h
input.o: have_malloc.h
input.o: have_newstr.h
input.o: have_stdlib.h
input.o: have_string.h
input.o: have_vs.h
input.o: hist.h
input.o: input.c
input.o: longbits.h
input.o: longlong.h
input.o: qmath.h
input.o: value.h
input.o: zmath.h
jump.o: jump.c
jump.o: jump.h
label.o: alloc.h
label.o: calc.h
label.o: cmath.h
label.o: endian_calc.h
label.o: func.h
label.o: have_malloc.h
label.o: have_newstr.h
label.o: have_stdlib.h
label.o: have_string.h
label.o: have_vs.h
label.o: label.c
label.o: label.h
label.o: longbits.h
label.o: longlong.h
label.o: opcodes.h
label.o: qmath.h
label.o: string.h
label.o: token.h
label.o: value.h
label.o: zmath.h
listfunc.o: alloc.h
listfunc.o: cmath.h
listfunc.o: endian_calc.h
listfunc.o: have_malloc.h
listfunc.o: have_newstr.h
listfunc.o: have_stdlib.h
listfunc.o: have_string.h
listfunc.o: have_vs.h
listfunc.o: listfunc.c
listfunc.o: longbits.h
listfunc.o: longlong.h
listfunc.o: qmath.h
listfunc.o: value.h
listfunc.o: zmath.h
longbits.o: longbits.c
longlong.o: longlong.c
matfunc.o: alloc.h
matfunc.o: cmath.h
matfunc.o: endian_calc.h
matfunc.o: have_malloc.h
matfunc.o: have_newstr.h
matfunc.o: have_stdlib.h
matfunc.o: have_string.h
matfunc.o: have_vs.h
matfunc.o: longbits.h
matfunc.o: longlong.h
matfunc.o: matfunc.c
matfunc.o: qmath.h
matfunc.o: value.h
matfunc.o: zmath.h
math_error.o: alloc.h
math_error.o: args.h
math_error.o: calc.h
math_error.o: cmath.h
math_error.o: endian_calc.h
math_error.o: have_malloc.h
math_error.o: have_newstr.h
math_error.o: have_stdlib.h
math_error.o: have_string.h
math_error.o: have_vs.h
math_error.o: longbits.h
math_error.o: longlong.h
math_error.o: math_error.c
math_error.o: qmath.h
math_error.o: std_arg.h
math_error.o: value.h
math_error.o: zmath.h
obj.o: alloc.h
obj.o: calc.h
obj.o: cmath.h
obj.o: endian_calc.h
obj.o: func.h
obj.o: have_malloc.h
obj.o: have_newstr.h
obj.o: have_stdlib.h
obj.o: have_string.h
obj.o: have_vs.h
obj.o: label.h
obj.o: longbits.h
obj.o: longlong.h
obj.o: obj.c
obj.o: opcodes.h
obj.o: qmath.h
obj.o: string.h
obj.o: symbol.h
obj.o: value.h
obj.o: zmath.h
opcodes.o: alloc.h
opcodes.o: args.h
opcodes.o: calc.h
opcodes.o: cmath.h
opcodes.o: endian_calc.h
opcodes.o: func.h
opcodes.o: have_malloc.h
opcodes.o: have_newstr.h
opcodes.o: have_stdlib.h
opcodes.o: have_string.h
opcodes.o: have_vs.h
opcodes.o: hist.h
opcodes.o: label.h
opcodes.o: longbits.h
opcodes.o: longlong.h
opcodes.o: opcodes.c
opcodes.o: opcodes.h
opcodes.o: qmath.h
opcodes.o: std_arg.h
opcodes.o: symbol.h
opcodes.o: value.h
opcodes.o: zmath.h
pix.o: alloc.h
pix.o: endian_calc.h
pix.o: have_malloc.h
pix.o: have_newstr.h
pix.o: have_stdlib.h
pix.o: have_string.h
pix.o: have_vs.h
pix.o: longbits.h
pix.o: longlong.h
pix.o: pix.c
pix.o: prime.h
pix.o: qmath.h
pix.o: zmath.h
prime.o: alloc.h
prime.o: endian_calc.h
prime.o: have_malloc.h
prime.o: have_newstr.h
prime.o: have_stdlib.h
prime.o: have_string.h
prime.o: have_vs.h
prime.o: jump.h
prime.o: longbits.h
prime.o: longlong.h
prime.o: prime.c
prime.o: prime.h
prime.o: qmath.h
prime.o: zmath.h
qfunc.o: alloc.h
qfunc.o: endian_calc.h
qfunc.o: have_malloc.h
qfunc.o: have_newstr.h
qfunc.o: have_stdlib.h
qfunc.o: have_string.h
qfunc.o: have_vs.h
qfunc.o: longbits.h
qfunc.o: longlong.h
qfunc.o: prime.h
qfunc.o: qfunc.c
qfunc.o: qmath.h
qfunc.o: zmath.h
qio.o: alloc.h
qio.o: args.h
qio.o: endian_calc.h
qio.o: have_malloc.h
qio.o: have_newstr.h
qio.o: have_stdlib.h
qio.o: have_string.h
qio.o: have_vs.h
qio.o: longbits.h
qio.o: longlong.h
qio.o: qio.c
qio.o: qmath.h
qio.o: std_arg.h
qio.o: zmath.h
qmath.o: alloc.h
qmath.o: endian_calc.h
qmath.o: have_malloc.h
qmath.o: have_newstr.h
qmath.o: have_stdlib.h
qmath.o: have_string.h
qmath.o: have_vs.h
qmath.o: longbits.h
qmath.o: longlong.h
qmath.o: qmath.c
qmath.o: qmath.h
qmath.o: zmath.h
qmod.o: alloc.h
qmod.o: endian_calc.h
qmod.o: have_malloc.h
qmod.o: have_newstr.h
qmod.o: have_stdlib.h
qmod.o: have_string.h
qmod.o: have_vs.h
qmod.o: longbits.h
qmod.o: longlong.h
qmod.o: qmath.h
qmod.o: qmod.c
qmod.o: zmath.h
qtrans.o: alloc.h
qtrans.o: endian_calc.h
qtrans.o: have_malloc.h
qtrans.o: have_newstr.h
qtrans.o: have_stdlib.h
qtrans.o: have_string.h
qtrans.o: have_vs.h
qtrans.o: longbits.h
qtrans.o: longlong.h
qtrans.o: qmath.h
qtrans.o: qtrans.c
qtrans.o: zmath.h
string.o: alloc.h
string.o: calc.h
string.o: cmath.h
string.o: endian_calc.h
string.o: have_malloc.h
string.o: have_newstr.h
string.o: have_stdlib.h
string.o: have_string.h
string.o: have_vs.h
string.o: longbits.h
string.o: longlong.h
string.o: qmath.h
string.o: string.c
string.o: string.h
string.o: value.h
string.o: zmath.h
symbol.o: alloc.h
symbol.o: calc.h
symbol.o: cmath.h
symbol.o: endian_calc.h
symbol.o: func.h
symbol.o: have_malloc.h
symbol.o: have_newstr.h
symbol.o: have_stdlib.h
symbol.o: have_string.h
symbol.o: have_vs.h
symbol.o: label.h
symbol.o: longbits.h
symbol.o: longlong.h
symbol.o: opcodes.h
symbol.o: qmath.h
symbol.o: string.h
symbol.o: symbol.c
symbol.o: symbol.h
symbol.o: token.h
symbol.o: value.h
symbol.o: zmath.h
token.o: alloc.h
token.o: args.h
token.o: calc.h
token.o: cmath.h
token.o: endian_calc.h
token.o: have_malloc.h
token.o: have_newstr.h
token.o: have_stdlib.h
token.o: have_string.h
token.o: have_vs.h
token.o: longbits.h
token.o: longlong.h
token.o: qmath.h
token.o: std_arg.h
token.o: string.h
token.o: token.c
token.o: token.h
token.o: value.h
token.o: zmath.h
try_stdarg.o: have_vs.h
try_stdarg.o: try_stdarg.c
value.o: alloc.h
value.o: calc.h
value.o: cmath.h
value.o: endian_calc.h
value.o: func.h
value.o: have_malloc.h
value.o: have_newstr.h
value.o: have_stdlib.h
value.o: have_string.h
value.o: have_vs.h
value.o: label.h
value.o: longbits.h
value.o: longlong.h
value.o: opcodes.h
value.o: qmath.h
value.o: string.h
value.o: symbol.h
value.o: value.c
value.o: value.h
value.o: zmath.h
value.o: zrand.h
version.o: alloc.h
version.o: calc.h
version.o: cmath.h
version.o: endian_calc.h
version.o: have_malloc.h
version.o: have_newstr.h
version.o: have_stdlib.h
version.o: have_string.h
version.o: have_vs.h
version.o: longbits.h
version.o: longlong.h
version.o: qmath.h
version.o: value.h
version.o: version.c
version.o: zmath.h
zfunc.o: alloc.h
zfunc.o: endian_calc.h
zfunc.o: have_malloc.h
zfunc.o: have_newstr.h
zfunc.o: have_stdlib.h
zfunc.o: have_string.h
zfunc.o: have_vs.h
zfunc.o: longbits.h
zfunc.o: longlong.h
zfunc.o: zfunc.c
zfunc.o: zmath.h
zio.o: alloc.h
zio.o: args.h
zio.o: endian_calc.h
zio.o: have_malloc.h
zio.o: have_newstr.h
zio.o: have_stdlib.h
zio.o: have_string.h
zio.o: have_vs.h
zio.o: longbits.h
zio.o: longlong.h
zio.o: std_arg.h
zio.o: zio.c
zio.o: zmath.h
zmath.o: alloc.h
zmath.o: endian_calc.h
zmath.o: have_malloc.h
zmath.o: have_newstr.h
zmath.o: have_stdlib.h
zmath.o: have_string.h
zmath.o: have_vs.h
zmath.o: longbits.h
zmath.o: longlong.h
zmath.o: zmath.c
zmath.o: zmath.h
zmod.o: alloc.h
zmod.o: endian_calc.h
zmod.o: have_malloc.h
zmod.o: have_newstr.h
zmod.o: have_stdlib.h
zmod.o: have_string.h
zmod.o: have_vs.h
zmod.o: longbits.h
zmod.o: longlong.h
zmod.o: zmath.h
zmod.o: zmod.c
zmul.o: alloc.h
zmul.o: endian_calc.h
zmul.o: have_malloc.h
zmul.o: have_newstr.h
zmul.o: have_stdlib.h
zmul.o: have_string.h
zmul.o: have_vs.h
zmul.o: longbits.h
zmul.o: longlong.h
zmul.o: zmath.h
zmul.o: zmul.c
zprime.o: alloc.h
zprime.o: endian_calc.h
zprime.o: have_malloc.h
zprime.o: have_newstr.h
zprime.o: have_stdlib.h
zprime.o: have_string.h
zprime.o: have_vs.h
zprime.o: jump.h
zprime.o: longbits.h
zprime.o: longlong.h
zprime.o: prime.h
zprime.o: qmath.h
zprime.o: zmath.h
zprime.o: zprime.c
zrand.o: alloc.h
zrand.o: cmath.h
zrand.o: endian_calc.h
zrand.o: have_malloc.h
zrand.o: have_newstr.h
zrand.o: have_stdlib.h
zrand.o: have_string.h
zrand.o: have_vs.h
zrand.o: longbits.h
zrand.o: longlong.h
zrand.o: qmath.h
zrand.o: value.h
zrand.o: zmath.h
zrand.o: zrand.c
zrand.o: zrand.h
