## Project specific variables
PROG = test/test
CXXSTD = c++11
HDRDIR = .

## Implicit variable defaults
WARNFLAGS += -pedantic -Wall -Wextra -Werror
CXXFLAGS  += $(WARNFLAGS) -Weffc++
CXXFLAGS  += -I$(HDRDIR) -std=$(CXXSTD)
LDLIBS    += -lglfw -lGLEW -lGL

## Build type
CXXFLAGS += -g

## Files
SRCS =
HDRS =

## Standard targets

.PHONY: all
all: $(PROG)

.PHONY: check
check: test

.PHONY: test
test: $(PROG)
	cd $(<D) && ./$(<F)

.PHONY: distclean
distclean:
	$(RM) $(PROG)

## Main targets

test/test: CXXFLAGS += -DGLSHADER_TEST
test/test: test/test.cpp $(SRCS)

## Header dependency targets

$(SRCS): $(HDRS)
	touch $@

## Auxiliary targets

.PHONY: install-deps-build
install-deps-build:
	sudo apt-get install \
	    libgl1-mesa-dev \
	    libglew-dev \
	    libglm-dev

.PHONY: install-deps-test
install-deps-test:
	sudo apt-get install \
	    libglfw3-dev

.PHONY: debug
debug: $(PROG)
	cd $(<D) && gdb ./$(<F)