diff --git a/README b/README index 6f749a9..06f7357 100644 --- a/README +++ b/README @@ -23,49 +23,52 @@ generated, dynamically-typed printf. Read the documentation in doc/ for more. ------------------------------------------------------------------------ + +BUILDING: + $ ./configure --prefix=/usr/local + $ make + $ make install + +------------------------------------------------------------------------ + DEPENDENCIES: * Requires GHC >= 6.4 -* Requires GNU make or BSD make to build -* 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) +* Requires Cabal ------------------------------------------------------------------------ +* 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. * 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 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 ------------------------------------------------------------------------- -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: +* The documentation relies on latex, dvips, tex2page: $ cd doc && make +------------------------------------------------------------------------ + EXAMPLES: Have a look in the examples/ directory for many examples of how to diff --git a/config.h.in b/config.h.in index fcdaca6..b96798b 100644 --- a/config.h.in +++ b/config.h.in @@ -39,5 +39,8 @@ /* Which ghc to use */ #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 */ #undef __MINGW32__ diff --git a/configure b/configure index 54cc271..1f27a97 100644 --- a/configure +++ b/configure @@ -272,7 +272,7 @@ PACKAGE_STRING= PACKAGE_BUGREPORT= 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='' # Initialize some variables set by options. @@ -803,6 +803,7 @@ Optional Features: --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --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: --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] @@ -1486,6 +1487,7 @@ _ACEOF if test "${enable_debug+set}" = set; then enableval="$enable_debug" + cat >>confdefs.h <<_ACEOF #define DEBUG 1 _ACEOF @@ -1494,6 +1496,20 @@ else : 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. @@ -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 - 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 # This file is a shell script that caches the results of configure @@ -3220,6 +3236,7 @@ do case "$ac_config_target" in # Handling of arguments. "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/unsafeio/Unsafe.conf" ) CONFIG_FILES="$CONFIG_FILES examples/makewith/unsafeio/Unsafe.conf" ;; "config.h" ) CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;; @@ -3315,6 +3332,7 @@ s,@PREFIX@,$PREFIX,;t t s,@TOP@,$TOP,;t t s,@GHC@,$GHC,;t t s,@GLASGOW_HASKELL@,$GLASGOW_HASKELL,;t t +s,@HASKELL_SRC@,$HASKELL_SRC,;t t s,@TEX@,$TEX,;t t s,@TEX2PAGE@,$TEX2PAGE,;t t s,@CC@,$CC,;t t diff --git a/configure.ac b/configure.ac index c6895ba..3320413 100644 --- a/configure.ac +++ b/configure.ac @@ -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 AC_ARG_ENABLE(debug, [ --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) if test -z "$TEX" ; then @@ -128,6 +137,6 @@ AC_CHECK_FUNCS(arc4random) AC_PROG_INSTALL # 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 diff --git a/src/System/Plugins/Parser.hs b/src/System/Plugins/Parser.hs index 40ebcea..58714ac 100644 --- a/src/System/Plugins/Parser.hs +++ b/src/System/Plugins/Parser.hs @@ -1,4 +1,4 @@ -{-# OPTIONS -fglasgow-exts #-} +{-# OPTIONS -cpp -fglasgow-exts #-} -- -- Copyright (C) 2004 Don Stewart - http://www.cse.unsw.edu.au/~dons -- @@ -24,11 +24,19 @@ module System.Plugins.Parser ( replaceModName ) where +#include "../../../config.h" + import Data.List import Data.Char import Data.Either +#if defined(WITH_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 @@ -38,7 +46,11 @@ parse :: FilePath -- ^ module name -> Either String HsModule -- ^ abstract syntax parse f fsrc = +#if defined(WITH_HSX) case parseFileContentsWithMode (ParseMode f) fsrc of +#else + case parseModuleWithMode (ParseMode f) fsrc of +#endif ParseOk src -> Right src ParseFailed loc _ -> Left $ srcmsg loc where diff --git a/src/System/Plugins/Utils.hs b/src/System/Plugins/Utils.hs index 0ec5331..086cf01 100644 --- a/src/System/Plugins/Utils.hs +++ b/src/System/Plugins/Utils.hs @@ -69,7 +69,6 @@ import Data.List import System.IO import System.Environment ( getEnv ) import System.Directory -import qualified Control.Exception as Control.Exception (handle) -- --------------------------------------------------------------------- -- some misc types we use diff --git a/src/plugins.cabal b/src/plugins.cabal.in similarity index 93% rename from src/plugins.cabal rename to src/plugins.cabal.in index 58f3c5d..e928e13 100644 --- a/src/plugins.cabal +++ b/src/plugins.cabal.in @@ -32,6 +32,6 @@ exposed-modules: c-sources: Language/Hi/hschooks.c 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