# file: Makefile	G. Moody	24 June 1989
#			Last revised: 20 December 2001
# `make' description file for the WAVE User's 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 WAVE User's 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 WAVE User's Guide includes a comprehensive tutorial, with reference
# material, for WAVE, an interactive waveform browser with facilities for
# annotation editing and control of external analysis programs.  The WAVE
# User's Guide documents the original version of WAVE, which has an XView
# (Open Look) GUI and runs on PCs under Linux, and on SPARC-based systems
# under SunOS or Solaris.  A beta version of WAVE with a GTK+ GUI runs under
# Linux and under MS-Windows and is similar enough to the original WAVE that
# the WAVE User's Guide can be used for reference;  for further information,
# search for GTKWave on PhysioNet.

# 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 have the necessary formatting software, the WAVE User's 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 wug-book' (requires troff, latex, dvips, and a printer)
# HTML		'make wug.html' (requires latex2html and perl)
# PDF		'make wug.pdf'  (requires pdflatex)
# PostScript	'make wug.ps'   (requires 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:	18 July 2002
# Change the settings below as appropriate for your setup.

# Set COLORS to 'color' if you have a color printer and would like to print
# in color, or if your non-color printer accepts and prints color PostScript
# acceptably (most modern PostScript printers do, and Ghostscript also converts
# color to shades of grey acceptably.)  Set COLORS to 'grey' otherwise.
COLORS = color
#COLORS = grey

# 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

# 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
# print the cover of the guide).  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'.

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

.IGNORE:

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

install:
	@echo Nothing to install in wug-src.

uninstall:
	rm -f ../wug/*

# 'make wug-book': print a copy of the WAVE User's Guide
wug-book:	wug.ps
	cp wug.cover wugcover
	echo $(SHORTDATE) >>wugcover
	echo .bp >>wugcover
	$(TROFF) wugcover >wugcover.ps
	$(PSPRINT) wugcover.ps
	$(PSPRINT) wug.ps

# 'make wug.html': format the WAVE User's Guide as HTML
#   'wug.aux' is listed as a prerequisite because the figure numbers are
#   recorded there.  It doesn't matter if it was created by latex or pdflatex.
#   Note that the file 'wug.html' created at the end of this process is empty;
#   it is created only so that 'make' can easily determine if the real HTML
#   files (in ../wug/) are up-to-date.
wug.html:	wug.tex wug.aux
	cp -p ../misc/icons/* wave/png/* ../../examples/stdev.c \
	 wave/misc/example.xws ../wug
	wave/scripts/wugfigures -color	# get a set of figures
	latex2html -dir ../wug -local_icons \
	 -up_url="../manuals.shtml" -up_title="Books about PhysioToolkit" wug
	cp wave/scripts/dossify-html wave/scripts/fixlinks ../wug
	cd ../wug; ./dossify-html *.html
	cd ../wug; rm -f dossify-html fixlinks *.html *.orig
	cd ../wug; rm -f .ID_MAP .IMG_PARAMS .ORIG_MAP images.*
	mv ../wug/*.pl .
	wave/scripts/fixwug.sh ../wug
	cd ../wug; ln -s wug.htm index.html; find `pwd` -print | doschk
	wave/scripts/fixinfo >../../wave/wave.info
	touch wug.html

# 'make wug.pdf': format the WAVE User's Guide as PDF
wug.pdf:	wug.tex
	wave/scripts/wugfigures -pdf
	convert -scale 50\% wave/ppm/print-setup-window.ppm.gz \
	  print-setup-window.pdf
	convert -scale 50\% wave/ppm/title-with-parens.ppm.gz \
	  title-with-parens.pdf
	# epstopdf chokes on the two files above for some reason.
	# convert does not do a great job on them, but the results are
	# at least recognizable!
	rm -f wug.aux wug.idx wug.ind wug.toc
	pdflatex wug
	makeindex wug.idx
	pdflatex wug
	makeindex wug.idx
	pdflatex wug

# 'make wug.ps': format the WAVE User's Guide as PostScript
wug.ps:		wug.tex
	wave/scripts/wugfigures -$(COLORS)	# get a set of figures
	rm -f wug.aux wug.idx wug.ind wug.toc
	latex wug
	makeindex wug.idx
	latex wug
	makeindex wug.idx
	latex wug
	dvips $(D2PARGS) -o wug.ps wug.dvi

# 'wug.aux' is created by 'latex wug' or 'pdflatex wug' (which make slightly
# different versions of 'wug.aux').  It is a separate target because it is
# needed by 'make wug.html' (to obtain the figure numbers).  Either version
# of 'wug.aux' is acceptable for 'make wug.html'.
wug.aux:	wug.tex
	$(MAKE) wug.ps

wug.tex:	wug0.tex
	sed 's/WVRSN/$(WAVEVERSION)/' <wug0.tex | \
	 sed 's/LONGDATE/$(LONGDATE)/' >wug.tex

# 'make clean': remove intermediate and backup files
clean:
	wave/scripts/wugfigures -clean	# remove figures from this directory
	rm -rf internals.pl labels.pl wug.aux wug.dvi wug.html wug.idx \
	 wug.ilg wug.ind wug.log wug.out wug.pdf wug.ps wug.toc wug.tex \
         .xvpics wugcover* *~
