Skip to content

Commit 9b8026f

Browse files
committed
Extend build instructions in README
1 parent afbf177 commit 9b8026f

File tree

1 file changed

+59
-8
lines changed

1 file changed

+59
-8
lines changed

README.md

Lines changed: 59 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,9 @@
55
Alex is a Lex-like tool for generating Haskell scanners. For complete
66
documentation, see the doc directory.
77

8-
http://www.haskell.org/alex/
8+
- <https://www.haskell.org/alex/>
99

10-
http://hackage.haskell.org/package/alex
11-
12-
Alex is built using Cabal. First install GHC and cabal-install, then:
13-
14-
$ cabal configure
15-
$ cabal build
16-
$ cabal install
10+
- <https://hackage.haskell.org/package/alex>
1711

1812
Alex version 2.0 has changed fairly considerably since version 1.x,
1913
and the syntax is almost completely different. For a detailed list of
@@ -29,6 +23,63 @@ The source code in the 'src' and 'examples' directories is intended
2923
for a Haskell 98 compiler with hierarchical modules. It should work
3024
with GHC >= 5.04.
3125

26+
## Build Instructions
27+
28+
If you just want to *use* Alex, you can download or install (via
29+
`cabal install alex`) an
30+
[Alex release from Hackage](https://hackage.haskell.org/package/alex); also note that
31+
distributions such as the
32+
[Haskell Platform](https://www.haskell.org/platform/) and other package
33+
manager-based distributions provide packages for Alex. Moreover,
34+
recent versions of `cabal` will automatically install the required
35+
version of `alex` based on
36+
[`build-tools`/`build-tool-depends` declarations](http://cabal.readthedocs.io/en/latest/developing-packages.html#pkg-field-build-tool-depends).
37+
38+
Read on if you want to build Alex directly from Git.
39+
40+
Alex is built using GHC & Cabal; so first install
41+
[GHC](https://www.haskell.org/ghc) and
42+
[`cabal-install-2.0`](https://www.haskell.org/cabal) (or later).
43+
44+
Since Alex itself is implemented in terms of an Alex scanner,
45+
bootstrapping Alex is a bit tricky:
46+
47+
You need to have the build-tools `alex` and `happy` manually
48+
installed; either via your system package manager distribution, the
49+
Haskell Platform, or e.g. via (run this outside the Git repository!):
50+
51+
$ cabal install alex happy
52+
53+
which installs them into `${HOME}/.cabal/bin` by default (make sure
54+
they're in your `$PATH` for the next steps!).
55+
56+
### Variant A
57+
58+
First you need to generate the pre-processed the templates via
59+
60+
$ cabal new-run gen-alex-sdist
61+
62+
(otherwise `cabal install` will complain about
63+
"`data/AlexTemplate: copyFile: does not exist (No such file or directory)`")
64+
65+
And then you can install `alex` simply by invoking
66+
67+
$ cabal install
68+
69+
from inside the Git folder.
70+
71+
### Variant B
72+
73+
Alternatively, you can use the `Makefile` which automates the steps of
74+
producing a self-contained pre-bootstrapped source distribution with
75+
pre-generated lexer/scanners (and which also performs the `cabal
76+
new-run gen-alex-sdist` pre-preprocessing step):
77+
78+
$ make sdist
79+
$ cabal install dist/alex-*.tar.gz
80+
81+
## Contributing & Reporting Issues
82+
3283
Please report any bugs or comments at https://github.com/simonmar/alex/issues
3384

3485
Share and enjoy,

0 commit comments

Comments
 (0)