include Makefile.rules

CXXFLAGS  = -std=c++11 -W -Wall -O3 -ffast-math -g $(CXXFLAGS_PLATFORM)
DEFINES   = #-DSIMD
BUILD_DIR = .
SRC       = rotation.cpp \
	    image.cpp \
            pnm.cpp
HEADERS   = image.h \
	    pnm.h
OBJS      = $(patsubst %.cpp,%.o,$(SRC))
IMG       = img/lena_3000.pgm

all: $(OBJS)
	$(CXX) $(CXXFLAGS) $(LFLAGS) $(OBJS) -o $(BUILD_DIR)/rotation

%.o: %.cpp $(HEADERS)
	$(CXX) $(CXXFLAGS) $(DEFINES) $< -c -o $@

clean:
	@rm -f rotation *~ *.o .*.swp *.ppm *.pgm *.pnm cachegrind.out.* callgrind.out.*

run: all
	$(BUILD_DIR)/rotation $(IMG)

runall: all
	$(BUILD_DIR)/rotation img/lena_512.pgm
	$(BUILD_DIR)/rotation img/lena_1024.pgm
	$(BUILD_DIR)/rotation img/lena_3000.pgm

debug: all
	lldb $(BUILD_DIR)/rotation $(IMG)

cachegrind: all
	valgrind --tool=cachegrind --dsymutil=yes $(BUILD_DIR)/rotation $(IMG)

callgrind: all
	valgrind --tool=callgrind --dsymutil=yes $(BUILD_DIR)/rotation $(IMG)
