Use HOSTPLATFORM / *_HOST_OS to examine properties of the environment/compiler
we're using.
------------------------------------------------------------------------
------------------------------------------------------------------------
--- $Id: Main.hs,v 1.38 2002/04/18 12:15:56 simonmar Exp $
+-- $Id: Main.hs,v 1.39 2002/05/29 22:32:49 sof 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.
--
-- Program for converting .hsc files to .hs files, by converting the
-- file into a C program which is run to generate the Haskell source.
#include "../../includes/config.h"
#include "../../includes/config.h"
-#ifdef mingw32_TARGET_OS
let header = "Usage: "++prog++" [OPTIONS] INPUT.hsc [...]"
args <- getArgs
let opts@(flags, files, errs) = getOpt Permute options args
let header = "Usage: "++prog++" [OPTIONS] INPUT.hsc [...]"
args <- getArgs
let opts@(flags, files, errs) = getOpt Permute options args
-#ifdef mingw32_TARGET_OS
h <- getModuleHandle Nothing
n <- getModuleFileName h
let tempName = reverse (drop (length "\\bin\\hsc2hs.exe") (reverse n)) ++ "\\template-hsc.h"
h <- getModuleHandle Nothing
n <- getModuleFileName h
let tempName = reverse (drop (length "\\bin\\hsc2hs.exe") (reverse n)) ++ "\\template-hsc.h"
------------------------------------------------------------------------
-- Convert paths foo/baz to foo\baz on Windows
------------------------------------------------------------------------
-- Convert paths foo/baz to foo\baz on Windows
-#if defined(mingw32_TARGET_OS)
+#if defined(mingw32_HOST_OS)
subst a b ls = map (\ x -> if x == a then b else x) ls
dosifyPath xs = subst '/' '\\' xs
#else
subst a b ls = map (\ x -> if x == a then b else x) ls
dosifyPath xs = subst '/' '\\' xs
#else
# -----------------------------------------------------------------------------
# -----------------------------------------------------------------------------
-# $Id: Makefile,v 1.32 2002/04/30 14:40:33 simonmar Exp $
+# $Id: Makefile,v 1.33 2002/05/29 22:32:50 sof Exp $
TOP=../..
include $(TOP)/mk/boilerplate.mk
TOP=../..
include $(TOP)/mk/boilerplate.mk
-ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
+ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
+HS_PROG = hsc2hs$(exeext)
+endif
+ifeq "$(HOSTPLATFORM)" "i386-unknown-cygwinw32"
HS_PROG = hsc2hs$(exeext)
endif
HS_PROG = hsc2hs$(exeext)
endif
SRC_HC_OPTS += -package util -cpp
SRC_HC_OPTS += -package util -cpp
-ifeq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
+
+ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
SRC_HC_OPTS += -package win32 '-\#include <process.h>'
endif
SRC_HC_OPTS += -package win32 '-\#include <process.h>'
endif
-ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
+ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
INSTALLED_SCRIPT_PROG = hsc2hs
endif
INPLACE_SCRIPT_PROG = hsc2hs-inplace
INSTALLED_SCRIPT_PROG = hsc2hs
endif
INPLACE_SCRIPT_PROG = hsc2hs-inplace
else
HSC2HS_BINDIR=$(FPTOOLS_TOP_ABS)/$(CURRENT_DIR)
HSC2HS_DIR=$(FPTOOLS_TOP_ABS)/$(CURRENT_DIR)
else
HSC2HS_BINDIR=$(FPTOOLS_TOP_ABS)/$(CURRENT_DIR)
HSC2HS_DIR=$(FPTOOLS_TOP_ABS)/$(CURRENT_DIR)
-ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
-HSC2HS_EXTRA="--cc=$(CC) --cflag=-D__GLASGOW_HASKELL__=$(ProjectVersionInt) -I$(FPTOOLS_TOP_ABS)/$(INCLUDE_DIR)"
-else
+
+ifeq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
extra_flags=$(addprefix --cflag=,$(filter-out -O,$(SRC_CC_OPTS)))
extra_flags=$(addprefix --cflag=,$(filter-out -O,$(SRC_CC_OPTS)))
-HSC2HS_EXTRA="--cc=$(CC) $(extra_flags) --cflag=-D__GLASGOW_HASKELL__=$(ProjectVersionInt) -I$(FPTOOLS_TOP_ABS)/$(INCLUDE_DIR)"
+
+HSC2HS_EXTRA="--cc=$(CC) $(extra_flags) --cflag=-D__GLASGOW_HASKELL__=$(ProjectVersionInt) -I$(FPTOOLS_TOP_ABS)/$(INCLUDE_DIR)"
endif
$(SCRIPT_PROG) : Makefile
endif
$(SCRIPT_PROG) : Makefile
@echo "cDEFAULT_TMPDIR = \"$(DEFAULT_TMPDIR)\"" >> $(CONFIG_HS)
@echo "cGCC = \"$(WhatGccIsCalled)\"" >> $(CONFIG_HS)
@echo "progNameSuffix = \"$(exeext)\"" >> $(CONFIG_HS)
@echo "cDEFAULT_TMPDIR = \"$(DEFAULT_TMPDIR)\"" >> $(CONFIG_HS)
@echo "cGCC = \"$(WhatGccIsCalled)\"" >> $(CONFIG_HS)
@echo "progNameSuffix = \"$(exeext)\"" >> $(CONFIG_HS)
-ifneq "$(TARGETPLATFORM)" "i386-unknown-mingw32"
+ifneq "$(HOSTPLATFORM)" "i386-unknown-mingw32"
@echo "pathSep = '/'" >> $(CONFIG_HS)
else
@echo "pathSep = (toEnum 92 :: Char)" >> $(CONFIG_HS)
@echo "pathSep = '/'" >> $(CONFIG_HS)
else
@echo "pathSep = (toEnum 92 :: Char)" >> $(CONFIG_HS)