Today I forked a copy of the Mercury Github repository as I’ve seen at least one thing so far (albeit orthogonal to the language itself) I can submit a PR for. In order to build it though, you have to have a binary already installed as it is a “boot-strapping” process as most of Mercury is actually written in…Mercury!
Step 1: Getting a workable compiler
The first step is to go to this page: http://dl.mercurylang.org/index.html
and download the latest release of the day (ROTD) and then build it such that you restrict it to just the minimum build in order to be able to then check out and build the latest Github version. Once you have obtained, unpacked and moved into that folder from a command prompt:
$ cd -folder- $ ./configure --enable-minimal-install $ make $ sudo make install
Once all is said and done, you will get some instructions to add into your environment setup so that it works next time you open a new command line. Follow those instructions because in order for the next step to work you must have mmc
available on the path, and probably a load more tools that come with it. I didn’t look.
Step 2: Checking out the Github repo
The URL I’ve shown here is the official Mercury repo, but I forked a copy from my own github page, either way…
$ git clone https://github.com/Mercury-Language/mercury.git
Step 3: Building the beast
OK, now we are making progress and almost ready to make the build happen. But first, a note… I joined the mailing list and so far it has been very very helpful and very very friendly to my questions, and thanks to a comment from the legend that is AlaskanEmily
:
I would recommend only building a few grades, and not just letting configure do it’s thing. If you’re new to Mercury, then usually just something like
–enable-libgrades=hlc.gc,none.gc.stseg,none.gc.debug.stseg
So, in that case, the next couple of steps are:
$ cd mercury $ make realclean $ sh prepare.sh $ ./configure --enable-libgrades=hlc.gc,none.gc.stseg,none.gc.debug.stseg $ make PARALLEL=-j10 $ sudo make install
And…..be patient…it takes a while. I mean, a while. If it hadn’t been for that timely intervention I swear my laptop was ready to take on a liquid plastic form as it had been building with the default options.
Again, once it is finished, follow the instructions to put the DEV version on your path now, for me, my .zshrc
file contains these lines,
# Mercury
export PATH=$PATH:/usr/local/mercury-DEV/bin
export MANPATH=$MANPATH:/usr/local/mercury-DEV/share/man
export INFOPATH=$INFOPATH:/usr/local/mercury-DEV/share/info
and my ~/.emacs
contains this little section.
;;;;
;;
;; Mercury
;;
;;;;
(add-to-list 'load-path "/usr/local/mercury-DEV/lib/mercury/elisp")
(autoload 'mdb "gud" "Invoke the Mercury debugger" t)
(add-to-list 'auto-mode-alist '("\\.m\\'" . mercury-mode))
Congratulations! If all went well, you now have a fully functional Mercury system that you built all for yourself which means you can fork, tweak and generally learn more about it.