# Tv Makefile
#
# SYNOPSIS:
#
#   make [all]  - makes everything.
#   make TARGET - makes the given target.
#   make clean  - removes all files generated by make.

# iutest root directory
IUTEST_DIR = ../..

# sample code
SAMPLE_DIR = ../../samples

#
# Flags passed to the C++ compiler.
CPPFLAGS += -I$(IUTEST_DIR)/include
CPPFLAGS += -I"$(CUDA_PATH)/include"
CPPFLAGS += -L"$(CUDA_PATH)/lib" -lcudart

ifdef TARGET_X86
CPPFLAGS += --machine 32
endif

CXXFLAGS += 
#CXXFLAGS += -DSHOW_FAILURE

CXXFLAGS += $(DEFS)
CC = gcc


# All tests produced by this Makefile.  Remember to add new tests you
# created to the list.
TESTS = sample
BIN = $(TESTS)

# All iutest headers.  Usually you shouldn't change this
# definition.
IUTEST_HEADERS = $(IUTEST_DIR)/include/*.hpp \
                 $(IUTEST_DIR)/include/impl/*.ipp \
                 $(IUTEST_DIR)/include/internal/*.hpp \
                 $(IUTEST_DIR)/include/listener/*.hpp \
                 $(IUTEST_DIR)/include/util/*.hpp \
                 $(IUTEST_DIR)/include/gtest/*.hpp \
                 $(IUTEST_DIR)/include/gtest/switch/*.hpp

# House-keeping build targets.

.PHONY: clean default all run

all : $(TESTS)

clean :
	rm -f $(TESTS) *.obj

# Builds a sample test.  

# compilers
NVCC              := nvcc

# Builds a sample test.  

main.obj : $(SAMPLE_DIR)/main.cpp $(IUTEST_HEADERS) Makefile
	$(NVCC) $(CPPFLAGS) $(CXXFLAGS) -c $(SAMPLE_DIR)/main.cu -o main.obj

$(TESTS) : main.obj
	$(NVCC) $(CPPFLAGS) $(CXXFLAGS) $^ -o $@
	
run: $(TESTS)
	./$(BIN)

