#		@(#)makefile.mex	1.7  12/01/98
#
#	Makefile for gmt <--> matlab conversion programs
#	Use with GMT 3.1 or later
#

include ../makegmt.macros

# 1. Make sure the following are set for your site.
#    (EXT and MEX are currently set for a Sun running Solaris)

MATDIR	= /local/matlab
ARCH	= `arch`
EXT	= mexsol # mexhp3 (HP/9000 s300), mexrs6 (IBM), mexds (Dec), mexsg (SGI), mexvx (Vax), mexsol (Solaris)
#MEX	= -L$(MATDIR)/extern/lib/$(ARCH) -lmex
#MEX	= -L$(MATDIR)/extern/lib/ibm_rs -lmat		# On IBM RS6000 we must set directly
MEX	= -L$(MATDIR)/extern/lib/sol2 -lmat		# On Solaris we must set directly

# 2. If you have write permission in $MATLAB, switch the comments below so the
#    install target becomes upgrade instead of all.

#install:	upgrade
install:	all

#----------------------------------------------------------------------------
#	The rest should should be ok. NO EDITING BEYOND HERE
#----------------------------------------------------------------------------

GMT     = -L.. -lgmt
CDF     = -L$(NETCDF)/lib -lnetcdf
FLAGS	= -I.. -I$(MATDIR)/extern/include -I$(NETCDF)/include


all:		grdinfo grdread grdwrite

upgrade:	all
		cp *.$(EXT) *.m $(MATDIR)/toolbox/local

# Because grdinfo is also a GMT program the source here is called
# grdinfo2.c but we make a mex file called grdinfo.$EXT

grdinfo:	
		mex $(FLAGS) grdinfo2.c -output grdinfo $(GMT) $(CDF) $(MEX) 

grdread:	
		mex $(FLAGS) grdread.c $(GMT) $(CDF) $(MEX) 

grdwrite:	
		mex $(FLAGS) grdwrite.c $(GMT) $(CDF) $(MEX)

clean:
		\rm -f *.$(EXT) *% .gmt* .mexrc.sh

