#/bin/sh
###############################################################
#  $Author: hkmoffa $
#  $Date: 2006/04/30 22:09:32 $
#  $Revision: 1.11 $
#
#  Copyright 2001 California Institute of Technology
#
###############################################################


.SUFFIXES :
.SUFFIXES : .cpp .d .o

INSTALL_TSC = ../../../bin/install_tsc
do_ranlib = @DO_RANLIB@

CXX_FLAGS = @CXXFLAGS@ $(CXX_OPT)

OBJS = ct.o Storage.o ctsurf.o ctrpath.o \
       ctreactor.o ctfunc.o ctxml.o ctonedim.o ctmultiphase.o
CLIB_H= Cabinet.h    ctreactor.h  clib_defs.h  ctfunc.h \
        ctnum.h ctsurf.h  ct.h   ctrpath.h      Storage.h \
        ctbdry.h    ctonedim.h    ctxml.h   ctmultiphase.h  ctstagn.h   

DEPENDS = $(OBJS:.o=.d)

# Fortran libraries
FORT_LIBS = @FLIBS@

shared_ctlib = @SHARED_CTLIB@

# the C++ compiler
CXX = @CXX@

# external libraries
EXT_LIBS = -lzeroD -loneD @LOCAL_LIBS@ 

# the directory where the Cantera libraries are located
CANTERA_LIBDIR=@buildlib@
# ../../../lib
LIB_DEPS = $(CANTERA_LIBDIR)/libcantera.a \
           $(CANTERA_LIBDIR)/libzeroD.a \
           $(CANTERA_LIBDIR)/liboneD.a 

# the directory where Cantera include files may be found.
CANTERA_INCDIR=../../src

CXX_INCLUDES = -I$(CANTERA_INCDIR)  

# flags passed to the C++ compiler/linker for the linking step
LCXX_FLAGS = -L$(CANTERA_LIBDIR) @CXXFLAGS@

# how to compile C++ source files to object files
.@CXX_EXT@.@OBJ_EXT@:
	$(CXX) -c $< $(CXX_INCLUDES) $(CXX_FLAGS) @PIC@

LIB_NAME=lib@CT_SHARED_LIB@

ifeq ($(shared_ctlib),1)
CTLIB = @buildlib@/$(LIB_NAME)@SO@
else
CTLIB = @buildlib@/$(LIB_NAME).a
endif

all: $(CTLIB)
 
$(CTLIB): $(OBJS) $(LIB_DEPS)
	$(RM)     $(CTLIB)
ifeq ($(shared_ctlib),1)
	$(CXX) -o $(CTLIB) $(OBJS) $(LCXX_FLAGS)\
                @SHARED@ $(LINK_OPTIONS) \
                $(EXT_LIBS) @LIBS@ $(FORT_LIBS)
else
	@ARCHIVE@ $(CTLIB) $(OBJS)
ifeq ($(do_ranlib),1)
	@RANLIB@ $(CTLIB)
endif
endif

clean:
	$(RM) $(OBJS) $(CTLIB)
	(if test -d SunWS_cache ; then \
           $(RM) -rf SunWS_cache ; \
         fi )


install:
	@INSTALL@ -d @ct_libdir@
	@INSTALL@ -m 644 $(CTLIB) @ct_libdir@
ifeq ($(do_ranlib),1)
ifeq ($(shared_ctlib),0)
	@RANLIB@ @ct_libdir@/$(LIB_NAME).a
endif
endif


win-install:
	@INSTALL@ ../../../lib/clib.lib @prefix@/lib/cantera


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

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

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