HC = ghc CABAL_TARGETS = configure build register install clean test configure_opts = --scratchdir=build --user register_opts = --inplace --user exes = $(shell awk -F ": " '$$1 == "Executable" { print $$2; }' config.cabal) all: build setup: Setup.hs $(HC) -o $@ --make $< .setup-config: config.cabal $(MAKE) configure build: .setup-config .PHONY: $(CABAL_TARGETS) $(CABAL_TARGETS): %: setup config.cabal ./setup $* -v $($*_opts) $(exes): %: setup config.cabal ./setup build $@ -v $(build_opts)