#
#  Makefile for calctool, a calculator program.
#
#  @(#)Makefile 1.23 90/08/14
#
#  Copyright (c) Rich Burridge.
#                Sun Microsystems, Australia - All rights reserved.
#
#  Permission is given to distribute these sources, as long as the
#  copyright messages are not removed, and no monies are exchanged.
#
#  No responsibility is taken for any errors inherent either in the comments
#  or the code of this program, but if reported to me then an attempt will
#  be made to fix them.
#
#======================================================================
#
#  There are various small changes needed when compiling calctool on
#  different systems. These have been isolated here, and should
#  be uncommented if needed.
#
#======================================================================
#
#  Calctool uses an helpfile to supply online help for each key.
#  By default this file is called "calctool.help", and is looked
#  for in every directory on the users search path. You can also
#  override it's location and name at runtime with the -h option.
#  It can also be specified here by uncommenting the following
#  macro definition and setting appropriately.
#
HELPNAME        = -DHELPNAME=\"%%DATADIR%%/calctool.help\"
#-----------------------------------------------------------------------
#  An attempt is now made at using a portable math library. You should
#  carefully setup the following three definitions.
#
#  One of the things this is not the same on all machines is the
#  floating point format. If your machine does *not* use IEEE floating
#  point format, then the following definition needs to be uncommented.
#
#NOIEEE             = -DIEEE
#-----------------------------------------------------------------------
#  Some machines send a SIGFPE on math errors despite the presense
#  of the handler routine in calctool.c. If calctool cores when you
#  divide by zero, uncomment this and calctool will ignore FPE
#  signals.
#
#STUPID_FPE         = -DSTUPID_FPE
#-----------------------------------------------------------------------
#  Not all machines have the index() string library function. If you
#  don't have this function then you should uncomment the NOINDEX
#  definition below.
#
#NOINDEX         = -DNOINDEX
#-----------------------------------------------------------------------
#  If you are compiling the MGR version, then the following three
#  definitions should be uncommented.
#
#MGRHOME         = /usr/mgr
#MGRPARAM        = -DMGRHOME=\"$(MGRHOME)\"
#MGRINCDIR       = -I$(MGRHOME)/include
#-----------------------------------------------------------------------
#  If you are compiling the NeWS version, then the following definition
#  should be uncommented and set to the default location for the calctool
#  PostScript file, which is downloaded to the NeWS server.
#
#NEWSFILE        = -DNEWSFILE=\"$(LIBDIR)/calctool.ps\"
#-----------------------------------------------------------------------
#  Calctool loads a run control file when it starts. By default
#  this file is called ".calctoolrc", and is taken from the users
#  home directory. If there is a similar file in the current directory,
#  then these values override the default ones. Its name and location
#  can also be specified here by uncommenting the following macro
#  definition and setting appropriately.
#
#RCNAME          = -DRCNAME=\".calctoolrc\"
#-----------------------------------------------------------------------
#  If you not running under a BSD4.3 derived system, the parameters
#  to the select call are different, and this definition should be
#  uncommented. You need to uncomment this for SunOS v3.x.
#
#SELTYPE        = -DNO_4.3SELECT
#-----------------------------------------------------------------------
#  Note that with SunOS v4.x it is possible to create a shared library
#  for the calctool routines. If you wish to do this, then you should
#  uncomment the other three definitions below, commented out the initial
#  two.
#
#LIBNAME         = libcalctool.a
#CALCLIB	        = $(LIBNAME)
#
# Shared library definitions. Uncomment if required.
LIBNAME         = libcalctool.so.1
CALCLIB         = -L . -lcalctool
SHLIB           = %%FPIC%%
#-----------------------------------------------------------------------
#  If you are not running under a BSD4.3 derived system, then the
#  second parameter to a select call is a pointer to an integer function,
#  and this definition needs to be uncommented. You need to uncomment this
#  for SunOS v3.x.
#
#SIGRET         = -DNO_4.3SIGNAL
#--------------------------------------------------------------------------
#  Calctool endevours to provide a numeric keypad using the right function
#  keypad. The Sun3 keyboard has a different pad setup to the Sun4 keyboard.
#  If you wish to use these function keys with a Sun4 keyboard, then you
#  need to uncomment the following definition.
#
SUN4_KEYBOARD  = -DSUN4_KEYBOARD
#-------------------------------------------------------------------------
#  If you are running SunOS v3.x, then pr_ttext doesn't exist, and
#  you must uncomment this definition.
#
#TTEXT          = -DNO_PR_TTEXT
#-------------------------------------------------------------------------
#  If you are compiling the X11 version and the X11 include and
#  library files are not in a standard place, then the following
#  two lines should be uncommented, and set appropriately.
#
X11INCDIR         = -I%%X11BASE%%/include
X11LIBDIR         = -L%%X11BASE%%/lib
#-------------------------------------------------------------------------
#  If you are compiling the XView version, then the following two lines
#  should be uncommented.
#
XVIEWINCDIR      = -I%%X11BASE%%/include
XVIEWLIBDIR      = -L%%X11BASE%%/lib
#
#=========================================================================
#
#  Default locations where calctool files will be installed.
#  You might wish to alter these values.
#
BINDIR          = $(PREFIX)/bin
LIBDIR          = $(PREFIX)/lib
MANDIR          = $(PREFIX)/man/man$(MANSECT)
MANSECT         = 1
#
#  Compilation flags and standard macro definitions.
#
CFLAGS		+=   $(HELPNAME) $(NEWSFILE) $(STUPID_FPE) $(NOIEEE) \
		     $(NOINDEX) $(RCNAME) $(SELTYPE) $(SHLIB) $(SIGRET) \
		     $(SUN4_KEYBOARD) $(TTEXT) $(MGRPARAM) $(MGRINCDIR) \
		     $(X11INCDIR) $(XVIEWINCDIR)
#
#=========================================================================

BINARIES        = %%BINARIES%%

#CC		= cc

LIBSRCS         = graphics.c display.c functions.c get.c
LIBOBJS         = graphics.o display.o functions.o get.o
STDSRCS         = calctool.c mathlib.c
STDOBJS         = calctool.o mathlib.o
OBJS            = $(STDOBJS) $(LIBNAME)

GSRCS           = mgr.c news.c sunview.c tty.c x11.c xview.c
HDRS            = calctool.h color.h extern.h mathlib.h
IMAGES          = calctool.icon calctool.color.icon help.cursor
OTHERS          = Makefile README TODO calctool.help calctool.1 \
		  CHANGES calctool.ps patchlevel.h .calctoolrc \
		  Imakefile.main Imakefile.lib

SFILES1		= $(STDSRCS)
SFILES2         = $(LIBSRCS)
SFILES3         = $(GSRCS)
SFILES4         = $(HDRS) $(IMAGES)
SFILES5         = $(OTHERS)

MGRLIBS         = $(CALCLIB) $(MGRHOME)/lib/libmgr.a -lm
NEWSLIBS        = $(CALCLIB) $$OPENWINHOME/lib/libcps.a -lm
SVIEWLIBS       = $(CALCLIB) -lsuntool -lsunwindow -lpixrect -lm
TTYLIBS	        = $(CALCLIB) -ltermcap -lm
X11LIBS         = $(CALCLIB) -lX11 -lm
XVIEWLIBS       = $(CALCLIB) -lxview -lolgx -lX11 -lm

.PRECIOUS:      $(LIBNAME)

help:
		@echo
		@echo "You need to specify one of the following options:"
		@echo
		@echo "  make mgr        - to make the MGR version."
		@echo "  make news       - to make the NeWS version."
		@echo "  make sunview    - to make the SunView version."
		@echo "  make tty        - to make the dumb tty version."
		@echo "  make x11        - to make the X11 version."
		@echo "  make xview      - to make the XView version."
		@echo
		@echo "This should be followed by:"
		@echo
		@echo "  make install"
		@echo "  make clean"
		@echo

all:            $(BINARIES)

mgr:            $(OBJS) mgr.o
		$(CC) -o mgr_calctool $(CFLAGS) $(STDOBJS) mgr.o $(MGRLIBS)
		-cp mgr_calctool calctool

news:           $(OBJS) news.o
		$(CC) -o ps_calctool $(CFLAGS) $(STDOBJS) news.o $(NEWSLIBS)
		-cp ps_calctool calctool

sunview:        $(OBJS) sunview.o
		$(CC) -o sv_calctool $(CFLAGS) $(STDOBJS) sunview.o $(SVIEWLIBS)
		-cp sv_calctool calctool

tty_calctool:   $(OBJS) tty.o
		$(CC) -o tty_calctool $(CFLAGS) $(STDOBJS) tty.o $(TTYLIBS)

xcalctool:      $(OBJS) x11.o
		$(CC) -o xcalctool $(X11LIBDIR) $(CFLAGS) $(STDOBJS) x11.o \
				$(X11LIBS)

xv_calctool:    $(OBJS) xview.o
		$(CC) -o xv_calctool $(XVIEWLIBDIR) $(CFLAGS) $(STDOBJS) \
				xview.o $(XVIEWLIBS)

libcalctool.a:  $(LIBOBJS)
		ar rv $@ $?
		ranlib $@
                 
#  These are the library creation rules for making the shared calctool
#  library (available with SunOS v4.x).
 
libcalctool.so.1:	$(LIBOBJS)
			$(CC) -shared -o ${LIBNAME} $?
			ln -sf ${LIBNAME} libcalctool.so

install:
		install -c -m 644 $(LIBNAME) $(LIBDIR)
		install -s -m 751 calctool $(BINDIR)
		install -c -m 644 calctool.help $(LIBDIR)
		install -c -m 644 calctool.ps $(LIBDIR)
		install -c -m 644 calctool.1 $(MANDIR)/calctool.$(MANSECT)

clean:;         rm -f *.o archive.* *~ *.a $(BINARIES) core

lint:;		lint $(CFLAGS) $(STDSRCS) $(LIBSRCS) tty.c $(TTYLIBS)
		lint $(CFLAGS) $(STDSRCS) $(LIBSRCS) sunview.c $(SVIEWLIBS)
		lint $(CFLAGS) $(STDSRCS) $(LIBSRCS) xview.c $(XVIEWLIBS)
		lint $(CFLAGS) $(STDSRCS) $(LIBSRCS) x11.c $(X11LIBS)
		lint $(CFLAGS) $(STDSRCS) $(LIBSRCS) news.c $(NEWSLIBS)
		lint $(CFLAGS) $(STDSRCS) $(LIBSRCS) mgr.c $(MGRLIBS)

shar:;          shar.script $(SFILES1) > archive.1
		shar.script $(SFILES2) > archive.2
		shar.script $(SFILES3) > archive.3
		shar.script $(SFILES4) > archive.4
		shar.script $(SFILES5) > archive.5

create:		SCCS
		-sccs create $(STDSRCS) $(GSRCS) $(HDRS) $(IMAGES) $(OTHERS)
SCCS:
		-mkdir SCCS
		chmod 755 SCCS

calctool.o:	calctool.c patchlevel.h color.h calctool.h
display.o:	display.c calctool.h color.h extern.h
functions.o:	functions.c calctool.h color.h extern.h
get.o:		get.c patchlevel.h calctool.h color.h extern.h
graphics.o:	graphics.c calctool.h color.h extern.h
mathlib.o:	mathlib.c mathlib.h calctool.h
mgr.o:		mgr.c calctool.h color.h extern.h
news.o:		news.c calctool.h color.h extern.h
sunview.o:	sunview.c calctool.h color.h extern.h
tty.o:		tty.c calctool.h color.h extern.h
x11.o:		x11.c calctool.h color.h extern.h
xview.o:	xview.c calctool.h color.h extern.h


syntax highlighted by Code2HTML, v. 0.9.1