a84a8d508a0778b13a4d097a6dd34b95feae78acJens Elkner# to be included by Makefile
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmdSHELL := $(shell [ -x /bin/ksh93 ] && echo '/bin/ksh93' || echo '/bin/bash' )
aa4fbedb87724ee8397a269d364674f763282d04Eugen KuksaOSNAME := $(shell uname -s)
aa4fbedb87724ee8397a269d364674f763282d04Eugen KuksaOSVERS := $(shell uname -v 2>/dev/null)
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmd# Strip off the longest prefix ending with '-' incl. of arg $1, split remaining
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmd# string by '.' and calculate 1.000.000 * ${major} + 1.000 * ${minor} + ${tiny)
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmd# what makes comparing version numbers much easier. If any part in the version
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmd# string is not a number, it gets replaced by '0'.
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmd# This macro requires features found in shells like ksh93 or bash.
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmdversion = $(shell X="$(1)"; X="$${X\#\#*-}"; A=( $${X//./ } 0 0 0 ); \
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmd A=( $$( printf "%d %d %d" "$${A[0]}" "$${A[1]}" "$${A[2]}" )); \
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmd echo $$(( $${A[0]} * 1000000 + $${A[1]} * 1000 + $${A[2]} )) \
f8597aabc9db75dcf504e3151faf220a165c90d1Eugen Kuksa# If stack exists, use it. Otherwise skip it and use the system GHC.
aa4fbedb87724ee8397a269d364674f763282d04Eugen KuksaSTACK ?= $(shell command -v stack 2> /dev/null)
aa4fbedb87724ee8397a269d364674f763282d04Eugen KuksaSTACK_EXEC :=
aa4fbedb87724ee8397a269d364674f763282d04Eugen KuksaSTACK_TARGET :=
aa4fbedb87724ee8397a269d364674f763282d04Eugen KuksaSTACK_UPGRADE_TARGET :=
aa4fbedb87724ee8397a269d364674f763282d04Eugen KuksaSTACK_DEPENDENCIES_FLAGS :=
aa4fbedb87724ee8397a269d364674f763282d04Eugen Kuksaifneq ($(STACK),)
f8597aabc9db75dcf504e3151faf220a165c90d1Eugen Kuksa STACK_EXEC := $(STACK) exec --
f8597aabc9db75dcf504e3151faf220a165c90d1Eugen Kuksa # Upgrade Haskell-Stack if the version requirement of 1.4.0 is not met
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmd STACK_VERSION := $(call version, $(shell stack --numeric-version))
f8597aabc9db75dcf504e3151faf220a165c90d1Eugen Kuksa STACK_TARGET := stack
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmd STACK_UPGRADE_TARGET := \
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmd $(shell [ $(STACK_VERSION) -lt 1004000 ] && echo 'stack_upgrade' )
aa4fbedb87724ee8397a269d364674f763282d04Eugen Kuksa ifeq "$(OSNAME)" "Darwin"
aa4fbedb87724ee8397a269d364674f763282d04Eugen Kuksa STACK_DEPENDENCIES_FLAGS := --flag gtk:have-quartz-gtk
961087225d1d2b9534152a346d1a3755ed952fcdJens Elkner## check-programatica convenience target helper vars:
a84a8d508a0778b13a4d097a6dd34b95feae78acJens Elkner# The URL of the programatica source archive to download if missing. It must be
a84a8d508a0778b13a4d097a6dd34b95feae78acJens Elkner# a gzippid tar archive, which can be get using wget!
a84a8d508a0778b13a4d097a6dd34b95feae78acJens Elkner# Don't quote! Space and other shell metcharacters are not allowed!
a84a8d508a0778b13a4d097a6dd34b95feae78acJens ElknerPROGRAMATICA_SRC_URL ?= \
961087225d1d2b9534152a346d1a3755ed952fcdJens Elkner http://theo.cs.uni-magdeburg.de/downloads/hets/src/programatica-1.0.0.5.tar.gz
961087225d1d2b9534152a346d1a3755ed952fcdJens Elkner# As an alternative, if you have a local copy of the programatica source
a84a8d508a0778b13a4d097a6dd34b95feae78acJens Elkner# archive to use.
a84a8d508a0778b13a4d097a6dd34b95feae78acJens Elkner# Don't quote! Space and other shell metcharacters are not allowed!
a84a8d508a0778b13a4d097a6dd34b95feae78acJens ElknerPROGRAMATICA_SRC_FILE ?= \
a84a8d508a0778b13a4d097a6dd34b95feae78acJens Elkner# The local file gets tried first, and if not usable the remote on gets fetched.
a84a8d508a0778b13a4d097a6dd34b95feae78acJens Elkner# If both are unset or set to an empty string, programatica support is skipped.
756f31c6dd0843b4435c0ca66485ec19139eb1a8Eugen Kuksa# We assume ghc 7+
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmdGHCVERSION := $(call version, $(shell $(STACK_EXEC) ghc --numeric-version))
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmdGHCRTSOPTS := $(shell [ $(GHCVERSION) -ge 7000000 ] && echo '-rtsopts')
a84a8d508a0778b13a4d097a6dd34b95feae78acJens Elknerifneq ($(findstring SunOS, $(OSNAME)),)
a84a8d508a0778b13a4d097a6dd34b95feae78acJens Elkner PATCH = gpatch
a84a8d508a0778b13a4d097a6dd34b95feae78acJens Elkner ifneq ($(findstring Generic, $(OSVERS)),)
a84a8d508a0778b13a4d097a6dd34b95feae78acJens Elkner SUNRUNPATH = -optl-R/opt/csw/lib
a84a8d508a0778b13a4d097a6dd34b95feae78acJens Elkner FIXED_GLADE = 0
a84a8d508a0778b13a4d097a6dd34b95feae78acJens Elkner FIXED_GLADE = 1
a84a8d508a0778b13a4d097a6dd34b95feae78acJens Elkner PATCH = patch
3de77a6e8f37af46de7047a9b83ee69b46d13095Eugen KuksaHC = $(STACK_EXEC) ghc -optl-s -XTemplateHaskell -threaded $(GHCRTSOPTS)
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmd# Compile on all CPU cores in parallel if GHC >= 8.0 is used.
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmdHC += $(shell [ $(GHCVERSION) -ge 8000000 ] && echo '-j')
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmdHCPKG := $(STACK_EXEC) ghc-pkg $(GHC_PKG_FLAGS)
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmdHAXMLVERSION := $(call version, $(shell $(HCPKG) latest HaXml))
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmdHAXML_PACKAGE := $(shell [ $(HAXMLVERSION) -ge 1020000 ] && echo '-DHAXML')
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmdHAXML_PACKAGE_COMPAT := \
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmd $(shell [ $(HAXMLVERSION) -lt 1021000 ] && echo '-DHAXML_COMPAT')
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmdTARVERSION := $(call version, $(shell $(HCPKG) latest tar))
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmdTAR_PACKAGE := $(shell [ $(TARVERSION) -gt 0 ] && echo '-DTAR_PACKAGE')
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmdUNIXVERSION := $(call version, $(shell $(HCPKG) latest unix))
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmdUNIX_PACKAGE := $(shell [ $(UNIXVERSION) -ge 2000000 ] && echo '-DUNIX')
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmdGLADEVERSION := $(call version, $(shell $(HCPKG) latest glade))
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmdGLADE_PACKAGE := \
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmd $(shell [ $(GLADEVERSION) -ge 12000 ] && echo '-DGTKGLADE $(SUNRUNPATH)')
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmdGLADE_PACKAGE += $(shell [ $(GLADEVERSION) -lt 13000 ] && \
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmd [ $(FIXED_GLADE) = '0' ] && echo '-DGTK12')
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmdHASKELINEVERSION := $(call version, $(shell $(HCPKG) latest haskeline))
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmdHASKELINE_PACKAGE := \
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmd $(shell [ $(HASKELINEVERSION) -ge 6000 ] && echo '-DHASKELINE')
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmdHEXPATVERSION := $(call version, $(shell $(HCPKG) latest hexpat))
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmdHEXPAT_PACKAGE := $(shell [ $(HEXPATVERSION) -gt 0 ] && echo '-DHEXPAT')
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmdHTTPVERSION = $(call version, $(shell $(HCPKG) latest HTTP))
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmdHTTP_PACKAGE = $(shell [ $(HTTPVERSION) -lt 4000000000 ] && echo '-DNOHTTP')
005603425396f16a79d0443c251649cd505909f8Jens ElknerHTTPCVERSION := $(call version, $(shell $(HCPKG) latest http-client))
005603425396f16a79d0443c251649cd505909f8Jens ElknerWGET := $(shell [ $(HTTPCVERSION) -ge 5007 ] && echo '-DNO_WGET' )
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmdUNIVERSION := $(call version, $(shell $(HCPKG) latest uni-uDrawGraph))
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmdUNI_PACKAGE := $(shell [ $(UNIVERSION) -ge 2000000 ] && echo '-DUNI_PACKAGE')
961087225d1d2b9534152a346d1a3755ed952fcdJens Elkner# If programatica src, i.e. Setup.hs et. al. is there ...
961087225d1d2b9534152a346d1a3755ed952fcdJens ElknerPFE_SETUP := $(shell ls -1 $(PFE_SETUP_FILE) 2>/dev/null )
961087225d1d2b9534152a346d1a3755ed952fcdJens Elkner# check for haskell programatica module ...
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmdPROGRAMATICAVERSION := $(call version, \
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmd $(shell [ -n "$(PFE_SETUP)" ] && $(HCPKG) latest programatica))
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmdPFE_FLAGS := $(shell [ $(PROGRAMATICAVERSION) -ge 1000000 ] && \
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmd echo '-package programatica -DPROGRAMATICA')
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmdWARPVERSION := $(call version, $(shell $(HCPKG) latest warp))
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmdHTTPTYPESVERSION := $(call version, $(shell $(HCPKG) latest http-types))
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmd# warp ensures by itself, that it is linked against the proper wai package. So
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmd# no need to check by ourselves.
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmdSERVER_FLAG := $(shell [ $(WARPVERSION) -ge 1000000 ] && echo '-DSERVER')
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmdSERVER_FLAG += $(shell [ $(WARPVERSION) -ge 3000000 ] && echo '-DWARP3')
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmdSERVER_FLAG += $(shell [ $(WARPVERSION) -lt 2000000 ] && \
d23ecf32e56cce69bc42eb5c96dddf7909c623abjelmd echo '-DWARP1 ' && [ $(HTTPTYPESVERSION) -ge 9000 ] && echo '-DHTTPTYPES')
4e9e95ba35a68f3c767bc0b23ebf9e904e442517Christian Maederifneq ($(strip $(UNI_PACKAGE)),)
b6d11ac9a9c43ae636a4d968eb7542748b46296dChristian Maeder ifeq ($(strip $(HTTP_PACKAGE)),)
b6d11ac9a9c43ae636a4d968eb7542748b46296dChristian Maeder TESTTARGETFILES += SoftFOL/tests/CMDL_tests.hs
961087225d1d2b9534152a346d1a3755ed952fcdJens ElknerHC_OPTS_WITHOUTGLADE = $(PARSEC_FLAG) \
005603425396f16a79d0443c251649cd505909f8Jens Elkner $(TIME_PACKAGE) $(TAR_PACKAGE) $(HTTP_PACKAGE) $(WGET) $(UNIX_PACKAGE) \
e4f0eaffd002e9e553ee113be33f9aa6e4181c43Christian Maeder $(UNI_PACKAGE) $(HASKELINE_PACKAGE) $(HEXPAT_PACKAGE) \
3dde4051c307b609159a097f08a05108fdd036efJonathan von Schroeder $(PFE_FLAGS) $(SERVER_FLAG) $(HAXML_PACKAGE) $(HAXML_PACKAGE_COMPAT) \
3dde4051c307b609159a097f08a05108fdd036efJonathan von Schroeder -DRDFLOGIC -DCASLEXTENSIONS
a91757fe2b73b73c43f41b6aa29876a1ae9e9b1bChristian Maeder# for profiling (or a minimal hets) comment out the previous two package lines
a91757fe2b73b73c43f41b6aa29876a1ae9e9b1bChristian Maeder# and the $(GLADE_PACKAGE) below
961087225d1d2b9534152a346d1a3755ed952fcdJens ElknerHC_OPTS = $(HC_OPTS_WITHOUTGLADE) $(GLADE_PACKAGE)