Commit a296464e authored by rrt's avatar rrt

[project @ 2001-08-15 14:36:21 by rrt]

Cut'n'paste rawSystem from hslibs rather than messing around trying to copy
SystemExts.lhs into compiler/main, which makes for Makefile pain.
parent 3919d260
# -----------------------------------------------------------------------------
# $Id: Makefile,v 1.186 2001/08/15 14:02:54 sewardj Exp $
# $Id: Makefile,v 1.187 2001/08/15 14:36:21 rrt Exp $
TOP = ..
include $(TOP)/mk/boilerplate.mk
......@@ -143,19 +143,16 @@ HS_SRCS += $(CONFIG_HS)
# GHC with GHC 5.02 or better, but lacking that we have the following
# hack:
# copy rawSystem.c from hslibs/lang/cbits
# and SystemExts.lhs from hslibs/lang
# into main/ (where they'll be compiled and linked with the compiler)
# into main/ (where it'll be compiled and linked with the compiler)
# (the Haskell-side code is ifdefed into main/SysTools.lhs)
ifneq "$(ghc_502_at_least)" "YES"
C_SRCS += main/rawSystem.c
HS_SRCS := $(filter-out main/SystemExts.lhs,$(HS_SRCS)) main/SystemExts.lhs
SRC_CC_OPTS += -I$(GHC_LIB_DIR)/std/cbits
SRC_MKDEPENDC_OPTS += -I$(GHC_LIB_DIR)/std/cbits
HS_OBJS += main/rawSystem.o
main/rawSystem.c : $(FPTOOLS_TOP)/hslibs/lang/cbits/rawSystem.c
$(CP) $< main
main/SystemExts.lhs: $(FPTOOLS_TOP)/hslibs/lang/SystemExts.lhs
$(CP) $< main
endif
endif
# End of system hack
......
-----------------------------------------------------------------------------
-- $Id: SysTools.lhs,v 1.49 2001/08/15 09:32:40 rrt Exp $
-- $Id: SysTools.lhs,v 1.50 2001/08/15 14:36:21 rrt Exp $
--
-- (c) The University of Glasgow 2001
--
......@@ -74,7 +74,12 @@ import qualified Posix
#else
import List ( isPrefixOf )
import MarshalArray
import SystemExts ( rawSystem )
-- use the line below when we can be sure of compiling with GHC >=
-- 5.02, and remove the implementation of rawSystem at the end of this
-- file
import PrelIOBase -- this can be removed when SystemExts is used
import CError ( throwErrnoIfMinus1 ) -- as can this
-- import SystemExts ( rawSystem )
#endif
#include "HsVersions.h"
......@@ -795,4 +800,16 @@ foreign import "_getpid" getProcessID :: IO Int -- relies on Int == Int32 on Win
getProcessID :: IO Int
getProcessID = Posix.getProcessID
#endif
rawSystem :: String -> IO ExitCode
rawSystem "" = ioException (IOError Nothing InvalidArgument "rawSystem" "null command" Nothing)
rawSystem cmd =
withUnsafeCString cmd $ \s -> do
status <- throwErrnoIfMinus1 "rawSystem" (primRawSystem s)
case status of
0 -> return ExitSuccess
n -> return (ExitFailure n)
foreign import ccall "rawSystemCmd" unsafe primRawSystem :: UnsafeCString -> IO Int
\end{code}
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