1<title>Compiling and Installing Fossil</title> 2 3<h2>0.0 Using A Pre-compiled Binary</h2> 4 5<p>[/uv/download.html|Pre-compiled binaries] are available for recent 6releases. Just download 7the appropriate executable for your platform 8and put it on your $PATH. 9To uninstall, simply delete the executable. 10To upgrade from an older release, just overwrite the older binary with 11the newer one.</p> 12 13<p>For details about how those binaries are built, see 14[/wiki?name=Release+Build+How-To | the Release Build How-To wiki page].</p> 15 16 17<h2>0.1 Executive Summary</h2> 18 19<p>Building and installing is very simple. Three steps:</p> 20 21<ol> 22<li> Download and unpack a source tarball or ZIP. 23<li> <b>./configure; make</b> 24<li> Move the resulting "fossil" or "fossil.exe" executable to someplace on 25your $PATH. 26</ol> 27 28<p><hr> 29 30<h2>1.0 Obtaining The Source Code</h2> 31 32<p>Fossil is self-hosting, so you can obtain a ZIP archive or tarball 33containing a snapshot of the <em>latest</em> version directly from 34Fossil's own fossil repository. Additionally, source archives of 35<em>released</em> versions of 36fossil are available from the [/uv/download.html|downloads page]. 37To obtain a development version of fossil, follow these steps:</p> 38 39<ol> 40<li><p>Point your web browser to [https://fossil-scm.org/]</li> 41 42<li><p>Click on the [/timeline|Timeline] 43link at the top of the page.</p></li> 44 45<li><p>Select a version of of Fossil you want to download. The latest 46version on the trunk branch is usually a good choice. Click on its 47link.</p></li> 48 49<li><p>Finally, click on one of the 50"Zip Archive" or "Tarball" links, according to your preference. 51These link will build a ZIP archive or a gzip-compressed tarball of the 52complete source code and download it to your computer. 53</ol> 54 55<h2>Aside: Is it really safe to use an unreleased development version of 56the Fossil source code?</h2> 57 58Yes! Any check-in on the 59[/timeline?t=trunk | trunk branch] of the Fossil 60[http://fossil-scm.org/home/timeline | Fossil self-hosting repository] 61will work fine. (Dodgy code is always on a branch.) In the unlikely 62event that you pick a version with a serious bug, it still won't 63clobber your files. Fossil uses several 64[./selfcheck.wiki | self-checks] prior to committing any 65repository change that prevent loss-of-work due to bugs. 66 67The Fossil [./selfhost.wiki | self-hosting repositories], especially 68the one at [http://fossil-scm.org/home], usually run a version 69of trunk that is less than a week or two old. Look at the bottom 70left-hand corner of this screen (to the right of "This page was 71generated in...") to see exactly which version of Fossil is 72rendering this page. It is always safe to use whatever version 73of the Fossil code you find running on the main Fossil website. 74 75<h2>2.0 Compiling</h2> 76 77<ol> 78<li value="5"> 79<p>Unpack the ZIP or tarball you downloaded then 80<b>cd</b> into the directory created.</p></li> 81 82<li><i>(Optional, Debian-compatible Linux only)</i> 83Make sure you have all the necessary tools and libraries at hand by running: 84<b>sudo apt install tcl-dev tk libssl-dev</b>. 85 86<li><i>(Optional, Unix only)</i> 87Run <b>./configure</b> to construct a makefile. 88 89<ol type="a"> 90<li><p> 91The build system for Fossil on Unix-like systems assumes that the 92OpenSSL development and runtime files are available on your system, 93because unprotected repositories are trivial to attack otherwise. 94Indeed, some public Fossil repositories — including Fossil's own — today 95run in an HTTPS-only mode, so that you can't even do an anonymous clone 96from them without using the TLS features added to Fossil by OpenSSL. To 97weaken that stance could allow a 98[https://en.wikipedia.org/wiki/Man-in-the-middle_attack|man in the 99middle attack], such as one that substitutes malicious code into your 100Fossil repository clone.</p> 101 102<p>You can force the Fossil build system to avoid searching for, building 103against, and linking to the OpenSSL library by passing 104<b>--with-openssl=none</b> to the <tt>configure</tt> script.</p> 105 106<p>If you do not have the OpenSSL development libraries on your system, 107we recommend that you install them, typically via your OS's package 108manager. The Fossil build system goes to a lot of effort to seek these 109out wherever they may be found, so that is typically all you need to 110do.</p> 111 112<p>For more advanced use cases, see the [./ssl.wiki#openssl-bin|OpenSSL 113discussion in the "TLS and Fossil" document].</p> 114 115<li><p> 116To build a statically linked binary (suitable for use inside a chroot 117jail) add the <b>--static</b> option. 118 119<li><p> 120To enable the native [./th1.md#tclEval | Tcl integration feature] feature, 121add the <b>--with-tcl=1</b> and <b>--with-tcl-private-stubs=1</b> options. 122 123<li><p> 124Other configuration options can be seen by running 125<b>./configure --help</b> 126</ol> 127 128<li><p>Run "<b>make</b>" to build the "fossil" or "fossil.exe" executable. 129The details depend on your platform and compiler. 130 131<ol type="a"> 132<li><p><i>Unix</i> → the configure-generated Makefile should work on 133all Unix and Unix-like systems. Simply type "<b>make</b>". 134 135<li><p><i>Unix without running "configure"</i> → if you prefer to avoid 136running configure, you can also use: <b>make -f Makefile.classic</b>. You may 137want to make minor edits to Makefile.classic to configure the build for your 138system. 139 140<li><p><i>MinGW / MinGW-w64</i> → The best-supported path is to build 141via the MinGW specific Makefile under a POSIX build of GNU make: 142"<b>make -f win/Makefile.mingw</b>". 143 144There is limited support for building under MinGW's native Windows port 145of GNU Make instead by defining the <tt>USE_WINDOWS=1</tt> variable, but 146it's better to build under MSYS, Cygwin, or WSL on Windows since this 147mode doesn't take care of cases such as the "openssl" target, which 148depends on <tt>sed</tt>. We've gone as far down this path as is 149practical short of breaking cross-compilation under Linux, macOS, and so 150forth, as we'd have to do to make everything work under 151<tt>cmd.exe</tt>. 152 153Unless you're building under MSYS where commands like "<tt>gcc</tt>" 154give MinGW's GCC and not some other version, you will need to make minor 155edits to win/Makefile.mingw to configure the cross-compilation 156environment. It should suffice to switch to one of the predefined 157<tt>PREFIX</tt> values, causing the build to be done using 158"<tt>x86_64-w64-mingw32-gcc</tt>" for example, yielding a 64-bit native 159Windows binary. 160 161To enable the native [./th1.md#tclEval | Tcl integration feature], use a 162command line like the following (all on one line): 163 164<b>make -f win/Makefile.mingw FOSSIL_ENABLE_TCL=1 FOSSIL_ENABLE_TCL_STUBS=1 FOSSIL_ENABLE_TCL_PRIVATE_STUBS=1</b> 165 166Alternatively, running <b>./configure</b> under MSYS should give a 167suitable top-level Makefile. However, options passed to configure that are 168not applicable on Windows may cause the configuration or compilation to fail 169(e.g. fusefs, internal-sqlite, etc). 170 171<li><p><i>MSVC</i> → Use the MSVC makefile. 172 173Run all of the following from a "x64 Native Tools Command Prompt". 174 175First 176change to the "win/" subdirectory ("<b>cd win</b>") then run 177"<b>nmake /f Makefile.msc</b>".<br><br>Alternatively, the batch 178file "<b>win\buildmsvc.bat</b>" may be used and it will attempt to 179detect and use the latest installed version of MSVC.<br><br>To enable 180the optional <a href="https://www.openssl.org/">OpenSSL</a> support, 181first <a href="https://www.openssl.org/source/">download the official 182source code for OpenSSL</a> and extract it to an appropriately named 183"<b>openssl</b>" subdirectory within the local 184[/tree?ci=trunk&name=compat | compat] directory then make sure that some recent 185<a href="http://www.perl.org/">Perl</a> binaries are installed locally, 186and finally run one of the following commands: 187<blockquote><pre> 188nmake /f Makefile.msc FOSSIL_ENABLE_SSL=1 FOSSIL_BUILD_SSL=1 PERLDIR=C:\full\path\to\Perl\bin 189</pre></blockquote> 190<blockquote><pre> 191buildmsvc.bat FOSSIL_ENABLE_SSL=1 FOSSIL_BUILD_SSL=1 PERLDIR=C:\full\path\to\Perl\bin 192</pre></blockquote> 193To enable the optional native [./th1.md#tclEval | Tcl integration feature], 194run one of the following commands or add the "FOSSIL_ENABLE_TCL=1" 195argument to one of the other NMAKE command lines: 196<blockquote><pre> 197nmake /f Makefile.msc FOSSIL_ENABLE_TCL=1 198</pre></blockquote> 199<blockquote><pre> 200buildmsvc.bat FOSSIL_ENABLE_TCL=1 201</pre></blockquote> 202 203<li><p><i>Cygwin</i> → The same as other Unix-like systems. It is 204recommended to configure using: "<b>configure --disable-internal-sqlite</b>", 205making sure you have the "libsqlite3-devel" , "zlib-devel" and 206"openssl-devel" packages installed first. 207</ol> 208</ol> 209 210<h2>3.0 Installing</h2> 211 212<ol> 213<li value="9"> 214<p>The finished binary is named "fossil" (or "fossil.exe" on Windows). 215Put this binary in a 216directory that is somewhere on your PATH environment variable. 217It does not matter where.</p> 218 219<li> 220<p><b>(Optional:)</b> 221To uninstall, just delete the binary.</p> 222</ol> 223 224<h2>4.0 Additional Considerations</h2> 225 226<ul> 227<li><p> 228 If the makefiles that come with Fossil do not work for 229 you, or for some other reason you want to know how to build 230 Fossil manually, then refer to the 231 [./makefile.wiki | Fossil Build Process] document which describes 232 in detail what the makefiles do behind the scenes. 233 234<li><p> 235 The fossil executable is self-contained and stand-alone and usually 236 requires no special libraries or other software to be installed. However, 237 the "--tk" option to the [/help/diff|diff command] requires that Tcl/Tk 238 be installed on the local machine. You can get Tcl/Tk from 239 [http://www.activestate.com/activetcl|ActiveState]. 240 241<li><p> 242 To build on older Macs (circa 2002, MacOS 10.2) edit the Makefile 243 generated by configure to add the following lines: 244 <blockquote><pre> 245 TCC += -DSQLITE_WITHOUT_ZONEMALLOC 246 TCC += -D_BSD_SOURCE 247 TCC += -DWITHOUT_ICONV 248 TCC += -Dsocketlen_t=int 249 TCC += -DSQLITE_MAX_MMAP_SIZE=0 250</pre></blockquote> 251</ul> 252 253<h2>5.0 Building a Static Binary on Linux using Docker</h2> 254 255Building a static binary on Linux is not as straightforward as it 256could be because the GNU C library requires that certain components be 257dynamically loadable. That can be worked around by building against a 258different C library, which is simplest to do by way of a container 259environment like [https://www.docker.com/ | Docker]. 260 261The following instructions for building fossil using Docker 262were adapted from [https://fossil-scm.org/forum/forumpost/5dd2d61e5f | forumpost/5dd2d61e5f]. 263These instructions assume that docker is installed and that the user running 264these instructions has permission to do so (i.e., they are <tt>root</tt> or 265are a member of the <tt>docker</tt> group). 266 267First, create a file named <tt>Dockerfile</tt> with the following contents: 268 269<pre><code> 270# Alpine >3.13 breaks stuff on many host OSes! For details see: 271# https://wiki.alpinelinux.org/wiki/Draft_Release_Notes_for_Alpine_3.14.0#faccessat2 272# FROM alpine:edge 273FROM alpine:3.13 274RUN apk update \ 275 && apk upgrade \ 276 && apk add --no-cache \ 277 curl gcc make tcl \ 278 musl-dev \ 279 openssl-dev zlib-dev \ 280 openssl-libs-static zlib-static \ 281 && curl \ 282 "https://fossil-scm.org/home/tarball/fossil-src.tar.gz?name=fossil-src&uuid=trunk" \ 283 -o fossil-src.tar.gz \ 284 && tar xf fossil-src.tar.gz \ 285 && cd fossil-src \ 286 && ./configure \ 287 --static \ 288 --disable-fusefs \ 289 --with-th1-docs \ 290 --with-th1-hooks \ 291 && make 292</code></pre> 293 294Be sure to modify the <tt>configure</tt> flags, if desired. e.g., add <tt>--json</tt> 295for JSON support. 296 297From the directory containing that file, build it with docker: 298 299<pre><code># docker build -t fossil_static .</code></pre> 300 301If you get permissions errors when running that as a non-root user, 302be sure to add the user to the <tt>docker</tt> group before trying 303again. 304 305That creates a docker image and builds a static fossil binary inside 306it. That step will take several minutes or more, depending on the 307speed of the build environment. 308 309Next, create a docker container to host the image we just created: 310 311<pre><code># docker create --name fossil fossil_static</code></pre> 312 313Then copy the fossil binary from that container: 314 315<pre><code># docker cp fossil:/fossil-src/fossil fossil</code></pre> 316 317The resulting binary will be <em>huge</em> because it is built with 318debug info. To strip that information, reducing the size greatly: 319 320<pre><code># strip fossil</code></pre> 321 322To delete the Docker container and image (if desired), run: 323 324<pre><code># docker container rm fossil 325# docker image ls 326</code></pre> 327 328Note the IDs of the images named <tt>fossil_static</tt> and <tt>alpine</tt>, then: 329 330<pre><code>docker image rm THE_FOSSIL_ID THE_ALPINE_ID</code></pre> 331 332 333<h2>6.0 Building on/for Android</h2> 334 335<h3>6.1 Cross-compiling from Linux</h3> 336 337The following instructions for building Fossil for Android, 338without requiring a rooted OS, are adapted from 339[https://fossil-scm.org/forum/forumpost/e0e9de4a7e | forumpost/e0e9de4a7e]. 340 341On the development machine, from the fossil source tree: 342 343<pre><code>export CC=$NDK_PATH/toolchains/llvm/prebuilt/linux-x86_64/bin/armv7a-linux-androideabi21-clang 344./configure --with-openssl=none 345make 346</code></pre> 347 348 349On the Android device, enable the <em>USB debugging</em> option from 350Developer menu in Device Options. Connect the device to the development 351system with USB. If it's configured and connected properly, 352the device should show up in the output of <code>adb devices</code>: 353 354<pre><code>sudo adb devices 355</code></pre> 356 357Copy the resulting fossil binary onto the device... 358 359<pre><code>sudo adb push fossil /data/local/tmp 360</code></pre> 361 362And run it from an <code>adb</code> shell: 363 364<pre><code>sudo adb shell 365> cd /data/local/tmp 366# Fossil requires a HOME directory to work with: 367> export HOME=$PWD 368> export PATH=$PWD:$PATH 369> fossil version 370This is fossil version 2.11 [e5653a4ceb] 2020-03-26 18:54:02 UTC 371</code></pre> 372 373The output might, or might not, include warnings such as: 374 375<pre><code>WARNING: linker: ./fossil: unused DT entry: type 0x6ffffef5 arg 0x1464 376WARNING: linker: ./fossil: unused DT entry: type 0x6ffffffe arg 0x1ba8 377WARNING: linker: ./fossil: unused DT entry: type 0x6fffffff arg 0x2 378</code></pre> 379 380The source of such warnings is not 100% certain. 381Some information about these (reportedly harmless) warnings can 382be found 383[https://stackoverflow.com/a/41900551 | on this StackOverflow post]. 384