CC = g++
#the compiler to use

INC = -I$(QTDIR)/include
#define the directory with the qt files to include in it
LIB = -L$(QTDIR)/lib
#defines the directory with the library files in it
CFLAGS=-g
#any compiler options
LIBS = -lqt -lGL -lGLU -lm
#libs you are compiling with

BEFORE=$(INC) $(CFLAGS)
#just a shorthand for all the stuff that goes into a compiler pass

.SUFFIXES: .h .moc .cpp .o
#define the suffixes you are going to teach it
#doing %h:%.moc makes life harder for telling it you need to check if the moc is new
.h.moc:
#this is how you make .h files into .moc files
	moc $< > $@
# moc -> meta object compiler, a special qt program you need to run to setup all the signals and slots
# $<  -> aliases to the .h files name
# >   -> its output is piped into a file
# $@  -> is the name of the .moc file created
.cpp.o: $@.moc
#now we are teaching it how to make .o files out of .cpp files, $@.moc -> it has to make the moc file first
	$(CC) $(BEFORE) -c $<
# $(CC) -> the variable defined above for the name of the compiler
# $(BEFORE) another variable defined above that expands into the arguments to pass to the compiler
# -c just building object files no linking
# $< expands to the name of the .cpp file
ALL: go
# if you just type make, it builds go

#********************** TO ADD NEW FILES **************************************************
# 1) if its a new class give it a new .o file under OBJS
# 2) create a section for it with the other .os and list all the files it uses
# 3) that should be it, it should know how to build the files once it knows what they are.
#*****************************************************************************************
OBJS=main.o window.o glwindow.o
#the list of .o files you need
window.o: window.h window.moc window.cpp
glwindow.o: glwindow.h glwindow.moc glwindow.cpp ball.h node.h
#defines which files each .o depends on (anything it includes).


go: $(OBJS)
#to build go you need all the object files
	$(CC) $(BEFORE) -o go $(OBJS) $(LIB) $(LIBS)
#the final compiler pass links all the .o's together

clean:
	rm -f core *.o *~ *.moc go
#convenience function for removing unused files
