#BHEADER**********************************************************************
# Copyright (c) 2006   The Regents of the University of California.
# Produced at the Lawrence Livermore National Laboratory.
# Written by the HYPRE team. UCRL-CODE-222953.
# All rights reserved.
#
# This file is part of HYPRE (see http://www.llnl.gov/CASC/hypre/).
# Please see the COPYRIGHT_and_LICENSE file for the copyright notice, 
# disclaimer, contact information and the GNU Lesser General Public License.
#
# HYPRE is free software; you can redistribute it and/or modify it under the
# terms of the GNU General Public License (as published by the Free Software 
# Foundation) version 2.1 dated February 1999.
#
# HYPRE is distributed in the hope that it will be useful, but WITHOUT ANY 
# WARRANTY; without even the IMPLIED WARRANTY OF MERCHANTABILITY or FITNESS 
# FOR A PARTICULAR PURPOSE.  See the terms and conditions of the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# $Revision: 1.13 $
#EHEADER**********************************************************************






include ../../config/Makefile.config
include babel.make

IORSRCS_NONNULL = $(filter-out bHYPRE_SStructVariable_IOR.c, ${IORSRCS})
# ... ignore zero-length file because it will confuse the gcc/ar interaction

CINCLUDES=${INCLUDES} ${MPIINCLUDE}
CDEFS = 
 
BABEL_RUNTIME_INCLUDES=\
  -I$(HYPRE_SRC_TOP_DIR)/babel-runtime/sidl
BABEL_RUNTIME_SIDL_LIBS=\
  -L$(HYPRE_SRC_TOP_DIR)/babel-runtime/sidl/.libs\
  -lsidl-1.0.0 -lsidl
# ... note re the use of the .libs directory above.  Its contents will
# get copied (by babel/Makefile) to hypre/lib, but the copy hasn't
# happened yet, and we need to point to the sidl libraries now.

C_COMPILE_FLAGS=\
 -I..\
 -I$(HYPRE_SRC_TOP_DIR)\
 -I$(HYPRE_SRC_TOP_DIR)/hypre/include\
 ${BABEL_RUNTIME_INCLUDES}\
 ${CINCLUDES}\
 ${CDEFS}
 
LIBFLAGS = ${LIBDIRS} ${LIBS}
LDLIBFLAGS = ${LDLIBDIRS} ${LDLIBS}
 
LFLAGS =\
 -L.\
 -L../seq_mv\
 -L../utilities\
 -lHYPRE_parcsr_mv\
 -lHYPRE_seq_mv\
 -lHYPRE_utilities\
 ${LIBFLAGS} ${LDLIBFLAGS}

HEADERS = ${STUBHDRS} ${IORHDRS} ${IMPLHDRS}

FILES = ${IMPLSRCS} ${IORSRCS_NONNULL} ${SKELSRCS} ${STUBSRCS} \
 bHYPRE_Extensions.c

OBJS = ${FILES:.c=.o}
# SHARED_OBJS = ${FILES:.c=.lo}

##################################################################
# Targets
##################################################################

all: libbHYPRE${HYPRE_LIB_SUFFIX}
	cp -fp $(srcdir)/*.h ${HYPRE_BUILD_DIR}/include
	cp -fp libbHYPRE* ${HYPRE_BUILD_DIR}/lib
 
install: all
	cp -fp $(srcdir)/*.h ${HYPRE_INC_INSTALL}
	cp -fp libbHYPRE* ${HYPRE_LIB_INSTALL}
 
clean:
	rm -f *.o *.lo libbHYPRE*

distclean: clean

##################################################################
# Rules
##################################################################

libbHYPRE.a: ${OBJS}
	@echo  "Building $@ ... "
	${AR} $@ ${OBJS}
	${RANLIB} $@

libbHYPRE.so: ${OBJS}
	@echo  "Building $@ ... "
	${BUILD_CC_SHARED} -o $@ ${OBJS} -L${HYPRE_LIB_INSTALL} \
	-lHYPRE_DistributedMatrixPilutSolver\
	-lHYPRE_DistributedMatrixPilutSolver\
	-lHYPRE_DistributedMatrix\
	-lHYPRE_Euclid\
	-lHYPRE_IJ_mv\
	-lHYPRE_krylov\
	-lHYPRE_MatrixMatrix\
	-lHYPRE_multivector\
	-lHYPRE_ParaSails\
	-lHYPRE_parcsr_block_mv\
	-lHYPRE_parcsr_ls\
	-lHYPRE_parcsr_mv\
	-lHYPRE_seq_mv\
	-lHYPRE_sstruct_ls\
	-lHYPRE_sstruct_mv\
	-lHYPRE_struct_ls\
	-lHYPRE_struct_mv\
	-lHYPRE_superlu\
	-lHYPRE_utilities\
	${BABEL_RUNTIME_SIDL_LIBS}

${OBJS}: ${HEADERS}


