{-# LANGUAGE NamedFieldPuns #-}

module GHC.Toolchain.Tools.Ranlib
    ( Ranlib(..)
    , findRanlib
    ) where

import GHC.Toolchain.Prelude
import GHC.Toolchain.Program

newtype Ranlib = Ranlib { Ranlib -> Program
ranlibProgram :: Program
                        }
    deriving (Int -> Ranlib -> ShowS
[Ranlib] -> ShowS
Ranlib -> String
(Int -> Ranlib -> ShowS)
-> (Ranlib -> String) -> ([Ranlib] -> ShowS) -> Show Ranlib
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
$cshowsPrec :: Int -> Ranlib -> ShowS
showsPrec :: Int -> Ranlib -> ShowS
$cshow :: Ranlib -> String
show :: Ranlib -> String
$cshowList :: [Ranlib] -> ShowS
showList :: [Ranlib] -> ShowS
Show, ReadPrec [Ranlib]
ReadPrec Ranlib
Int -> ReadS Ranlib
ReadS [Ranlib]
(Int -> ReadS Ranlib)
-> ReadS [Ranlib]
-> ReadPrec Ranlib
-> ReadPrec [Ranlib]
-> Read Ranlib
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
$creadsPrec :: Int -> ReadS Ranlib
readsPrec :: Int -> ReadS Ranlib
$creadList :: ReadS [Ranlib]
readList :: ReadS [Ranlib]
$creadPrec :: ReadPrec Ranlib
readPrec :: ReadPrec Ranlib
$creadListPrec :: ReadPrec [Ranlib]
readListPrec :: ReadPrec [Ranlib]
Read, Ranlib -> Ranlib -> Bool
(Ranlib -> Ranlib -> Bool)
-> (Ranlib -> Ranlib -> Bool) -> Eq Ranlib
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
$c== :: Ranlib -> Ranlib -> Bool
== :: Ranlib -> Ranlib -> Bool
$c/= :: Ranlib -> Ranlib -> Bool
/= :: Ranlib -> Ranlib -> Bool
Eq, Eq Ranlib
Eq Ranlib =>
(Ranlib -> Ranlib -> Ordering)
-> (Ranlib -> Ranlib -> Bool)
-> (Ranlib -> Ranlib -> Bool)
-> (Ranlib -> Ranlib -> Bool)
-> (Ranlib -> Ranlib -> Bool)
-> (Ranlib -> Ranlib -> Ranlib)
-> (Ranlib -> Ranlib -> Ranlib)
-> Ord Ranlib
Ranlib -> Ranlib -> Bool
Ranlib -> Ranlib -> Ordering
Ranlib -> Ranlib -> Ranlib
forall a.
Eq a =>
(a -> a -> Ordering)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> Bool)
-> (a -> a -> a)
-> (a -> a -> a)
-> Ord a
$ccompare :: Ranlib -> Ranlib -> Ordering
compare :: Ranlib -> Ranlib -> Ordering
$c< :: Ranlib -> Ranlib -> Bool
< :: Ranlib -> Ranlib -> Bool
$c<= :: Ranlib -> Ranlib -> Bool
<= :: Ranlib -> Ranlib -> Bool
$c> :: Ranlib -> Ranlib -> Bool
> :: Ranlib -> Ranlib -> Bool
$c>= :: Ranlib -> Ranlib -> Bool
>= :: Ranlib -> Ranlib -> Bool
$cmax :: Ranlib -> Ranlib -> Ranlib
max :: Ranlib -> Ranlib -> Ranlib
$cmin :: Ranlib -> Ranlib -> Ranlib
min :: Ranlib -> Ranlib -> Ranlib
Ord)

findRanlib :: ProgOpt -> M Ranlib
findRanlib :: ProgOpt -> M Ranlib
findRanlib ProgOpt
progOpt = String -> M Ranlib -> M Ranlib
forall a. Show a => String -> M a -> M a
checking String
"for 'ranlib'" (M Ranlib -> M Ranlib) -> M Ranlib -> M Ranlib
forall a b. (a -> b) -> a -> b
$ do
    ranlibProgram <- String -> ProgOpt -> [String] -> M Program
findProgram String
"ranlib archiver" ProgOpt
progOpt [String
"ranlib", String
"llvm-ranlib"]
    return $ Ranlib {ranlibProgram}