Commit 3b4e3984 authored by qrczak's avatar qrczak
Browse files

[project @ 2001-03-29 17:56:18 by qrczak]

Generated C files are named *_hsc.h and *_hsc.c (again).
parent 6c05aa01
......@@ -214,16 +214,6 @@ tags:
</listitem>
</varlistentry>
<varlistentry>
<term><literal>-s FILE</literal> or
<literal>--support=FILE</literal></term>
<listitem>
<para>Basename of the C file and C header
(with <literal>.c</literal>, <literal>.h</literal>
suffixes removed).</para>
</listitem>
</varlistentry>
<varlistentry>
<term><literal>--help</literal></term>
<listitem>
......@@ -240,22 +230,22 @@ tags:
</variablelist>
<para>The input file should end with .hsc. Output files by
default get names with the <literal>*.hsc</literal> pattern
default get names with the <literal>.hsc</literal> suffix
replaced:</para>
<informaltable>
<tgroup cols=2>
<tbody>
<row>
<entry><literal>*.hs</literal></entry>
<entry><literal>.hs</literal></entry>
<entry>Haskell file</entry>
</row>
<row>
<entry><literal>Hs*.h</literal></entry>
<entry><literal>_hsc.h</literal></entry>
<entry>C header</entry>
</row>
<row>
<entry><literal>Hs*.c</literal></entry>
<entry><literal>_hsc.c</literal></entry>
<entry>C file</entry>
</row>
</tbody>
......
......@@ -92,9 +92,9 @@ endif
CLEAN_FILES += PrelGHC.hi $(foreach way, $(WAYS), PrelGHC.$(way)_hi)
CLEAN_FILES += \
$(patsubst %.hsc, %.hs, $(HSC_SRCS)) \
$(patsubst %.hsc, Hs%.c, $(HSC_SRCS)) \
$(patsubst %.hsc, Hs%.h, $(HSC_SRCS))
$(patsubst %.hsc, %.hs, $(HSC_SRCS)) \
$(patsubst %.hsc, %_hsc.c, $(HSC_SRCS)) \
$(patsubst %.hsc, %_hsc.h, $(HSC_SRCS))
#-----------------------------------------------------------------------------
# Installation; need to install .hi files as well as libraries
......
------------------------------------------------------------------------
-- $Id: Main.hs,v 1.28 2001/03/29 08:03:21 qrczak Exp $
-- $Id: Main.hs,v 1.29 2001/03/29 17:56:18 qrczak 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.
......@@ -32,7 +32,6 @@ data Flag
| Include String
| Define String (Maybe String)
| Output String
| Support String
include :: String -> Flag
include s@('\"':_) = Include s
......@@ -53,11 +52,10 @@ options = [
Option "I" [] (ReqArg (CompFlag . ("-I"++))
"DIR") "passed to the C compiler",
Option "L" ["lflag"] (ReqArg LinkFlag "FLAG") "flag to pass to the linker",
Option "" ["no-compile"] (NoArg NoCompile) "stop after writing *_make.c",
Option "" ["no-compile"] (NoArg NoCompile) "stop after writing *_hsc_make.c",
Option "i" ["include"] (ReqArg include "FILE") "as if placed in the source",
Option "D" ["define"] (ReqArg define "NAME[=VALUE]") "as if placed in the source",
Option "o" ["output"] (ReqArg Output "FILE") "name of main output file",
Option "s" ["support"] (ReqArg Support "FILE") "basename of support output files (with .h, .c removed)",
Option "" ["help"] (NoArg Help) "display this help and exit",
Option "" ["version"] (NoArg Version) "output version information and exit"]
......@@ -415,35 +413,30 @@ splitExt name =
output :: [Flag] -> String -> [Token] -> IO ()
output flags name toks = do
let (dir, file) = splitName name
(base, ext) = splitExt file
(outName, outDir, outBase) <- case [f | Output f <- flags] of
[]
| not (null ext) &&
last ext == 'c' -> return (dir++base++init ext, dir, base)
| ext == ".hs" -> return (dir++base++"_out.hs", dir, base)
| otherwise -> return (dir++base++".hs", dir, base)
where
(dir, file) = splitName name
(base, ext) = splitExt file
[f] -> let
(dir', file') = splitName f
(base', _) = splitExt file'
in return (f, dir', base')
(dir, file) = splitName f
(base, _) = splitExt file
in return (f, dir, base)
_ -> onlyOne "output file"
supportDirBase <- case [f | Support f <- flags] of
[] -> return (outDir++"Hs"++outBase)
[f] -> return f
_ -> onlyOne "support file"
let cProgName = outDir++outBase++"_make.c"
oProgName = outDir++outBase++"_make.o"
progName = outDir++outBase++"_make"
outHName = supportDirBase++".h"
outCName = supportDirBase++".c"
let cProgName = outDir++outBase++"_hsc_make.c"
oProgName = outDir++outBase++"_hsc_make.o"
progName = outDir++outBase++"_hsc_make"
outHName = outDir++outBase++"_hsc.h"
outCName = outDir++outBase++"_hsc.c"
let execProgName
| null dir = "./"++progName
| otherwise = progName
| null outDir = "./"++progName
| otherwise = progName
let specials = [(pos, key, arg) | Special pos key arg <- toks]
......
......@@ -112,7 +112,7 @@ endif # BootingViaC
#-----------------------------------------------------------------------------
# hsc2hs Suffix Rules
#
Hs%.c Hs%.h %.hs : %.hsc
%_hsc.c %_hsc.h %.hs : %.hsc
$(HSC2HS) $<
#-----------------------------------------------------------------------------
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment