hledger/Version.hs
2009-05-23 23:53:12 +00:00

47 lines
1.5 KiB
Haskell

{-# OPTIONS_GHC -cpp #-}
module Version
where
import Ledger.Utils
import Options (progname)
-- updated by build process from VERSION
version = "0.5.0"
#ifdef PATCHES
-- a "make" development build defines PATCHES from the repo state
patchlevel = "." ++ show PATCHES -- must be numeric !
#else
patchlevel = ""
#endif
buildversion = version ++ patchlevel
versionstr = prettify $ splitAtElement '.' buildversion
where
prettify (major:minor:bugfix:patches:[]) =
printf "%s.%s%s%s%s" major minor bugfix' patches' desc
where
bugfix'
| bugfix `elem` ["0"{-,"98","99"-}] = ""
| otherwise = "."++bugfix
patches'
| patches/="0" = " + "++patches++" patches"
| otherwise = ""
desc
-- | bugfix=="98" = " (alpha)"
-- | bugfix=="99" = " (beta)"
| otherwise = ""
prettify s = intercalate "." s
versionmsg = progname ++ " " ++ versionstr ++ configmsg ++ "\n"
where configmsg
| null configflags = ""
| otherwise = ", built with " ++ intercalate ", " configflags
configflags = tail [""
#ifdef VTY
,"vty"
#endif
#ifdef HAPPS
,"happs"
#endif
]