1 {-# OPTIONS_GHC -cpp #-}
    2 module Version
    3 where
    4 import Ledger.Utils
    5 import Options (progname)
    6 
    7 -- updated by build process from VERSION
    8 version       = "0.5.1"
    9 #ifdef PATCHLEVEL
   10 -- a "make" development build defines PATCHLEVEL from the repo state
   11 patchlevel = "." ++ show PATCHLEVEL -- must be numeric !
   12 #else
   13 patchlevel = ""
   14 #endif
   15 buildversion  = version ++ patchlevel
   16 
   17 versionstr    = prettify $ splitAtElement '.' buildversion
   18                 where
   19                   prettify (major:minor:bugfix:patches:[]) =
   20                       printf "%s.%s%s%s%s" major minor bugfix' patches' desc
   21                           where
   22                             bugfix'
   23                                 | bugfix `elem` ["0"{-,"98","99"-}] = ""
   24                                 | otherwise = "."++bugfix
   25                             patches'
   26                                 | patches/="0" = " + "++patches++" patches"
   27                                 | otherwise = ""
   28                             desc
   29 --                                 | bugfix=="98" = " (alpha)"
   30 --                                 | bugfix=="99" = " (beta)"
   31                                 | otherwise = ""
   32                   prettify s = intercalate "." s
   33 
   34 versionmsg    = progname ++ " " ++ versionstr ++ configmsg ++ "\n"
   35     where configmsg
   36               | null configflags = ""
   37               | otherwise = ", built with " ++ intercalate ", " configflags
   38 
   39 configflags   = tail [""
   40 #ifdef VTY
   41   ,"vty"
   42 #endif
   43 #ifdef HAPPS
   44   ,"happs"
   45 #endif
   46  ]