CC = nvcc -arch=sm_75
DEBUG ?= false
DIRS = dist build

ifeq ($(DEBUG), false)
    CC += -O3
else
    CC += -g -G
endif

.PHONY: all run

all: $(DIRS) dist/app

dist/app: build/main.o build/op.o
	$(CC) $^ -o $@ -lcuda

build/op.o: op.ptx
	$(CC) $^ -dc -o $@

build/main.o: main.cu
	$(CC) $^ -ptx -o build/main.ptx
	$(CC) $^ -rdc=true -dc -o $@

$(DIRS):
	mkdir -p $@

clean:
	rm -rf $(DIRS)