Last active
June 24, 2016 13:19
-
-
Save wenkokke/ef9fc9d9cf8ef48865ba to your computer and use it in GitHub Desktop.
A simple makefile which delegates every task to a Shake build file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
BUILDFILE := ./buildfile.hs | |
BUILD := ./_build/build | |
BUILDDIR := $(dir $(BUILD)) | |
SOURCES := $(shell find .) | |
SOURCES := $(filter-out ./Makefile,$(SOURCES)) | |
SOURCES := $(filter-out $(BUILD),$(SOURCES)) | |
SOURCES := $(filter-out $(BUILDFILE),$(SOURCES)) | |
# Delegate the default task. | |
default: | |
@$(MAKE) $(BUILD) | |
@$(BUILD) | |
# Delegate all file tasks for existing files. | |
$(SOURCES): | |
@$(MAKE) $(BUILD) | |
@$(BUILD) "$@" | |
.PHONY: $(SOURCES) | |
# Delegate all other tasks. | |
.DEFAULT: | |
@$(MAKE) $(BUILD) | |
@$(BUILD) "$@" | |
# Compile buildfile.hs. | |
$(BUILD): $(BUILDFILE) | |
cabal install shake | |
mkdir -p $(BUILDDIR) | |
ghc --make $(BUILDFILE) -rtsopts -with-rtsopts=-I0 -outputdir=$(BUILDDIR) -o $(BUILD) | |
# Clean up the _build directory. | |
clean: | |
@rm -rf $(BUILDDIR) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment