# file: Makefile	G. Moody	 9 June 1983
#			Last revised:	4 April 1997
# UNIX 'make' description file for DB applications
#
# Copyright(C) Massachusetts Institute of Technology 1997. All rights reserved.

# This file is used with the UNIX `make' command to install the standard
# applications that come with the ECG DB software package.  Before using it
# for the first time, check that the site-specific variables below are
# appropriate for your system.  To build and install the applications, just
# type `make' (from within this directory).  To print a set of source listings,
# type `make listing'.

# Site-specific variables
# -----------------------

# CC is the name of your C compiler.  These applications can be compiled with
# K&R C compilers (`cc' on most if not all UNIX systems) as well as with ANSI
# C compilers such as GNU C (`gcc').  To use the K&R C compiler available on
# most UNIX systems, uncomment the next line.
CC = cc
# For `gcc', uncomment the next line (and see CFLAGS below).
# CC = gcc

# If you trust your C compiler's optimizer, you may wish to add -O to CFLAGS;
# for debugging, add -g to CFLAGS.  (If you use `gcc', you may use both;  most
# other C compilers do not permit you to do so.)  Add -DNOMALLOC_H if you have
# neither `stdlib.h' nor `malloc.h' (see ../lib/dblib.h).  Add -DNOSTRSTR if
# you don't have the ANSI C `strstr' function (check your system's `string.h'
# or `strings.h' file, normally in /usr/include; see `pschart.c' and `psfd.c').
CFLAGS = -O -L/usr/local/lib

# LDFLAGS is appended to the C compiler command line to specify loading the
# DB library.  Unless you have changed the value of DBLIB in the `Makefile'
# for the DB library, `-ldb' should be correct.
LDFLAGS = -ldb

# BINDIR specifies the directory in which the applications will be installed;
# it should be a directory in the PATH of those who will use the applications.
# You will need to have write permission in BINDIR.  Users of this software
# will need to have search (execute) permission in BINDIR.
BINDIR = /usr/local/bin

# PSPDIR specifies the directory in which PostScript prolog files are kept.
# (You may use any directory for this purpose;  if you have other PostScript
# applications, you may wish to keep all of your prolog files in the same
# directory, often /usr/local/lib/ps).  You will need to have write permission
# in PSPDIR.  Users of this software will need to have search (execute)
# permission in PSPDIR.
PSPDIR = /usr/local/lib/ps

# PRINT is the name of the program used to produce listings (including any
# options for the desired formatting).
PRINT = lpr

# SETXPERMISSIONS is the command needed to make the installed files accessible
# to those who will use them.  The value given below makes them readable and
# executable by everyone, and writeable by the owner only.  (If you perform the
# installation as `root', `root' is the owner of the installed files.)
SETXPERMISSIONS = chmod 755

# SETPERMISSIONS is similarly used to make installed data files accessible.
# These files should not be marked as executable.
SETPERMISSIONS = chmod 644

# STRIP is the command used to compact the compiled binaries by removing their
# symbol tables.
STRIP = strip
# To retain the symbol tables for debugging, comment out the previous line, and
# uncomment the next line.
# STRIP = :

# .............................................................................
# This section contains `make' definitions for those applications that require
# function libraries not included in this software package.

# PLIB is the set of C compiler options needed to load the UNIX plot(3)
# library (needed for `dbplot' only).  Normally these should include `-lplot'
# (the device-independent library, requiring the output of `dbplot' to be piped
# into a suitable plot interpreter), but you may wish to use a device-specific
# library if `dbplot' will be used on only one type of graphical output
# device.  Some such libraries may also require `-lm'.  Some USG versions of
# UNIX do not include the plot(3) library or interpreters;  see PLOT for
# more information, along with notes on writing your own plot(3) library.  You
# may compile and install `dbplot' by uncommenting the next two lines.
DBPLOT = dbplot
PLIB = -lplot
# If you don't have a plot(3) library, uncomment the next two lines.
# DBPLOT =
# PLIB =

# If you are installing these applications on a Sun workstation, you may
# compile and install `dbtool' by uncommenting the next two lines.
DBTOOL = dbtool
SLIB = -lsuntool -lsunwindow -lpixrect
# Otherwise, you probably don't have the necessary graphics functions, and
# you will not be able to use `dbtool';  in this case, uncomment the next
# two lines.
# DBTOOL =
# SLIB =
# DPMM should correspond to your screen resolution in pixels per millimeter
# (4.0 for Sun 16" monitors, and 2.83 for Sun 19" monitors;  others may
# vary).  If you are not compiling `dbtool', ignore this variable.
DPMM = 4.0

# Note that `sample', `view', and `vsetup' are MS-DOS programs, not usable
# under UNIX.

#.............................................................................

# The remainder of these site-specific variables are needed only if you wish
# to use `lint' to check the sources.

# LINT is the name of your `lint' command.
LINT = lint

# LCFLAGS are the `lint' options needed to perform checks.  BSD (including
# SunOS and Ultrix) lint does not accept the `-g' and `-O' options as does
# System V lint, so we cannot simply append CFLAGS to these variables for BSD
# lint.  If you have added any `-D' options to CFLAGS, add them to LLFLAGS and
# LCFLAGS as well.  Uncomment the next line if you have BSD lint.
LCFLAGS =
# On System V (and earlier versions of UNIX), uncomment the next line instead.
# LCFLAGS = -ahnu $(CFLAGS)

# It should not be necessary to modify anything below this line.
# -----------------------------------------------------------------------------

CFILES = bxb.c calibrate.c dbcollate.c dbdesc.c dbplot.c dbtool.c dbwhich.c \
 ecgeval.c epic.c fir.c ihr.c mfilt.c mrgann.c mxm.c nst.c plotstm.c \
 pschart.c psfd.c rdann.c rdsamp.c rxr.c sample.c sigamp.c skewedit.c snip.c \
 sortann.c sqrs.c sqrs125.c sumann.c sumstats.c tach.c view.c vsetup.c \
 wrann.c wrsamp.c xform.c
XFILES = bxb calibrate dbcollate dbdesc dbwhich ecgeval epic fir ihr mfilt \
 mrgann mxm nst plotstm pschart psfd rdann rdsamp rxr sigamp skewedit snip \
 sortann sqrs sqrs125 sumann sumstats tach wrann wrsamp xform \
 $(DBPLOT) $(DBTOOL)
PSFILES = pschart.pro psfd.pro
OTHERFILES = PLOT cshsetdb setdb dossetdb.bat sample8.hea
MFILES = Makefile makefile.dos

# General rule for compiling C sources into executable files.  This is
# redundant for most versions of `make', but at least one System V version
# needs it.
.c:
	$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)

# `make' or `make install':  build and install applications, clean up
install:	all
	cp $(XFILES) $(BINDIR)
	cd $(BINDIR); $(SETXPERMISSIONS) $(XFILES)
	cp $(PSFILES) $(PSPDIR)
	cd $(PSPDIR); $(SETPERMISSIONS) $(PSFILES)
	$(MAKE) clean

# `make all': build applications
all:	$(XFILES)
	$(STRIP) $(XFILES)

# `make check':  check sources with `lint' (the `rm' command cleans up files
# generated by SysV `lint' only)
check:
	-$(MAKE) CC=$(LINT) "CFLAGS=$(LCFLAGS)" $(XFILES) 
	rm -f llib-l*.ln

# `make clean':  remove intermediate and backup files
clean:
	rm -f $(XFILES) *.o *~

# `make listing':  print a listing of DB applications sources
listing:
	$(PRINT) README $(MFILES) $(CFILES) $(PSFILES) $(OTHERFILES)

# Rules for compiling applications that require non-standard options

bxb:		bxb.c
	$(CC) $(CFLAGS) bxb.c -o $@ $(LDFLAGS) -lm
dbplot:		dbplot.c
	$(CC) $(CFLAGS) dbplot.c -o $@ $(LDFLAGS) $(PLIB)
dbtool:		dbtool.c
	$(CC) $(CFLAGS) -DDPMM=$(DPMM) dbtool.c -o $@ $(LDFLAGS) $(SLIB)
mxm:		mxm.c
	$(CC) $(CFLAGS) mxm.c -o $@ $(LDFLAGS) -lm
nst:		nst.c
	$(CC) $(CFLAGS) nst.c -o $@ $(LDFLAGS) -lm
plotstm:	plotstm.c
	$(CC) $(CFLAGS) plotstm.c -o $@
pschart:	pschart.c
	$(CC) $(CFLAGS) -DPROLOG=\"$(PSPDIR)/pschart.pro\" pschart.c -o $@ \
          $(LDFLAGS)
psfd:		psfd.c
	$(CC) $(CFLAGS) -DPROLOG=\"$(PSPDIR)/psfd.pro\" psfd.c -o $@ $(LDFLAGS)
sigamp:		sigamp.c
	$(CC) $(CFLAGS) sigamp.c -o $@ $(LDFLAGS) -lm

# Odds and ends.
calibrate.c:
	mv calibr8.c calibrate.c
dbcollate.c:
	mv dbcoll8.c dbcollate.c
