Fix --print-docdir for relocatable builds; fixes #1226
authorIan Lynagh <igloo@earth.li>
Wed, 19 Sep 2007 14:01:00 +0000 (14:01 +0000)
committerIan Lynagh <igloo@earth.li>
Wed, 19 Sep 2007 14:01:00 +0000 (14:01 +0000)
compiler/Makefile
compiler/main/Main.hs

index 4691689..e19e560 100644 (file)
@@ -272,6 +272,11 @@ endif
        @echo "cUSER_WAY_OPTS        = \"$(USER_WAY_OPTS)\"" >> $(CONFIG_HS)
        @echo "cDEFAULT_TMPDIR       = \"$(DEFAULT_TMPDIR)\"" >> $(CONFIG_HS)
        @echo "cDocDir               = \"$(docdir)\""         >> $(CONFIG_HS)
+ifeq "$(RelocatableBuild)" "YES"
+       @echo "cRelocatableBuild     = True"                  >> $(CONFIG_HS)
+else
+       @echo "cRelocatableBuild     = False"                 >> $(CONFIG_HS)
+endif
        @echo done.
 
 CLEAN_FILES += $(CONFIG_HS)
index f6e0002..1e5dedc 100644 (file)
@@ -96,8 +96,6 @@ main =
                                   exitWith ExitSuccess
     ShowSupportedLanguages  -> do showSupportedLanguages
                                   exitWith ExitSuccess
-    ShowDocDir              -> do showDocDir
-                                  exitWith ExitSuccess
     ShowVersion             -> do showVersion
                                   exitWith ExitSuccess
     ShowNumVersion          -> do putStrLn cProjectVersion
@@ -173,7 +171,7 @@ main =
     ShowUsage              -> showGhcUsage dflags cli_mode
     PrintLibdir            -> putStrLn (topDir dflags)
     ShowSupportedLanguages -> alreadyHandled
-    ShowDocDir             -> alreadyHandled
+    ShowDocDir             -> showDocDir (topDir dflags)
     ShowVersion            -> alreadyHandled
     ShowNumVersion         -> alreadyHandled
     ShowInterface f        -> doShowIface dflags f
@@ -477,10 +475,11 @@ showSupportedLanguages :: IO ()
 showSupportedLanguages = do mapM_ putStrLn supportedLanguages
                             exitWith ExitSuccess
 
-showDocDir :: IO ()
-showDocDir = do
-  putStrLn cDocDir
-  exitWith ExitSuccess
+showDocDir :: FilePath -> IO ()
+showDocDir topdir = putStrLn docDir
+    where docDir = if cRelocatableBuild
+                   then topdir ++ "/doc"
+                   else cDocDir
 
 showVersion :: IO ()
 showVersion = do