Cabal on Windows, revisited

Graham Klyne gk at
Mon Nov 1 11:17:28 EST 2004

I'm having another go at Building Cabal for Windows, this time using the 
make utility from mingw.   (HMake doesn't serve, as it's specific to 
compiling Haskell programs.  Mainly, I need to get the preprocessing 
performed for loading into Hugs).

Issues noted.


1. The "mkdir -p" command fails:  under Windows, the syntax of this command 
is different.   I realize there are many other Unix shell commands that 
just wont work in a make file under Windows, so I'm going to proceed to 
create a Windows-specific makefile for Hugs.

2. I've replaced the GHC invocations with cpphs, rather like the makefile 
target for creating documentation.

3. I've changed the temporary target directory to dist\tmp\Distribution 
(needs to be the right name to match hierarchical module names with 
Hugs).  Also created subdirectory Simple.  Also copied Setup.lhs to 
dist\tmp, and used that as the Haskell program to be run using RunHugs.

4. I also create a target directory and preprocessing commands for the 
Compat modules: dist\tmp\Compat.

5. At this point, using a batch file to run Setup, I can issue the command 
Setup --help:
E:\HaskellTools\cabal>C:\DEV\Hugs98\runhugs-20040109.exe dist\tmp\Setup.lhs 
Usage: disttmpSetup.lhs [GLOBAL FLAGS] COMMAND [FLAGS]

Global flags:
   -h, -?  --help  Show this help text

   configure     Prepare to build the package.
   build         Make this package ready for installation.
   clean         Clean up after a build.
   install       Copy the files into the install locations.
   sdist         Generate a source distribution file (.tar.gz or .zip).
   register      Register this package with the compiler.
   unregister    Unregister this package with the compiler.

For more information about a command, try 'disttmpSetup.lhs COMMAND --help'.


It's a small thing, but it looks as if the path separators in 
'dist\tmp\Setup.lhs' are being inappropriately interpreted.

6. I tweak the makefile to be sensitive to the presence of 
'dist\tmp\Setup.lhs', and running Setup config gives this:
E:\HaskellTools\cabal>make config
.\Setup configure --hugs --prefix=E:\Temp\Cabal

E:\HaskellTools\cabal>RunHaskell dist\tmp\Setup.lhs configure --hugs 
--prefix E:

E:\HaskellTools\cabal>C:\DEV\Hugs98\runhugs-20040109.exe dist\tmp\Setup.lhs 
configure --hugs --prefix E:\Temp\Cabal
Configuring Cabal-0.1...
configure: searching for hugs in path.
Cannot find compiler for hugs
make: *** [config] Error 1


I guess this is because of my unusual Hugs setup:
(a) I don't have Hugs on the path, and
(b) I am currently using a non-standard name for the RunHugs executable.
Both problems are resolved if I can override the search for the RunHugs 
executable with a command line option to specify it.

That looks like the "--with-compiler" option.  I try using that with the 
name of my batch file (which is on the path), but get a different error:
E:\HaskellTools\cabal>C:\DEV\Hugs98\runhugs-20040109.exe dist\tmp\Setup.lhs 
configure --hugs --with-compiler RunHaskell --prefix E:\Temp\Cabal
Configuring Cabal-0.1...
configure: looking for package tool: hugs-package near compiler in RunHaskell
Cannot find package tool: ./hugs-package
make: *** [config] Error 1


OK, it seems to need the actual Hugs executable to find the proper path, so 
I'll have to make that available and try again:
E:\HaskellTools\cabal>C:\DEV\Hugs98\runhugs-20040109.exe dist\tmp\Setup.lhs 
igure --hugs --with-compiler C:\DEV\Hugs98\Hugs.exe --prefix E:\Temp\Cabal
Configuring Cabal-0.1...
configure: looking for package tool: hugs-package near compiler in 
Cannot find package tool: ./hugs-package
make: *** [config] Error 1


I note the '\' in the filename are being processed incorrectly 
again.  Also, it still can't find the package tool ./hugs-package.


That's about as far as I'm going to get here.  My makefile so far is:
CPPHS=RunHaskell ..\cpphs\cpphs.hs --noline

# build the library itself:  for Hugs, this is simply preprocessing into a 
new directory

         mkdir dist\tmp\Distribution\Simple
         mkdir dist\tmp\Compat
         copy Setup.lhs dist\tmp\Setup.lhs
         $(CPPHS) Distribution/Package.hs > dist/tmp/Distribution/Package.hs
         $(CPPHS) Distribution/Misc.hs > dist/tmp/Distribution/Misc.hs
         $(CPPHS) Distribution/Version.hs > dist/tmp/Distribution/Version.hs
         $(CPPHS) Distribution/Setup.hs > dist/tmp/Distribution/Setup.hs
         $(CPPHS) Distribution/ModuleTest.hs > 
         $(CPPHS) Distribution/Simple.hs > dist/tmp/Distribution/Simple.hs
         $(CPPHS) Distribution/Make.hs > dist/tmp/Distribution/Make.hs
         $(CPPHS) Distribution/InstalledPackageInfo.hs > 
         $(CPPHS) Distribution/Simple/Build.hs > 
         $(CPPHS) Distribution/Simple/Install.hs > 
         $(CPPHS) Distribution/Simple/Configure.hs > 
         $(CPPHS) Distribution/Simple/Register.hs > 
         $(CPPHS) Distribution/Simple/Utils.hs > 
         $(CPPHS) Distribution/Simple/SrcDist.hs > 
         $(CPPHS) Distribution/Simple/GHCPackageConfig.hs > 
         $(CPPHS) Distribution/GetOpt.hs > dist/tmp/Distribution/GetOpt.hs
         $(CPPHS) Compat/Exception.hs > dist/tmp/Compat/Exception.hs
         $(CPPHS) Compat/H98.hs > dist/tmp/Compat/H98.hs
         $(CPPHS) Compat/RawSystem.hs > dist/tmp/Compat/RawSystem.hs
         $(CPPHS) Compat/ReadP.hs > dist/tmp/Compat/ReadP.hs

setup-hugs: dist/tmp/Setup.lhs

setup: setup-hugs

config: setup
         .\Setup configure --hugs --with-compiler=$(HUGS) --prefix=$(PREF)

My Setup.bat file is:
rem run setup program for installing cabal
rem assumes that RunHaskell utility or batch file is on the path

RunHaskell dist\tmp\Setup.lhs %1 %2 %3 %4 %5 %6 %7 %8

My RunHaskell.bat file is:
C:\DEV\Hugs98\runhugs-20040109.exe %1 %2 %3 %4 %5 %6 %7 %8 %9
(As I mentioned, I'm using a modified version of RunHugs, hence the unusual 


Graham Klyne
For email:

More information about the Libraries mailing list