|
# Installing and configuring Cygwin
|
|
# Setting Up Cygwin for building GHC
|
|
|
|
|
|
|
|
1. Install [ Cygwin](http://www.cygwin.com/)
|
|
|
|
|
|
Install Cygwin from [ http://www.cygwin.com/](http://www.cygwin.com/).
|
|
1. You must install enough Cygwin *packages* to support building GHC. If you miss out any of these, strange things will happen to you. There are two ways to do this:
|
|
The installation process is straightforward; we install it in
|
|
|
|
`c:/cygwin`.
|
|
|
|
|
|
|
|
|
|
- The direct, but laborious way is to select all of the following packages in the installation dialogue:
|
|
|
|
`cvs`,
|
|
|
|
`openssh`,
|
|
|
|
`autoconf`,
|
|
|
|
`binutils`,
|
|
|
|
`gcc`,
|
|
|
|
`flex`,
|
|
|
|
`make`.
|
|
|
|
To see these packages, click on the "View" button in the "Select Packages" stage of Cygwin's installation dialogue, until the view says "Full".
|
|
|
|
- The clever way is to point the Cygwin installer at the
|
|
|
|
`ghc-depends` package, which is kept at [ http://haskell.org/ghc/cygwin](http://haskell.org/ghc/cygwin). When the Cygwin installer asks you to "Choose a Download Site", choose one of the offered mirror sites; and then type "[ http://haskell.org/ghc/cygwin](http://haskell.org/ghc/cygwin)" into the "User URL" box and click "Add"; now two sites are selected. (The Cygwin installer remembers this for next time.) Click "Next". In the "Select Packages" dialogue box that follows, click the "+" sign by "Devel", scroll down to the end of the "Devel" packages, and choose `ghc-depends`.
|
|
|
|
|
|
You must install enough Cygwin *packages* to support
|
|
1. Now set the following user environment variables:
|
|
building GHC. If you miss out any of these, strange things will happen to you. There are two ways to do this:
|
|
|
|
|
|
|
|
- The direct, but laborious way is to
|
|
- Add `c:/cygwin/bin` and `c:/cygwin/usr/bin` to your `PATH`
|
|
select all of the following packages in the installation dialogue:
|
|
- Set `MAKE_MODE` to `UNIX`. If you don't do this you get very weird messages when you type `make`, such as:
|
|
`cvs`,
|
|
|
|
`openssh`,
|
|
|
|
`autoconf`,
|
|
|
|
`binutils` (includes ld and (I think) ar),
|
|
|
|
`gcc`,
|
|
|
|
`flex`,
|
|
|
|
`make`.
|
|
|
|
To see these packages,
|
|
|
|
click on the "View" button in the "Select Packages"
|
|
|
|
stage of Cygwin's installation dialogue, until the view says "Full". The default view, which is
|
|
|
|
"Category" isn't very helpful, and the "View" button is rather unobtrousive.
|
|
|
|
- The clever way is to point the Cygwin installer at the
|
|
|
|
`ghc-depends` package, which is kept at
|
|
|
|
[ http://haskell.org/ghc/cygwin](http://haskell.org/ghc/cygwin).
|
|
|
|
When the Cygwin installer asks you to "Choose a Download Site", choose one of
|
|
|
|
the
|
|
|
|
offered mirror sites; and then type "[ http://haskell.org/ghc/cygwin](http://haskell.org/ghc/cygwin)" into the
|
|
|
|
"User URL" box and click "Add"; now two sites are selected. (The Cygwin
|
|
|
|
installer remembers this for next time.)
|
|
|
|
Click "Next".
|
|
|
|
|
|
|
|
In the "Select Packages" dialogue box that follows, click the "+" sign by
|
|
```wiki
|
|
"Devel", scroll down to the end of the "Devel" packages, and choose
|
|
/c: /c: No such file or directory
|
|
`ghc-depends`.
|
|
```
|
|
The package `ghc-depends` will not actually install anything itself,
|
|
- Set `SHELL` to `c:/cygwin/bin/bash`. When you invoke a shell in Emacs, this `SHELL` is what you get.
|
|
but forces additional packages to be added by the Cygwin installer.
|
|
- Set `HOME` to point to your home directory. This is where, for example, `bash` will look for your `.bashrc` file. Ditto `emacs` looking for `.emacsrc`
|
|
|
|
|
|
|
|
|
|
Now set the following user environment variables:
|
|
|
|
|
|
|
|
- Add `c:/cygwin/bin` and `c:/cygwin/usr/bin` to your `PATH`
|
|
|
|
- Make sure the MinGW `gcc` and `ld` are in your `PATH` before the Cygwin `gcc` (hopefully this requirement will go away at some point; see [\#2966](https://gitlab.haskell.org//ghc/ghc/issues/2966))
|
|
|
|
- Set `MAKE_MODE` to `UNIX`. If you
|
|
|
|
don't do this you get very weird messages when you type
|
|
|
|
`make`, such as:
|
|
|
|
|
|
|
|
```wiki
|
|
|
|
/c: /c: No such file or directory
|
|
|
|
```
|
|
|
|
- Set `SHELL` to
|
|
|
|
`c:/cygwin/bin/bash`. When you invoke a shell in Emacs, this
|
|
|
|
`SHELL` is what you get.
|
|
|
|
- Set `HOME` to point to your
|
|
|
|
home directory. This is where, for example,
|
|
|
|
`bash` will look for your `.bashrc`
|
|
|
|
file. Ditto `emacs` looking for `.emacsrc`
|
|
|
|
|
|
|
|
|
|
|
|
Here are some things to be aware of when using Cygwin:
|
|
Here are some things to be aware of when using Cygwin:
|
|
|
|
|
|
- Cygwin implements a symbolic link as a text file with some
|
|
- Cygwin implements a symbolic link as a text file with some magical text in it. So other programs that don't use Cygwin's I/O libraries won't recognise such files as symlinks. In particular, programs compiled by GHC are meant to be runnable without having Cygwin, so they don't use the Cygwin library, so they don't recognise symlinks.
|
|
magical text in it. So other programs that don't use Cygwin's
|
|
|
|
I/O libraries won't recognise such files as symlinks.
|
|
- Some script files used in the make system start with "`#!/bin/perl`", (and similarly for `sh`). Notice the hardwired path! So you need to ensure that your `/bin` directory has at least `sh`, `perl`, and `cat` in it. All these come in Cygwin's `bin` directory, which you probably have installed as `c:/cygwin/bin`. By default Cygwin mounts "`/`" as `c:/cygwin`, so if you just take the defaults it'll all work ok. (You can discover where your Cygwin root directory `/` is by typing `mount`.) Provided `/bin` points to the Cygwin `bin` directory, there's no need to copy anything. If not, copy these binaries from the `cygwin/bin` directory (after fixing the `sh.exe` stuff mentioned in the previous bullet). |
|
In particular, programs compiled by GHC are meant to be runnable
|
|
|
|
without having Cygwin, so they don't use the Cygwin library, so
|
|
|
|
they don't recognise symlinks.
|
|
|
|
- Some script files used in the make system start with "`#!/bin/perl`",
|
|
|
|
(and similarly for `sh`). Notice the hardwired path!
|
|
|
|
So you need to ensure that your `/bin` directory has at least
|
|
|
|
`sh`, `perl`, and `cat` in it.
|
|
|
|
All these come in Cygwin's `bin` directory, which you probably have
|
|
|
|
installed as `c:/cygwin/bin`. By default Cygwin mounts "`/`" as
|
|
|
|
`c:/cygwin`, so if you just take the defaults it'll all work ok.
|
|
|
|
(You can discover where your Cygwin
|
|
|
|
root directory `/` is by typing `mount`.)
|
|
|
|
Provided `/bin` points to the Cygwin `bin`
|
|
|
|
directory, there's no need to copy anything. If not, copy these binaries from the `cygwin/bin`
|
|
|
|
directory (after fixing the `sh.exe` stuff mentioned in the previous bullet). |
|
|