Make dependency on HSX *optional*. Use ./configure --enable-hsx to use it

This commit is contained in:
Don Stewart 2005-08-19 01:43:17 +00:00
parent 9d68153395
commit e59c59d3ea
7 changed files with 78 additions and 34 deletions

57
README
View File

@ -23,49 +23,52 @@ generated, dynamically-typed printf.
Read the documentation in doc/ for more. Read the documentation in doc/ for more.
------------------------------------------------------------------------ ------------------------------------------------------------------------
BUILDING:
$ ./configure --prefix=/usr/local
$ make
$ make install
------------------------------------------------------------------------
DEPENDENCIES: DEPENDENCIES:
* Requires GHC >= 6.4 * Requires GHC >= 6.4
* Requires GNU make or BSD make to build * Requires Cabal
* Requires HSX, Niklas Broberg's Haskell parser library, available at:
darcs get http://www.cs.chalmers.se/~d00nibro/haskell-src-exts
Read the README with this package for how to install it (quite simple)
------------------------------------------------------------------------ ------------------------------------------------------------------------
* Optional:
If you are doing a lot of `merge'-related operations, and require
an extended haskell parser, you can compile hs-plugins to use
HSX, Niklas Broberg's Haskell parser library, available at:
darcs get http://www.cs.chalmers.se/~d00nibro/haskell-src-exts
To get hs-plugins to use HSX, use the --enable-hsx to ./configure.
Make sure to install HSX first though :)
------------------------------------------------------------------------
* On cygwin/windows you (a) make sure the cygwin "find" is before the
windows "find" on your PATH, and (b) to give the windows-style path
(e.g., "c:/cygwin/usr/local") in the ./configure --prefix=foo/bar
step
* 'plugs' requires a working readline library. * 'plugs' requires a working readline library.
* If you wish to use TH in plugins, or to run load()-programs in GHCi, * If you wish to use TH in plugins, or to run load()-programs in GHCi,
you require a patch to GHC's linker, that was committed into ghc you require a patch to GHC's linker, that was committed into ghc
6.3, and ghc 6.2 -stable branch, and is available from 6.2.2 onwards. 6.3, and ghc 6.2 -stable branch, and is available from 6.2.2 onwards.
* If you need to regenerate ./configure you need >= autoconf-2.53 * If you need to regenerate ./configure you need >= autoreconf-2.53
------------------------------------------------------------------------ * The documentation relies on latex, dvips, tex2page:
BUILDING:
$ ./configure --prefix=/usr/local
$ make
$ make install
* On cygwin/windows you (a) make sure the cygwin "find" is before the
windows "find" on your PATH, and (b) to give the windows-style path
(e.g., "c:/cygwin/usr/local") in the ./configure --prefix=foo/bar
step
If you wish to register the libraries as official ghc pkg (probably as
root):
$ make register
And to unregister (maybe as root):
$ make unregister
Once it is registered, you can link against the library by just adding
-package plugins to your command line.
The documentation relies on latex, dvips, tex2page:
$ cd doc && make $ cd doc && make
------------------------------------------------------------------------
EXAMPLES: EXAMPLES:
Have a look in the examples/ directory for many examples of how to Have a look in the examples/ directory for many examples of how to

View File

@ -39,5 +39,8 @@
/* Which ghc to use */ /* Which ghc to use */
#undef WITH_GHC #undef WITH_GHC
/* Defined if hs-plugins is to be built with Niklas Broberg's HSX parser */
#undef WITH_HSX
/* Defined if compiling with mingw */ /* Defined if compiling with mingw */
#undef __MINGW32__ #undef __MINGW32__

22
configure vendored
View File

@ -272,7 +272,7 @@ PACKAGE_STRING=
PACKAGE_BUGREPORT= PACKAGE_BUGREPORT=
ac_unique_file="src/System/Plugins.hs" ac_unique_file="src/System/Plugins.hs"
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os PREFIX TOP GHC GLASGOW_HASKELL TEX TEX2PAGE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LIBOBJS LTLIBOBJS' ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS build build_cpu build_vendor build_os PREFIX TOP GHC GLASGOW_HASKELL HASKELL_SRC TEX TEX2PAGE CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LIBOBJS LTLIBOBJS'
ac_subst_files='' ac_subst_files=''
# Initialize some variables set by options. # Initialize some variables set by options.
@ -803,6 +803,7 @@ Optional Features:
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-debug Enable a debug version of hs-plugins to be built --enable-debug Enable a debug version of hs-plugins to be built
--enable-hsx Enable a debug version of hs-plugins to be built
Optional Packages: Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes] --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
@ -1486,6 +1487,7 @@ _ACEOF
if test "${enable_debug+set}" = set; then if test "${enable_debug+set}" = set; then
enableval="$enable_debug" enableval="$enable_debug"
cat >>confdefs.h <<_ACEOF cat >>confdefs.h <<_ACEOF
#define DEBUG 1 #define DEBUG 1
_ACEOF _ACEOF
@ -1494,6 +1496,20 @@ else
: :
fi; fi;
# Allow a debugging version of hs-plugins to be built
# Check whether --enable-hsx or --disable-hsx was given.
if test "${enable_hsx+set}" = set; then
enableval="$enable_hsx"
HASKELL_SRC=haskell-src-exts ;
cat >>confdefs.h <<_ACEOF
#define WITH_HSX 1
_ACEOF
else
HASKELL_SRC=haskell-src
fi;
# Extract the first word of "tex", so it can be a program name with args. # Extract the first word of "tex", so it can be a program name with args.
@ -2692,7 +2708,7 @@ test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
# System.Process uses cmd or command.com shell on Windows, doen't use Cygwin or MSYS shell # System.Process uses cmd or command.com shell on Windows, doen't use Cygwin or MSYS shell
ac_config_files="$ac_config_files config.mk examples/makewith/io/TestIO.conf examples/makewith/unsafeio/Unsafe.conf" ac_config_files="$ac_config_files config.mk src/plugins.cabal examples/makewith/io/TestIO.conf examples/makewith/unsafeio/Unsafe.conf"
cat >confcache <<\_ACEOF cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure # This file is a shell script that caches the results of configure
@ -3220,6 +3236,7 @@ do
case "$ac_config_target" in case "$ac_config_target" in
# Handling of arguments. # Handling of arguments.
"config.mk" ) CONFIG_FILES="$CONFIG_FILES config.mk" ;; "config.mk" ) CONFIG_FILES="$CONFIG_FILES config.mk" ;;
"src/plugins.cabal" ) CONFIG_FILES="$CONFIG_FILES src/plugins.cabal" ;;
"examples/makewith/io/TestIO.conf" ) CONFIG_FILES="$CONFIG_FILES examples/makewith/io/TestIO.conf" ;; "examples/makewith/io/TestIO.conf" ) CONFIG_FILES="$CONFIG_FILES examples/makewith/io/TestIO.conf" ;;
"examples/makewith/unsafeio/Unsafe.conf" ) CONFIG_FILES="$CONFIG_FILES examples/makewith/unsafeio/Unsafe.conf" ;; "examples/makewith/unsafeio/Unsafe.conf" ) CONFIG_FILES="$CONFIG_FILES examples/makewith/unsafeio/Unsafe.conf" ;;
"config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
@ -3315,6 +3332,7 @@ s,@PREFIX@,$PREFIX,;t t
s,@TOP@,$TOP,;t t s,@TOP@,$TOP,;t t
s,@GHC@,$GHC,;t t s,@GHC@,$GHC,;t t
s,@GLASGOW_HASKELL@,$GLASGOW_HASKELL,;t t s,@GLASGOW_HASKELL@,$GLASGOW_HASKELL,;t t
s,@HASKELL_SRC@,$HASKELL_SRC,;t t
s,@TEX@,$TEX,;t t s,@TEX@,$TEX,;t t
s,@TEX2PAGE@,$TEX2PAGE,;t t s,@TEX2PAGE@,$TEX2PAGE,;t t
s,@CC@,$CC,;t t s,@CC@,$CC,;t t

View File

@ -108,10 +108,19 @@ AC_DEFINE_UNQUOTED(GHC_LIB_PATH, "$GHC_LIB_PATH", [Path to ghc libraries])
# Allow a debugging version of hs-plugins to be built # Allow a debugging version of hs-plugins to be built
AC_ARG_ENABLE(debug, AC_ARG_ENABLE(debug,
[ --enable-debug Enable a debug version of hs-plugins to be built], [ --enable-debug Enable a debug version of hs-plugins to be built],
[ AC_DEFINE_UNQUOTED(DEBUG, [1], [Defined if a debugging version is to be built]) ], [
AC_DEFINE_UNQUOTED(DEBUG, [1], [Defined if a debugging version is to be built]) ],
[ : ]) [ : ])
# Allow a debugging version of hs-plugins to be built
AC_ARG_ENABLE(hsx,
[ --enable-hsx Enable a debug version of hs-plugins to be built],
[ HASKELL_SRC=haskell-src-exts ;
AC_DEFINE_UNQUOTED(WITH_HSX, [1],
[Defined if hs-plugins is to be built with Niklas Broberg's HSX parser]) ],
[ HASKELL_SRC=haskell-src ])
AC_SUBST(HASKELL_SRC)
AC_CHECK_PROG(TEX,tex,tex) AC_CHECK_PROG(TEX,tex,tex)
if test -z "$TEX" ; then if test -z "$TEX" ; then
@ -128,6 +137,6 @@ AC_CHECK_FUNCS(arc4random)
AC_PROG_INSTALL AC_PROG_INSTALL
# System.Process uses cmd or command.com shell on Windows, doen't use Cygwin or MSYS shell # System.Process uses cmd or command.com shell on Windows, doen't use Cygwin or MSYS shell
AC_CONFIG_FILES([config.mk examples/makewith/io/TestIO.conf examples/makewith/unsafeio/Unsafe.conf]) AC_CONFIG_FILES([config.mk src/plugins.cabal examples/makewith/io/TestIO.conf examples/makewith/unsafeio/Unsafe.conf])
AC_OUTPUT AC_OUTPUT

View File

@ -1,4 +1,4 @@
{-# OPTIONS -fglasgow-exts #-} {-# OPTIONS -cpp -fglasgow-exts #-}
-- --
-- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons -- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons
-- --
@ -24,11 +24,19 @@ module System.Plugins.Parser (
replaceModName replaceModName
) where ) where
#include "../../../config.h"
import Data.List import Data.List
import Data.Char import Data.Char
import Data.Either import Data.Either
#if defined(WITH_HSX)
import Language.Haskell.Hsx import Language.Haskell.Hsx
#else
import Language.Haskell.Parser
import Language.Haskell.Syntax
import Language.Haskell.Pretty
#endif
-- --
-- | parse a file (as a string) as Haskell src -- | parse a file (as a string) as Haskell src
@ -38,7 +46,11 @@ parse :: FilePath -- ^ module name
-> Either String HsModule -- ^ abstract syntax -> Either String HsModule -- ^ abstract syntax
parse f fsrc = parse f fsrc =
#if defined(WITH_HSX)
case parseFileContentsWithMode (ParseMode f) fsrc of case parseFileContentsWithMode (ParseMode f) fsrc of
#else
case parseModuleWithMode (ParseMode f) fsrc of
#endif
ParseOk src -> Right src ParseOk src -> Right src
ParseFailed loc _ -> Left $ srcmsg loc ParseFailed loc _ -> Left $ srcmsg loc
where where

View File

@ -69,7 +69,6 @@ import Data.List
import System.IO import System.IO
import System.Environment ( getEnv ) import System.Environment ( getEnv )
import System.Directory import System.Directory
import qualified Control.Exception as Control.Exception (handle)
-- --------------------------------------------------------------------- -- ---------------------------------------------------------------------
-- some misc types we use -- some misc types we use

View File

@ -32,6 +32,6 @@ exposed-modules:
c-sources: c-sources:
Language/Hi/hschooks.c Language/Hi/hschooks.c
includes: Linker.h includes: Linker.h
Build-Depends: base, haskell98, Cabal, haskell-src-exts>=0.2 Build-Depends: base, haskell98, Cabal, @HASKELL_SRC@
ghc-options: -Wall -O -fvia-C -funbox-strict-fields -fno-warn-missing-signatures -threaded ghc-options: -Wall -O -fvia-C -funbox-strict-fields -fno-warn-missing-signatures -threaded