HIPCC ?= hipcc
HIPFLAGS ?=

POSITIVE_SRCS := $(wildcard positive/*.cpp)
NEGATIVE_SRCS := $(wildcard negative/*.cpp)
POSITIVE_BINS := $(patsubst positive/%.cpp,build/%,$(POSITIVE_SRCS))
NEGATIVE_BINS := $(patsubst negative/%.cpp,build/%,$(NEGATIVE_SRCS))

ALL_BINS := $(POSITIVE_BINS) $(NEGATIVE_BINS)

.PHONY: all clean positive negative

all: $(ALL_BINS)

positive: $(POSITIVE_BINS)

negative: $(NEGATIVE_BINS)

# Static pattern rules: each binary list is bound to its own source
# directory. Plain pattern rules with the same `build/%` target would
# override each other under GNU Make, silently breaking one of the two
# build sets.
$(POSITIVE_BINS): build/%: positive/%.cpp | build
	$(HIPCC) $(HIPFLAGS) -o $@ $<

$(NEGATIVE_BINS): build/%: negative/%.cpp | build
	$(HIPCC) $(HIPFLAGS) -o $@ $<

build:
	mkdir -p build

clean:
	rm -rf build/*
