# MAKEFILE: compile sparse matrix program for standard UNIX (e.g. Sun) 
#
# Author:  Joe Hummel, UC-Irvine.
#
# These targets build the sparse matrix program, clean dir, or backup the code.
#
# NOTE: see file "main.h" for #defines you may want to define before
#       building the executable.  See also "sparse.h".
#
CC      = gcc
#CFLAGS  = -pg -DScaleMatrix -DSolveMatrix -DOutputSolution
CFLAGS  = -O3 -DScaleMatrix -DSolveMatrix -DOutputSolution -DRUNTIME
#CFLAGS  = -g -DScaleMatrix -DSolveMatrix -DOutputSolution -DDEBUG -DVERBOSE
LDFLAGS = -lm -static
#LDFLAGS = -lm 

SOURCES = main.c sparse.c ~/clock.c
OBJECTS = main.o sparse.o clock.o
EXEFILE = sm

$(EXEFILE): $(OBJECTS)
	$(CC)  -o $(EXEFILE) $(OBJECTS) $(LDFLAGS)
#	rm -f $(OBJECTS)

main.o: main.c main.h sparse.h 
	$(CC) $(CFLAGS) -c main.c
sparse.o: sparse.c main.h sparse.h 
	$(CC) $(CFLAGS) -c sparse.c
clock.o: ~/clock.c
	$(CC) $(CFLAGS) -c sparse.c
#####################################################################
# Clean directory... 
clean:
	rm -f *.o
	rm -f $(EXEFILE) 

#####################################################################
# Make a backup... 
backup:
	rm -f sm.tar.Z
	tar cvf sm.tar Makefile* ARun Run* corr* README *.c *.h
	compress sm.tar
