2009-09-22 16:22:44 +04:00
|
|
|
{-# LANGUAGE CPP #-}
|
2009-06-05 06:07:38 +04:00
|
|
|
{-
|
2009-12-11 01:43:23 +03:00
|
|
|
Version-related utilities. See the Makefile for details of our version
|
|
|
|
numbering policy.
|
2009-06-05 06:07:38 +04:00
|
|
|
-}
|
|
|
|
|
2009-02-27 05:55:54 +03:00
|
|
|
module Version
|
|
|
|
where
|
2009-06-05 06:07:38 +04:00
|
|
|
import System.Info (os, arch)
|
2009-02-27 05:55:54 +03:00
|
|
|
import Ledger.Utils
|
|
|
|
import Options (progname)
|
|
|
|
|
2009-06-05 06:07:38 +04:00
|
|
|
-- version and PATCHLEVEL are set by the makefile
|
2010-02-04 00:54:32 +03:00
|
|
|
version = "0.8.0"
|
2009-06-05 06:07:38 +04:00
|
|
|
|
2009-06-03 00:37:34 +04:00
|
|
|
#ifdef PATCHLEVEL
|
|
|
|
patchlevel = "." ++ show PATCHLEVEL -- must be numeric !
|
2009-04-02 04:45:57 +04:00
|
|
|
#else
|
|
|
|
patchlevel = ""
|
|
|
|
#endif
|
2009-06-05 06:07:38 +04:00
|
|
|
|
2009-06-05 06:40:33 +04:00
|
|
|
buildversion = version ++ patchlevel :: String
|
2009-02-27 05:55:54 +03:00
|
|
|
|
2009-06-05 06:40:33 +04:00
|
|
|
binaryfilename = prettify $ splitAtElement '.' buildversion :: String
|
2009-06-05 06:07:38 +04:00
|
|
|
where
|
|
|
|
prettify (major:minor:bugfix:patches:[]) =
|
2009-06-17 20:18:53 +04:00
|
|
|
printf "hledger-%s.%s%s%s-%s-%s%s" major minor bugfix' patches' os' arch suffix
|
2009-06-05 06:07:38 +04:00
|
|
|
where
|
|
|
|
bugfix'
|
|
|
|
| bugfix `elem` ["0"{-,"98","99"-}] = ""
|
2009-09-23 13:22:53 +04:00
|
|
|
| otherwise = '.' : bugfix
|
2009-06-05 06:07:38 +04:00
|
|
|
patches'
|
2009-09-23 13:22:53 +04:00
|
|
|
| patches/="0" = '+' : patches
|
2009-06-05 06:07:38 +04:00
|
|
|
| otherwise = ""
|
2009-06-17 20:18:53 +04:00
|
|
|
(os',suffix)
|
|
|
|
| os == "darwin" = ("mac","")
|
|
|
|
| os == "mingw32" = ("windows",".exe")
|
|
|
|
| otherwise = (os,"")
|
2009-09-23 13:48:14 +04:00
|
|
|
prettify (major:minor:bugfix:[]) = prettify [major,minor,bugfix,"0"]
|
|
|
|
prettify (major:minor:[]) = prettify [major,minor,"0","0"]
|
|
|
|
prettify (major:[]) = prettify [major,"0","0","0"]
|
2009-06-05 13:44:20 +04:00
|
|
|
prettify [] = error "VERSION is empty, please fix"
|
|
|
|
prettify _ = error "VERSION has too many components, please fix"
|
2009-06-05 06:07:38 +04:00
|
|
|
|
2009-06-05 06:40:33 +04:00
|
|
|
versionstr = prettify $ splitAtElement '.' buildversion :: String
|
2009-02-27 05:55:54 +03:00
|
|
|
where
|
|
|
|
prettify (major:minor:bugfix:patches:[]) =
|
2009-12-11 01:43:14 +03:00
|
|
|
printf "%s.%s%s%s" major minor bugfix' patches'
|
2009-02-27 05:55:54 +03:00
|
|
|
where
|
|
|
|
bugfix'
|
|
|
|
| bugfix `elem` ["0"{-,"98","99"-}] = ""
|
2009-09-23 13:22:53 +04:00
|
|
|
| otherwise = '.' : bugfix
|
2009-02-27 05:55:54 +03:00
|
|
|
patches'
|
2009-12-04 02:31:58 +03:00
|
|
|
| patches/="0" = "+"++patches
|
2009-02-27 05:55:54 +03:00
|
|
|
| otherwise = ""
|
|
|
|
prettify s = intercalate "." s
|
|
|
|
|
2009-06-05 06:40:33 +04:00
|
|
|
versionmsg = progname ++ "-" ++ versionstr ++ configmsg :: String
|
2009-02-27 05:55:54 +03:00
|
|
|
where configmsg
|
2009-06-05 06:07:38 +04:00
|
|
|
| null configflags = " with no extras"
|
|
|
|
| otherwise = " with " ++ intercalate ", " configflags
|
2009-02-27 05:55:54 +03:00
|
|
|
|
|
|
|
configflags = tail [""
|
2010-02-16 06:39:19 +03:00
|
|
|
#ifdef CHART
|
|
|
|
,"chart"
|
|
|
|
#endif
|
2009-02-27 05:55:54 +03:00
|
|
|
#ifdef VTY
|
|
|
|
,"vty"
|
|
|
|
#endif
|
2010-02-16 06:39:19 +03:00
|
|
|
#if defined(WEB)
|
|
|
|
,"web (using simpleserver)"
|
|
|
|
#else if defined(WEBHAPPSTACK)
|
|
|
|
,"web (using happstack)"
|
2009-02-27 05:55:54 +03:00
|
|
|
#endif
|
|
|
|
]
|