# Look at the various macros to decide how to compile for your setup.
# Set CC, CFLAGS, PROF, PROFLIB, LDFLAGS, INCLUDE, LIB.  See README
# for further information.
# Sample values for a T3E, clusters of SGI's or Linux PC's running 
# MPICH or LAM are included.

# Use this with LAM MPI.  For other versions omit definition of CC
#CC = /usr/local/lam/bin/hcc

# Additional CFLAGS: -DDEBUG
#                    -DDIST_OUTPUT
# The DEBUG flag generates huge amounts of output.  So use it with
# caution:  it may be a good idea to define DEBUG in the source file
# containing the code you want to debug, rather than defining it for
# all source files.

# Use these CFLAGS for SGI's 
#CFLAGS   =  -g -fullwarn -DDEBUG
#CFLAGS = -g -fullwarn -DDIST_OUTPUT
#CFLAGS = -g -fullwarn
#CFLAGS = -O2 -fullwarn

# Use these for Linux
CFLAGS   = -g -Wall
#CFLAGS   = -g -Wall -DDEBUG
#CFLAGS   = -O3 -Wall

# Use these for the T3E
#CFLAGS = -g -h msglevel_3

# Turn off profiling
# Don't forget to comment out prof.h,c,o
# PROF =
# PROFLIB =

# Turn on totals only profiling
PROF = -DPROF
PROFLIB = 

# Turn on automatic profiling  (Only with mpich, untested)
#PROF = 
#PROFLIB = -llmpi -lmpe

# Turn on custom profiling  (Only with mpich, untested)
#PROF = -DPROF
#PROFLIB =  -llmpi -lmpe -lm

LDFLAGS  =  

# Use this for mpich
INCLUDE  =  -I/usr/local/mpi/include  -I.

# Use this for LAM
#INCLUDE  =  -I/usr/local/lam/include  -I.

# Use this for T3E
#INCLUDE  =  -I.

# Use this for building with mpich
LIB      =  -lm -L/usr/local/mpi/lib -lmpich

# Use this for building with lam
#LIB      =  -lm -L/usr/local/lam/lib -lmpi

# Use this for building on the T3E
#LIB       = -lm

####################################################################
####### You shouldn't need to edit anything below this line ########
####################################################################

SOURCE = \
        main.c \
	input.c \
	equations.c \
	output.c \
	solver.c \
	utility.c \
        comm.c \
        prof.c \
        nscanf.c \
        globals.c \
        create_read_constants.c

HDRS = \
	input.h \
	equations.h \
	output.h \
	solver.h \
	utility.h \
        comm.h \
        prof.h \
        nscanf.h \
        globals.h \
        read_constants.h
        
OBJS = \
        main.o \
	input.o \
	equations.o \
	output.o \
	solver.o \
	utility.o \
        comm.o \
        prof.o \
        nscanf.o \
        globals.o

OTHER = \
	read_constants.t \
        constant_list



solve: $(OBJS) read_constants.o
	$(CC) -o solve $(CFLAGS) $(OBJS) read_constants.o $(INCLUDE) \
	$(PROFLIB) $(LDFLAGS) $(LIB) 

read_constants.c: equations.h read_constants.h read_constants.t \
	create_read_constants.c constant_list
	$(CC) $(CFLAGS) -o create_read_constants create_read_constants.c \
		$(INCLUDE)
	./create_read_constants

clean:
	rm -f solve *.o core create_read_constants read_constants.c

tar:
	tar cvf solve.tar $(SOURCE) $(HDRS) $(OTHER) Makefile constants
	gzip solve.tar

main.o: equations.h output.h input.h solver.h utility.h nscanf.h globals.h

input.o: input.h equations.h utility.h nscanf.h globals.h

equations.o: equations.h utility.h comm.h nscanf.h read_constants.h globals.h

output.o: output.h globals.h

solver.o: solver.h equations.h output.h utility.h prof.h globals.h
#solver.o: solver.h equations.h output.h utility.h

utility.o: utility.h

comm.o: comm.h utility.h

prof.o: prof.h

nscanf.o: nscanf.h

globals.o:  globals.h

.c.o:
	$(CC) -c $(CFLAGS) $(PROF) $*.c $(INCLUDE)
