Commit 78ccdb33 authored by phigley's avatar phigley
Browse files

Add --program-prefix and --program-suffix options to configure (#208)

parent cf5d5705
......@@ -666,13 +666,15 @@ makefile pkg_descr lbi flags = do
installExe :: Verbosity -- ^verbosity
-> FilePath -- ^install location
-> FilePath -- ^Build location
-> (FilePath, FilePath) -- ^Executable (prefix,suffix)
-> PackageDescription
-> IO ()
installExe verbosity pref buildPref pkg_descr
installExe verbosity pref buildPref (progprefix, progsuffix) pkg_descr
= do createDirectoryIfMissingVerbose verbosity True pref
withExe pkg_descr $ \ (Executable e _ _) -> do
let exeFileName = e <.> exeExtension
copyFileVerbose verbosity (buildPref </> e </> exeFileName) (pref </> exeFileName)
fixedExeFileName = (progprefix ++ e ++ progsuffix) <.> exeExtension
copyFileVerbose verbosity (buildPref </> e </> exeFileName) (pref </> fixedExeFileName)
-- |Install for ghc, .hi, .a and, if --with-ghci given, .o
installLib :: Verbosity -- ^verbosity
......
......@@ -343,9 +343,10 @@ install
-> FilePath -- ^Executable install location
-> FilePath -- ^Program location on target system
-> FilePath -- ^Build location
-> (FilePath,FilePath) -- ^Executable (prefix,suffix)
-> PackageDescription
-> IO ()
install verbosity libDir installProgDir binDir targetProgDir buildPref pkg_descr = do
install verbosity libDir installProgDir binDir targetProgDir buildPref (progprefix,progsuffix) pkg_descr = do
try $ removeDirectoryRecursive libDir
smartCopySources verbosity [buildPref] libDir (libModules pkg_descr) hugsInstallSuffixes True False
let buildProgDir = buildPref </> "programs"
......@@ -362,9 +363,10 @@ install verbosity libDir installProgDir binDir targetProgDir buildPref pkg_descr
-- FIX (HUGS): use extensions, and options from file too?
-- see http://hackage.haskell.org/trac/hackage/ticket/43
let hugsOptions = hcOptions Hugs (options (buildInfo exe))
let baseExeFile = progprefix ++ (exeName exe) ++ progsuffix
let exeFile = case os of
Windows _ -> binDir </> exeName exe <.> ".bat"
_ -> binDir </> exeName exe
Windows _ -> binDir </> baseExeFile <.> ".bat"
_ -> binDir </> baseExeFile
let script = case os of
Windows _ ->
let args = hugsOptions ++ [targetName, "%*"]
......
......@@ -87,7 +87,9 @@ install pkg_descr lbi flags = do
docdir = docPref,
htmldir = htmlPref,
haddockdir = interfacePref,
includedir = incPref
includedir = incPref,
progprefix = progprefixPref,
progsuffix = progsuffixPref
} = absoluteInstallDirs pkg_descr lbi copydest
docExists <- doesDirectoryExist $ haddockPref pkg_descr
info verbosity ("directory " ++ haddockPref pkg_descr ++
......@@ -128,15 +130,15 @@ install pkg_descr lbi flags = do
GHC -> do withLib pkg_descr () $ \_ ->
GHC.installLib verbosity lbi libPref dynlibPref buildPref pkg_descr
withExe pkg_descr $ \_ ->
GHC.installExe verbosity binPref buildPref pkg_descr
GHC.installExe verbosity binPref buildPref (progprefixPref, progsuffixPref) pkg_descr
JHC -> do withLib pkg_descr () $ JHC.installLib verbosity libPref buildPref pkg_descr
withExe pkg_descr $ JHC.installExe verbosity binPref buildPref pkg_descr
withExe pkg_descr $ JHC.installExe verbosity binPref buildPref (progprefixPref, progsuffixPref) pkg_descr
Hugs -> do
let targetProgPref = progdir (absoluteInstallDirs pkg_descr lbi NoCopyDest)
let scratchPref = scratchDir lbi
Hugs.install verbosity libPref progPref binPref targetProgPref scratchPref pkg_descr
Hugs.install verbosity libPref progPref binPref targetProgPref scratchPref (progprefixPref, progsuffixPref) pkg_descr
NHC -> do withLib pkg_descr () $ NHC.installLib verbosity libPref buildPref (package pkg_descr)
withExe pkg_descr $ NHC.installExe verbosity binPref buildPref
withExe pkg_descr $ NHC.installExe verbosity binPref buildPref (progprefixPref, progsuffixPref)
_ -> die ("only installing with GHC, JHC, Hugs or nhc98 is implemented")
return ()
-- register step should be performed by caller.
......
......@@ -109,7 +109,9 @@ data InstallDirs dir = InstallDirs {
docdir :: dir,
mandir :: dir,
htmldir :: dir,
haddockdir :: dir
haddockdir :: dir,
progprefix :: dir,
progsuffix :: dir
} deriving (Read, Show)
instance Functor InstallDirs where
......@@ -127,7 +129,9 @@ instance Functor InstallDirs where
docdir = f (docdir dirs),
mandir = f (mandir dirs),
htmldir = f (htmldir dirs),
haddockdir = f (haddockdir dirs)
haddockdir = f (haddockdir dirs),
progprefix = f (progprefix dirs),
progsuffix = f (progsuffix dirs)
}
instance Monoid dir => Monoid (InstallDirs dir) where
......@@ -145,7 +149,9 @@ instance Monoid dir => Monoid (InstallDirs dir) where
docdir = mempty,
mandir = mempty,
htmldir = mempty,
haddockdir = mempty
haddockdir = mempty,
progprefix = mempty,
progsuffix = mempty
}
mappend = combineInstallDirs mappend
......@@ -167,7 +173,9 @@ combineInstallDirs combine a b = InstallDirs {
docdir = docdir a `combine` docdir b,
mandir = mandir a `combine` mandir b,
htmldir = htmldir a `combine` htmldir b,
haddockdir = haddockdir a `combine` haddockdir b
haddockdir = haddockdir a `combine` haddockdir b,
progprefix = progprefix a `combine` progprefix b,
progsuffix = progsuffix a `combine` progsuffix b
}
appendSubdirs :: (a -> a -> a) -> InstallDirs a -> InstallDirs a
......@@ -239,7 +247,9 @@ defaultInstallDirs comp userInstall hasLibs = do
_other -> "$datadir" </> "doc" </> "$pkgid",
mandir = "$datadir" </> "man",
htmldir = "$docdir" </> "html",
haddockdir = "$htmldir"
haddockdir = "$htmldir",
progprefix = "",
progsuffix = ""
}
-- ---------------------------------------------------------------------------
......@@ -277,7 +287,9 @@ substituteTemplates pkgId compilerId dirs = dirs'
mandir = subst docdir (prefixBinLibDataVars ++ [docdirVar]),
htmldir = subst htmldir (prefixBinLibDataVars ++ [docdirVar]),
haddockdir = subst haddockdir (prefixBinLibDataVars ++
[docdirVar, htmldirVar])
[docdirVar, htmldirVar]),
progprefix = subst progprefix [],
progsuffix = subst progsuffix []
}
-- The initial environment has all the static stuff but no paths
env = initialPathTemplateEnv pkgId compilerId
......
......@@ -164,9 +164,11 @@ installLib verb dest build_dir pkg_descr _ = do
createDirectoryIfMissingVerbose verb True dest
copyFileVerbose verb (build_dir </> p) (dest </> p)
installExe :: Verbosity -> FilePath -> FilePath -> PackageDescription -> Executable -> IO ()
installExe verb dest build_dir _ exe = do
let out = exeName exe </> exeExtension
installExe :: Verbosity -> FilePath -> FilePath -> (FilePath,FilePath) -> PackageDescription -> Executable -> IO ()
installExe verb dest build_dir (progprefix,progsuffix) _ exe = do
let exe_name = exeName exe
src = exe_name </> exeExtension
out = (progprefix ++ exe_name ++ progsuffix) </> exeExtension
createDirectoryIfMissingVerbose verb True dest
copyFileVerbose verb (build_dir </> out) (dest </> out)
copyFileVerbose verb (build_dir </> src) (dest </> out)
......@@ -226,13 +226,16 @@ getModulePaths lbi bi =
installExe :: Verbosity -- ^verbosity
-> FilePath -- ^install location
-> FilePath -- ^Build location
-> (FilePath, FilePath) -- ^Executable (prefix,suffix)
-> Executable
-> IO ()
installExe verbosity pref buildPref exe
installExe verbosity pref buildPref (progprefix,progsuffix) exe
= do createDirectoryIfMissingVerbose verbosity True pref
let exeFileName = exeName exe <.> exeExtension
copyFileVerbose verbosity (buildPref </> exeName exe </> exeFileName)
(pref </> exeFileName)
let exeBaseName = exeName exe
exeFileName = exeBaseName <.> exeExtension
fixedExeFileName = (progprefix ++ exeBaseName ++ progsuffix) <.> exeExtension
copyFileVerbose verbosity (buildPref </> exeBaseName </> exeFileName)
(pref </> fixedExeFileName)
-- |Install for nhc98: .hi and .a files
installLib :: Verbosity -- ^verbosity
......
......@@ -338,6 +338,16 @@ configureCommand progConf = makeCommand name shortDesc longDesc defaultFlags opt
configScratchDir (\v flags -> flags { configScratchDir = v })
(reqArgFlag "DIR")
,option "" ["program-prefix"]
"prefix to be applied to installed executables"
progprefix (\v flags -> flags { progprefix = v } )
(installDirArgTitle "PREFIX")
,option "" ["program-suffix"]
"suffix to be applied to installed executables"
progsuffix (\v flags -> flags { progsuffix = v } )
(installDirArgTitle "SUFFIX")
,option "" ["enable-library-vanilla"]
"Enable vanilla libraries"
configVanillaLib (\v flags -> flags { configVanillaLib = v })
......@@ -454,10 +464,12 @@ configureCommand progConf = makeCommand name shortDesc longDesc defaultFlags opt
showFlagList :: [(String, Bool)] -> [String]
showFlagList fs = [ if not set then '-':fname else fname | (fname, set) <- fs]
installDirArg get set = reqArgFlag "DIR"
installDirArgTitle title get set = reqArgFlag title
(fmap fromPathTemplate.get.configInstallDirs)
(\v flags -> flags { configInstallDirs =
set (fmap toPathTemplate v) (configInstallDirs flags)})
installDirArg = installDirArgTitle "DIR"
emptyConfigFlags :: ConfigFlags
emptyConfigFlags = mempty
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment