AC_DEFUN([FP_FIND_ROOT],[
AC_MSG_CHECKING(for path to top of build tree)
-hardtop=`pwd`
+dnl This would be
+dnl make -C utils/pwd clean && make -C utils/pwd
+dnl except we don't want to have to know what make is called. Sigh.
+cd utils/pwd
+rm -f *.o
+rm -f *.hi
+rm -f pwd
+rm -f pwd.exe
+$WithGhc -v0 --make pwd
+cd ../..
+
+hardtop=`utils/pwd/pwd forwardslash`
dnl Remove common automounter nonsense
dnl
-hardtop=`echo $hardtop | sed 's|^/tmp_mnt.*\(/local/.*\)$|\1|' | sed 's|^/tmp_mnt/|/|' | sed 's|^//\(.\)/|\1:/|' `
+hardtop=`echo $hardtop | sed 's|^/tmp_mnt.*\(/local/.*\)$|\1|' | sed 's|^/tmp_mnt/|/|'`
dnl Find 'hardtop_plat', the native format for 'hardtop'
dnl (i.e., right kind of \dnl slashes on a Win32 box, but with b-slashes
AC_SUBST(exeext)
-FP_FIND_ROOT
-
dnl --------------------------------------------------------------
dnl * Project specific configuration options
dnl --------------------------------------------------------------
WithGhc="$GHC"])
AC_SUBST([WithGhc])
+FP_FIND_ROOT
+
AC_ARG_WITH(hc,
[AC_HELP_STRING([--with-hc=ARG],
[Use ARG as the path to the compiler for compiling ordinary
--- /dev/null
+
+# We don't include any of the boilerplate Makefiles as we are used
+# by configure. GHC should be overridden on the command line to the
+# GHC that you want to use.
+
+GHC=ghc
+
+.PHONY: all clean
+
+all:
+ $(GHC) --make pwd
+
+clean:
+ rm -f *.o
+ rm -f *.hi
+ rm -f pwd
+ rm -f pwd.exe
+
--- /dev/null
+
+module Main where
+
+import System.Directory
+import System.Environment
+
+main :: IO ()
+main = do args <- getArgs
+ let escape = case args of
+ ["quadruple-backslash"] -> escape_quadruple_backslash
+ ["forwardslash"] -> escape_forwardslash
+ _ -> error ("pwd: Bad args: " ++ show args)
+ d <- getCurrentDirectory
+ putStr $ concatMap escape d
+
+-- In prog006 we have to escape \ twice, once to get through sed and
+-- again to get through parsing pkg.conf
+escape_quadruple_backslash :: Char -> String
+escape_quadruple_backslash '\\' = "\\\\\\\\"
+escape_quadruple_backslash c = [c]
+
+-- Normally we can get away with just replacing backslashes with forwardslashes
+escape_forwardslash :: Char -> String
+escape_forwardslash '\\' = "/"
+escape_forwardslash c = [c]
+