# file: Makefile.dos	G. Moody	2 November 1989
#			Last revised:	  24 May 2000
# MSDOS `make' description file template for WFDB applications
#
# -----------------------------------------------------------------------------
# WFDB applications: programs for working with annotated signals
# Copyright (C) 2000 George B. Moody
#
# These programs are free software; you can redistribute them and/or modify
# them under the terms of the GNU General Public License as published by the
# Free Software Foundation; either version 2 of the License, or (at your
# option) any later version.
#
# These programs are distributed in the hope that they will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# these programs; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
# You may contact the author by e-mail (george@mit.edu) or postal mail
# (MIT Room E25-505A, Cambridge, MA 02139 USA).  For updates to this software,
# please visit PhysioNet (http://www.physionet.org/).
# _____________________________________________________________________________
#
# This file is a template for a `make' description file generated by `install',
# which generates `makefile' by concatenating `wfdbcon' with this file (and
# stripping out comments).  To use this file without `install', define these
# variables as appropriate for your system:

#   BINDIR	The directory in which the applications will be installed.
#   CC		The name of the command-line C compiler.
#   CDFLAGS	Optional arguments to be supplied to CC to produce object files
#		 with debugging symbols.
#   COFLAGS	Optional arguments to be supplied to CC to produce optimized
#		 object files (or normal object files if no optimization is
#		 available).
#   WFDBDIR	The directory in which WFDB data files are to be installed. (More
#		 than one directory may be used for this purpose;  WFDBDIR names
#		 the primary writeable directory.  See the discussion of the
#		 WFDB path in the ECG Database Programmer's Guide for details.)
#   LWFDB		CC option to link with the standard WFDB library.
#   LWFDBL	CC option to link with the large model WFDB library.
#   ML		CC option to compile for the large memory model.
#   PSPDIR	The directory in which PostScript prolog files will be
#		 installed.
#   PSPDST	The same as PSPDIR, except that any `\' characters should be
#		 quoted (i.e., represented as `\\';  Borland (Turbo) `make'
#		 requires *four* `\' characters to pass one in a string).
#		 PSPDST should end with a quoted `\'.
#   Q		The string necessary to insert a `"' character into a macro
#		 definition.
#   XXFILES	Optional executables to be built;  these may include any of:
#		   sample.exe
#		   view.exe
#		   vsetup.exe
#		The program `sample' requires hardware and software from
#		Microstar Laboratories; see `sample.c' for details.  The
#		Microstar headers ioutil.h, clock.h, and c_lib.c should be
#		installed in INCDIR, and the Microstar large-model library
#		should be installed in LIBDIR.  Microstar supplies libraries
#		for use with Microsoft C and Turbo C;  copy the appropriate one
#		to LIBDIR and name it `cdapl.lib'.  Do this before attempting
#		to compile `sample'.
#
#		The programs `view' and `vsetup' are written to use the
#		Microsoft C graphics library (`graphics.lib').  Precompiled
#		versions of `view' and `vsetup' are provided in the `bin'
#		directory. 

# Commands needed to build and install the WFDB applications are given below for
# several versions of `make'.
#
# Borland (Turbo) `make':
#    make install
# Microsoft `make' (supplied with Microsoft C before version 6.0):
#    make makefile
# Microsoft `nmake' (supplied with Microsoft C 6.0 and later versions):
#    nmake install

# Most versions of `make' allow you to override the settings of make variables
# from the command line, so that it may not be necessary to edit this file to
# test the effects of small modifications to it.

# For optimized code, uncomment the next line.
CFLAGS = $(COFLAGS)
# Otherwise, if you modify the sources and need to debug them, uncomment the
# next line.
# CFLAGS = $(CDFLAGS)

# Except as noted at the end of this file, it should not be necessary to modify
# anything below this line.
# -----------------------------------------------------------------------------

XFILES = bxb.exe calsig.exe ecgeval.exe epic.exe fir.exe ihr.exe mfilt.exe \
 mrgann.exe mxm.exe nst.exe plotstm.exe pschart.exe psfd.exe rdann.exe \
 rdsamp.exe rxr.exe sampfreq.exe sigamp.exe skewedit.exe snip.exe sortann.exe \
 sqrs.exe sqrs125.exe sumann.exe sumstats.exe tach.exe wfdbcol8.exe \
 wfdbdesc.exe wfdbwhic.exe wrann.exe wrsamp.exe wvscript.exe xform.exe \
 $(XXFILES)

# General rule for compiling C sources into executable files
.c.exe:
	$(CC) $(CFLAGS) $*.c $(LWFDB)

# Rules for compiling programs that require non-standard options
# (Only Borland C/C++ 4.0 is known to require the large model to compile bxb,
# epic, nst, pschart, psfd, rxr, sumstats, and xform.  If your compiler permits
# it, you may get slightly faster executables of these programs using the small
# model.)

bxb.exe:	bxb.c
	$(CC) $(CFLAGS) $(ML) $*.c $(LWFDBL)

calsig.exe:	calsig.c
	$(CC) $(CFLAGS) $(ML) $*.c $(LWFDBL)

epic.exe:	epic.c
	$(CC) $(CFLAGS) $(ML) $*.c $(LWFDBL)

nst.exe:	nst.c
	$(CC) $(CFLAGS) $(ML) $*.c $(LWFDBL)

plotstm.exe:	plotstm.c
	$(CC) $(CFLAGS) $*.c

pschart.exe:	pschart.c
	$(CC) $(CFLAGS) $(ML) -DPROLOG=$(Q)$(PSPDST)pschart.pro$(Q) $*.c $(LWFDBL)

psfd.exe:	psfd.c
	$(CC) $(CFLAGS) $(ML) -DPROLOG=$(Q)$(PSPDST)psfd.pro$(Q) $*.c $(LWFDBL)

rxr.exe:	rxr.c
	$(CC) $(CFLAGS) $(ML) $*.c $(LWFDBL)

sample.exe:	sample.c
	-$(CC) $(CFLAGS) $(ML) $*.c $(LSAMPLE)

sumstats.exe:	sumstats.c
	$(CC) $(CFLAGS) $(ML) $*.c $(LWFDBL)

view.exe:	view.c
	cl -Ox view.c -link wfdb graphics

vsetup.exe:	vsetup.c
	cl -Ox vsetup.c -link graphics

xform.exe:	xform.c
	$(CC) $(CFLAGS) $(ML) $*.c $(LWFDBL)

$(BINDIR):
	-mkdir $(BINDIR)

$(PSPDIR):
	-mkdir $(PSPDIR)

install:	$(XFILES) $(BINDIR) $(PSPDIR)
	copy *.exe $(BINDIR)
	copy setwfdb.bat $(BINDIR)
	copy *.pro $(PSPDIR)

# If you are using Microsoft `make', you may wish to comment out the next
# three lines to avoid having `make' clean up automatically.
clean:
	del *.obj
	del *.exe
