Permalink
Browse files

Tweak Makefile. Now allows out-of tree dist directory.

This is useful if you keep the sources in a place that might be shared
across several different machines.  E.g., the sources might be stored
on a remote (and backed-up) filesystem, but the compiled files should
be stored locally and need not require backup.
  • Loading branch information...
1 parent bcecd7d commit be138b002e3a065a1505c8f0af7d680b538b1532 @nominolo nominolo committed Dec 2, 2009
Showing with 34 additions and 24 deletions.
  1. +23 −19 Makefile
  2. +11 −5 config.mk.sample
View
@@ -1,22 +1,27 @@
-.PHONY: default clean install-lib install-deps setup
+.PHONY: default clean install-lib install-deps setup test
default: all
all: build
-include config.mk
+-include config.mk
+
+# Make sure we know the absolute path of the current directory.
+TOP := $(shell pwd)
# If not set in custom config.mk, use the default versions
HC ?= ghc
PKG ?= ghc-pkg
HADDOCK ?= haddock
+CABAL ?= cabal
+DIST ?= $(TOP)/dist
-DIST = dist
DIST_LIB = $(DIST)/lib
DIST_SERVER = $(DIST)/server
-SETUP_DIST = setup-dist
+SETUP_DIST = $(DIST)/setup
SETUP = $(SETUP_DIST)/Setup
-DOTDOTSETUP = cabal
+# Use this directory for testing from-scratch builds. (TODO)
+DIST_SCRATCH = $(DIST)/scratch
CABAL_INSTALL_OPTS += --ghc --with-compiler=$(HC) --with-hc-pkg=$(PKG)
CABAL_FLAGS ?=
@@ -32,21 +37,21 @@ $(DIST)/build/libHSscion-0.1.a: $(SETUP) $(DIST)/setup-config $(wildcard lib/**/
$(SETUP) build --builddir=$(DIST)
$(DIST):
- mkdir $(DIST)
+ mkdir -p $@
$(SETUP): Setup.hs $(SETUP_DIST)
$(HC) --make $< -o $@
$(SETUP_DIST):
- mkdir $@
+ mkdir -p $@
setup: $(SETUP)
build: $(DIST)/build/libHSscion-0.1.a
# TODO: dodgy
install: $(DIST)/build/libHSscion-0.1.a
- cabal install
+ $(CABAL) install
# test: build
# echo main | $(HC) --interactive -package ghc -DDEBUG -isrc -idist/build tests/RunTests.hs
@@ -62,14 +67,13 @@ distclean: clean
# $(SETUP) haddock --with-haddock=$(HADDOCK)
printvars:
- @echo "UseInplaceGhc = $(UseInplaceGhc)"
- @echo "GHC_PATH = $(GHC_PATH)"
- @echo "HC = $(HC)"
- @echo "PKG = $(PKG)"
- @echo "HADDOCK = $(HADDOCK)"
- @echo "CABAL_INSTALL = $(CABAL_INSTALL)"
- @echo " ..._OPTS = $(CABAL_INSTALL_OPTS)"
- @echo "CABAL_FLAGS = $(CABAL_FLAGS)"
- @echo "---------------------------------------------------------------"
- @echo "DIST_LIB = $(DIST_LIB)"
- @echo "SETUP_DIST = $(SETUP_DIST)"
+ @echo "UseInplaceGhc = $(UseInplaceGhc)"
+ @echo "GHC_PATH = $(GHC_PATH)"
+ @echo "HC = $(HC)"
+ @echo "PKG = $(PKG)"
+ @echo "HADDOCK = $(HADDOCK)"
+ @echo "CABAL = $(CABAL_INSTALL)"
+ @echo "CABAL_INSTALL_OPTS = $(CABAL_INSTALL_OPTS)"
+ @echo "CABAL_FLAGS = $(CABAL_FLAGS)"
+ @echo "DIST = $(DIST)"
+ @echo "TOP = $(TOP)"
View
@@ -11,9 +11,9 @@ UseInplaceGhc = NO
ifeq "$(UseInplaceGhc)" "YES"
GHC_PATH = /absolute/path/to/ghc
-HC ?= $(GHC_PATH)/inplace/bin/ghc-stage2
-PKG ?= $(GHC_PATH)/inplace/bin/ghc-pkg
-HADDOCK ?= $(GHC_PATH)/inplace/bin/haddock
+HC = $(GHC_PATH)/inplace/bin/ghc-stage2
+PKG = $(GHC_PATH)/inplace/bin/ghc-pkg
+HADDOCK = $(GHC_PATH)/inplace/bin/haddock
else
@@ -23,5 +23,11 @@ HADDOCK = haddock
endif
-# path to 'cabal' program from the 'cabal-install' tool.
-CABAL_INSTALL = cabal
+# If you want to put the files generated by the build somewhere
+# outside of the source directory uncomment and customise the
+# following line
+
+# DIST = $(HOME)/tmp/dist-cabal/scion/
+
+# path to 'cabal' program from the 'cabal-install' package.
+# CABAL = cabal

0 comments on commit be138b0

Please sign in to comment.