##############################################################################
#
#  Sample Makefile for C/C++ applications for the UTSC environment.
#    Works for single and multiple file programs.
#
##############################################################################

# Define C compiler
CC            = gcc

# Define C++ compiler
CCC	          = g++

# Define C compiler options
CFLAGS        = -Wall -c -g #-DSCAN_CONVERT

# Define C++ compiler options
CCCFLAGS      = -Wall -c -g #-DSCAN_CONVERT

# Define C/C++ pre-processor options
CPPFLAGS      = -I./ -IInclude #-framework OpenGL -framework glut

# Define location of GLUT directory (/usr/local for UTSC)
#GLUTDIR       = /usr/local
GLUTDIR       = -framework GLUT

# Define location of OpenGL directory (/usr/local for UTSC)
#GLDIR         = /usr/local
GLDIR         = -framework OpenGL

# Define location of GLUI directory
#GLUIDIR       = /usr/X11R6
GLUIDIR       = /usr

# Define location of OpenGL and GLU libraries along with their lib names
GL_LIBS       = -framework OpenGL #-LLib  -lopengl32  -lglu32

# Define location of Glut libraries along with glut lib name 
GLUT_LIBS     = -framework glut #-LLib -lglut

# Define location of GLUI libraries along with glui lib name
GLUI_LIBS     = -L. -lglui

# Define location of the X11 Windows directory (for X11 Windows header files)
#XLIBDIR       = /usr/include

# Define location of X Windows libraries,  and the X11 library names
XLIBS         =  #-L/usr/X11R6/lib # -lX11 -lXi -lXmu

# Define the location of the destination directory for the executable file
DEST	      = .

# Define the location of all header file directories
INCDIR        = $(GLUIDIR)/include $(GLDIR)/include /usr/local/include/ Include

# Define flags that should be passed to the linker
LDFLAGS	      =

# Define libraries to be linked with
LIBS	      = $(GLUI_LIBS) $(GL_LIBS) $(GLUT_LIBS) -lm $(XLIBS)# -ldl

# Define linker
LINKER	      = g++

# Define all object files to be the same as CPPSRCS but with all the .cpp and .c suffixes replaced with .o
OBJ           = $(CPPSRCS:.cpp=.o) $(CSRCS:.c=.o)

# Define name of target executable
PROGRAM	      = spline

# Define all C source files here
CSRCS         =

# Define all C++ source files here
CPPSRCS       = main.cpp noise.cpp polyfill.cpp Stroke.cpp

##############################################################################
# Define additional rules that make should know about in order to compile our
# files.                                        
##############################################################################

# Define default rule if Make is run without arguments
all : $(PROGRAM)

# Define rule for compiling all C++ files
%.o : %.cpp
	$(CCC) $(CCCFLAGS) $(CPPFLAGS) $*.cpp

# Define rule for compiling all C files
%.o : %.c
	$(CC) $(CFLAGS) $(CPPFLAGS) $*.c

# Define rule for creating executable
$(PROGRAM) :	$(OBJ)
		@echo -n "Loading $(PROGRAM) ... "
		$(LINKER) $(LDFLAGS) $(OBJ) $(LIBS) -o $(PROGRAM)
		@echo "done"

# Define rule to clean up directory by removing all object, temp and core
# files along with the executable
clean :
	@rm -f $(OBJ) *~ core $(PROGRAM)






