##############################################################################
# cs132 sample C++ makefile
#
# Copy this file into the directory where you keep the source files of
# your program. Change the variables EXEC and OFILES below to reflect 
# your source. When you are ready to compile your program, just type 
# 'make' in the directory.
##############################################################################

.KEEP_STATE:
.SILENT:
.SUFFIXES: .c .h

# Define a rule for building .o from .C files
.c.o:
	echo "compiling $<"
	$(CCPLUS)  $(IFLAGS) -c $(CFLAGS) $<

# define a rule for building executable (no suffix) from .o files
.o:
	echo "linking $<"
	$(CCFINAL) -O -o  $(EXEC) $(OFILES) $(LFLAGS) $(LIBS)

##############################################################################
# Change EXEC to the name of the executable which you wish to
# create. Make OFILES be the name of all the .C files in your program,
# but change the .C to .o.
##############################################################################
EXEC	= concur
OFILES 	= cflow.o cflow2.o com.o edgenode.o graph2.o graph_alg.o heap.o main.o mygraph.o path.o sumtree.o

#OFILES	= graph2.o heap.o graph_alg.o sumtree.o path.o cfgraph.o
#main.o mygraph.o 


# Compiler specifications
# Use spr's compiler and linker (makes it easier to use spr's debuggers)
#CCPLUS	= /course/cs132/bin/CC
#CCFINAL	= CC
#CCPLUS = /u/spr/commands.sun4/CC
#CCFINAL =/u/spr/commands.sun4/CC
CCPLUS = /usr/lang/CC
CCFINAL = /usr/lang/CC

LEDADIR = /pro/leda/2.0.1

IFLAGS	= -I$(LEDADIR)/incl
LFLAGS	= -L/cs/lib  -L$(LEDADIR)/libATT -liprof
LIBS	= -lG -lL -lm

# Uncomment this when you need to start using FIELD to debug (it takes 50%
# longer to make with this option).
 FIELDFLAGS= -fxref

##############################################################################
# These are different make options.  You can invoke them by typing 
# the label name.  For example to time your make, type 'make time' -- 
# 'make' being the name of this command and 'time' being the label used 
# below to define the result.  
##############################################################################

all := CFLAGS=$(FLAGS) -g 
opt := CFLAGS=$(FLAGS) -O4

# Standard make, it makes everything.  You can type 'make all' or 
# just 'make'
all:	$(OFILES)
	$(RM) $(EXEC)
	echo -n "make finished at "; date
	echo "linking $<"
	$(CCFINAL) -g -o $(EXEC) $(OFILES) $(LFLAGS) $(LIBS) -Bstatic

opt:	$(OFILES)
	$(RM) $(EXEC)
	echo -n "make finished at "; date
	echo "linking $<"
	$(CCFINAL) -O4 -o $(EXEC) $(OFILES) $(LFLAGS) $(LIBS)

concur: 
	echo "linking $<"
	$(CCFINAL) -g -o $(EXEC) $(OFILES) $(LFLAGS) $(LIBS)

# Clean up after making. 
clean:
	echo "removing" *.o
	$(RM) *.o
	if [ -d /tmp/$(USER)tmp ]; \
	 then echo "clearing /tmp/$(USER)tmp"; $(MAKE) tclean; fi

# Make tags for emacs and vi. The result will be stored in a text 
# file 'TAGS' in your current directory.
tags:
	etags -t *.[CH]

# Time your make.
time:
	/usr/bin/time $(MAKE)



