From: sof Date: Tue, 11 Feb 2003 04:32:06 +0000 (+0000) Subject: [project @ 2003-02-11 04:32:06 by sof] X-Git-Tag: Approx_11550_changesets_converted~1183 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=2ae353a8f2af07cbe01d8817e93b28f65332c6fa;p=ghc-hetmet.git [project @ 2003-02-11 04:32:06 by sof] Tighten up prev commit: - win32: only add default --template=... option if the template file exists. - if user has supplied --cc=.., use it as a default for 'ld'. --- diff --git a/ghc/utils/hsc2hs/Main.hs b/ghc/utils/hsc2hs/Main.hs index ea842f5..4afabd2 100644 --- a/ghc/utils/hsc2hs/Main.hs +++ b/ghc/utils/hsc2hs/Main.hs @@ -1,7 +1,7 @@ {-# OPTIONS -fglasgow-exts #-} ------------------------------------------------------------------------ --- $Id: Main.hs,v 1.44 2003/02/07 21:55:36 sof Exp $ +-- $Id: Main.hs,v 1.45 2003/02/11 04:32:06 sof Exp $ -- -- Program for converting .hsc files to .hs files, by converting the -- file into a C program which is run to generate the Haskell source. @@ -101,12 +101,17 @@ main = do flags_w_tpl <- if any template_flag flags then return flags else - do { mb_path <- getExecDir "/bin/hsc2hs.exe" ; - case mb_path of - Nothing -> return flags - - Just path -> return (Template (path ++ "/template-hsc.h") : flags) } - + do mb_path <- getExecDir "/bin/hsc2hs.exe" + add_opt <- + case mb_path of + Nothing -> return id + Just path -> do + let templ = path ++ "/template-hsc.h" + flg <- doesFileExist templ + if flg + then return ((Template templ):) + else return id + return (add_opt flags) case (files, errs) of (_, _) | any isHelp flags_w_tpl -> putStrLn (usageInfo header options) @@ -512,7 +517,7 @@ output flags name toks = do _ -> onlyOne "compiler" linker <- case [l | Linker l <- flags] of - [] -> locateGhc "ghc" + [] -> locateGhc compiler [l] -> return l _ -> onlyOne "linker"