## ///////////////////////////////////////////////////////////////////////////
## @file    makefile
## @author  Michael Holst
## @brief   Makefile for building the PMG binary.
## @version $Id: Make.dist,v 1.4 2010/08/12 05:52:58 fetk Exp $
## @attention
## @verbatim
##
## PMG -- Parallel algebraic MultiGrid
## Copyright (C) 1994-- Michael Holst.
##
## Michael Holst <mholst@math.ucsd.edu>
## University of California, San Diego
## Department of Mathematics, 5739 AP&M
## 9500 Gilman Drive, Dept. 0112
## La Jolla, CA 92093-0112 USA                                                  
## http://math.ucsd.edu/~mholst
##
## This file is part of PMG.
##
## PMG 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; either version 2 of the License, or
## (at your option) any later version.
##
## PMG 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
## GNU General Public License for more details.
##
## You should have received a copy of the GNU General Public License
## along with PMG; if not, write to the Free Software
## Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
##
## Linking PMG statically or dynamically with other modules is making a
## combined work based on PMG. Thus, the terms and conditions of the GNU
## General Public License cover the whole combination.
## 
## SPECIAL GPL EXCEPTION
## In addition, as a special exception, the copyright holders of PMG
## give you permission to combine the PMG program with free software
## programs and libraries that are released under the GNU LGPL or with
## code included in releases of ISIM, PMV, PyMOL, SMOL, VMD, and Vision.
## Such combined software may be linked with PMG and redistributed together 
## in original or modified form as mere aggregation without requirement that 
## the entire work be under the scope of the GNU General Public License.
## This special exception permission is also extended to any software listed
## in the SPECIAL GPL EXCEPTION clauses by the FEtk and APBS libraries.
## 
## Note that people who make modified versions of PMG are not obligated
## to grant this special exception for their modified versions; it is
## their choice whether to do so. The GNU General Public License gives
## permission to release a modified version without this exception; this
## exception also makes it possible to release a modified version which
## carries forward this exception.
##
## @endverbatim
## ///////////////////////////////////////////////////////////////////////////

SRC_PREC = double
DES_PREC = double

##############################################################################
# Makefile for the XMG package.
#
# author: michael holst
# linux flags
##############################################################################

MACHINE	= linux

FC	= f77
FCFLAGS	= -c
FLFLAGS	=
FOPT	=
FDEBUG	= -g

CC	= cc
CCFLAGS	= -c
CLFLAGS	=
COPT	=
CDEBUG	= -g

AR	= ar rv
ARFLAGS	=
ARLIB	= true

LK	= f77
LKFLAGS =
LKX	= -o

FXT	= .f
CXT	= .c
OXT	= .o
EXT	=
LXT	= .a

RM	= rm -f
MV	= mv

##############################################################################
#
#MACHINE	= irix
#
#FC	= f77 -o32
#FCFLAGS	= -c -Nn20000
#FLFLAGS	=
#FOPT	=
#FDEBUG	= -g
#
#CC	= cc -o32
#CCFLAGS	= -c
#CLFLAGS	=
#COPT	=
#CDEBUG	= -g
#
#AR	= ar rv
#ARFLAGS	=
#ARLIB	= true
#
#LK	= f77 -o32
#LKFLAGS = -L/usr/lib -lF77 -lU77 -lI77 -lm
#LKX	= -o
#
#FXT	= .f
#CXT	= .c
#OXT	= .o
#EXT	=
#LXT	= .a
#
#RM	= rm -f
#MV	= mv
#
##############################################################################
# DO NOT MODIFY MAKEFILE BELOW THIS LINE
##############################################################################
# libraries

MGLIB		= mgrid$(LXT)

FLIBPATHS	=
FLIBRARIES	=
FINCLUDES 	=
FLIBS		= $(FLIBPATHS) $(FLIBRARIES) 
FFLAGS		= $(FINCLUDES) $(FOPT) $(FDEBUG)

CLIBPATHS       =
CLIBRARIES      =
CINCLUDES 	=
CLIBS		= $(CLIBPATHS) $(CLIBRARIES) 
CFLAGS		= $(CINCLUDES) $(COPT) $(CDEBUG)

LIBS		= $(MGLIB) $(CLIBS) $(FLIBS)

##############################################################################
# directories

BIN     = ../bin
MISC    = ../misc
MYSRC   = ../mysrc

##############################################################################
# modules

DRIV	= mainsubd$(OXT) \
	cgmgdrvd$(OXT) newdrvd$(OXT) mgdrvd$(OXT) powerd$(OXT) \
	ncgdrvd$(OXT) nsordrvd$(OXT) ngsdrvd$(OXT) nwjdrvd$(OXT) \
	nrchdrvd$(OXT)
SUPP	= matvecd$(OXT) mikpckd$(OXT) smoothd$(OXT) nsmoothd$(OXT) \
	buildAd$(OXT) buildBd$(OXT) mblasd$(OXT) secd$(OXT) rand$(OXT)
LINM	= cgd$(OXT) sord$(OXT) gsd$(OXT) wjd$(OXT) rchd$(OXT)
NONM	= ncgd$(OXT) nsord$(OXT) ngsd$(OXT) nwjd$(OXT) nrchd$(OXT)
PROB	= dlphsubd$(OXT) pded$(OXT)
MGUT	= newtond$(OXT) cgmgd$(OXT) mgcsd$(OXT) mgfasd$(OXT) mgsubd$(OXT) \
	mlinpckd$(OXT) ninterpd$(OXT) buildPd$(OXT) buildGd$(OXT)	
ALLO	= $(DRIV) $(SUPP) $(LINM) $(NONM) $(PROB) $(MGUT)

##############################################################################
# rules

all : go$(EXT) gof$(EXT)
go$(EXT) : main$(OXT) $(MGLIB) 
	$(LK) main$(OXT) $(LKFLAGS) $(LIBS) $(LKX) go$(EXT)
###	$(LK) main$(OXT), go$(EXT), nul.map, llibfor7.lib $(MGLIB)
gof$(EXT) : maind$(OXT) $(MGLIB) 
	$(LK) maind$(OXT) $(LKFLAGS) $(LIBS) $(LKX) gof$(EXT)
###	$(LK) maind$(OXT), gof$(EXT), nul.map, llibfor7.lib $(MGLIB)
main$(OXT) : main$(CXT)
	$(CC) $(CCFLAGS) $(CFLAGS) $*$(CXT)
maind$(OXT) : maind$(FXT)
	$(FC) $(FCFLAGS) $(FFLAGS) $*$(FXT)
$(MGLIB) : $(ALLO)
	$(ARLIB) $(MGLIB)
$(FXT)$(OXT) :
	$(FC) $(FCFLAGS) $(FFLAGS) $*$(FXT)
	$(AR) $(MGLIB) $(ARFLAGS)$*$(OXT)
$(CXT)$(OXT) :
	$(CC) $(CCFLAGS) $(CFLAGS) $*$(CXT)
	$(AR) $(MGLIB) $(ARFLAGS)$*$(OXT)
clean :
	$(RM) *$(OXT) go$(EXT) gof$(EXT) $(MGLIB)

##############################################################################
# tools

noperf : 
	/bin/csh $(MISC)/noperf.drv $(DES_PREC)
unread : 
	/bin/csh $(MISC)/unread.drv $(DES_PREC)
check :
	/bin/csh $(MISC)/check.drv $(DES_PREC)

