#############################################################
# Generic makefile for C++
#   Gary M. Zoppetti
#   William Killian
#
# Usage:
#   make depend (if dependencies have changed)
#   make
#
# All source and header files must be in same directory
#
#############################################################

# C++ compiler
CXX      := g++
# C compiler
CC	 := g++
# Include directories, prefaced with "-I"
INCDIRS  := -I.
# C++ compiler flags
CXXFLAGS := -std=c++11 -Wall -g $(INCDIRS)

# Linker; for C++ should be $(CXX)
LINK     := $(CXX)
# Library directories, prefaced with "-L"
LIBDIRS  := 
# Libraries we're using, prefaced with "-l"
LDLIBS   := 
# Linker flags
LDFLAGS  := $(LIBDIRS)

# Dependencies file
DEPENDS      := Makefile.d
DEPEND_FLAGS := -MM
MAKEDEPEND   := $(CXX) $(CXXFLAGS) $(DEPEND_FLAGS) 

# Important suffixes
HEADER_SUFFIX := h
SOURCE_SUFFIX := cc
OBJ_SUFFIX    := o

#############################################################

# Change this to be the executable name
TARGET   := RadixSort
# Build the array of source files
SOURCES  := $(wildcard *.$(SOURCE_SUFFIX))
# Build the array of header files
HEADERS  := $(wildcard *.$(HEADER_SUFFIX))
# Build the array of object files
OBJECTS  := $(patsubst %.$(SOURCE_SUFFIX), %.$(OBJ_SUFFIX), \
			$(SOURCES))

#############################################################
## Rules

.PHONY : all exe clean depend

all : exe

exe : $(TARGET)

$(TARGET) : $(OBJECTS)
	$(LINK) $(LDFLAGS) $^ $(LDLIBS) -o $@

depend : $(DEPENDS)

$(DEPENDS) : $(SOURCES) $(HEADERS)
	$(MAKEDEPEND) $(SOURCES) > $(DEPENDS)

clean :
	@$(RM) $(TARGET) a.out core
	@$(RM) $(OBJECTS)
	@$(RM) *.d
	@$(RM) *~ 

-include $(DEPENDS)
