# This is the comment symbol, whenever you want to type a comment
# please put this symbol first.

# Modified April 24. Eliza Dubroff. p2.mak

# Here we define some nicknames to be used during compilation

# The CCDEBUG variable defines the flags under which the compiler is
# going to work. The -c flag produce .o (object files) only and not
# linking is done. The -g flag is used for debugging reasons. This flag
# allows debugger such as gdb to use the core file for detecting the bugs.

CCDEBUG = -g 


# The INCLUDE variable defines the directories where the compiler
# should search for header files (.h files) 

INCLUDE = 

# To use a nickname we put it inside ${...}

CFLAGS = ${CCDEBUG}

# We set up paths to search for the libraries needed for linking

LIBDIR = -L ./lib


# Now specify the libraries we want
# m is the math library
# We will also automatically get CC which is the C++ library

LFLAGS = -lm ${CCDEBUG}

# This is a shell script which launches the C++ translator

CC = g++


# The SOURCES variables have all the sources files of your code. If
# you only have one source code just put that one. If you have more than
# one please put as many as you have.

SOURCES =  	beam.cc \
		p2.cc

# Macro to create a string with .o files that will have the same name as all
# the .cc files

OBJECTS = ${SOURCES:.cc=.o}

# The PROGS variable is the one that define the program that you are making.

PROGS = p2

# all is a special name and make tries to make this by default
# this line reads "all depends on ${PROGS}"

all: ${PROGS} 

# The following command explain the compiler how to make the prog filename.
# It also says that filename depends on all the files in the OBJECTS variable.
# The $@ means that put the name of filenmae same than the target as defined
# by all.

p2: $(OBJECTS) 
	$(CC) $(OBJECTS) -o $@ ${LFLAGS} $(LIBDIR)

# When the compiler try to make filename may find that filename1.o hasn't been
# made. So, the compiler try to make it and the following command explain 
# the compiler how to make it.
# It also says that filename1.o depends on filename1.cc filename1.h
# This is important so that compiler knows that even if filename1.o exists. 
# Its time stamping should be later than filename1.cc filename1.h
# If it is no later, it means that something has changed and the filename1.o
# has to be created again.
# Here you only define as many programs you have and with the name that you give.
# Remeber that filename1 is only a place holder.

beam.o: beam.cc beam.h
	$(CC) $(CFLAGS) $(INCLUDE) -c beam.cc
p2.o: p2.cc beam.h
	$(CC) $(CFLAGS) $(INCLUDE) -c p2.cc











