# file: Makefile	G. Moody	 1 May 1990
#			Last revised:  16 November 2001		WAVE 6.5
# `make' description file for WAVE
#
# -----------------------------------------------------------------------------
# WAVE: Waveform analyzer, viewer, and editor
# Copyright (C) 2001 George B. Moody
#
# This program is free software; you can redistribute it and/or modify it 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.
#
# This program is distributed in the hope that it 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
# this program; 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 compile and install WAVE.
# WAVE can be compiled and run only on UNIX systems, although any networked
# system with an X11 server can be used to view its output;  suitable servers
# are available for MS-DOS, the Macintosh, and VAX VMS as well as UNIX.
# In order to compile WAVE, you must have already installed the X11 Xlib
# (libX11.a), XView (libxview.a), and WFDB (libwfdb.a) libraries, and their
# associated header files (in /usr/include/X11, /usr/include/xview, and
# /usr/include/ecg respectively).  The WFDB library source is included with the
# WAVE distribution (in the `lib' directory at the same level as this one).
# Xlib and XView are freely available by anonymous FTP as parts of the X11R4
# distribution from expo.lcs.mit.edu and other sites, or from the MIT Software
# Distribution Center, MIT Room E32-300, Cambridge, MA 02139 USA; telephone
# +1-617-253-6966.  See the main help file (wave.hl0, in this directory) for
# further information.
#
# Before using this file for the first time, check that the site-specific
# variables below are appropriate for your system.  To build and install WAVE,
# just type `make' (from within this directory).
# _____________________________________________________________________________
# file: version.def		G. Moody	24 May 2000
#				Last revised:	8 February 2008
# Each release of the WFDB Software Package is identified by a three-part
# version number, defined here:
MAJOR = 10
MINOR = 4
RELEASE = 6
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 = 1

# 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.8
# _____________________________________________________________________________

# Definitions generated by 'configure'

PACKAGE = wfdb-10.4.6
SRCDIR = "/home/george/wfdb-10.4.6"
LONGDATE = 4 April 2008
SHORTDATE = APRIL 2008
# _____________________________________________________________________________

# file: linux.def		G. Moody	31 May 2000
#				Last revised:  4 August 2005
# '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

# LC and LL are used to determine C compiler and linker options needed to
# enable NETFILES (code that allows applications linked to the WFDB library to
# read input from HTTP and FTP servers, in addition to the standard filesystem
# support available without NETFILES).  The WFDB library can use either
# libcurl (recommended) or libwww to provide NETFILES support.  To use libcurl,
# set LC to `curl-config --cflags` (note the backquotes) and LN to
# `curl-config --libs`.  Otherwise, to use libwww, set LC to
# `libwww-config --cflags` and LL to `libwww-config --libs`.  If neither
# libcurl nor libwww is available, LC and LL should be empty (and NETFILES
# will be disabled).
LC =
LL =

# 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 = $(WFDBROOT)/share/info

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

# 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 = $(WFDBROOT)/share/man

# 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)

# MFLAGS is the set of architecture-dependent (-m*) compiler options, which
# is usually empty.  See the gcc manual for information about gcc's -m options.
MFLAGS =

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

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

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

# ...........................................................................
# This section of definitions is used only when compiling WAVE, which is
# possible only if the XView and Xlib libraries and include files have been
# installed.

# OPENWINHOME specifies the root directory of the OpenWindows hierarchy.
# This is usually /usr/openwin.
OPENWINHOME = /usr/openwin

# OWINCDIR is the directory in which the `xview' directory containing XView
# *.h files is found.
OWINCDIR = $(OPENWINHOME)/include

# OWLIBDIR is the directory in which the XView library is found.
OWLIBDIR = $(OPENWINHOME)/lib

# XHOME specifies the root directory of the X11 hierarchy.
# This is usually /usr/X11R6 (or /usr/X11).
XHOME = /usr/X11R6

# XINCDIR is the directory in which the 'X11' directory containing X11 *.h
# files is found.  This is usually /usr/X11R6/include, although there is often
# a link connecting /usr/include/X11 to this directory.
XINCDIR = $(XHOME)/include

# XLIBDIR is the directory in which the X11 libraries are found.
XLIBDIR = $(XHOME)/lib

# WCFLAGS is the set of C compiler options to use when compiling WAVE.
WCFLAGS = $(CFLAGS) -I$(OWINCDIR) -I$(XINCDIR)

# HELPOBJ can be set to "help.o" if you wish to recompile the XView spot help
# functions in "wave/help.c" (recommended under Linux).
HELPOBJ = help.o
# Otherwise, use the version in libxview by uncommenting the next line:
# HELPOBJ =

# WLDFLAGS is the set of loader options appended to the C compiler command line
# to specify loading the WFDB, XView, and Xlib libraries.
WLDFLAGS = $(LDFLAGS) -L$(OWLIBDIR) -L$(XLIBDIR) -lxview -lolgx -lX11
# Users of Red Hat Linux 5.0 or 5.1 (not later versions), use this instead:
# WLDFLAGS = $(LDFLAGS) -L$(XLIBDIR) $(OWLIBDIR)/libxview.a \
#  $(OWLIBDIR)/libolgx.a -lX11
# This setting avoids incompatibilities with the shared (dynamic) libraries.
# ...........................................................................

# `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	31 May 2000
#				Last revised:   11 May 2006
# Change the settings below as appropriate for your setup.

# Choose directories in which to install WAVE and its ancillary files by
# editing the variables below.  You will need write permission in all of them
# in order to install WAVE successfully, and WAVE users will need read
# permission in all of them.  If the directories don't exist already, they
# will be created with appropriate permissions by the installation procedure.

# This section of site-dependent variables specifies the locations in your
# file system where the WAVE software and data files will be installed.
# You may choose a different set of locations if you prefer, but documentation
# included in this package generally assumes that you have used the defaults
# given here.  You will need write permission in all of the directories named
# in this section, and users of the software will need read permission in all
# of these directories.  Generally, you will need `root' permissions in order
# to install the software in the standard places.

# HELPDIR specifies the directory in which the on-line help files are kept.
# The installation procedure creates a subdirectory, `wave', in HELPDIR, and
# installs several files there.
HELPDIR = $(WFDBROOT)/help

# MENUDIR specifies the directory in which the default analysis menu file is
# kept.
MENUDIR = $(WFDBROOT)/lib

# RESDIR specifies the directory in which X11 client resource files are kept.
RESDIR = $(WFDBROOT)/lib/X11/app-defaults

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

HFILES = wave.h bitmaps.h xvwave.h
CFILES = wave.c init.c mainpan.c modepan.c helppan.c logpan.c annpan.c edit.c \
 grid.c sig.c annot.c analyze.c scope.c search.c xvwave.c help.c
OFILES = wave.o init.o mainpan.o modepan.o helppan.o logpan.o annpan.o edit.o \
 grid.o sig.o annot.o analyze.o scope.o search.o xvwave.o $(HELPOBJ)
HELPFILES = analysis.hlp buttons.hlp editing.hlp intro.hlp log.hlp news.hlp \
 printing.hlp resource.hlp
OTHERFILES = wave.hl0 wave.info demo.txt Wave.res wavemenu.def Makefile

all:	wave wave.hlp news.hlp

# `make install':  compile and install WAVE and its help files
install:  $(BINDIR) $(HELPDIR)/wave $(MENUDIR) $(RESDIR) wave.hlp news.hlp
	rm -f wave.o analyze.o xvwave.o
	$(MAKE) wave  # make sure all compiled-in paths are up-to-date
	$(STRIP) wave; $(SETXPERMISSIONS) wave;	../install.sh $(BINDIR) wave
	cp $(HELPFILES) wave.hlp wave.info demo.txt $(HELPDIR)/wave
	cd $(HELPDIR)/wave; $(SETPERMISSIONS) $(HELPFILES) wave.info demo.txt
	-cp wavemenu.def $(MENUDIR) && \
	 $(SETPERMISSIONS) $(MENUDIR)/wavemenu.def
	-cp Wave.res $(RESDIR)/Wave && $(SETPERMISSIONS) $(RESDIR)/Wave

# 'make collect': retrieve the installed applications
collect:
	../conf/collect.sh $(BINDIR) wave
	../conf/collect.sh $(HELPDIR)/wave $(HELPFILES) wave.info demo.txt
	../conf/collect.sh $(MENUDIR) wavemenu.def
	../conf/collect.sh $(RESDIR) Wave

uninstall:
	../uninstall.sh $(BINDIR) wave
	../uninstall.sh $(HELPDIR)/wave $(HELPFILES) wave.hlp wave.info \
	  demo.txt
	rmdir $(HELPDIR) || echo "(Ignored)"
	../uninstall.sh $(MENUDIR) wavemenu.def
	../uninstall.sh $(RESDIR) Wave
	../uninstall.sh $(LIBDIR)/X11
	../uninstall.sh $(LIBDIR)

wave:		$(OFILES)
	$(CC) $(WCFLAGS) -o wave $(OFILES) $(WLDFLAGS)

# `make help':  show help text
help:
	@echo "*************************************************************"
	@echo "To print the WAVE manual, type 'make manual'."
	@echo "If you have a PostScript printer, you may also wish to print"
	@echo "the WAVE User's Guide, by typing 'make guide'."
	@echo "*************************************************************"
	@echo
	@../conf/prompt "Press <Return> to view the manual on-screen: "
	@read x
	@echo
	@soelim wave.hl0 | more
	@echo
	@echo "*************************************************************"
	@echo "To print the WAVE manual, type 'make manual'."
	@echo "If you have a PostScript printer, you may also wish to print"
	@echo "the WAVE User's Guide, by typing 'make guide'."
	@echo "*************************************************************"

wave-static:	$(OFILES)
	$(CC) $(WCFLAGS) -o wave-static $(OFILES) -static $(LDFLAGS)

soelim:		soelim.c
	$(CC) -o soelim -O soelim.c

wave.hlp:	soelim wave.hl0 $(HELPFILES)
	./soelim wave.hl0 >wave.hlp

news.hlp:
	sed s/WAVEVERSION/$(WAVEVERSION)/ <wave.prf | sed "s/WHEN/`date`/" | \
	 sed "s%HELPDIR%$(HELPDIR)%" >news.hlp

# `make manual': print the on-line manual
manual:
	./soelim wave.hl0 | $(PRINT)

# `make guide': print the WAVE User's Guide
guide:
	cd ../doc; make wug-book

# `make TAGS':  make an `emacs' TAGS file
TAGS:		$(HFILES) $(CFILES)
	@etags $(HFILES) $(CFILES)

# `make clean':  remove intermediate and backup files
clean:
	rm -f soelim wave wave-static *.o *~ wave.hlp news.hlp

# `make listing':  print a listing of WAVE sources
listing:	wave.hlp news.hlp
	$(PRINT) README REGCARD $(HFILES) $(CFILES) $(HELPFILES) $(OTHERFILES)

# Dependencies and special rules for compilation of the modules of `wave'
wave.o:
	$(CC) -c $(WCFLAGS) -DHELPDIR=\"$(HELPDIR)\" wave.c
init.o:		wave.h xvwave.h init.c
	$(CC) -c $(WCFLAGS) init.c
mainpan.o:	wave.h xvwave.h mainpan.c Makefile
	$(CC) -c $(WCFLAGS) -DWAVEVERSION=\"$(WAVEVERSION)\" mainpan.c
modepan.o:	wave.h xvwave.h modepan.c
	$(CC) -c $(WCFLAGS) modepan.c
helppan.o:	wave.h xvwave.h helppan.c
	$(CC) -c $(WCFLAGS) -DWAVEVERSION=\"$(WAVEVERSION)\" helppan.c
logpan.o:	wave.h xvwave.h logpan.c
	$(CC) -c $(WCFLAGS) logpan.c
annpan.o:	wave.h xvwave.h annpan.c
	$(CC) -c $(WCFLAGS) annpan.c
edit.o:		wave.h xvwave.h edit.c
	$(CC) -c $(WCFLAGS) edit.c
grid.o:		wave.h xvwave.h grid.c
	$(CC) -c $(WCFLAGS) grid.c
search.o:	wave.h xvwave.h search.c
	$(CC) -c $(WCFLAGS) search.c
sig.o:		wave.h xvwave.h sig.c
	$(CC) -c $(WCFLAGS) sig.c
annot.o:	wave.h xvwave.h annot.c
	$(CC) -c $(WCFLAGS) -DWAVEVERSION=\"$(WAVEVERSION)\" annot.c
analyze.o:
	$(CC) -c $(WCFLAGS) -DMENUDIR=\"$(MENUDIR)\" analyze.c
scope.o:	wave.h xvwave.h scope.c
	$(CC) -c $(WCFLAGS) scope.c
xvwave.o:
	$(CC) -c $(WCFLAGS) -DRESDIR=\"$(RESDIR)\" xvwave.c
help.o:		help.c
	$(CC) -c $(WCFLAGS) -w help.c

# Create directories for installation if necessary.
$(BINDIR):
	mkdir -p $(BINDIR); $(SETDPERMISSIONS) $(BINDIR)
$(HELPDIR):
	mkdir -p $(HELPDIR); $(SETDPERMISSIONS) $(HELPDIR)
$(HELPDIR)/wave:
	mkdir -p $(HELPDIR)/wave; $(SETDPERMISSIONS) $(HELPDIR)/wave
$(MENUDIR):
	mkdir -p $(MENUDIR); $(SETDPERMISSIONS) $(MENUDIR)
$(RESDIR):
	mkdir -p $(RESDIR); $(SETDPERMISSIONS) $(RESDIR)
