From c63aaee42e3e95276861121286eefce511cd1343 Mon Sep 17 00:00:00 2001 From: mthomas Date: Sun, 27 Oct 2002 10:38:33 +0000 Subject: [PATCH] [project @ 2002-10-27 10:38:32 by mthomas] Remove Win32 library dependency. --- ghc/utils/ghc-pkg/Main.hs | 4 ++-- ghc/utils/ghc-pkg/Makefile | 4 ++-- ghc/utils/hsc2hs/Main.hs | 24 ++++++++++++++++++++---- ghc/utils/hsc2hs/Makefile | 4 ++-- 4 files changed, 26 insertions(+), 10 deletions(-) diff --git a/ghc/utils/ghc-pkg/Main.hs b/ghc/utils/ghc-pkg/Main.hs index 35a22a9..cf3adc9 100644 --- a/ghc/utils/ghc-pkg/Main.hs +++ b/ghc/utils/ghc-pkg/Main.hs @@ -1,7 +1,7 @@ {-# OPTIONS -fglasgow-exts #-} ----------------------------------------------------------------------------- --- $Id: Main.hs,v 1.28 2002/09/13 15:01:40 simonpj Exp $ +-- $Id: Main.hs,v 1.29 2002/10/27 10:38:32 mthomas Exp $ -- -- Package management tool ----------------------------------------------------------------------------- @@ -34,7 +34,7 @@ import ParsePkgConfLite #include "../../includes/config.h" #ifdef mingw32_HOST_OS -import CString +import Foreign.C.String import Foreign #endif diff --git a/ghc/utils/ghc-pkg/Makefile b/ghc/utils/ghc-pkg/Makefile index 896742e..bd04d06 100644 --- a/ghc/utils/ghc-pkg/Makefile +++ b/ghc/utils/ghc-pkg/Makefile @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# $Id: Makefile,v 1.18 2002/09/09 11:32:38 simonmar Exp $ +# $Id: Makefile,v 1.19 2002/10/27 10:38:33 mthomas Exp $ TOP=../.. include $(TOP)/mk/boilerplate.mk @@ -24,7 +24,7 @@ INSTALL_LIBEXECS += $(HS_PROG) ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32" HS_PROG = ghc-pkg.exe INSTALL_PROGS += $(HS_PROG) -SRC_HC_OPTS += -package win32 +SRC_HC_OPTS += -fglasgow-exts '-\#include ' -optl "-Wl,-lkernel32" endif # ----------------------------------------------------------------------------- diff --git a/ghc/utils/hsc2hs/Main.hs b/ghc/utils/hsc2hs/Main.hs index 2527516..ee30d09 100644 --- a/ghc/utils/hsc2hs/Main.hs +++ b/ghc/utils/hsc2hs/Main.hs @@ -1,5 +1,5 @@ ------------------------------------------------------------------------ --- $Id: Main.hs,v 1.40 2002/09/09 11:39:42 simonmar Exp $ +-- $Id: Main.hs,v 1.41 2002/10/27 10:38:33 mthomas Exp $ -- -- Program for converting .hsc files to .hs files, by converting the -- file into a C program which is run to generate the Haskell source. @@ -25,7 +25,23 @@ import List (intersperse) #include "../../includes/config.h" #ifdef mingw32_HOST_OS -import Win32DLL +-- import Win32DLL +import Foreign.C.String (CString, peekCString) +import Foreign.C.Types +import Foreign.Ptr (nullPtr) +import Foreign.Marshal.Alloc (mallocBytes, free) + +foreign import stdcall "GetModuleHandle" c_GetModuleHandle :: CString -> IO CUInt +foreign import stdcall "GetModuleFileName" c_GetModuleFilename :: CUInt -> CString -> CUInt -> IO CUInt + +ourName :: IO String +ourName = do h <- c_GetModuleHandle nullPtr + cstr <- mallocBytes cstr_len + rv <- c_GetModuleFilename h cstr (CUInt (fromIntegral cstr_len)) + str <- peekCString cstr + free cstr + return str + where cstr_len = 512 #endif version :: String @@ -77,8 +93,7 @@ main = do args <- getArgs let opts@(flags, files, errs) = getOpt Permute options args #ifdef mingw32_HOST_OS - h <- getModuleHandle Nothing - n <- getModuleFileName h + n <- ourName let tempName = reverse (drop (length "\\bin\\hsc2hs.exe") (reverse n)) ++ "\\template-hsc.h" let fflags = if [t | Template t <- flags] /= [] then flags else (Template tempName) : flags let opts = (fflags, files, errs) @@ -744,3 +759,4 @@ showCString = concatMap showCChar intToDigit (ord c `quot` 64), intToDigit (ord c `quot` 8 `mod` 8), intToDigit (ord c `mod` 8)] + diff --git a/ghc/utils/hsc2hs/Makefile b/ghc/utils/hsc2hs/Makefile index 033621d..cba41da 100644 --- a/ghc/utils/hsc2hs/Makefile +++ b/ghc/utils/hsc2hs/Makefile @@ -1,5 +1,5 @@ # ----------------------------------------------------------------------------- -# $Id: Makefile,v 1.34 2002/09/09 11:39:43 simonmar Exp $ +# $Id: Makefile,v 1.35 2002/10/27 10:38:33 mthomas Exp $ TOP=../.. include $(TOP)/mk/boilerplate.mk @@ -26,7 +26,7 @@ endif SRC_HC_OPTS += -cpp ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32" -SRC_HC_OPTS += -package win32 '-\#include ' +SRC_HC_OPTS += -fglasgow-exts '-\#include ' -optl "-Wl,-lkernel32" endif ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32" -- 1.7.10.4