Library Infrastructure, HaXml and Windows

Graham Klyne GK at
Tue Jan 20 13:10:04 EST 2004

Thanks, your recipe was helpful to get me started.  I'm trying to turn this 
into a Windows batch file, which I'll post back for your consideration 
(work-in-progress copy below).

I notice that the Win32 distribution of GHC does not include ar, so I've 
located and downloaded a MinGW kit.


Compiling the source kit, I find module:
imports FiniteMap when what is provided by GHC is Data.FiniteMap.


Otherwise, the compilation and library build seems to complete OK.


Copying the .hi files to the imports directory tree, I find that one 
existing file (from the GHC installation) is requested to be overwritten:
   Overwrite C:\DEV\ghc\ghc-6.2\imports\Text\PrettyPrint\HughesPJ.hi

For now, I've refused the override and renamed the source file in the HaXml 
tree.  Is there any reason that the GHC version should be replaced?   (The 
source codes seem to be quite different, but clearly based on the same 
origin:  a comment suggests that the HaXml version has been converted to 
"Standard Haskell".)


Finally, I seem to be having a minor problem installing the resulting package:
--add-package  0<pkg.conf
Reading package info from stdin... done.
Expanding embedded variables... done.
warning: can't find GHCi lib `HSHaXml.o'
Saving old package config file... done.
Writing new package config file... done.

I have confirmed that the file exists in the GHC install directory:
C:\DEV\ghc\ghc-6.2>dir *HaXml*
  Volume in drive C is SYS
  Volume Serial Number is F4A9-5305

  Directory of C:\DEV\ghc\ghc-6.2

20/01/04  14:42         2,073,869 HSHaXml.o
20/01/04  14:42         2,322,312 libHSHaXml.a

I can't figure what I'm doing wrong here:  can anyone help?


Here's my work-in-progress file Make.bat.  Note that the lines
    set SRCS=...
    set OBJS=...
are very long lines (about 500 characters).
REM Build HaXml package using GHC

set GHCDIR=C:\DEV\ghc\ghc-6.2
set GHC=C:\DEV\ghc\ghc-6.2\bin\ghc.exe
set GHCPKG=C:\DEV\ghc\ghc-6.2\bin\ghc-pkg.exe
set AR=C:\DEV\MinGW\bin\ar.exe
set LD=C:\DEV\ghc\ghc-6.2\gcc-lib\ld.exe

set SRC=C:\DEV\Haskell\lib\HaXml-1.10\src
set SRCS=Text/XML/HaXml.hs Text/XML/HaXml/Combinators.hs 
Text/XML/HaXml/Lex.hs  Text/XML/HaXml/Parse.hs Text/XML/HaXml/Pretty.hs 
Text/XML/HaXml/Types.hs Text/XML/HaXml/Validate.hs 
Text/XML/HaXml/Wrappers.hs Text/XML/HaXml/OneOfN.hs 
Text/XML/HaXml/Xml2Haskell.hs Text/XML/HaXml/Haskell2Xml.hs 
Text/XML/HaXml/Verbatim.hs Text/XML/HaXml/Escape.hs 
Text/XML/HaXml/Html/Generate.hs Text/XML/HaXml/Html/Parse.hs 
Text/XML/HaXml/Html/Pretty.hs Text/XML/HaXml/Xtract/Combinators.hs 
Text/XML/HaXml/Xtract/Lex.hs Text/XML/HaXml/Xtract/Parse.hs 
set OBJS=Text/XML/HaXml.o Text/XML/HaXml/Combinators.o 
Text/XML/HaXml/Lex.o  Text/XML/HaXml/Parse.o Text/XML/HaXml/Pretty.o 
Text/XML/HaXml/Types.o Text/XML/HaXml/Validate.o Text/XML/HaXml/Wrappers.o 
Text/XML/HaXml/OneOfN.o Text/XML/HaXml/Xml2Haskell.o 
Text/XML/HaXml/Haskell2Xml.o Text/XML/HaXml/Verbatim.o 
Text/XML/HaXml/Escape.o Text/XML/HaXml/Html/Generate.o 
Text/XML/HaXml/Html/Parse.o Text/XML/HaXml/Html/Pretty.o 
Text/XML/HaXml/Xtract/Combinators.o Text/XML/HaXml/Xtract/Lex.o 
Text/XML/HaXml/Xtract/Parse.o Text/ParserCombinators/HuttonMeijerWallace.o

if "%1"=="Remove" goto Remove

rem -- Compile sources and create library archive
cd %SRC%
%GHC% --make -cpp -i. -package-name HaXml %SRCS%
%AR% r libHSHaXml.a %OBJS%

rem -- Create library file for GHCi
%LD% -r --whole-archive -o HSHaXml.o libHSHaXml.a

rem -- Install the library archive(s) where GHC can find them

rem -- Install the interface files where GHC can find them
rem    /L - list only, /Y - overrite without confirmation
rem    /S - copy subdirectories, /T - create directories only
rem    /F - display full filenames while copying
XCOPY /S /F *.hi %GHCDIR%\imports

rem -- Finally, register the package with GHC
%GHCPKG% --add-package <pkg.conf

goto Exit

%GHCPKG% --remove-package HaXml


At 10:52 20/01/04 +0000, Malcolm Wallace wrote:
>You can avoid using 'configure' and 'make' by just following the
>recipe in the Makefile by hand.  Realising that as a Windows person
>you are probably inexperienced in reading a Makefile, here is the
>quick version.
>     cd src
>     ghc --make -cpp -i. -package-name HaXml  $(SRCS)
>         [ Replace $(SRCS) with the cut-and-pasted list of files from the 
> Makefile ]
>     ar r libHSHaXml.a $(OBJS)
>         [ $(OBJS) is the source-file list replacing .hs by .o ]
>     ld -r --whole-archive -o HSHaXml.o libHSHaXml.a
>         [ only if you need to play with it in GHCi ]
>     cp libHSHaXml.a HSHaXml.o $(GHC_LIB_DIR)
>         [ install the library archive(s) where GHC can find them ]
>     { tar cf interfaces.tar `find Text -name *.hi -print`
>       cp interfaces.tar $(GHC_LIB_DIR)/imports
>       cd $(GHC_LIB_DIR)/imports
>       tar xf interfaces.tar
>       rm interfaces.tar
>     }
>         [ install the interface files where GHC can find them ]
>     ghc-pkg --add-package <pkg.conf
>         [ and finally register the package with GHC ]
>Obviously I have used some Unix-isms here, but you will know the
>Windows equivalents better than I can guess them.

Graham Klyne
For email:

More information about the Libraries mailing list