Make work again on Windows. Main.hs has to be passed through CPP now.
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
--- $Id: Main.hs,v 1.19 2001/02/13 15:53:10 qrczak Exp $
+-- $Id: Main.hs,v 1.20 2001/02/13 16:11:27 rrt Exp $
--
-- (originally "GlueHsc.hs" by Marcin 'Qrczak' Kowalczyk)
--
--
-- (originally "GlueHsc.hs" by Marcin 'Qrczak' Kowalczyk)
--
--
-- See the documentation in the Users' Guide for more details.
--
-- See the documentation in the Users' Guide for more details.
+#include "../../includes/config.h"
+
import GetOpt
import System (getProgName, getArgs, ExitCode(..), exitWith, exitFailure)
import KludgedSystem (system, defaultCompiler)
import GetOpt
import System (getProgName, getArgs, ExitCode(..), exitWith, exitFailure)
import KludgedSystem (system, defaultCompiler)
removeFile progName
when needsH $ writeFile outHName $
removeFile progName
when needsH $ writeFile outHName $
- "#ifndef "++includeGuard++"\n\
- \#define "++includeGuard++"\n\
- \#if __GLASGOW_HASKELL__ && __GLASGOW_HASKELL__ < 409\n\
- \#include <Rts.h>\n\
- \#endif\n\
- \#include <HsFFI.h>\n\
- \#if __NHC__\n\
- \#undef HsChar\n\
- \#define HsChar int\n\
+ "#ifndef "++includeGuard++"\n\
+ \#define "++includeGuard++"\n\
+ \#if __GLASGOW_HASKELL__ && __GLASGOW_HASKELL__ < 409\n\
+ \#include <Rts.h>\n\
+ \#endif\n\
+ \#include <HsFFI.h>\n\
+ \#if __NHC__\n\
+ \#undef HsChar\n\
+ \#define HsChar int\n\
\#endif\n"++
concat ["#include "++n++"\n" | Include n <- flags]++
concatMap outTokenH specials++
\#endif\n"++
concat ["#include "++n++"\n" | Include n <- flags]++
concatMap outTokenH specials++
(header, _:body) -> case break isSpace header of
(name, args) ->
outCLine pos++
(header, _:body) -> case break isSpace header of
(name, args) ->
outCLine pos++
- "#define hsc_"++name++"("++dropWhile isSpace args++") \
+ "#define hsc_"++name++"("++dropWhile isSpace args++") \
\printf ("++joinLines body++");\n"
_ -> ""
where
\printf ("++joinLines body++");\n"
_ -> ""
where
outHeaderHs :: [Flag] -> Maybe String -> [(SourcePos, String, String)] -> String
outHeaderHs flags inH toks =
outHeaderHs :: [Flag] -> Maybe String -> [(SourcePos, String, String)] -> String
outHeaderHs flags inH toks =
- "#if __GLASGOW_HASKELL__ && __GLASGOW_HASKELL__ < 409\n\
- \ printf (\"{-# OPTIONS -optc-D__GLASGOW_HASKELL__=%d #-}\\n\", \
- \__GLASGOW_HASKELL__);\n\
+ "#if __GLASGOW_HASKELL__ && __GLASGOW_HASKELL__ < 409\n\
+ \ printf (\"{-# OPTIONS -optc-D__GLASGOW_HASKELL__=%d #-}\\n\", \
+ \__GLASGOW_HASKELL__);\n\
\#endif\n"++
includeH++
concatMap outSpecial toks
\#endif\n"++
includeH++
concatMap outSpecial toks
(enum, rest) -> let
this = case break (== '=') $ dropWhile isSpace enum of
(name, []) ->
(enum, rest) -> let
this = case break (== '=') $ dropWhile isSpace enum of
(name, []) ->
- " hsc_enum ("++t++", "++f++", \
+ " hsc_enum ("++t++", "++f++", \
\hsc_haskellize (\""++name++"\"), "++
name++");\n"
(hsName, _:cName) ->
\hsc_haskellize (\""++name++"\"), "++
name++");\n"
(hsName, _:cName) ->
- " hsc_enum ("++t++", "++f++", \
+ " hsc_enum ("++t++", "++f++", \
\printf (\"%s\", \""++hsName++"\"), "++
cName++");\n"
in this++enums rest
\printf (\"%s\", \""++hsName++"\"), "++
cName++");\n"
in this++enums rest
's':'t':'r':'u':'c':'t':' ':_ -> arg++"\n"
't':'y':'p':'e':'d':'e':'f':' ':_ -> arg++"\n"
'i':'n':'l':'i':'n':'e':' ':_ ->
's':'t':'r':'u':'c':'t':' ':_ -> arg++"\n"
't':'y':'p':'e':'d':'e':'f':' ':_ -> arg++"\n"
'i':'n':'l':'i':'n':'e':' ':_ ->
- "#ifdef __GNUC__\n\
- \extern\n\
+ "#ifdef __GNUC__\n\
+ \extern\n\
\#endif\n"++
arg++"\n"
_ -> "extern "++header++";\n"
\#endif\n"++
arg++"\n"
_ -> "extern "++header++";\n"
't':'y':'p':'e':'d':'e':'f':' ':_ -> ""
'i':'n':'l':'i':'n':'e':' ':_ ->
outCLine pos++
't':'y':'p':'e':'d':'e':'f':' ':_ -> ""
'i':'n':'l':'i':'n':'e':' ':_ ->
outCLine pos++
- "#ifndef __GNUC__\n\
- \extern\n\
+ "#ifndef __GNUC__\n\
+ \extern\n\
- "\n#ifndef __GNUC__\n\
- \;\n\
+ "\n#ifndef __GNUC__\n\
+ \;\n\
\#else\n"++
body++
"\n#endif\n"
\#else\n"++
body++
"\n#endif\n"