# file: Makefile	G. Moody	24 June 1989
#			Last revised: 20 December 2001
# `make' description file for the WFDB Applications Guide
#
# -----------------------------------------------------------------------------
# WFDB applications: programs for working with annotated signals
# Copyright (C) 2001 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 create and install on-line
# versions of the WFDB Applications Guide, and also to print it.  Before using
# this file for the first time, check that the site-specific variables below
# are appropriate for your system.

# The WFDB Applications Guide documents the application programs provided in
# the app, convert, psd, wave (briefly), and wview subdirectories of wfdb, as
# well as the file formats supported by the WFDB Software Package. It also
# includes a tutorial on evaluation of arrhythmia and ischemia detectors using
# this software and standard databases.

# The most recent version of this guide is always available on PhysioNet
# (follow the links from http://www.physionet.org/physiotools/manuals.shtml).
# Use any web browser to read it.

# If you follow the instructions for a standard installation of the WFDB
# Software Package, the man pages from this directory will be installed so they
# can be read using 'man', 'xman', etc.  The individual pages will be
# accessible to the UNIX `man' command, and to similar commands such as `xman',
# provided that MANDIR (see below) is in your MANPATH (type `man man' for
# further information).

# If you have the necessary formatting software, these man pages and the
# remainder of the WFDB Applications Guide can be produced in a wide variety of
# formats from the sources in in this directory.  Here is a brief list of
# available formats and the commands needed to produce them:

# printed copy	'make wag-book'(requires troff, tbl, latex, dvips, & a printer)
# HTML		'make wag.html'(requires rman, latex2html, and perl)
# man pages	'make wag.man'
# PDF		'make wag.pdf' (requires troff, tbl, latex, dvips, and ps2pdf)
# PostScript	'make wag.ps'  (requires troff, tbl, latex, and dvips)
# _____________________________________________________________________________
# file: version.def		G. Moody	24 May 2000
#				Last revised:  8 August 2002
# Each release of the WFDB Software Package is identified by a three-part
# version number, defined here:
MAJOR = 10
MINOR = 2
RELEASE = 7
VERSION = $(MAJOR).$(MINOR).$(RELEASE)

# RPMRELEASE can be incremented if changes are made between official
# releases.  It should be reset to 1 whenever the VERSION is changed.
RPMRELEASE = 2

# VDEFS is the set of C compiler options needed to set version number variables
# while compiling the WFDB Software Package.
VDEFS = -DWFDB_MAJOR=$(MAJOR) -DWFDB_MINOR=$(MINOR) -DWFDB_RELEASE=$(RELEASE)

# WAVEVERSION is the WAVE version number.
WAVEVERSION = 6.5
# _____________________________________________________________________________

# Definitions generated by 'configure'

PACKAGE = wfdb-10.2.7
LONGDATE = 8 August 2002
SHORTDATE = AUGUST 2002
# _____________________________________________________________________________

# file: linux.def		G. Moody	31 May 2000
#				Last revised: 17 December 2001
# 'make' definitions for compiling the WFDB Software Package under Linux

# Choose a value for WFDBROOT to determine where the WFDB Software Package will
# be installed.  One of the following is usually a reasonable choice.
# Installing in /usr generally requires root permissions, but will be easiest
# for future software development (no special -I or -L options will be needed
# to compile software with the WFDB library, since the *.h files and the
# library will be installed in the standard directories).
WFDBROOT = /usr
# Installing in /usr/local usually requires root permissions.  On a multi-user
# system where it is desirable to keep the OS vendor's software separate from
# other software, this is a good choice.  Another common choice in such cases
# is /opt .
# WFDBROOT = /usr/local
# To install without root permissions, a good choice is to set WFDBROOT to the
# name of your home directory, as in the example below (change as needed).
# WFDBROOT = /home/frodo

# If the W3C's libwww library of HTTP and FTP client code is available, and
# you wish to compile a WFDB library with NETFILES support, set LWC to
# 'libwww-config' (a utility supplied with libwww).  Otherwise set LWC to ':'
# (a program that does nothing, successfully).
LWC = libwww-config

# LDLIBWWW, which is appended to LDFLAGS below, is the set of options needed
# to link with libwww.  If libwww is not installed, or if libwfdb is a shared
# library, LDLIBWWW can be empty (if there is a '#' immediately after the '='
# below, the remainder of the line is ignored, so LDLIBWWW is empty in this
# case).  Otherwise, it is generated from the output of LWC.  Note that up to
# three passes through the option list are necessary to satisfy all
# dependencies when linking to the static libwww libraries.
LDLIBWWW = # `$(LWC) --libs` `$(LWC) --libs` `$(LWC) --libs`

# 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.
BINDIR = $(WFDBROOT)/bin

# DBDIR specifies the name of a directory in which to install the contents
# of the `data' directory.
DBDIR = $(WFDBROOT)/database

# INCDIR specifies the name of a directory in which to install the WFDB
# library's #include <...> files.
INCDIR = $(WFDBROOT)/include

# INFODIR is the GNU info directory (optional, needed to `make info').
INFODIR = /usr/share/info

# LIBDIR specifies the name of a directory in which to install the WFDB
# library.
LIBDIR = $(WFDBROOT)/lib

# PSPDIR specifies the name of a directory in which to install the PostScript
# prolog (*.pro) files from the 'app' directory.
PSPDIR = $(WFDBROOT)/lib/ps

# CC is the name of your C compiler.
CC = gcc

# CCDEFS is the set of C compiler options needed to set preprocessor variables
# while compiling the WFDB Software Package.  CCDEFS should always include
# VDEFS.
CCDEFS = $(VDEFS)

# CFLAGS is the set of C compiler options.  CFLAGS should always include
# CCDEFS.
CFLAGS = -g -O $(CCDEFS) `$(LWC) --cflags` -I$(INCDIR)

# LDFLAGS is appended to the C compiler command line to specify loading the
# WFDB library.
LDFLAGS = -L$(LIBDIR) -lwfdb $(LDLIBWWW)

# WFDBLIB is the name of the standard WFDB library.  In order to access it via
# `-lwfdb', WFDBLIB should be `libwfdb.a'.
WFDBLIB = libwfdb.a

# BUILDLIB is the command that creates the static WFDB library once its
# components have been compiled separately;  the list of *.o files that
# make up the library will be appended to BUILDLIB.
BUILDLIB = $(AR) $(ARFLAGS) $(WFDBLIB)

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

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

# SETDPERMISSIONS is similarly used to make directories created during the
# installation accessible.
SETDPERMISSIONS = chmod 755

# SETLPERMISSIONS is the command needed to make the WFDB library usable by
# programs linked to it.
SETLPERMISSIONS = chmod 644

# SETXPERMISSIONS is the command needed to make the applications accessible.
SETXPERMISSIONS = chmod 755

# 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 = :

# `make' (with no target specified) will be equivalent to `make all'.
make-all:	all

# `make lib-post-install' should be run after installing the WFDB library.
lib-post-install:
	ranlib $(LIBDIR)/$(WFDBLIB)

lib-post-uninstall:
	echo "Nothing to be done for lib-post-uninstall"
# _____________________________________________________________________________
# file: Makefile.tpl		G. Moody	 24 May 2000
#				Last revised:   8 August 2002
# Change the settings below as appropriate for your setup.

# D2PARGS is a list of options for dvips.  Uncomment one of these to set the
# paper size ("a4" is most common except in the US and Canada):
# D2PARGS = -t a4
D2PARGS = -t letter

# LN is a command that makes the file named by its first argument accessible
# via the name given in its second argument.  If your system supports symbolic
# links, uncomment the next line.
LN = ln -sf
# Otherwise uncomment the next line if your system supports hard links.
# LN = ln
# If your system doesn't support links at all, copy files instead.
# LN = cp

# MANDIR is the root of the man page directory tree.  On most systems, this is
# something like /usr/man or /usr/local/man (type 'man man' to find out).
MANDIR = /usr/local/man

# MAN1, MAN3, MAN5, and MAN7 are the directories in which local man pages for
# section 1 (commands), section 3 (libraries), section 5 (formats), and
# section 7 (conventions and miscellany) go.  You may wish to use
# $(MANDIR)/manl for all of these; if so, uncomment the next four lines.
# MAN1 = $(MANDIR)/manl
# MAN3 = $(MANDIR)/manl
# MAN5 = $(MANDIR)/manl
# MAN7 = $(MANDIR)/manl
# Uncomment the next four lines to put the man pages in with the standard
# ones.
MAN1 = $(MANDIR)/man1
MAN3 = $(MANDIR)/man3
MAN5 = $(MANDIR)/man5
MAN7 = $(MANDIR)/man7
# If you want to put the man pages somewhere else, edit 'maninst.sh' first.

# PSPRINT is the name of the program that prints PostScript files. If your
# printer is not a PostScript printer, see the GhostScript documentation to see
# how to do this (since the figure files are in PostScript form, it is not
# sufficient to use a non-PostScript dvi translator such as dvilj).
PSPRINT = lpr

# TROFF is the name of the program that prints UNIX troff files (needed to
# 'make ag' and for the covers of the guides).  Use 'groff' if you have
# GNU groff (the preferred formatter).
TROFF = groff
# Use 'ptroff' if you have Adobe TranScript software.
# TROFF = ptroff
# Consult your system administrator if you have neither 'groff' nor 'ptroff'.
# Other (untested) possibilities are 'psroff', 'ditroff', 'nroff', and 'troff'.

# TMAN is the TROFF option needed to load the 'man' macro package.  This should
# not need to be changed unless your system is non-standard;  see the file
# 'tmac.dif' for comments on a page-numbering bug in some versions of the 'man'
# package.
# TMAN = -man
# Use the alternate definition below to get consecutively numbered pages using
# GNU groff.  Omit -rD1 if the final document will be printed on only one side
# of each page.
TMAN = -rC1 -rD1 -man

# TMS is the TROFF option needed to load the 'ms' macro package.  Use the
# following definition to get the standard 'ms' macros.
# TMS = -ms
# Use the following definition to get the GNU groff version of the 'ms' macros.
TMS = -mgs

# WAGPSREQ is the target that must be made in order to make the PostScript
# version of the manual (wag.ps), and MAKEWAGPS is the command that must be
# run in order to do this.  The process is a bit convoluted, because the
# simple PostScript version (wag0.ps) is concatenated from several PostScript
# files and thus lacks DSCs (document structuring comments).  wag0.ps can be
# printed or viewed directly, but most (perhaps all) viewers are incapable of
# allowing the user to jump to a random page in a PostScript file that lacks
# DSCs, and it's not easy to select a subset of pages to print in such a
# file.  If you have ghostscript version 7.x or later (earlier versions will
# not work properly), ps2pdf (included with ghostscript) and acroread (or
# pdftops), you can translate wag0.ps into PDF (adding the DSCs in the
# process), and then translate the PDF file back into PostScript with DSCs.
# A disadvantage of this is that the PDF version is roughly 25% larger than
# wag0.ps, and the final PostScript version is nearly twice as large as
# wag0.ps, and takes longer to render as a result.  To enable creation of
# PostScript with DSCs in this way, uncomment the next two lines:
WAGPSREQ = wag.pdf
MAKEWAGPS = acroread -toPostScript -level1 -fast wag.pdf
# You can use pdftops instead of acroread by commenting out the previous line
# and uncommenting the next one.
# MAKEWAGPS = pdftops wag.pdf
# Otherwise, uncomment the next two lines instead:
# WAGPSREQ = wag0.ps
# MAKEWAGPS = cp wag0.ps wag.ps

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

.IGNORE:

all:	wag.html wag.ps wag.pdf
	cp -p wag.ps wag.pdf ../wag

install:	wag.man

uninstall:
	../../uninstall.sh $(MAN1) *.1 ad2m.1 ann2rr.1 m2a.1 md2a.1 hrlomb.1 \
	 hrmem.1 hrplot.1 plot3d.1 cshsetwfdb.1 vsetup.1 rr2ann.1 gtkwave.1
	../../uninstall.sh $(MAN3) *.3
	../../uninstall.sh $(MAN5) *.5
	../../uninstall.sh $(MAN7) *.7
	rm -f ../wag/*

# 'make wag-book': print a copy of the WFDB Applications Guide
wag-book:	wag0.ps
	cp wag.cover wagcover
	echo $(SHORTDATE) >>wagcover
	echo .bp >>wagcover
	$(TROFF) wagcover >wagcover.ps
	$(PSPRINT) wagcover.ps
	$(PSPRINT) wag0.ps

# 'make wag.html': format the WFDB Applications Guide as HTML
wag.html:
	cp -p ../misc/icons/* fixag.sh fixag.sed ../wag
	./manhtml.sh ../wag *.1 *.3 *.5 *.7
	latex2html -dir ../wag -local_icons -prefix in \
	 -up_url="wag.htm" -up_title="WFDB Applications Guide" install
	latex2html -dir ../wag -local_icons -prefix ev \
	 -up_url="wag.htm" -up_title="WFDB Applications Guide" eval
	cd ../wag; rm -f index.html WARNINGS *.aux *.log *.tex
	sed "s/LONGDATE/$(LONGDATE)/" <intro.ht0 >../wag/intro.htm
	sed "s/LONGDATE/$(LONGDATE)/" <faq.ht0 >../wag/faq.htm
	cd ../wag; ./fixag.sh "$(LONGDATE)" *.html; rm -f fixag.sh images.*
	cd ../wag; rm -f .I* .ORIG_MAP *.html *.pl fixag.sed
	sed "s/LONGDATE/$(LONGDATE)/" <wag.ht0 | \
	  sed "s/VERSION/$(VERSION)/" >../wag/wag.htm
	cd ../wag; ln -s wag.htm index.html

# 'make wag.man': install the man pages from the WFDB Applications Guide
wag.man:
	test -d $(MAN1) || ( mkdir -p $(MAN1); $(SETDPERMISSIONS) $(MAN1) )
	test -d $(MAN3) || ( mkdir -p $(MAN3); $(SETDPERMISSIONS) $(MAN3) )
	test -d $(MAN5) || ( mkdir -p $(MAN5); $(SETDPERMISSIONS) $(MAN5) )
	test -d $(MAN7) || ( mkdir -p $(MAN7); $(SETDPERMISSIONS) $(MAN7) )
	./maninst.sh $(MAN1) $(MAN3) $(MAN5) $(MAN7) "$(SETPERMISSIONS)"
	$(LN) $(MAN1)/a2m.1 $(MAN1)/ad2m.1
	$(LN) $(MAN1)/a2m.1 $(MAN1)/ahaconvert.1
	$(LN) $(MAN1)/a2m.1 $(MAN1)/m2a.1
	$(LN) $(MAN1)/a2m.1 $(MAN1)/md2a.1
	$(LN) $(MAN1)/ann2rr.1 $(MAN1)/rr2ann.1
	$(LN) $(MAN1)/hrfft.1 $(MAN1)/hrlomb.1
	$(LN) $(MAN1)/hrfft.1 $(MAN1)/hrmem.1
	$(LN) $(MAN1)/hrfft.1 $(MAN1)/hrplot.1
	$(LN) $(MAN1)/plot2d.1 $(MAN1)/plot3d.1
	$(LN) $(MAN1)/setwfdb.1 $(MAN1)/cshsetwfdb.1
	$(LN) $(MAN1)/view.1 $(MAN1)/vsetup.1
	$(LN) $(MAN1)/wave.1 $(MAN1)/gtkwave.1

# 'make wag.pdf': format the WFDB Applications Guide as PDF
wag.pdf:	wag0.ps
	ps2pdf wag0.ps wag.pdf

# 'make wag.ps': format the WFDB Applications Guide as PostScript
wag.ps:		$(WAGPSREQ)
	$(MAKEWAGPS)

wag0.ps:	wag.tex appguide.int install.tex eval.tex
	sed 's/VERSION/$(VERSION)/' <wag.tex | \
	 sed 's/LONGDATE/$(LONGDATE)/' >wag1.tex
	latex wag1
	dvips -o wag1.ps wag1
	sed "s/LONGDATE/$(LONGDATE)/" <appguide.int | \
	  sed "s/VERSION/$(VERSION)/" | \
	  tbl | \
	  $(TROFF) $(TMS) -o3- >wag2.ps
	tbl *.1 *.3 *.5 | $(TROFF) $(TMAN) >wag3.ps
	sed "s/LONGDATE/$(LONGDATE)/" <install.tex | \
	  sed "s/VERSION/$(VERSION)/" >wag4.tex
	latex wag4
	dvips $(D2PARGS) -o wag4.ps wag4.dvi
	sed "s/LONGDATE/$(LONGDATE)/" <eval.tex | \
	  sed "s/VERSION/$(VERSION)/" >wag5.tex
	latex wag5
	dvips $(D2PARGS) -o wag5.ps wag5.dvi
	cat wag[123].ps blankpage wag4.ps blankpage wag5.ps | grep -v '^%%' >wag0.ps

# 'make clean': remove intermediate and backup files
clean:
	rm -f *.aux *.dvi *.log *.ps *.toc intro.htm faq.htm wag.pdf wagcover \
	      wag[145].tex *~
