# Makefile
# CSE 333 Lecture 12 code

CXX = g++
CPPFLAGS = -Wall -g -std=c++11
PROGS =  heappoint strtest  # won't build: arrays sanepoint sanepoint_2011

# default target attempts to build all executables (arrays should error)
all: $(PROGS)

# using Point class with cctor and op= disabled (private + no def)
sanepoint: sanepoint.o Point.o
	$(CXX) $(CPPFLAGS) -o $@ $^

sanepoint.o: sanepoint.cc Point.h
	$(CXX) $(CPPFLAGS) -c $<

Point.o: Point.cc Point.h
	$(CXX) $(CPPFLAGS) -c $<


# simple heap allocation example
heappoint: heappoint.o Point.o
	$(CXX) $(CPPFLAGS) -o $@ $^

heappoint.o: heappoint.cc Point.h
	$(CXX) $(CPPFLAGS) -c $<

# array heap allocation examples
arrays: arrays.o Point.o
	$(CXX) $(CPPFLAGS) -o $@ $^

arrays.o: arrays.cc Point.h
	$(CXX) $(CPPFLAGS) -c $<

	
# Str class example - with new/delete
strtest: strtest.o Str.o
	$(CXX) $(CPPFLAGS) -o $@ $^

strtest.o: strtest.cc Str.h
	$(CXX) $(CPPFLAGS) -c $<

Str.o: Str.cc Str.h
	$(CXX) $(CPPFLAGS) -c $<

# phony target - remove generated files and backups
clean:
	rm -rf *.o *~ *.dSYM $(PROGS)