# file: Makefile-dos-gcc	G. Moody	 23 April 1997
#				Last revised:	  24 May 2000
# GCC-DOS 'make' description file 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 used with the UNIX `make' command to cross-compile MS-DOS
# binaries of the standard applications that come with the WFDB 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 -f Makefile-dos-gcc' (from within this
# directory).

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

# CCDIR is the directory containing the cross-compiler and the binary
# file utilities for MSDOS.
CCDIR = /usr/lib/gcc-lib/i386-go32-msdos/2.7.2

# CC is the name of the cross-compiler.
CC = $(CCDIR)/gcc

# CCDEFS is the set of C compiler options needed to set preprocessor variables
# while compiling the WFDB Software Package.  You should include definitions of
# the major, minor, and release numbers, and of MSDOS, as shown below.  Other
# definitions are needed only for various versions of UNIX and should be
# omitted here.
CCDEFS = -DWFDB_MAJOR=$(MAJOR) -DWFDB_MINOR=$(MINOR) -DWFDB_RELEASE=$(RELEASE)\
  -DMSDOS

# CFLAGS is the list of C compiler options used when compiling programs in the
# `app', `convert', and `example' directories.  Add the following options to
# CFAPP as appropriate (separating them by spaces if you use more than one):
#   -g		  to save symbols for debugging
#   -O		  to use the optimizer
#   -I$(INCDIR)   needed if INCDIR is not in the normal search path for
#		   `#include' files;  harmless otherwise
#   -L$(LIBDIR)   needed if LIBDIR is not in the normal library search path;
#		   harmless if LIBDIR is in the normal library search path
# As noted above, gcc-dos allows you to use both -g and -O if you wish.
CFLAGS = -O -I/usr/local/dos/include $(CCDEFS) -L/usr/local/dos/lib

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

# 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/dos/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/dos/lib/ps

# STRIP is the command used to compact the compiled binaries by removing their
# symbol tables.  The next line is commented out because $(CCDIR)/strip fails.
# STRIP = $(CCDIR)/strip
# To retain the symbol tables for debugging, comment out the previous line, and
# uncomment the next line.
STRIP = :

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

CFILES = bxb.c calsig.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 wfdbcollate.c wfdbdesc.c wfdbwhich.c wrann.c wrsamp.c \
 xform.c
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 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 xform.exe
PSFILES = pschart.pro psfd.pro

# General rule for compiling C sources into executable files.
.SUFFIXES: .exe
.c.exe:
	$(CC) $(CFLAGS) $< -o $@ $(LDFLAGS)

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

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

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

# Rules for compiling applications that require non-standard options

bxb.exe:	bxb.c
	$(CC) $(CFLAGS) bxb.c -o $@ $(LDFLAGS) -lm
calsig.exe:	calsig.c
	$(CC) $(CFLAGS) calsig.c -o $@ $(LDFLAGS)
wfdbcol8.exe:	wfdbcollate.c
	$(CC) $(CFLAGS) wfdbcollate.c -o $@ $(LDFLAGS)
wfdbwhic.exe:	wfdbwhich.c
	$(CC) $(CFLAGS) wfdbwhich.c -o $@ $(LDFLAGS)
mxm.exe:	mxm.c
	$(CC) $(CFLAGS) mxm.c -o $@ $(LDFLAGS) -lm
nst.exe:	nst.c
	$(CC) $(CFLAGS) nst.c -o $@ $(LDFLAGS) -lm
plotstm.exe:	plotstm.c
	$(CC) $(CFLAGS) plotstm.c -o $@
pschart.exe:	pschart.c
	$(CC) $(CFLAGS) -DPROLOG=\"$(PSPDIR)/pschart.pro\" pschart.c -o $@ \
          $(LDFLAGS)
psfd.exe:	psfd.c
	$(CC) $(CFLAGS) -DPROLOG=\"$(PSPDIR)/psfd.pro\" psfd.c -o $@ $(LDFLAGS)
sigamp.exe:	sigamp.c
	$(CC) $(CFLAGS) sigamp.c -o $@ $(LDFLAGS) -lm
