#
# smallptGPU & smallptCPU Makefile
#

ATISTREAMSDKROOT=/home/david/src/ati-stream-sdk-v2.0-lnx64

CC=gcc
CCFLAGS=-O3 -msse2 -mfpmath=sse -ftree-vectorize -funroll-loops -Wall \
	-I$(ATISTREAMSDKROOT)/include -L$(ATISTREAMSDKROOT)/lib/x86_64 -lglut -lOpenCL
# Jens's patch for MacOS, comment the 2 lines above and un-comment the lines below
#CCFLAGS=-O3 -ftree-vectorize -msse -msse2 -msse3 -mssse3 -fvariable-expansion-in-unroller \
#	-cl-fast-relaxed-math -cl-mad-enable -Wall -framework OpenCL -framework OpenGl -framework Glut

default: all

all: smallptCPU smallptGPU preprocessed_kernels

smallptCPU: smallptCPU.c displayfunc.c Makefile vec.h camera.h geom.h displayfunc.h simplernd.h scene.h geomfunc.h
	$(CC) $(CCFLAGS) -DSMALLPT_CPU -o smallptCPU smallptCPU.c displayfunc.c

smallptGPU: smallptGPU.c displayfunc.c Makefile vec.h camera.h geom.h displayfunc.h simplernd.h scene.h geomfunc.h
	$(CC) $(CCFLAGS) -DSMALLPT_GPU -o smallptGPU smallptGPU.c displayfunc.c

clean:
	rm -rf smallptCPU smallptGPU image.ppm SmallptGPU-v1.4 smallptgpu-v1.4.tgz preprocessed_rendering_kernel.cl

preprocessed_kernels:
	cpp <rendering_kernel.cl >preprocessed_rendering_kernel.cl

tgz: clean all
	mkdir SmallptGPU-v1.4
	cp -r smallptCPU smallptGPU scenes camera.h displayfunc.c displayfunc.h geomfunc.h geom.h \
		LICENSE.txt Makefile README.txt scene.h simplernd.h smallptCPU.c smallptGPU.c \
		vec.h rendering_kernel.cl preprocessed_rendering_kernel.cl \
		SmallptGPU.exe glut32.dll SmallptGPU-v1.4
	tar zcvf smallptgpu-v1.4.tgz SmallptGPU-v1.4
	rm -rf SmallptGPU-v1.4
