# Makefile for OASIS Decode routine
# Author:   Bob Herlien
# Project:  OASIS Moorings
# Created:  11/24/91
#

## rules

.s.o :
	@rm -f $@
	$(AS) -o $<

.c.o :
	@rm -f $@
	$(CC) $(CFLAGS) $<


## files and directories

MAKEFILE	= Makefile
ARCHIVE		= decode.tar

INCLUDES	= decode.h argos.h

SOURCES		= decode.c extract.c file.c range.c atlas.c ctd.c no3.c ac9.c \
		  spec.c port.c getoasis.c calsh6.f argos.c argextract.c \
		  argfile.c argfilter.c argmerge.c sendoasis.c gf.c tstring.c showmoor.c

OBJECTS		= $(SOURCES:.c=.o)

ALLFILES	= $(MAKEFILE) $(INCLUDES) $(SOURCES)

## tools
#CC		= cc
#LD		= cc
CC		= /mbari/local/bin/gcc
LD		= /mbari/local/bin/gcc
RM		= rm -f

## flags

INCLUDEFLAGS	= -I.
DEBUGFLAG	= -g
#CFLAGS		= -c -Aa $(DEBUGFLAG) $(INCLUDEFLAGS) -D_HPUX_SOURCE
CFLAGS		= -c -ansi -O -W $(DEBUGFLAG) $(INCLUDEFLAGS) -D_HPUX_SOURCE
LDFLAGS		=
CLDFLAGS	= -ansi -O -W $(DEBUGFLAG) $(INCLUDEFLAGS) -D_HPUX_SOURCE
FFLAGS		= +E1 $(DEBUGFLAG)
LIBS		= -lM


## actions

default : decode extract argos argfilter argextract argmerge

$(ARCHIVE).gz: $(ALLFILES)
	  $(RM) $(ARCHIVE) $(ARCHIVE).Z
	  tar crvf $(ARCHIVE) $(ALLFILES)
	  gzip $(ARCHIVE)

tar	: $(ARCHIVE).gz

rel1:
	  ci -q -u$(REV) $(MAKEFILE) $(INCLUDES) $(SOURCES:decode.c=)

#release :
#	  rcs -l $(ALLFILES)
#	  ci -f -u$(REV) decode.c
#	  @echo "Ignore ci warnings that unchanged file checkins are aborted"
#	  make rel1 REV=`rlog decode.c | awk '$$1 == "head:" {print $$2}'`
#	  rcs -u $(ALLFILES)
	 
release :
	  rcs -l $(ALLFILES)
	  @echo "Ignore ci warnings that unchanged file checkins are aborted"
	  ci -f -q -u$(REV) $(MAKEFILE) $(INCLUDES) $(SOURCES)
	  rcs -u $(ALLFILES)
	 
clean	:
	  $(RM) *.o


## dependencies

$(OBJECTS): $(INCLUDES)

extract : extract.o file.o range.o atlas.o ctd.o no3.o spec.o ac9.o gf.o tstring.o
	 $(RM) extract
	 $(LD) -o extract $(LDFLAGS) extract.o file.o range.o atlas.o ctd.o \
		no3.o spec.o ac9.o gf.o tstring.o $(LIBS)

tstime : tstime.o
	 $(RM) tstime
	 $(LD) -o tstime $(LDFLAGS) tstime.o $(LIBS)

decode : decode.o file.o atlas.o ctd.o no3.o spec.o ac9.o gf.o
	 $(RM) decode
	 $(LD) -o decode $(LDFLAGS) decode.o file.o atlas.o ctd.o no3.o \
		spec.o ac9.o gf.o $(LIBS)

showmoor : showmoor.o
	$(RM) showmoor
	$(LD) -o showmoor $(LDFLAGS) showmoor.o $(LIBS)

m1 :	m1.o
	$(RM) m1
	$(LD) -o m1 $(LDFLAGS) m1.o $(LIBS)

m2 :	m2.o
	$(RM) m2
	$(LD) -o m2 $(LDFLAGS) m2.o $(LIBS)

m3 :	m3.o
	$(RM) m3
	$(LD) -o m3 $(LDFLAGS) m3.o $(LIBS)

drifter : drifter.o
	$(RM) drifter
	$(LD) -o drifter $(LDFLAGS) drifter.o $(LIBS)

getoasis : getoasis.o port.o range.o
	$(LD) -o getoasis $(LDFLAGS) getoasis.o port.o range.o

sendoasis : sendoasis.o port.o
	$(LD) -o sendoasis $(LDFLAGS) sendoasis.o port.o

getctd : getctd.o ctd.o
	 $(RM) getctd
	 $(LD) -o getctd $(LDFLAGS) getctd.o ctd.o $(LIBS)

calsh6 : calsh6.f
	 f77 -o$(PROGRAM) $(FFLAGS) $@

chktmp  : chktmp.c
	  cc -o chktmp $(CFLAGS) chktmp.c $(LIBS)

argos.o : argos.c $(INCLUDES)
	$(CC) $(CFLAGS) -o argos.o argos.c

argfile.o : argfile.c decode.h
	$(CC) $(CFLAGS) -o argfile.o argfile.c

argos  : argos.o argfile.o spec.o ac9.o
	$(LD) -o argos $(LDFLAGS) argos.o argfile.o spec.o ac9.o $(LIBS)

argextract.o : argextract.c $(INCLUDES)
	$(CC) $(CFLAGS) -o argextract.o argextract.c

argextract : argextract.o argfile.o spec.o ac9.o
	$(LD) -o argextract $(LDFLAGS) argextract.o argfile.o spec.o ac9.o $(LIBS)

argfilter : argfilter.c
	$(CC) $(CLDFLAGS) -o argfilter argfilter.c

argmerge : argmerge.c
	$(CC) $(CLDFLAGS) -o argmerge argmerge.c

argfilt1 : argfilt1.c
	$(CC) $(CLDFLAGS) -o argfilt1 argfilt1.c
