https://geneweb.tuxfamily.org/w/api.php?action=feedcontributions&user=Ricounet67&feedformat=atomGeneWeb - User contributions [en]2024-03-29T10:27:12ZUser contributionsMediaWiki 1.35.13https://geneweb.tuxfamily.org/w/index.php?title=OCaml&diff=3384OCaml2018-04-28T11:39:10Z<p>Ricounet67: /* Under OS X */</p>
<hr />
<div>{{DISPLAYTITLE:Installing OCaml and Camlp5 to compile GeneWeb}}<br />
{{toc right}}<br />
Compiling GeneWeb requires the '''installation of [http://ocaml.org/ OCaml] and [http://camlp5.gforge.inria.fr/ Camlp5]'''. Nowadays, the simplest method is to install them through [http://opam.ocaml.org/ OPAM] (OCaml preferred package manager) that is able to manage multiple versions of OCaml on the same machine. Note that Camlp5 must be installed for each version of the compiler.<br />
<br />
Without OPAM, the old way of doing this was to install/compile OCaml and Camlp5 all by yourself.<br />
<br />
When Ocaml and camlp5 are installed, you can [[#Clone repository and compile GeneWeb|clone repository to compile GeneWeb]].<br />
<br />
Don’t forget that if your base has been built under an old version, it won't be compatible with bases built with new version: one should [[recover]] through the [[GWformat|'''.gw''' format]] to migrate from one to the other.<br />
<br />
== For GeneWeb 7 ==<br />
=== Under Linux ===<br />
This has been tested on a [https://www.debian.org/devel/debian-installer/ Debian] in March 2018 (debian-9.3.0-i386-netinst.iso).<br />
<br />
To install Opam/OCaml (4.05)/Camlp5 (7.05)/ocamlfind (1.7.3):<br />
<pre><br />
apt-get install opam<br />
opam init<br />
opam update<br />
opam switch 4.05.0<br />
eval `opam config env`<br />
opam install -y ocamlfind camlp5<br />
</pre><br />
<br />
If ocamlfind install fails, try installing the packages {{c|pkg-config}} or {{c|m4}} from your distribution.<br />
<br />
=== Under OS X ===<br />
This has been tested on OS X El Capitan 10.11.6 in February 2018.<br />
<br />
The best way to install Opam/OCaml is to install it with [http://brew.sh/ Homebrew], a package management software.<br />
You have to install first homebrew in a '''Terminal''' window by typing or pasting this command:<br />
<pre><br />
/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"<br />
</pre><br />
<br />
If this gives the error “Illegal variable name.”, switch to Bash.<br />
<br />
Once homebrew is installed you can easily install Opam in Terminal application with these commands:<br />
<pre><br />
brew install opam <br />
opam init<br />
opam update<br />
opam switch 4.05<br />
</pre><br />
and then OCaml:<br />
<br />
<pre><br />
opam install -y camlp5 ocamlfind lablgtk<br />
eval `opam config env`<br />
</pre><br />
<br />
Before compiling GeneWeb you need to update Bash with Homebrew in a Terminal window:<br />
<pre><br />
brew install bash <br />
</pre><br />
Do not take into account the caveats about Bash path. You can now download and compile GeneWeb.<br />
<br />
=== Under Windows using Cygwin ===<br />
This has been tested on Windows 7 x64 and x86 in February 2018.<br />
<br />
If you have [https://en.wikipedia.org/wiki/Windows_PowerShell Windows Powershell] (embedded in Windows since XP SP2), this [https://gist.github.com/a2line/f134c88c80eafcf0411b38e32a0a7128 batch script] will download/compile/install Cygwin/Opam/OCaml/Camlp5/Ocamfind/GeneWeb for you. You can download the script copying this line on a Windows prompt (command line) '''with administrator rights''':<br />
<pre>powershell.exe -Command (new-object System.Net.WebClient).DownloadFile('https://gist.github.com/a2line/f134c88c80eafcf0411b38e32a0a7128/raw/','opamwin.bat')</pre><br />
<br />
Then just launch the downloaded script typing {{c|opamwin}} in the same console to install everything.<br />
<br />
Without Powershell, you have to download the batch file [https://gist.github.com/a2line/f134c88c80eafcf0411b38e32a0a7128/raw/ opamwin.bat] and the right Cygwin setup [https://www.cygwin.com/setup-x86_64.exe x64] or [https://www.cygwin.com/setup-x86.exe x86] manually. Launch the script under a prompt with administrator rights and having Cygwin setup in the same directory.<br />
<br />
== GeneWeb 6.xx with OPAM ==<br />
=== Under Linux ===<br />
[[download|Sources of GeneWeb 6.04, 6.05 and 6.08]] can be build easily with Opam switching to OCaml 3.12.1 (see [https://github.com/geneweb/geneweb/issues/435 #435]). On Debian:<br />
<pre><br />
opam switch 3.12.1<br />
eval `opam config env`<br />
opam install -y camlp5 ocamlfind<br />
</pre><br />
<br />
When using Opam on old sources, we need to replace the path to Camlp5 {{c|1=CAMLP5D=+camlp5}} in {{c|tools/Makefile.inc}} with a sed command after configuring Makefile:<br />
./configure<br />
sed -i 's|CAMLP5D=+camlp5|CAMLP5D=~/.opam/3.12.1/lib/camlp5|' tools/Makefile.inc<br />
make<br />
make distrib<br />
<br />
You can check the path to Camlp5 with {{c|camlp5 -where}} or {{c|ocamlfind query camlp5}}, for this exemple camlp5 lib is in {{c|/root/.opam/3.12.1/lib/camlp5/}}.<br />
<br />
=== Under Windows ===<br />
Previous chapter for Linux works for Windows under Cygwin modifying a few steps, OCaml version name is:<br />
<pre><br />
opam switch 3.12.1+mingw32<br />
</pre><br />
<br />
Using relative path or {{c|/cygdrive/…}} don’t work, we must target camlp5 lib using its full Windows path that depends of where is your home directory in Cygwin installation:<br />
<pre><br />
sed -i 's|CAMLP5D=.*|CAMLP5D=c:\\cygwin\\home\\user\\.opam\\3.12.1+mingw32\\lib\\camlp5|' tools/Makefile.inc<br />
</pre><br />
<br />
Building version 6.07 like this also works under Windows.<br />
<br />
== Clone repository and compile GeneWeb ==<br />
GeneWeb uses the version control software [https://en.wikipedia.org/wiki/Git_(software) Git]. Its repository is hosted on [https://github.com Github] at https://github.com/geneweb/geneweb. To compile GeneWeb, you need [[#top|OCaml]].<br />
<br />
git clone https://github.com/geneweb/geneweb<br />
cd geneweb<br />
./configure && make opt && make distrib<br />
<br />
If GeneWeb compilation fails, look at [[News#8 March 2016: Continuous integration|continuous integration tools]] to see if latest build is passing on your plateform. <br />
<br />
=== Build options ===<br />
{{c|./configure}} options:<br />
-h|--help<br />
show this help<br />
--api<br />
build the API<br />
-d|--debug<br />
add debugging symbols to the build command<br />
-i|--interactive<br />
run configure interactively<br />
-s|--static<br />
statically link libraries<br />
-we|--warn-error<br />
treat warnings as errors<br />
<br />
For example, if you want debug symbols/warnings use {{c|./configure -d -we}} then you can launch gwd adding {{c|1=OCAMLRUNPARAM=b}} to trigger the printing of a stack backtrace when an uncaught exception aborts the program.<br />
<br />
== GeneWeb/OCaml/Camlp5 compability chart ==<br />
{| class="wikitable centre" <br />
|-<br />
! GeneWeb || Ocaml || Camlp4/5<br />
|-<br />
| 1.07-2.07 || 2.01-2.02 || p4*<br />
|-<br />
| 3.01-3.03 || 2.01-2.04 || p4*<br />
|-<br />
| 3.04-3.07 || 2.01-3.00 || p4*<br />
|-<br />
| 3.08-4.01 || 3.00 || p4*<br />
|- <br />
| 4.02 || 3.01 || p4*<br />
|-<br />
| 4.03 || 3.02 || p4*<br />
|-<br />
| 4.04-4.07 || 3.04 ||<br />
|-<br />
| 4.08-4.09 || 3.06 || p4*<br />
|-<br />
| 4.10 || 3.08 ||<br />
|-<br />
| 5.00-5.01 || ||<br />
|-<br />
| 5.02 || 3.11 || p5 6.02.1**<br />
|-<br />
| 6.00-6.08 || 3.12.1 || p5 6.04-6.16<br />
|-<br />
| 7 master || 4.05 || p5 6.13-7.05<br />
|}<br />
<nowiki>*</nowiki> “same version number” for camlp4 as Ocaml version number<br />
<br />
<nowiki>**</nowiki> Dominique Deram, [http://dominique95880.free.fr/divers/compilgw/compilwin_gw.htm compilation under Windows XP] (jan. 2011)<br />
<br />
<br />
{{manual}}<br />
<br />
[[Category:Manual]]</div>Ricounet67