# -*-Mode: indented-text;-*-
# Makefile:    cdunif makefile
#
# Copyright:   1996, Regents of the University of California
#	       This software may not be distributed to others without
#	       permission of the author.
#
# Author:      Bob Drach, Lawrence Livermore National Laboratory
#              drach@llnl.gov
#
# Version:     $Id$
#
# Revision History:
#
# $Log: Makefile.in,v $
# Revision 1.4  1997/11/24  17:28:29  drach
# - Added QL package to cdunif
# - Added NdimIntersect function to CDMS
#
# Revision 1.3  1997/11/10  19:22:40  drach
# - Added cuvargets to cdunif, cdSlabRead to cdms
#
# Revision 1.2  1997/09/26  21:47:40  drach
# - Added caching of netCDF unlimited dimension
#
# Revision 1.1  1996/09/09  18:22:08  drach
# - Integrated with configuration scripts
# - (CRAY) added ieee2cray conversion
# - GrADS/GRIB I/O works on all platforms now
# - Support for platform-independent gribmap
#
#
# Note: Makefile is generated from Makefile.in by top level configure
#

# Install prefix for architecture-independent files
prefix=         @prefix@

# Install prefix for architecture-dependent files
exec_prefix=    @exec_prefix@

# Expanded directories
BINDIR=$(exec_prefix)/bin
INCLUDEDIR=$(prefix)/include
LIBDIR=$(exec_prefix)/lib
MANDIR=$(prefix)/man
PARMDIR=$(prefix)/lib/lats

# Set the compiler flag for the 64-bit Opteron platform
ARCH=$(shell uname -m)
ifeq ($(ARCH),x86_64)
   CC = gcc -fPIC -D__x86_64__
else
   CC = @CC@
endif
ifneq (@GRIB2INC@,)
 CFLAGS = -I../../include -I"@NCINC@" -I@HDFINC@ -I@DRSINC@ @CFLAGS@ $(DEBUG) -Dgrads -I@GRIB2INC@ @GRIB2OPTS@
else
 CFLAGS = -I../../include -I"@NCINC@" -I@HDFINC@ -I@DRSINC@ @CFLAGS@ $(DEBUG)
endif
CPPFLAGS = @CPPFLAGS@ -DSTNDALN=1 -DBYTEORDER=@GRADS_BYTEORDER@ -DGRADS_CRAY=@GRADS_CRAY@ @QLOPTS@ @PPOPTS@ @GRIB2OPTS@
DEBUG = -O
DEFS = @DEFS@
FC = @FC@
FFLAGS = -I../../include @FFLAGS@ $(DEBUG)
INSTALL = @INSTALL@
INSTALL_PROGRAM = @INSTALL_PROGRAM@
LDFLAGS = -L../../../lib -lcdms @NCOPTS@ @HDFOPTS@ @DRSOPTS@ @LIBS@ @GRIB2LIB@
OS = @OS@
RANLIB = @RANLIB@

# Shell to run make subcommands
SHELL = /bin/sh

# Do not change values below this line
#
LIBRARY		= ../../lib/libcdms.a
OBJS		= cdunif.o cdunifint.o cdunifgen.o cdunifdrs.o cdunifgrads.o cdunifnc.o cdunifhdf.o cdunifslab.o cdunifstub.o cdunifra.o cdrra.o cdsort.o gamach.o gaio.o gaprnt.o gautil.o gaddes.o galloc.o gabufr.o gabufrtbl.o cdunifql.o @GRADS_IEEE2CRAY_OBJECT@

all:		$(OBJS) FORCE
		ar rv $(LIBRARY) $(OBJS)
		cd cdunifpp; $(MAKE) DEBUG=$(DEBUG)
		$(RANLIB) $(LIBRARY)

cdunif.o:	cdunif.c ../../include/cdunifint.h ../../include/cdunif.h
cdunifint.o:	cdunifint.c ../../include/cdunifint.h ../../include/cdunif.h
cdunifgen.o:	cdunifgen.c ../../include/cdunifint.h ../../include/cdunif.h
cdunifdrs.o:	cdunifdrs.c
cdunifgrads.o:	cdunifgrads.c ../../include/cdmsint.h ../../include/cdms.h ../../include/cdunif.h ../../include/cdunifint.h ../../include/grads.h
cdunifhdf.o:	cdunifhdf.c ../../include/cdunifint.h
cdunifnc.o:	cdunifnc.c ../../include/cdunifint.h
cdunifslab.o:	cdunifslab.c ../../include/cdunifint.h
cdunifstub.o:	cdunifstub.c ../../include/cdunifint.h ../../include/cdunif.h
cdunifra.o:	cdunifra.c ../../include/cdunifint.h ../../include/cdunif.h
cdrra.o:	cdrra.c ../../include/cdunif.h
cdsort.o:	cdsort.c
gamach.o:	gamach.c ../../include/grads.h
gaio.o:         gaio.c ../../include/grads.h
gaprnt.o:	gaprnt.c ../../include/grads.h
gautil.o:	gautil.c ../../include/grads.h
gaddes.o:	gaddes.c ../../include/grads.h
cdunifql.o:	cdunifql.c ../../include/cdmsint_new.h ../../include/cdunifint.h
galloc.o:	galloc.c ../../include/grads.h ../../include/gatypes.h
gabufr.o:	gabufr.c ../../include/grads.h ../../include/gatypes.h
gabufrtbl.o:	gabufrtbl.c ../../include/grads.h ../../include/gatypes.h

ieee2cray.o:	ieee2cray.f
		cft77 -i 64 -a static -Rb ieee2cray.f

.SUFFIXES: .F

.c.o:
	$(CC) $(CPPFLAGS) $(DEFS) $(CFLAGS) -c $<

.c:
	$(CC) $(CPPFLAGS) $(DEFS) $(CFLAGS) -o $@ $< $(LDFLAGS)

.F:
	case $(OS) in \
	     'aix') \
		    /usr/ccs/lib/cpp -P $(CPPFLAGS) $(CFLAGS) $(INCLUDES) $(DEFS) $< $@.f; \
		    $(FC) $(FFLAGS) $(LDFLAGS) $(LIBS) $@.f -o $@; \
		    rm $@.f; \
		    ;; \
	     *) \
		    $(FC) $(CPPFLAGS) $(INCLUDES) $(DEFS) $(FFLAGS) -o $@ $< $(LDFLAGS) $(LIBS); \
		    ;; \
	esac

clean:
	-rm -f *.o core *.~*~
	cd cdunifpp; $(MAKE) clean

distclean: clean

FORCE:
