# file: Makefile-dos-gcc	G. Moody	23 April 1997
#
# GCC-DOS 'make' description file for compiling the DB library
#
# Copyright(C) Massachusetts Institute of Technology 1997. All rights reserved.

# This file is used with the UNIX `make' command to cross-compile the DB
# library.  Before using it for the first time, check that the site-specific
# variables below are appropriate for your system.  To build and install the
# MS-DOS DB library, just type `make -f Makefile-dos-gcc' (from within this
# directory).

# Version numbers
# ---------------

# Each release of the DB Software Package is identified by a three-part version
# number, defined in this section (unless overridden by settings in the top-
# level Makefile for the DB Software Package).  See the top-level Makefile
# (in the parent of this directory) for details.
MAJOR = 9
MINOR = 7
RELEASE = 0
VERSION = $(MAJOR).$(MINOR).$(RELEASE)

# 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

# INCDIR should be one of the directories searched by CC for #include <...>
# files.
INCDIR = /usr/local/dos/include

# CCDEFS is the set of C compiler options needed to set preprocessor variables
# while compiling the DB 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 = -DDB_MAJOR=$(MAJOR) -DDB_MINOR=$(MINOR) -DDB_RELEASE=$(RELEASE) -DMSDOS

# CFLAGS is the set of C compiler options.  CFLAGS should always include
# CCDEFS.  Add the following options to CFLAGS as appropriate (separating them
# by spaces if you use more than one):
#   -g		  to save symbols for debugging
#   -O		  if you trust your C compiler's optimizer
#   -I$(INCDIR)   needed if INCDIR is not in the normal search path for
#		   `#include' files;  harmless otherwise
# `gcc-dos' is able to accept both -g and -O simultaneously; using a debugger
# on optimized code can be tricky, though, and you may prefer to compile with
# -g and not -O if you need to use a symbolic debugger.  For normal use,
# optimized code is preferable (the gcc optimizer is solid and effective).
CFLAGS = -O -I$(INCDIR) $(CCDEFS)

# LIBDIR should be one of the directories searched by CC's loader for -l...
# libraries.  You will also need to have write permission in LIBDIR.  If you
# plan to make a shared DB library (see below), note that DB application users
# will need to have read permission in LIBDIR.
LIBDIR = /usr/local/dos/lib

# DBLIB is the name of the standard DB library.  In order to access it via
# `-ldb', DBLIB should be `libdb.a'.
DBLIB = libdb.a

# MAKE is the name of the `make' utility itself, in this case with an option
# to use the special gcc-dos Makefiles by default when running a recursive
# make.
MAKE = make -f Makefile-dos-gcc

# AR is the name of the command used to build a `.a' library from `.o'
# files, and ARFLAGS is the set of options used when doing so.
AR = $(CCDIR)/ar
# ARFLAGS = rv

# BUILDLIB is the command to be used to create DBLIB once all of its components
# have been compiled separately.  This will not usually need to be changed.
BUILDLIB = $(AR) $(ARFLAGS) $(DBLIB) $(OFILES)

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

HEADERS = $(INCDIR)/ecg/db.h $(INCDIR)/ecg/ecgcodes.h $(INCDIR)/ecg/ecgmap.h
HFILES = db.h ecgcodes.h ecgmap.h dblib.h
CFILES = dbinit.c annot.c signal.c calib.c dbio.c
OFILES = dbinit.o annot.o signal.o calib.o dbio.o
MFILES = Makefile makefile.dos

# `make' or `make install':  build and install the DB library and headers
install:	$(LIBDIR)/$(DBLIB)
$(LIBDIR)/$(DBLIB):	$(HEADERS) $(OFILES)
	$(BUILDLIB)
	cp $(DBLIB) $(LIBDIR) 

# `make lib': build the library in the current directory
lib:		$(HEADERS) $(OFILES)
	$(BUILDLIB)

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

# Rules for installing the header files
$(INCDIR)/ecg:
	mkdir $(INCDIR)/ecg
$(INCDIR)/ecg/db.h:		$(INCDIR)/ecg db.h
	cp -p db.h $(INCDIR)/ecg
$(INCDIR)/ecg/ecgcodes.h:	$(INCDIR)/ecg ecgcodes.h
	cp -p ecgcodes.h $(INCDIR)/ecg
$(INCDIR)/ecg/ecgmap.h:		$(INCDIR)/ecg ecgmap.h
	cp -p ecgmap.h $(INCDIR)/ecg

# Prerequisites for the library modules
dbinit.o:	$(INCDIR)/ecg/db.h dblib.h dbinit.c
annot.o:	$(HEADERS) dblib.h annot.c
signal.o:	$(INCDIR)/ecg/db.h dblib.h signal.c
calib.o:	$(INCDIR)/ecg/db.h dblib.h calib.c
dbio.o:		$(INCDIR)/ecg/db.h dblib.h dbio.c
