Skip to content

Instantly share code, notes, and snippets.

@creichert
Last active August 29, 2015 14:11
Show Gist options
  • Save creichert/1dc8ea3eb819c27d693b to your computer and use it in GitHub Desktop.
Save creichert/1dc8ea3eb819c27d693b to your computer and use it in GitHub Desktop.
Yesod Scaffold Makefile
# Yesod Makefile
# yesod init --bare && make
# Running `make` in a fresh scaffold will build the sandbox and dependencies
# `yesod-devel` will be executed on each call to `make` assuming all the
# dependencies have been installed correctly.
CABAL?=cabal
YESOD?=.cabal-sandbox/bin/yesod
PKG = PACKAGENAME
ADMINPATH = /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
SYSDEPS = build-essential zlib1g-dev
PKG_DESCRIPTION = $(PKG).cabal
DEP = .cabal-sandbox
CONFIGURE = dist/setup-config
dev: $(DEP) $(CONFIGURE) devel
$(CONFIGURE): $(PKG_DESCRIPTION)
@$(CABAL) configure
$(DEP): $(PKG_DESCRIPTION)
@echo "System dependencies are missing and need to be installed with admin privileges"
@export PATH=$(ADMINPATH) \
&& (sudo apt-get --no-upgrade --no-install-recommends -y install $(SYSDEPS) || true)
@# This can be taken out but could be used in the case where
@# the repository is git cloned. It;s also possible to init the
@# sandbox after the base dependencies are installed
@[ -e $(DEP) ] || ( \
$(CABAL) update \
&& $(CABAL) sandbox init \
&& $(CABAL) install alex happy yesod-bin)
@$(CABAL) install -j \
--dependencies-only \
--enable-documentation \
--run-tests \
--haddock-hyperlink-source \
--reorder-goals
devel: $(CONFIGURE)
@export HASKELL_PACKAGE_SANDBOX=$(DEP) \
&& $(YESOD) devel
clean:
@$(CABAL) clean
reallyclean:
@$(CABAL) clean
@$(CABAL) sandbox delete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment