Compiling hdirect on windows with COM support

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Compiling hdirect on windows with COM support

Marc Weber

On Fri, Feb 03, 2006 at 07:55:30AM +0100, Gracjan Polak wrote:
>    Hi,
>    I would be iterested in seeing what you have done. And maybe helping
>    in getting it to work.
>    I did not find the examples :) Many links seem to be broken on HDirect
>    page.

Hi. I have finished. It took some more time as expected ;-)

Just install cygwin, and run this script. It will download parts of
fptools via cvs (so you need cvs and GNU make from cygwin)

Greetings, Marc

---------------------------- compilehdirect.sh ---

#!/bin/sh
# author: Marc Weber
# [hidden email]

# configure fptools

WORKDIR=${WORKDIR:-myfptoolsdirectory} # you can use "" here because cvs will checkout the folder "fptools" everything will be done in that..
CREATEZIPSTODEBUGTHISSCRIPT="" # "" = no "yes"=yes, for debugging purposes.

# hdirect lib info (will replace old file due to packaging info changes)
hdirectlibpkginfo="name: \"hdirect\"  \n\
import-dirs: \"\${hd_libdir}\" \n\
library-dirs: \"\${hd_libdir}\" \n\
hs-libraries: \"HShdirect\" \n\
include-dirs: \"\${hd_libdir}\" \n\
depends: \"base\", \"haskell98\" \n\
exposed:True \n\
exposed-modules:\"HDirect\",\"Pointer\" "
#hdirect comlib cabal pkg info:
hdirectcomlibpkginfo="name: com \n\
import-dirs: \"\${hd_imp}\" \n\
library-dirs: \"\${hd_lib}\" \n\
hs-libraries: \"HScom\" \n\
extra-libraries: \"kernel32\", \n\
        \"user32\", \n\
        \"ole32\", \n\
        \"oleaut32\", \n\
        \"advapi32\", \n\
        \"HScom\" \n\
include-dirs: \"\${hd_inc}\" \n\
depends: \"base\", \n\
        \"haskell98\" \n\
exposed:True \n\
exposed-modules: \"Com\", \n\
        \"TypeLib\", \n\
        \"ComPrim\", \n\
        \"Automation\", \n\
        \"AutoPrim\", \n\
        \"WideString\", \n\
        \"StdTypes\", \n\
        \"StdDispatch\", \n\
        \"ComServ\", \n\
        \"Connection\", \n\
        \"SafeArray\" "


confirm() { echo -e $1 "\n" "press return to proceed, Strg-C to exit"; read; }
info() { echo; echo $1; echo $1 | sed -e 's/./-/g' ; }
die() { echo $1 ; exit; }
question() { echo -e $1 "\n [y]es, [n]o"; read d; if [[ "$d"="y" ]]; then True ; else False; fi; }
dozip() { [ -z CREATEZIPSTODEBUGTHISSCRIPT ] || zip -r  ../$1.zip . || die "couldn't create zip" ; }
doziphd() { [ -z CREATEZIPSTODEBUGTHISSCRIPT ] || zip -r  ../../$1.zip . || die "couldn't create zip"; }

confirm "this script isn't well tested yet .. run it .. Read the code first because you are running it on your risk"
echo " you will need cvs, GNU make from cygwin. I've used ghc-6.4.1 from Win Installer"
confirm "Be sure to have your ghc in win PATH environment variable, else everything will work till compiling hdirect ;-) if you can run ghc.exe from cygwin shell everything should be fine."


[ -d "$WORKDIR" ] || mkdir "$WORKDIR"  || die "couldn't create working directory"
cd "$WORKDIR" || die "couldn't cd to working directory"

if [[ ! -d fptools ]]; then
#if :; then
       
        question "Shall I dwonload happy (say yes and add --enable-src-tree-happy to configure if you don't have happy)" && coHappy=1
        question "Shall I dwonload alex (say yes and add --enable-src-tree-alex to configure if you don't have alex)" && coAlex=1
        info "checking out fptools top directory"
        cvs -d:pserver:[hidden email]:/cvs co -l fptools || die "cvs checkout of fptools top directory failed"
        info "checking out fptools/glafp-utils (used by hdirect)"
        cvs -d:pserver:[hidden email]:/cvs co fptools/glafp-utils || die "cvs checkout of fptools top directory failed"
        info "checking out ghc"
        cvs -d:pserver:[hidden email]:/cvs co fptools/ghc || die "cvs checkout of fptools top directory failed"
        info "checking out hdirect"
        cvs  -d:pserver:[hidden email]:/cvs co fptools/hdirect || die "cvs check of hdirect failed"  
        info "checking out fptools/mk (needed by hdirect make)"
        cvs -d:pserver:[hidden email]:/cvs co -l fptools/mk || die "cvs checkout of fptools top directory failed"
        info "checking out ghc/mk (else hdirect/make will complaing about ghc/mk/paths.mk"
        cvs  -d:pserver:[hidden email]:/cvs co fptools/ghc/mk || die "cvs check of hdirect failed"  
        if [ ! -z coHappy ]; then
                info "checking out happy (else hdirect/make will complaing about ghc/mk/paths.mk"
                remhappy="add --enable-src-tree-happy"
                cvs  -d:pserver:[hidden email]:/cvs co fptools/happy || die "cvs check of hdirect failed"  
        fi
        if [ ! -z coAlex ]; then
                info "checking out alex (else hdirect/make will complaing about ghc/mk/paths.mk"
                remalex="add --enable-src-tree-alex"
                cvs  -d:pserver:[hidden email]:/cvs co fptools/alex || die "cvs check of hdirect failed"  
        fi
        cd fptools
        dozip AfterCO
        cd ..
else
        info "omitting cvs co because fptools already exists"
fi

cd fptools

if [ -f configure ]; then info "omitting autoreconf (configure already exists)";
        else  info "calling autoreconf"; autoreconf ||die "autoreconf failed" ;
fi

if [ -f config.status ]; then
        info "I omit configuring because fptools/conf exists. Remove it to configure again"
else
        if [ -f configure ]; then info "omitting autoreconf (configure already exists)";
                else  info "calling autoreconf"; autoreconf ||die "autoreconf failed"
        fi

        echo "Now you have to configure fptools, you can add --with-ghc=ARG to specify the ghc directory and --with-gcc to specify to point to the gcc/bin directory (because you want to compile native win apps you don't want to use gcc from cygwin!)"
        confirm "running bash now, please call configure"
        echo "Your command might look like this: ./configure --with-gcc='c:/MinGWStudio/MinGW/bin/gcc' --with-ghc='c:/ghc/ghc-6.4.1/bin/ghc.exe'"   $remhappy $remalex "; exit"
        echo "Press Ctrl-d when finished or enter exit to continue this script"
        bash dozip afterConfiguring
fi
info "***** starting compiling "
if [ -d happy  ]; then
        if [ ! -f happy/src/happy.exe ]; then
                info "happy in source tree. So I think you don't have it, yet. I'm running make"
                cd happy || die "couldn't cd to happy"
                make boot || die "couldn't make make boot"
                make || die "making happy failed"
                cd ..
        else
                echo "happy already built"
        fi
fi
if [ ! -z "$remalex" ]; then
        echo "I think alex is used to make configure not complain.. ;-)"
fi

if [ -f glafp-utils/.depend ]; then
        info "omitting glafp-utils because glasp-utils/.depend exists"
else
        info "Making glafp-utils now"
        cd glafp-utils
        make boot || die "couln't make boot (glafp-utils) but this doesn't seem to be serious, just restart script"
        make || die "couln't make hdirect^ (glafp-utils) but this doesn't seem to be serious, just restart script"
        cd ..
fi

cd hdirect
[ -f src/.depend ] || doziphd beforeBuildingHdirect
info "I'm trying to build hdirect now!"
if [ ! -f src/ihc.exe ]; then
        info "running make boot"
        make boot || die "couln't make boot (hdirect)"
        doziphd afterMakeBOOT
fi
if [ ! -f comlib/Automation.o ]; then
        info "running make (will build comlib and rebuild ihc.exe"
        make || die "couln't make hdirect^ (hdirect)"
        doziphd afterMake1
fi
# registering hdirect:
if ! ghc-pkg.exe describe hdirect; then
        cd lib
        # check wether hdirect.pkg has been replaced, yet due to changes in pkg info:
        if grep 'Package {' hdirect.pkg; then
                info "replacing hdirect.pkg due to changees in pkg info."
                echo "old pkg info (hdirect.pkg)"
                cat hdirect.pkg
                echo -e $hdirectlibpkginfo > hdirect.pkg
                echo "new pkg info (hdirect.pkg)"
                cat hdirect.pkg
        fi
        info "registering hdirect"
        #export hd_libdir="d:\\\\haskell\\\\fptools\\\\fptools\\\\hdirect\\\\lib"
        hd_libdir=$(cygpath -w $(pwd))
        export hd_libdir=${hd_libdir//\\/\\\\} # double "\" becaus of escaping
        echo $hd_libdir
        ghc-pkg.exe -u < hdirect.pkg || die "couldn't register hdirect"
        cd ..
fi

#registering comlib of hdirect
if ! ghc-pkg.exe describe comlib; then
        cd comlib
        # check wether com.pkg has been replaced, yet due to changes in pkg info:
        if grep 'Package{' com.pkg; then
                info "replacing com.pkg due to changees in pkg info."
                echo "old pkg info (com.pkg)"
                cat com.pkg
                echo -e $hdirectcomlibpkginfo > com.pkg
                echo "new pkg info (com.pkg)"
                cat com.pkg
        fi
        info "registering comlib"
        export hd_lib=""
        export hd_inc=""
        export hd_imp=""
        hd_lib=$(cygpath -w $(pwd))
        export hd_inc=${hd_lib//\\/\\\\}
        export hd_imp=${hd_lib//\\/\\\\}
        export hd_lib=${hd_lib//\\/\\\\}
        echo hd_lib $hd_lib
        echo hd_int $hd_int
        echo hd_inc $hd_inc
        ghc-pkg.exe -u < com.pkg || die "couldn't register comlib"
        cd ..
fi


       

# Now it's getting really hot: trying to build ihc.exe with support Typelibs:
export SUPPORT_TYPELIBS=YES
info "running make boot with exported SUPPORT_TYPELIBS=YES"
if [ ! -f src/ihc.exe ]; then
        info "running make boot"
        make boot || die "couln't make boot (hdirect)"
        doziphd afterMakeALL
fi

cd examples
info "running bash so that you can try some examples type exit then to exit script"
info "notice: you are now in $(pwd)"
bash
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Compiling hdirect on windows with COM support

Marc Weber
> echo "Press Ctrl-d when finished or enter exit to continue this script"
> bash dozip afterConfiguring
I did make a small mistake here:
it should look like this:
        bash
        dozip afterConfiguring

Oh.. and I did use gcc from mingw as you can see. I don't know yet how
to specify gcc.exe from ghc-6.4.1/gcc.exe without the configure script
complaining gcc can't produce executables becaus cc1 is missing.

Marc
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe
Reply | Threaded
Open this post in threaded view
|

Re: Compiling hdirect on windows with COM support

Marc Weber
On Mon, Feb 06, 2006 at 02:58:50PM +0100, Marc Weber wrote:

> > echo "Press Ctrl-d when finished or enter exit to continue this script"
> > bash dozip afterConfiguring
> I did make a small mistake here:
> it should look like this:
> bash
> dozip afterConfiguring
>
> Oh.. and I did use gcc from mingw as you can see. I don't know yet how
> to specify gcc.exe from ghc-6.4.1/gcc.exe without the configure script
> complaining gcc can't produce executables becaus cc1 is missing.

Aeh.. I had still a bug.. This is the correction.
See first commented link in script for details.
Hope this will be usefule sometimes for someone else

#!/bin/sh
# author: Marc Weber
# [hidden email]

# additional build documentation (should be included into hdirect, I
# think:
# http://cvs.haskell.org/cgi-bin/cvsweb.cgi/fptools/hdirect/distrib/INSTALL?rev=1.12

WORKDIR=${WORKDIR:-myfptoolsdirectory} # you can use "" here because cvs will checkout the folder "fptools" everything will be done in that..
CREATEZIPSTODEBUGTHISSCRIPT="" # "" = no "yes"=yes, for debugging purposes.

# hdirect lib info (will replace old file due to packaging info changes)
hdirectlibpkginfo="name: \"hdirect\"  \n\
import-dirs: \"\${hd_libdir}\" \n\
library-dirs: \"\${hd_libdir}\" \n\
hs-libraries: \"HShdirect\" \n\
include-dirs: \"\${hd_libdir}\" \n\
depends: \"base\", \"haskell98\" \n\
exposed:True \n\
exposed-modules:\"HDirect\",\"Pointer\" "
#hdirect comlib cabal pkg info:
hdirectcomlibpkginfo="name: com \n\
import-dirs: \"\${hd_imp}\" \n\
library-dirs: \"\${hd_lib}\" \n\
hs-libraries: \"HScom\" \n\
extra-libraries: \"kernel32\", \n\
        \"user32\", \n\
        \"ole32\", \n\
        \"oleaut32\", \n\
        \"advapi32\", \n\
        \"HScom\" \n\
include-dirs: \"\${hd_inc}\" \n\
depends: \"base\", \n\
        \"haskell98\" \n\
exposed:True \n\
exposed-modules: \"Com\", \n\
        \"TypeLib\", \n\
        \"ComPrim\", \n\
        \"Automation\", \n\
        \"AutoPrim\", \n\
        \"WideString\", \n\
        \"StdTypes\", \n\
        \"StdDispatch\", \n\
        \"ComServ\", \n\
        \"Connection\", \n\
        \"SafeArray\" "


confirm() { echo -e $1 "\n" "press return to proceed, Strg-C to exit"; read; }
info() { echo; echo $1; echo $1 | sed -e 's/./-/g' ; }
die() { echo $1 ; exit; }
question() { echo -e $1 "\n [y]es, [n]o"; read d; if [[ "$d"="y" ]]; then True ; else False; fi; }
dozip() { [ -z CREATEZIPSTODEBUGTHISSCRIPT ] || zip -r  ../$1.zip . || die "couldn't create zip" ; }
doziphd() { [ -z CREATEZIPSTODEBUGTHISSCRIPT ] || zip -r  ../../$1.zip . || die "couldn't create zip"; }

confirm "this script isn't well tested yet .. run it .. Read the code first because you are running it on your risk"
confirm "Be sure to have your ghc in win PATH environment variable, else everything will work till compiling hdirect ;-) if you can run ghc.exe from cygwin shell everything should be fine."


[ -d "$WORKDIR" ] || mkdir "$WORKDIR"  || die "couldn't create working directory"
cd "$WORKDIR" || die "couldn't cd to working directory"

if [[ ! -d fptools ]]; then
#if :; then
       
        question "Shall I dwonload happy (say yes and add --enable-src-tree-happy to configure if you don't have happy)" && coHappy=1
        question "Shall I dwonload alex (say yes and add --enable-src-tree-alex to configure if you don't have alex)" && coAlex=1
        info "checking out fptools top directory"
        cvs -d:pserver:[hidden email]:/cvs co -l fptools || die "cvs checkout of fptools top directory failed"
        info "checking out fptools/glafp-utils (used by hdirect)"
        cvs -d:pserver:[hidden email]:/cvs co fptools/glafp-utils || die "cvs checkout of fptools top directory failed"
        info "checking out ghc"
        cvs -d:pserver:[hidden email]:/cvs co fptools/ghc || die "cvs checkout of fptools top directory failed"
        info "checking out hdirect"
        cvs  -d:pserver:[hidden email]:/cvs co fptools/hdirect || die "cvs check of hdirect failed"  
        info "checking out fptools/mk (needed by hdirect make)"
        cvs -d:pserver:[hidden email]:/cvs co -l fptools/mk || die "cvs checkout of fptools top directory failed"
        info "checking out ghc/mk (else hdirect/make will complaing about ghc/mk/paths.mk"
        cvs  -d:pserver:[hidden email]:/cvs co fptools/ghc/mk || die "cvs check of hdirect failed"  
        if [ ! -z coHappy ]; then
                info "checking out happy (else hdirect/make will complaing about ghc/mk/paths.mk"
                remhappy="add --enable-src-tree-happy"
                cvs  -d:pserver:[hidden email]:/cvs co fptools/happy || die "cvs check of hdirect failed"  
        fi
        if [ ! -z coAlex ]; then
                info "checking out alex (else hdirect/make will complaing about ghc/mk/paths.mk"
                remalex="add --enable-src-tree-alex"
                cvs  -d:pserver:[hidden email]:/cvs co fptools/alex || die "cvs check of hdirect failed"  
        fi
        cd fptools
        dozip AfterCO
        cd ..
else
        info "omitting cvs co because fptools already exists"
fi

cd fptools

if [ -f configure ]; then info "omitting autoreconf (configure already exists)";
        else  info "calling autoreconf"; autoreconf ||die "autoreconf failed" ;
fi

if [ -f config.status ]; then
        info "I omit configuring because fptools/conf exists. Remove it to configure again"
else
        if [ -f configure ]; then info "omitting autoreconf (configure already exists)";
                else  info "calling autoreconf"; autoreconf ||die "autoreconf failed"
        fi

        echo "Now you have to configure fptools, you can add --with-ghc=ARG to specify the ghc directory and --with-gcc to specify to point to the gcc/bin directory (because you want to compile native win apps you don't want to use gcc from cygwin!)"
        confirm "running bash now, please call configure"
        echo "Your command might look like this: ./configure --with-gcc='c:/MinGWStudio/MinGW/bin/gcc' --with-ghc='c:/ghc/ghc-6.4.1/bin/ghc.exe'"   $remhappy $remalex "; exit"
        echo "Press Ctrl-d when finished or enter exit to continue this script"
        bash
        dozip afterConfiguring
fi
info "***** starting compiling "
if [ -d happy  ]; then
        if [ ! -f happy/src/happy.exe ]; then
                info "happy in source tree. So I think you don't have it, yet. I'm running make"
                cd happy || die "couldn't cd to happy"
                make boot || die "couldn't make make boot"
                make || die "making happy failed"
                cd ..
        else
                echo "happy already built"
        fi
fi
if [ ! -z "$remalex" ]; then
        echo "I think alex is used to make configure not complain.. ;-)"
fi

if [ -f glafp-utils/.depend ]; then
        info "omitting glafp-utils because glasp-utils/.depend exists"
else
        info "Making glafp-utils now"
        cd glafp-utils
        make boot || die "couln't make boot (glafp-utils) but this doesn't seem to be serious, just restart script"
        make || die "couln't make hdirect^ (glafp-utils) but this doesn't seem to be serious, just restart script"
        cd ..
fi

info "building hdirect"
cd hdirect ||die 'cd hdirect'
pwd
make boot || die "couldn't make "
make ||die make
make lib || die "couldn't make lib"

# registering hdirect: (isn't needed ? but doesn't harm)
if ! ghc-pkg.exe describe hdirect; then
        cd lib
        # check wether hdirect.pkg has been replaced, yet due to changes in pkg info:
        if grep 'Package {' hdirect.pkg; then
                info "replacing hdirect.pkg due to changees in pkg info."
                echo "old pkg info (hdirect.pkg)"
                cat hdirect.pkg
                echo -e $hdirectlibpkginfo > hdirect.pkg
                echo "new pkg info (hdirect.pkg)"
                cat hdirect.pkg
        fi
        info "registering hdirect"
        #export hd_libdir="d:\\\\haskell\\\\fptools\\\\fptools\\\\hdirect\\\\lib"
        hd_libdir=$(cygpath -w $(pwd))
        export hd_libdir=${hd_libdir//\\/\\\\} # double "\" becaus of escaping
        echo $hd_libdir
        ghc-pkg.exe -u < hdirect.pkg || die "couldn't register hdirect"
        cd ..
fi

#registering comlib of hdirect
if ! ghc-pkg.exe describe comlib; then
        cd comlib
        # check wether com.pkg has been replaced, yet due to changes in pkg info:
        if grep 'Package{' com.pkg; then
                info "replacing com.pkg due to changees in pkg info."
                echo "old pkg info (com.pkg)"
                cat com.pkg
                echo -e $hdirectcomlibpkginfo > com.pkg
                echo "new pkg info (com.pkg)"
                cat com.pkg
        fi
        info "registering comlib"
        export hd_lib=""
        export hd_inc=""
        export hd_imp=""
        hd_lib=$(cygpath -w $(pwd))
        export hd_inc=${hd_lib//\\/\\\\}
        export hd_imp=${hd_lib//\\/\\\\}
        export hd_lib=${hd_lib//\\/\\\\}
        echo hd_lib $hd_lib
        echo hd_int $hd_int
        echo hd_inc $hd_inc
        ghc-pkg.exe -u < com.pkg || die "couldn't register comlib"
        cd ..
fi

cd src
rm -f *.o
make depend SUPPORT_TYPELIBS=YES
make SUPPORT_TYPELIBS=YES
_______________________________________________
Haskell-Cafe mailing list
[hidden email]
http://www.haskell.org/mailman/listinfo/haskell-cafe