CHPL = chpl

CHPL_FLAGS = --fast

TARGETS = \
	binarytrees \
	chameneosredux \
	fannkuchredux \
	mandelbrot \
	meteor \
	meteor-fast \
	nbody \
	pidigits \
	regexdna \
	spectralnorm \
	threadring

CHPL_MAKE_REGEXP=$(shell python $(CHPL_HOME)/util/chplenv/chpl_regexp.py)
CHPL_MAKE_GMP=$(shell python $(CHPL_HOME)/util/chplenv/chpl_gmp.py)

REALS = $(TARGETS:%=%_real)

default: all

all: $(TARGETS)

clean: FORCE
	rm -f $(TARGETS) $(REALS)


binarytrees: binarytrees.chpl
	$(CHPL) -o $@ $(CHPL_FLAGS) $<

chameneosredux: chameneosredux.chpl
	$(CHPL) -o $@ $(CHPL_FLAGS) $<

fannkuchredux: fannkuchredux.chpl
	$(CHPL) -o $@ $(CHPL_FLAGS) $<

mandelbrot: mandelbrot.chpl
	$(CHPL) -o $@ $(CHPL_FLAGS) $<

meteor: meteor.chpl
	$(CHPL) -o $@ $(CHPL_FLAGS) $<

meteor-fast: meteor-fast.chpl
	$(CHPL) -o $@ $(CHPL_FLAGS) $<

nbody: nbody.chpl
	$(CHPL) -o $@ $(CHPL_FLAGS) --no-warnings $<

pidigits: pidigits.chpl
	@if [ "$(CHPL_MAKE_GMP)" != "none" ]; then \
	$(CHPL) -o $@ $(CHPL_FLAGS) $<; \
	else \
	echo "";\
	echo "Can't build pidigits without CHPL_GMP being enabled. See for details:"; \
	echo "http://chapel.cray.com/docs/latest/usingchapel/chplenv.html#chpl-gmp"; \
	echo ""; \
	fi


regexdna: regexdna.chpl
	@if [ "$(CHPL_REGEXP)" != "none" ]; then \
	$(CHPL) -o $@ $(CHPL_FLAGS) $<; \
	else \
	echo "";\
	echo "Can't build regexdna without CHPL_REGEXP being enabled. See for details:"; \
	echo "http://chapel.cray.com/docs/latest/usingchapel/chplenv.html#chpl-regexp"; \
	echo ""; \
	fi

spectralnorm: spectralnorm.chpl
	$(CHPL) -o $@ $(CHPL_FLAGS) $<

threadring: threadring.chpl
	$(CHPL) -o $@ $(CHPL_FLAGS) $<

FORCE:
