Commit 0d25c19d authored by Lennart Spitzner's avatar Lennart Spitzner
Browse files

Replace haskell package handling (package-db -> sandbox)

parent 5a932640
......@@ -29,7 +29,9 @@ make.log
curry2prolog/pakcsversion.pl
docs/src/version.tex
lib/
pkg/
.cabal-sandbox/
cabal.sandbox.config
# binaries
*.state
......
......@@ -46,10 +46,8 @@ export DOCDIR = $(ROOT)/docs
C2PVERSION=$(ROOT)/curry2prolog/pakcsversion.pl
# The version information file for the manual:
MANUALVERSION=$(DOCDIR)/src/version.tex
# Directory where local package installations are stored
export LOCALPKG = $(ROOT)/pkg
# The path to the package database
export PKGDB = $(LOCALPKG)/pakcs.conf.d
# The sandbox directory used for installing haskell/cabal packages
export ROOTSANDBOX = $(ROOT)/.cabal-sandbox
# Various executables used in the installation
# --------------------------------------------
......@@ -70,32 +68,12 @@ MAKELOG=make.log
# ----------------------------------------------------------
# The path to the Glasgow Haskell Compiler and Cabal
export GHC := $(shell which ghc)
export GHC-PKG := $(shell dirname "$(GHC)")/ghc-pkg
export CABAL = cabal
# Because of an API change in GHC 7.6,
# we need to distinguish GHC < 7.6 and GHC >= 7.6.
# GHC 7.6 renamed the option "package-conf" to "package-db".
# extract GHC version
GHC_MAJOR := $(shell "$(GHC)" --numeric-version | cut -d. -f1)
GHC_MINOR := $(shell "$(GHC)" --numeric-version | cut -d. -f2)
# Is the GHC version >= 7.6 ?
GHC_GEQ_76 = $(shell test $(GHC_MAJOR) -gt 7 -o \( $(GHC_MAJOR) -eq 7 \
-a $(GHC_MINOR) -ge 6 \) ; echo $$?)
# package-db (>= 7.6) or package-conf (< 7.6)?
ifeq ($(GHC_GEQ_76),0)
GHC_PKG_OPT = package-db
else
GHC_PKG_OPT = package-conf
endif
# Command to unregister a package
export GHC_UNREGISTER = "$(GHC-PKG)" unregister --$(GHC_PKG_OPT)="$(PKGDB)"
export PACKAGE_UNREGISTER = "$(CABAL)" sandbox hc-pkg -- unregister
# Command to install missing packages using cabal
export CABAL_INSTALL = "$(CABAL)" install --with-compiler="$(GHC)" \
--with-hc-pkg="$(GHC-PKG)" --prefix="$(LOCALPKG)" \
--global --package-db="$(PKGDB)" -O2
export CABAL_INSTALL = "$(CABAL)" install --with-compiler="$(GHC)" -O2
########################################################################
# The targets
......@@ -164,14 +142,13 @@ copylibs:
@if [ -d lib-trunk ] ; then cd lib-trunk && $(MAKE) -f Makefile.$(CURRYSYSTEM).install ; fi
# create package database
$(PKGDB):
"$(GHC-PKG)" init $@
$(CABAL) update
$(ROOTSANDBOX):
$(CABAL) sandbox init
# install front end (if sources are present):
.PHONY: frontend
frontend:
@if [ -d frontend ] ; then $(MAKE) $(PKGDB) && cd frontend && $(MAKE) ; fi
@if [ -d frontend ] ; then $(MAKE) $(ROOTSANDBOX) && cd frontend && $(MAKE) ; fi
# compile the tools:
.PHONY: tools
......@@ -306,6 +283,7 @@ distdated: dist
mv $(FULLNAME)-$(ARCH).tar.gz $(FULLNAME)-$(DIST_DATE)-$(ARCH).tar.gz
# Clean all files that should not be included in a distribution
# DANGER; deletes .git (!)
.PHONY: cleandist
cleandist:
rm -rf .git .gitmodules .gitignore
......
......@@ -5,25 +5,41 @@
# Retrieve all Haskell modules as dependencies for cymake
DEPS := $(shell find curry-base/src/ curry-frontend/src/ -type f)
# The sandbox config in curry-base linking to the root sandbox
SANDBOXBASECONF := curry-base/cabal.sandbox.config
# The sandbox config in curry-frontend linking to the root sandbox
SANDBOXFRONTENDCONF := curry-frontend/cabal.sandbox.config
# The sandbox config in . linking to the root sandbox
SANDBOXCONF := cabal.sandbox.config
# install the sources of the front end from its repository
$(CYMAKE): $(DEPS)
$(CYMAKE): $(DEPS) $(SANDBOXBASECONF) $(SANDBOXFRONTENDCONF)
$(MAKE) unregister
mkdir -p $(@D)
cd curry-base && $(CABAL_INSTALL)
$(MAKE) transformers # see below
cd curry-frontend && $(CABAL_INSTALL) --bindir=$(@D)
$(SANDBOXBASECONF):
cd curry-base && "$(CABAL)" sandbox init --sandbox="$(ROOTSANDBOX)"
$(SANDBOXFRONTENDCONF):
cd curry-frontend && "$(CABAL)" sandbox init --sandbox="$(ROOTSANDBOX)"
$(SANDBOXCONF):
"$(CABAL)" sandbox init --sandbox="$(ROOTSANDBOX)"
# Temporary workaround for https://github.com/haskell/cabal/issues/1855
# see also http://www.haskell.org/pipermail/cabal-devel/2014-May/009795.html
.PHONY: transformers
transformers:
transformers: $(SANDBOXCONF)
$(CABAL_INSTALL) transformers-compat -f transformers3
# unregister previous version to avoid cabal install failures
.PHONY: unregister
unregister:
-$(GHC_UNREGISTER) curry-frontend
-$(GHC_UNREGISTER) curry-base
unregister: $(SANDBOXCONF)
-$(PACKAGE_UNREGISTER) curry-frontend
-$(PACKAGE_UNREGISTER) curry-base
.PHONY: clean
clean:
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment