#/bin/sh
###############################################################
#  $Author: dggoodwin $
#  $Date: 2005/06/18 17:01:00 $
#  $Revision: 1.26 $
#
#  Copyright 2001-2004 California Institute of Technology
#  See file License.txt for licensing information
#
###############################################################

LIBS = @LOCAL_LIBS@ @LIBS@ @FLIBS@
SRCS = cantera/private/ctmethods.cpp \
       cantera/private/ctfunctions.cpp \
       cantera/private/xmlmethods.cpp \
       cantera/private/phasemethods.cpp \
       cantera/private/thermomethods.cpp \
       cantera/private/mixturemethods.cpp \
       cantera/private/kineticsmethods.cpp \
       cantera/private/transportmethods.cpp \
       cantera/private/reactormethods.cpp \
       cantera/private/reactornetmethods.cpp \
       cantera/private/wallmethods.cpp \
       cantera/private/flowdevicemethods.cpp \
       cantera/private/onedimmethods.cpp \
       cantera/private/surfmethods.cpp \
       cantera/private/funcmethods.cpp \
       cantera/private/write.cpp


CANTERA_LIBDIR=@buildlib@
os_is_win=@OS_IS_WIN@

ifeq ($(os_is_win),0)
LIB_DEPS = $(CANTERA_LIBDIR)/libcantera.a $(CANTERA_LIBDIR)/libzeroD.a \
           $(CANTERA_LIBDIR)/liboneD.a \
           $(CANTERA_LIBDIR)/libtransport.a \
           $(CANTERA_LIBDIR)/libclib.a \
           $(CANTERA_LIBDIR)/libconverters.a 
else
LIB_DEPS = $(CANTERA_LIBDIR)/cantera.lib $(CANTERA_LIBDIR)/zeroD.lib \
           $(CANTERA_LIBDIR)/oneD.lib \
           $(CANTERA_LIBDIR)/transport.lib 
endif

DEPENDS = $(SRCS:.cpp=.d)

.cpp.d:
	g++ -MM $(CXX_INCLUDES) $*.cpp > $*.d

all: cantera/ctmethods.@mex_ext@

cantera/ctmethods.@mex_ext@: $(SRCS) $(LIBDEPS) Makefile
ifeq ($(os_is_win),0)
	@PYTHON_CMD@ setup_matlab.py @prefix@/bin @buildlib@ @CT_SHARED_LIB@ '$(LIBS)'
else
	@PYTHON_CMD@ setup_winmatlab.py
endif
	(@MATLAB_CMD@ -nojvm -nosplash -r setup)
	rm -f setup.m 

install:
	@INSTALL@ -d @prefix@/matlab/toolbox/cantera/cantera
	@INSTALL@ -d @prefix@/matlab/toolbox/cantera/cantera-demos
	@INSTALL@ -d @prefix@/matlab/toolbox/cantera/cantera/private
	@INSTALL@ -d @prefix@/matlab/toolbox/cantera/cantera/@ThermoPhase/private
	@INSTALL@ -d @prefix@/matlab/toolbox/cantera/cantera/@Mixture/private
	@INSTALL@ -d @prefix@/matlab/toolbox/cantera/cantera/@Kinetics/private
	@INSTALL@ -d @prefix@/matlab/toolbox/cantera/cantera/@Transport/private
	@INSTALL@ -d @prefix@/matlab/toolbox/cantera/cantera/@Interface/private
	@INSTALL@ -d @prefix@/matlab/toolbox/cantera/cantera/@Solution
	@INSTALL@ -d @prefix@/matlab/toolbox/cantera/cantera/@XML_Node/private
	@INSTALL@ -d @prefix@/matlab/toolbox/cantera/cantera/@Reactor/private
	@INSTALL@ -d @prefix@/matlab/toolbox/cantera/cantera/@ReactorNet/private
	@INSTALL@ -d @prefix@/matlab/toolbox/cantera/cantera/@Wall/private
	@INSTALL@ -d @prefix@/matlab/toolbox/cantera/cantera/@FlowDevice/private
	@INSTALL@ -d @prefix@/matlab/toolbox/cantera/cantera/@Func/private
	@INSTALL@ -d @prefix@/matlab/toolbox/cantera/cantera/1D
	@INSTALL@ -d @prefix@/matlab/toolbox/cantera/cantera/1D/@Domain1D/private
	@INSTALL@ -d @prefix@/matlab/toolbox/cantera/cantera/1D/@Stack/private
	cd cantera; @INSTALL@ *.m *.@mex_ext@ @prefix@/matlab/toolbox/cantera/cantera
	cd cantera/private; @INSTALL@ *.m \
            @prefix@/matlab/toolbox/cantera/cantera/private
	cd cantera/examples; @INSTALL@ *.m @prefix@/matlab/toolbox/cantera/cantera-demos
	cd cantera/@ThermoPhase; @INSTALL@ \
            *.m @prefix@/matlab/toolbox/cantera/cantera/@ThermoPhase
	cd cantera/@ThermoPhase/private; @INSTALL@ *.m \
            @prefix@/matlab/toolbox/cantera/cantera/@ThermoPhase/private
	cd cantera/@Kinetics; @INSTALL@ *.m \
            @prefix@/matlab/toolbox/cantera/cantera/@Kinetics
	cd cantera/@Kinetics/private; @INSTALL@ *.m \
            @prefix@/matlab/toolbox/cantera/cantera/@Kinetics/private
	cd cantera/@Solution; @INSTALL@ *.m \
            @prefix@/matlab/toolbox/cantera/cantera/@Solution
	cd cantera/@Transport; @INSTALL@ *.m \
            @prefix@/matlab/toolbox/cantera/cantera/@Transport
	cd cantera/@Transport/private; @INSTALL@ *.m \
            @prefix@/matlab/toolbox/cantera/cantera/@Transport/private
	cd cantera/@Interface; @INSTALL@ \
            *.m @prefix@/matlab/toolbox/cantera/cantera/@Interface
	cd cantera/@Interface/private; @INSTALL@ *.m \
            @prefix@/matlab/toolbox/cantera/cantera/@Interface/private
	cd cantera/@Mixture; @INSTALL@ \
            *.m @prefix@/matlab/toolbox/cantera/cantera/@Mixture
	cd cantera/@Mixture/private; @INSTALL@ *.m \
            @prefix@/matlab/toolbox/cantera/cantera/@Mixture/private
	cd cantera/@XML_Node; @INSTALL@ *.m \
            @prefix@/matlab/toolbox/cantera/cantera/@XML_Node
	cd cantera/@Reactor; @INSTALL@ *.m \
            @prefix@/matlab/toolbox/cantera/cantera/@Reactor
	cd cantera/@Reactor/private; @INSTALL@ *.m \
            @prefix@/matlab/toolbox/cantera/cantera/@Reactor/private
	cd cantera/@ReactorNet; @INSTALL@ *.m \
            @prefix@/matlab/toolbox/cantera/cantera/@ReactorNet
	cd cantera/@ReactorNet/private; @INSTALL@ *.m \
            @prefix@/matlab/toolbox/cantera/cantera/@ReactorNet/private
	cd cantera/@Wall; @INSTALL@ *.m \
            @prefix@/matlab/toolbox/cantera/cantera/@Wall
	cd cantera/@Wall/private; @INSTALL@ *.m \
            @prefix@/matlab/toolbox/cantera/cantera/@Wall/private
	cd cantera/@FlowDevice; @INSTALL@ *.m \
            @prefix@/matlab/toolbox/cantera/cantera/@FlowDevice
	cd cantera/@FlowDevice/private; @INSTALL@ *.m \
            @prefix@/matlab/toolbox/cantera/cantera/@FlowDevice/private
	cd cantera/@Func; @INSTALL@ *.m \
            @prefix@/matlab/toolbox/cantera/cantera/@Func
	cd cantera/@Func/private; @INSTALL@ *.m \
            @prefix@/matlab/toolbox/cantera/cantera/@Func/private
	cd cantera/1D; @INSTALL@ *.m \
            @prefix@/matlab/toolbox/cantera/cantera/1D
	cd cantera/1D/@Domain1D; @INSTALL@ *.m \
            @prefix@/matlab/toolbox/cantera/cantera/1D/@Domain1D
	cd cantera/1D/@Domain1D/private; @INSTALL@ *.m \
            @prefix@/matlab/toolbox/cantera/cantera/1D/@Domain1D/private
	cd cantera/1D/@Stack; @INSTALL@ *.m \
            @prefix@/matlab/toolbox/cantera/cantera/1D/@Stack
	cd cantera/1D/@Stack/private; @INSTALL@ *.m \
            @prefix@/matlab/toolbox/cantera/cantera/1D/@Stack/private
	@INSTALL@ -d @ct_demodir@/matlab
	@INSTALL@ cantera/examples/*.m @ct_demodir@/matlab
	@INSTALL@ -d @ct_tutdir@/matlab
	@INSTALL@ cantera/tutorial/*.m @ct_tutdir@/matlab
	chown -R @username@ @ct_demodir@/matlab
	chown -R @username@ @ct_tutdir@/matlab


clean:
	rm -f cantera/private/*.o
	rm -f cantera/ctmethods.@mex_ext@

#depends: $(DEPENDS)
#	cat *.d > .depends
#	$(RM) $(DEPENDS) 

depends:
	echo "-"

TAGS: 
	etags *.h *.cpp

ifeq ($(wildcard .depends), .depends)
include .depends
endif

run-demo:
	(cd @ct_dir@; matlab -nojvm -nosplash -r cantera_demos)

test-demo:
	(cd @ct_dir@/demos/matlab; matlab -nojvm -nosplash -r test_demos)

# end of file



