[add targets.ini file and rules for installing it.
John Meacham <john@repetae.net>**20090622222208
 Ignore-this: d7482aac7549579df7bbbf9a952f2456
] hunk ./Makefile.am 47
+
hunk ./Makefile.am 78
+	$(INSTALL) -d $(DESTDIR)$(sysconfdir)/@PACKAGE@-@SHORTVERSION@
hunk ./Makefile.am 84
+	$(INSTALL_DATA) "$(srcdir)/data/targets.ini" $(DESTDIR)$(sysconfdir)/@PACKAGE@-@SHORTVERSION@ ;
addfile ./Support/IniParse.hs
hunk ./Support/IniParse.hs 1
+{-# OPTIONS_GHC -fglasgow-exts #-}
+module Support.IniParse(parseIniFiles) where
+
+
+import Control.Monad.State
+import GenUtil
+import Data.Char
+import Data.List
+import qualified Data.Map as Map
+import qualified Data.Sequence as Seq
+import qualified Data.Foldable as Seq
+import Control.Monad
+
+-- quick and dirty parser.
+
+type St = (Int,FilePath,String)
+
+newtype P a = P (State St a)
+    deriving(Monad,MonadState St)
+
+
+third (_,_,x) = x
+
+look :: P String
+look = gets third
+
+
+discard :: Int -> P ()
+discard n = do
+    (fl,fp,s) <- get
+    let (x,y) = splitAt n s
+    put (fl + length (filter (== '\n') x),fp, y)
+
+abort :: String -> P a
+abort msg = do
+    (l,fp,_)  <- get
+    fail $ fp ++ ":" ++ show l ++ ": " ++ msg
+
+
+dropSpace = do
+    x <- look
+    case x of
+        ';':_ -> pdropWhile ('\n' /=) >> dropSpace
+        c:_ | isSpace c -> pdropWhile isSpace >> dropSpace
+        _ -> return ()
+
+pdropWhile f  = do
+    x <- look
+    case x of
+        c:_ | f c -> discard 1 >> pdropWhile f
+        _ -> return ()
+
+ptakeWhile f  = do
+    x <- look
+    let ts = takeWhile f x
+    discard (length ts)
+    return ts
+
+
+
+pThings ch rs zs  = ans where
+    ans = look >>= \x -> case x of
+        '[':_ -> do
+            hv <- pHeader
+            dropSpace
+            pThings hv Seq.empty (zs Seq.|> (ch,rs))
+        _:_ -> do
+            v <- pValue
+            dropSpace
+            pThings ch (rs Seq.|> v) zs
+        [] -> return (zs Seq.|> (ch,rs))
+
+trim = rbdropWhile isSpace
+
+expect w = do
+    cs <- look
+    if w `isPrefixOf` cs then discard (length w) else abort ("expected " ++ show w)
+
+
+pValue = do
+    n <- ptakeWhile (`notElem` ['\n','='])
+    expect "="
+    rs <- ptakeWhile (/= '\n')
+    return (trim n, trim rs)
+
+pHeader = do
+    expect "["
+    n <- ptakeWhile (`notElem` "]\n")
+    expect "]"
+    return (trim n)
+
+
+
+-- We use laziness cleverly to avoid repeating work
+processIni :: Seq.Seq (String,Seq.Seq (String,String)) -> Map.Map String (Map.Map String String)
+processIni iniRaw = ans where
+    iniMap,iniMap' :: Map.Map String (Seq.Seq (String,String))
+    iniMap = Map.fromListWith (flip (Seq.><)) (Seq.toList iniRaw)
+    iniMap' = Map.map expandChains iniMap
+    expandChains x = join (fmap ecp x)
+    ecp :: (String,String) -> Seq.Seq (String,String)
+    ecp ("merge",v) = Map.findWithDefault Seq.empty v iniMap'
+    ecp x = Seq.singleton x
+    ans = Map.map (\c -> Seq.foldl res Map.empty c) iniMap'
+    res mp (k,v) | Just r <- getPrefix "+" (reverse k) = Map.insertWith f (reverse $ dropWhile isSpace r) v mp where
+        f y x = x ++ " " ++ y
+    res mp (k,v) = Map.insert k v mp
+
+    
+
+parseIniFile :: FilePath -> IO (Seq.Seq (String,Seq.Seq (String,String)))
+parseIniFile fp = do
+    let P act = dropSpace >> pThings "default" Seq.empty Seq.empty
+    c <- readFile fp
+    return $ evalState act (0,fp,c)
+
+
+parseIniFiles 
+    :: Bool          -- ^ whether verbose is enabled
+    -> [FilePath]    -- ^ the files (in order) we attempt to parse
+    -> [String]      -- ^ the m-flags 
+    -> IO (Map.Map String String)
+parseIniFiles verbose fs ss = do
+    let rf fn = catch (do c <- parseIniFile fn; pverb ("reading " ++ fn); return c) (\_ -> return Seq.empty) 
+        pverb s = if verbose then putErrLn s else return ()
+    fsc <- mapM rf fs
+    let pini = processIni (foldr (Seq.><) Seq.empty fsc)
+        f (x:xs) cm = case span (/= '=') x of
+            (be,'=':re) -> f xs (Map.insert be re cm)
+            (be,[]) -> f xs (Map.findWithDefault Map.empty be pini `Map.union` cm)
+        f [] cm = cm
+    return (f ss Map.empty)
+        
+
+
+
+
+--main = do
+--    as <- getArgs
+--    is <- mapM parseIniFile as
+--    let pi = processIni (foldr (Seq.><) Seq.empty is)
+--
+--    print "proc"
+--    let f (h,rs) = do
+--            putStrLn h
+--            mapM_ (\x -> putStr "    " >>  print x) (Map.toList rs)
+--    mapM_ f (Map.toList pi)
+
+
+
+
+
+
hunk ./Version/Config.hs.in 11
+confDir = "@JETCPATH@"
hunk ./configure.ac 1
-AC_INIT([jhc],[0.6.0])
+AC_INIT([jhc],[0.6.1])
hunk ./configure.ac 7
-REVISION=20090304
-SHORTVERSION=0.5
+REVISION=20090622
+SHORTVERSION=0.6
hunk ./configure.ac 33
+jetcpath=${sysconfdir}/$PACKAGE-$SHORTVERSION
hunk ./configure.ac 38
+AC_DEFINE_DIR(JETCPATH,jetcpath)
hunk ./configure.ac 51
+AC_SUBST(JETCPATH)
addfile ./data/targets.ini
hunk ./data/targets.ini 1
+;
+; configuration file for architectures and compiler options.
+;
+; the final value set is the one used.
+;
+; all '-m' parameters on the command line are parsed and processed in order.
+;
+; there is an implicit -mdefault processed first
+; entries in the user config file are appended to this one.
+;
+
+
+[default]
+cc=gcc
+gc=static
+cflags=-std=gnu99 -D_GNU_SOURCE -falign-functions=4 -ffast-math -Wshadow -Wextra -Wall -Wno-unused-parameter
+cflags_debug=-g
+cflags_nodebug=-DNDEBUG -O3
+profile=false
+autoload=base,haskell98
+
+
+[win32]
+gcc=i386-mingw32-gcc
+output_extension=.exe
+merge=i686
+
+; macintosh
+[osx]
+
+[osx-intel]
+gcc=i686-apple-darwin9-gcc
+merge=i686
+merge=osx
+
+[osx-powerpc]
+gcc=powerpc-apple-darwin9-gcc
+merge=be32
+merge=osx
+
+
+[i686]
+merge=le32
+arch=i686
+bits_max=64
+cflags_nodebug+=-fomit-frame-pointer
+
+[x86_64]
+bits_max=64
+merge=le64
+
+[le32]
+
+byteorder=le
+merge=32
+
+[be32]
+byteorder=be
+merge=32
+
+[le64]
+byteorder=le
+merge=64
+
+[be64]
+byteorder=be
+merge=64
+
+
+[32]
+cflags+=-m32
+bits=32
+
+[64]
+cflags+=-m64
+bits=64
+
hunk ./jhc.spec.in 42
+%{_sysconfdir}/@PACKAGE@-@SHORTVERSION@/targets.ini